Skip to content

Add endpoint-based HTTP Basic Authentication support with unified SPARQL Endpoints management#55

Merged
MathiasVDA merged 16 commits into
mainfrom
copilot/add-basic-authentication-support
Dec 11, 2025
Merged

Add endpoint-based HTTP Basic Authentication support with unified SPARQL Endpoints management#55
MathiasVDA merged 16 commits into
mainfrom
copilot/add-basic-authentication-support

Conversation

Copy link
Copy Markdown

Copilot AI commented Dec 11, 2025

Implementation Complete ✅

All requirements from the original issue have been met with the endpoint-based architecture, plus code review feedback has been addressed.

Requirements Met

  • User and developer configurable - Can be set via UI or programmatically via API
  • Part of Yasgui - Integrated into main YASGUI package
  • Configuration in the settings window - "SPARQL Endpoints" tab with comprehensive management UI
  • Persistent but think about security - Stored in localStorage with security warnings; credentials stored per-endpoint
  • Make sure all UI elements adapt colors depending on theme - Full CSS custom properties for light/dark theme support
  • Tests - Unit tests for authentication encoding
  • Docs, both user and dev - Complete documentation integrated into existing guides with security best practices

Latest Update: Code Review Fixes

Security & Best Practices:

  • Added check for existing Authorization header to prevent silent overwrites
  • Enhanced documentation with security warnings about localStorage risks
  • Recommend secure alternatives (session tokens, OAuth 2.0) in examples
  • Clear guidance on HTTPS-only usage

Behavior Improvements:

  • Endpoint-based auth now respects programmatically set basicAuth in request config
  • Proper deletion of authentication field when set to undefined in updates
  • Improved accessibility with aria-label on checkbox

Documentation Clarity:

  • Clarified that authentication is endpoint-based, not tab-based
  • All tabs using same endpoint share credentials
  • Updated examples to show correct usage pattern
  • Removed misleading "Multiple Tabs with Different Credentials" example
  • Added "Multiple Endpoints with Different Credentials" example

Architecture: Endpoint-Based Authentication

Before (Tab-Based - Original Implementation):

  • Authentication stored in tab.requestConfig.basicAuth
  • Each tab had its own credentials
  • Same endpoint in different tabs could have different credentials

After (Endpoint-Based - As Requested):

  • Authentication stored in persistentConfig.endpointConfigs[]
  • Credentials associated with endpoint URL
  • All tabs using the same endpoint share the same credentials
  • Auto-tracks accessed endpoints + Manual addition via UI
  • Designed for future authentication types (OAuth, Bearer, etc.)
  • Programmatic basicAuth takes precedence over endpoint-based auth

New Data Structure

interface EndpointConfig {
  endpoint: string;
  label?: string;  // Optional display name
  showAsButton?: boolean;  // Show as quick-switch button (requires label)
  authentication?: {
    type: 'basic';  // Future: 'bearer', 'oauth', etc.
    username: string;
    password: string;
  };
}

SPARQL Endpoints UI

The unified "SPARQL Endpoints" settings tab provides:

  1. Automatic Endpoint Tracking: Every endpoint you access is automatically added
  2. Manual Endpoint Addition: Add endpoints via form without accessing them first
  3. Endpoint Table with columns:
    • Endpoint URL (with truncation for long URLs)
    • Label (editable inline)
    • Button checkbox (show as quick-switch button, requires label) - now with aria-label for accessibility
    • Authentication status with "Configure" button
    • Delete action
  4. Authentication Modal per endpoint:
    • Type selector (currently Basic Auth, designed for extensibility)
    • Username and password fields
    • Security notice
    • Remove authentication option
  5. Add New Endpoint Form:
    • URL input field with improved validation
    • "+ Add Endpoint" button
    • Protocol validation (http/https)
    • Duplicate checking

Screenshots

Empty State with Add Form (Light Theme):

With Added Endpoint (Light Theme):

Usage Examples

Endpoint-Based Configuration (Recommended)

const yasgui = new Yasgui(document.getElementById("yasgui"));

// Configure authentication per-endpoint
yasgui.persistentConfig.addOrUpdateEndpoint("https://secure.example.com/sparql", {
  label: "My Secure Endpoint",
  showAsButton: true,
  authentication: {
    type: 'basic',
    username: "myuser",
    password: "mypassword"
  }
});

// All tabs using this endpoint will share these credentials
const tab1 = yasgui.addTab();
tab1.setRequestConfig({ endpoint: "https://secure.example.com/sparql" });

const tab2 = yasgui.addTab();
tab2.setRequestConfig({ endpoint: "https://secure.example.com/sparql" }); // Uses same auth

Programmatic Override (Advanced)

// If you set basicAuth directly in requestConfig, it takes precedence
const tab = yasgui.addTab();
tab.setRequestConfig({
  endpoint: "https://secure.example.com/sparql",
  basicAuth: {
    username: "override_user",
    password: "override_pass"
  }
});
// This tab will use the override credentials instead of endpoint-based auth

Security Notes

  • Credentials stored in browser localStorage
  • Only use with HTTPS endpoints to prevent credentials being sent in plain text
  • Clear security warnings displayed in UI and documentation
  • Users advised to be cautious on shared computers
  • Documentation recommends secure alternatives (session tokens, OAuth 2.0)
  • Error handling prevents application crashes from misconfigured authentication
  • Authorization header conflicts are detected and logged

Backwards Compatibility

  • Existing customEndpointButtons still supported alongside new endpointConfigs
  • Migration path preserves existing button configurations
  • No breaking changes to existing API
  • Programmatic basicAuth configuration still works and takes precedence

Future Extensibility

The authentication modal is designed to support future authentication types:

  • OAuth 2.0
  • Bearer tokens
  • API keys
  • Custom authentication schemes

Type selector infrastructure in place; only requires adding new authentication type handlers.

Original prompt

This section details on the original issue you should resolve

<issue_title>Add support for basic authentication</issue_title>
<issue_description>Basic Authentication (HTTP Basic Auth)

Username/password sent in Authorization header

  • User and developer configurable
  • Part of Yasgui
  • Configuration in the settings window
  • Persistent but think about security
  • Make sure all UI elements adapt colors depending on theme
  • Tests
  • Docs, both user and dev</issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 3 commits December 11, 2025 15:53
- Add BasicAuthConfig type to RequestConfig interface
- Add basicAuth field to request configuration with username/password
- Implement Authorization header generation in sparql.ts
- Add Authentication tab in Settings modal with username/password inputs
- Add security notice about localStorage and HTTPS usage
- Add proper theme-aware styling for auth inputs
- Build successfully compiles with new types

Co-authored-by: MathiasVDA <15101339+MathiasVDA@users.noreply.github.com>
- Add comprehensive user and developer documentation
- Create unit tests for base64 encoding and auth header format
- Document security considerations and best practices
- Add code examples for various authentication scenarios
- Include troubleshooting guide

Co-authored-by: MathiasVDA <15101339+MathiasVDA@users.noreply.github.com>
- Add error handling for basicAuth function calls
- Ensure authentication is cleared when credentials are incomplete
- Improve consistency of authentication state management

Co-authored-by: MathiasVDA <15101339+MathiasVDA@users.noreply.github.com>
Copilot AI changed the title [WIP] Add support for basic authentication implementation Add HTTP Basic Authentication support Dec 11, 2025
Copilot AI requested a review from MathiasVDA December 11, 2025 16:10
Copy link
Copy Markdown
Collaborator

@MathiasVDA MathiasVDA left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot the documentation needs to be integrated in the existing user and developer guide

- Move basic auth documentation from standalone file into existing guides
- Add authentication section to user guide after Settings Modal
- Add authentication section to developer guide in Request Configuration
- Remove standalone docs/basic-authentication.md file
- Keep user and developer documentation together in their respective guides

Co-authored-by: MathiasVDA <15101339+MathiasVDA@users.noreply.github.com>
Copy link
Copy Markdown
Author

Copilot AI commented Dec 11, 2025

@copilot the documentation needs to be integrated in the existing user and developer guide

Done in commit 0fb8c83. The basic authentication documentation has been integrated into the existing user and developer guides:

  • User guide: Added "Basic Authentication" section after "Settings Modal" feature
  • Developer guide: Added "Basic Authentication" section in "Request Configuration" with programmatic examples
  • Removed the standalone basic-authentication.md file

@MathiasVDA
Copy link
Copy Markdown
Collaborator

@copilot the authentication should be endpoint based and not tab based. Every tab that uses a certain endpoint should use the same authentication.

I propose to integrate the authentication settings with the endpoint buttons. Name this the 'SPARQL Endpoints' section. Store every endpoint that a user accessed in this list by default. Allow deletion as normal. Keep the label column but allow this to be empty. Add a checkbox that activates this endpoint as a button, only possible when a label has been supplied. Add a button 'configure authentication' (or similar). We'll add other types of authentication in the future so keep this in mind when doing the design.

Don't forget to rework the documentation and tests to align with your changes. Don't forget that any UI elements need to respond to theme changes.

Copilot AI and others added 2 commits December 11, 2025 17:58
- Add EndpointConfig interface for endpoint-based storage with authentication
- Update PersistentConfig to store endpoint configurations instead of tab-based auth
- Add methods to manage endpoint configs (get, set, add/update, delete)
- Modify Tab to inject authentication from endpoint config into request config
- Add auto-tracking of accessed endpoints
- Rename "Endpoint Buttons" tab to "SPARQL Endpoints" in settings modal
- Remove standalone "Authentication" tab from settings modal
- Preparing for comprehensive SPARQL Endpoints UI (next commit)

Co-authored-by: MathiasVDA <15101339+MathiasVDA@users.noreply.github.com>
- Create comprehensive SPARQL Endpoints settings tab
- Replace separate Authentication and Endpoint Buttons tabs
- Add endpoints table with columns: Endpoint, Label, Button, Authentication, Actions
- Implement authentication modal per endpoint (designed for future auth types)
- Add auto-tracking of accessed endpoints
- Update endpoint buttons to use new endpointConfigs with showAsButton flag
- Add complete CSS styling for table and modal with theme support
- Maintain backwards compatibility with legacy customEndpointButtons
- Build successfully compiles

Co-authored-by: MathiasVDA <15101339+MathiasVDA@users.noreply.github.com>
Copy link
Copy Markdown
Author

Copilot AI commented Dec 11, 2025

@copilot the authentication should be endpoint based and not tab based. Every tab that uses a certain endpoint should use the same authentication.

I propose to integrate the authentication settings...

Implemented in commits a5792d9 and 220c8da. The authentication is now endpoint-based with a unified "SPARQL Endpoints" settings tab.

Key Changes:

  • Authentication stored per-endpoint, not per-tab
  • All accessed endpoints automatically tracked
  • New table UI with columns: Endpoint, Label, Button checkbox, Authentication status, Delete action
  • "Configure Authentication" button opens modal per endpoint (designed for future auth types: OAuth, Bearer, etc.)
  • Label field + "Button" checkbox to show endpoints as quick-switch buttons
  • Full theme support with CSS custom properties
  • Backwards compatible with existing customEndpointButtons

Empty State Screenshot:
SPARQL Endpoints Tab - Empty

Note: The UI renders correctly in the code, showing an empty state initially. Endpoints are auto-tracked when you change to a new endpoint URL. The table will populate with columns for endpoint management, label editing, button toggle, and authentication configuration.

- Update user guide to reflect SPARQL Endpoints tab instead of Authentication tab
- Document endpoint-based storage model
- Add instructions for managing endpoints and configuring authentication per endpoint
- Update developer guide with endpoint configuration API examples
- Remove references to per-tab authentication
- Emphasize that authentication is now shared across tabs using the same endpoint

Co-authored-by: MathiasVDA <15101339+MathiasVDA@users.noreply.github.com>
Copilot AI changed the title Add HTTP Basic Authentication support Add endpoint-based HTTP Basic Authentication support with unified SPARQL Endpoints management Dec 11, 2025
@MathiasVDA
Copy link
Copy Markdown
Collaborator

@copilot the user should have the possibility to add an endpoint from the settings windows

- Add "Add New Endpoint" form with URL input and "+ Add Endpoint" button
- Allow users to manually add endpoints instead of only auto-tracking
- Validate URL format before adding
- Check for duplicate endpoints
- Show improved empty message: "No endpoints yet. Add one below or access an endpoint to have it automatically tracked."
- Add themed CSS styling for form (background, borders, button)
- Full theme support with CSS custom properties for light/dark modes

Co-authored-by: MathiasVDA <15101339+MathiasVDA@users.noreply.github.com>
Copy link
Copy Markdown
Author

Copilot AI commented Dec 11, 2025

@copilot the user should have the possibility to add an endpoint from the settings windows

Implemented in commit 37a2025. Users can now manually add endpoints from the settings window.

Features:

  • "Add New Endpoint" form at the bottom of SPARQL Endpoints tab
  • URL input field with validation
  • "+ Add Endpoint" button
  • Validates URL format and checks for duplicates
  • Updated empty state: "No endpoints yet. Add one below or access an endpoint to have it automatically tracked."
  • Full theme support (light/dark modes)

Empty State with Add Form:
Empty State

After Adding an Endpoint:
With Added Endpoint

…:Matdata-eu/Yasgui into copilot/add-basic-authentication-support
@MathiasVDA MathiasVDA marked this pull request as ready for review December 11, 2025 18:45
Copilot AI review requested due to automatic review settings December 11, 2025 18:45
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 12 out of 12 changed files in this pull request and generated 10 comments.

Comment thread packages/yasgui/src/TabSettingsModal.ts Outdated
Comment thread packages/yasgui/src/PersistentConfig.ts Outdated
Comment thread packages/yasqe/src/sparql.ts Outdated
Comment thread packages/yasqe/src/sparql.ts Outdated
Comment thread packages/yasgui/src/TabSettingsModal.ts
Comment thread docs/developer-guide.md Outdated
Comment thread packages/yasgui/src/Tab.ts Outdated
Comment thread packages/yasgui/src/TabSettingsModal.ts
Comment thread packages/yasqe/src/sparql.ts Outdated
Comment thread docs/developer-guide.md Outdated
MathiasVDA and others added 3 commits December 11, 2025 21:05
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
- Add check for existing Authorization header before adding basic auth
- Only inject endpoint-based auth if basicAuth not already set programmatically
- Properly delete authentication field when set to undefined in updates
- Add aria-label to "Show as Button" checkbox for accessibility
- Update documentation to clarify endpoint-based (not tab-based) authentication
- Add security warnings about localStorage credential storage
- Recommend secure alternatives (session tokens, OAuth) in examples

Co-authored-by: MathiasVDA <15101339+MathiasVDA@users.noreply.github.com>
@MathiasVDA MathiasVDA merged commit fcee9f4 into main Dec 11, 2025
1 check passed
@MathiasVDA MathiasVDA deleted the copilot/add-basic-authentication-support branch December 11, 2025 20:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support for basic authentication

3 participants