Skip to content

Conversation

@madhav-db
Copy link

This PR introduces the foundational token provider system that enables custom token sources for authentication. This is the first of three PRs implementing token federation support.

New components:

  • ITokenProvider: Core interface for token providers
  • Token: Token class with JWT parsing and expiration handling
  • StaticTokenProvider: Provides a constant token
  • ExternalTokenProvider: Delegates to a callback function
  • TokenProviderAuthenticator: Adapts token providers to IAuthentication

New auth types in ConnectionOptions:

  • 'token-provider': Use a custom ITokenProvider
  • 'external-token': Use a callback function
  • 'static-token': Use a static token string

This PR introduces the foundational token provider system that enables
custom token sources for authentication. This is the first of three PRs
implementing token federation support.

New components:
- ITokenProvider: Core interface for token providers
- Token: Token class with JWT parsing and expiration handling
- StaticTokenProvider: Provides a constant token
- ExternalTokenProvider: Delegates to a callback function
- TokenProviderAuthenticator: Adapts token providers to IAuthentication

New auth types in ConnectionOptions:
- 'token-provider': Use a custom ITokenProvider
- 'external-token': Use a callback function
- 'static-token': Use a static token string
Copy link

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

This PR introduces the foundational token provider infrastructure to enable custom token sources for authentication. The implementation adds core interfaces and classes that allow tokens to be sourced from static values, external callbacks, or custom providers, adapting them to work with the existing authentication system.

Key changes:

  • Introduces ITokenProvider interface and Token class for token management with JWT parsing and expiration handling
  • Adds three concrete provider implementations: StaticTokenProvider, ExternalTokenProvider, and TokenProviderAuthenticator
  • Extends connection options with three new auth types: token-provider, external-token, and static-token

Reviewed changes

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

Show a summary per file
File Description
lib/connection/auth/tokenProvider/ITokenProvider.ts Defines the core interface for token providers
lib/connection/auth/tokenProvider/Token.ts Implements token class with JWT parsing, expiration checking, and header management
lib/connection/auth/tokenProvider/StaticTokenProvider.ts Provides static token implementation with JWT support
lib/connection/auth/tokenProvider/ExternalTokenProvider.ts Delegates token retrieval to external callback functions
lib/connection/auth/tokenProvider/TokenProviderAuthenticator.ts Adapts token providers to the IAuthentication interface
lib/connection/auth/tokenProvider/index.ts Exports public API for token provider components
lib/contracts/IDBSQLClient.ts Adds new auth types and TokenCallback type definition
lib/DBSQLClient.ts Implements token provider auth type handling in client
tests/unit/connection/auth/tokenProvider/*.test.ts Comprehensive test coverage for all token provider components

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

LoggerStub doesn't have a logs property, so removed tests that
checked for debug and warning log messages. The important behavior
(token provider authentication) is still tested.
…ication

- Updated Token.fromJWT() documentation to reflect that it handles
  decoding failures gracefully instead of throwing errors
- Removed duplicate TokenCallback type definition from IDBSQLClient.ts
- Now imports TokenCallback from ExternalTokenProvider.ts to maintain
  a single source of truth
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.

2 participants