-
Notifications
You must be signed in to change notification settings - Fork 44
Add token provider infrastructure for token federation (Token Federation 1/3) #318
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
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
There was a problem hiding this 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
ITokenProviderinterface andTokenclass for token management with JWT parsing and expiration handling - Adds three concrete provider implementations:
StaticTokenProvider,ExternalTokenProvider, andTokenProviderAuthenticator - Extends connection options with three new auth types:
token-provider,external-token, andstatic-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
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:
New auth types in ConnectionOptions: