-
Notifications
You must be signed in to change notification settings - Fork 70
Add oidc support #374
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
Draft
luismeyer
wants to merge
7
commits into
main
Choose a base branch
from
oidc
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Add oidc support #374
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
62810cc
Add oidc support
luismeyer 55e5c7f
changeset
luismeyer 4333155
update tests
luismeyer 43b994c
update def script
luismeyer d5218fb
fix provider data
luismeyer ee1b538
update changeset
luismeyer e6e443e
fix createVercelAdapter
luismeyer File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| --- | ||
| "@flags-sdk/vercel": minor | ||
| "@vercel/prepare-flags-definitions": minor | ||
| "@vercel/flags-core": minor | ||
| --- | ||
|
|
||
| Add OIDC authentication support for Vercel Flags clients and generated flag definitions. | ||
|
|
||
| `@vercel/flags-core` can now create clients without an SDK key and authenticate with a Vercel OIDC token, while still supporting SDK keys and connection strings. Bundled definitions can be looked up by SDK key hash or OIDC project ID. | ||
|
|
||
| `@vercel/prepare-flags-definitions` now collects both SDK keys and `VERCEL_OIDC_TOKEN`, fetches definitions for each auth entry, deduplicates identical definitions across SDK keys and OIDC project IDs, and writes generated maps keyed by SDK key hash or project ID. | ||
|
|
||
| `@flags-sdk/vercel` now supports provider data lookup for Vercel flag origins that do not include an SDK key, allowing OIDC-backed clients to resolve project metadata. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -23,10 +23,10 @@ export type VercelAdapterDeclaration<ValueType, EntitiesType> = Omit< | |||||||||||||||
| */ | ||||||||||||||||
| export function createVercelAdapter( | ||||||||||||||||
| // usually a connection string, but can also be a pre-configured FlagsClient | ||||||||||||||||
| sdkKeyOrFlagsClient: string | FlagsClient, | ||||||||||||||||
| sdkKeyOrFlagsClient?: string | FlagsClient, | ||||||||||||||||
| ) { | ||||||||||||||||
| const flagsClient = | ||||||||||||||||
| typeof sdkKeyOrFlagsClient === 'string' | ||||||||||||||||
| typeof sdkKeyOrFlagsClient === 'string' || sdkKeyOrFlagsClient === undefined | ||||||||||||||||
| ? createClient(sdkKeyOrFlagsClient) | ||||||||||||||||
| : sdkKeyOrFlagsClient; | ||||||||||||||||
|
|
||||||||||||||||
|
|
@@ -86,9 +86,9 @@ export function vercelAdapter<ValueType, EntitiesType>(): Adapter< | |||||||||||||||
| return defaultVercelAdapter<ValueType, EntitiesType>(); | ||||||||||||||||
| } | ||||||||||||||||
|
|
||||||||||||||||
| const flagsClients = new Map<string, FlagsClient>(); | ||||||||||||||||
| const flagsClients = new Map<string | undefined, FlagsClient>(); | ||||||||||||||||
|
|
||||||||||||||||
| function getOrCreateClient(sdkKey: string): FlagsClient { | ||||||||||||||||
| function getOrCreateClient(sdkKey?: string): FlagsClient { | ||||||||||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's non-obvious that this will now also work for
Suggested change
|
||||||||||||||||
| let client = flagsClients.get(sdkKey); | ||||||||||||||||
| if (!client) { | ||||||||||||||||
| client = createClient(sdkKey); | ||||||||||||||||
|
|
@@ -99,14 +99,12 @@ function getOrCreateClient(sdkKey: string): FlagsClient { | |||||||||||||||
|
|
||||||||||||||||
| function isVercelOrigin( | ||||||||||||||||
| origin: unknown, | ||||||||||||||||
| ): origin is { provider: 'vercel'; sdkKey: string } { | ||||||||||||||||
| ): origin is { provider: 'vercel'; sdkKey?: string } { | ||||||||||||||||
| return ( | ||||||||||||||||
| typeof origin === 'object' && | ||||||||||||||||
| origin !== null && | ||||||||||||||||
| 'provider' in origin && | ||||||||||||||||
| (origin as Record<string, unknown>).provider === 'vercel' && | ||||||||||||||||
| 'sdkKey' in origin && | ||||||||||||||||
| typeof (origin as Record<string, unknown>).sdkKey === 'string' | ||||||||||||||||
| (origin as Record<string, unknown>).provider === 'vercel' | ||||||||||||||||
| ); | ||||||||||||||||
| } | ||||||||||||||||
|
|
||||||||||||||||
|
|
@@ -122,14 +120,14 @@ export async function getProviderData( | |||||||||||||||
| .filter((i): i is KeyedFlagDefinitionType => !Array.isArray(i)); | ||||||||||||||||
|
|
||||||||||||||||
| // Collect unique sdkKeys and resolve their projectIds | ||||||||||||||||
| const sdkKeys = new Set<string>(); | ||||||||||||||||
| const sdkKeys = new Set<string | undefined>(); | ||||||||||||||||
| for (const d of flagDefs) { | ||||||||||||||||
| if (isVercelOrigin(d.origin)) { | ||||||||||||||||
| sdkKeys.add(d.origin.sdkKey); | ||||||||||||||||
| } | ||||||||||||||||
| } | ||||||||||||||||
|
|
||||||||||||||||
| const projectIdBySdkKey = new Map<string, string>(); | ||||||||||||||||
| const projectIdBySdkKey = new Map<string | undefined, string>(); | ||||||||||||||||
| await Promise.all( | ||||||||||||||||
| Array.from(sdkKeys).map(async (sdkKey) => { | ||||||||||||||||
| const client = getOrCreateClient(sdkKey); | ||||||||||||||||
|
|
||||||||||||||||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
createVercelAdapterarg needs to be optional, such that it can default to the oidc one