Skip to content

Conversation

@QAM
Copy link
Contributor

@QAM QAM commented Nov 18, 2025

This commit introduces a comprehensive authentication system with OpenID Connect (OIDC) integration and JWT token support.

Features:

  • OIDC authentication with any OIDC-compliant provider (Keycloak, Auth0, Okta, etc.)
  • Session-based authentication with email stored in backend session
  • JWT token authentication as alternative to session-based auth
  • PKCE (Proof Key for Code Exchange) support for enhanced security
  • Middleware for protecting API routes with automatic redirect to login
  • HTML login page with error handling
  • Token generation and validation utilities

New modules:

  • src/server/auth/: Complete OIDC authentication module

    • index.js: Main authentication initialization
    • oidc.js: OIDC strategy configuration with Passport
    • middleware.js: requireAuth and optionalAuth middleware
    • routes.js: Authentication routes (/auth/login, /auth/callback, /auth/logout)
    • utils.js: Authentication utility functions
    • README.md: Comprehensive documentation
  • src/server/token/: JWT token management

    • index.js: Token generation endpoint with HTML interface and JSON API

Configuration:

  • Environment variables for OIDC configuration (OIDC_DISCOVERY_URL, OIDC_CLIENT_ID, etc.)
  • AUTH_ENABLED flag to enable/disable authentication
  • Session and JWT secret configuration
  • Automatic fallback when authentication is disabled

Integration:

  • Updated src/server/index.js to initialize authentication module
  • Updated src/utils/AxiosWrapper.js to handle authentication errors
  • All /api/* routes are automatically protected by requireAuth middleware

Dependencies added:

  • express-session: Session management
  • jsonwebtoken: JWT token generation and validation
  • passport: Authentication middleware
  • passport-oauth2: OAuth2/OIDC strategy for Passport

The authentication system is designed to be:

  • Independent and minimally invasive to existing codebase
  • Configurable via environment variables
  • Optional (can be disabled via AUTH_ENABLED=false)
  • Production-ready with security best practices

This commit introduces a comprehensive authentication system with OpenID
Connect (OIDC) integration and JWT token support.

Features:
- OIDC authentication with any OIDC-compliant provider (Keycloak, Auth0, Okta, etc.)
- Session-based authentication with email stored in backend session
- JWT token authentication as alternative to session-based auth
- PKCE (Proof Key for Code Exchange) support for enhanced security
- Middleware for protecting API routes with automatic redirect to login
- HTML login page with error handling
- Token generation and validation utilities

New modules:
- src/server/auth/: Complete OIDC authentication module
  - index.js: Main authentication initialization
  - oidc.js: OIDC strategy configuration with Passport
  - middleware.js: requireAuth and optionalAuth middleware
  - routes.js: Authentication routes (/auth/login, /auth/callback, /auth/logout)
  - utils.js: Authentication utility functions
  - README.md: Comprehensive documentation

- src/server/token/: JWT token management
  - index.js: Token generation endpoint with HTML interface and JSON API

Configuration:
- Environment variables for OIDC configuration (OIDC_DISCOVERY_URL, OIDC_CLIENT_ID, etc.)
- AUTH_ENABLED flag to enable/disable authentication
- Session and JWT secret configuration
- Automatic fallback when authentication is disabled

Integration:
- Updated src/server/index.js to initialize authentication module
- Updated src/utils/AxiosWrapper.js to handle authentication errors
- All /api/* routes are automatically protected by requireAuth middleware

Dependencies added:
- express-session: Session management
- jsonwebtoken: JWT token generation and validation
- passport: Authentication middleware
- passport-oauth2: OAuth2/OIDC strategy for Passport

The authentication system is designed to be:
- Independent and minimally invasive to existing codebase
- Configurable via environment variables
- Optional (can be disabled via AUTH_ENABLED=false)
- Production-ready with security best practices
@QAM QAM changed the title Add OIDC authentication and JWT token management [For auth/token. Don't merge]Add OIDC authentication and JWT token management Nov 18, 2025
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.

1 participant