-
Notifications
You must be signed in to change notification settings - Fork 11
Accept custom subdomains in auth.site, direct OAuth authorize to them #451
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
Merged
gh-worker-dd-mergequeue-cf854d
merged 9 commits into
master
from
oliverli/support-custom-subdomains-in-auth-site
Jul 13, 2026
+404
−77
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
ec416e2
feat(auth): accept a custom subdomain in auth.site for the OAuth flow
oliverli e752f43
docs(auth): document custom subdomain support for auth.site
oliverli ea27cd8
fix(auth): make parseSite case-insensitive, normalizing to lowercase
oliverli 781915a
feat(apps): point displayed App Builder URLs at the custom subdomain
oliverli 7e6a878
fix(auth): guard parseSite against non-string values
oliverli 99841e7
fix(apps): prioritize backend app_builder_url, fall back to a constru…
oliverli 1e61297
fix(apps): reuse upload's app_builder_id for release URL fallback
oliverli f016c41
refactor(core): move parseSite out of constants.ts into its own teste…
oliverli 453c231
chore(core): add app-builder-high-code as codeowner for the site helper
oliverli 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
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
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
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
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
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,66 @@ | ||
| // Unless explicitly stated otherwise all files in this repository are licensed under the MIT License. | ||
| // This product includes software developed at Datadog (https://www.datadoghq.com/). | ||
| // Copyright 2019-Present Datadog, Inc. | ||
|
|
||
| import { parseSite } from '@dd/core/helpers/site'; | ||
|
|
||
| describe('Core Helpers', () => { | ||
| describe('parseSite', () => { | ||
| const cases = [ | ||
| { | ||
| description: 'accept a bare known site unchanged', | ||
| input: 'us5.datadoghq.com', | ||
| expected: { site: 'us5.datadoghq.com' }, | ||
| }, | ||
| { | ||
| description: 'accept a custom subdomain on top of a known site', | ||
| input: 'customsubdomain.us5.datadoghq.com', | ||
| expected: { site: 'us5.datadoghq.com', subdomain: 'customsubdomain' }, | ||
| }, | ||
| { | ||
| description: 'accept a custom subdomain on top of a bare site', | ||
| input: 'foobar.datadoghq.com', | ||
| expected: { site: 'datadoghq.com', subdomain: 'foobar' }, | ||
| }, | ||
| { | ||
| description: 'prefer the longest (most specific) matching base site', | ||
| input: 'myorg.us5.datadoghq.com', | ||
| expected: { site: 'us5.datadoghq.com', subdomain: 'myorg' }, | ||
| }, | ||
| { | ||
| description: 'match case-insensitively and normalize to lowercase', | ||
| input: 'CustomSubdomain.US5.DatadogHQ.com', | ||
| expected: { site: 'us5.datadoghq.com', subdomain: 'customsubdomain' }, | ||
| }, | ||
| { | ||
| description: 'reject a site that is not a known site or subdomain of one', | ||
| input: 'not-a-real-site.example.com', | ||
| expected: undefined, | ||
| }, | ||
| { | ||
| description: 'reject a subdomain with multiple labels', | ||
| input: 'foo.bar.datadoghq.com', | ||
| expected: undefined, | ||
| }, | ||
| { | ||
| description: 'reject a subdomain with invalid characters', | ||
| input: 'foo_bar.datadoghq.com', | ||
| expected: undefined, | ||
| }, | ||
| { | ||
| description: 'reject a non-string value instead of throwing', | ||
| input: 123 as unknown as string, | ||
| expected: undefined, | ||
| }, | ||
| { | ||
| description: 'reject a null value instead of throwing', | ||
| input: null as unknown as string, | ||
| expected: undefined, | ||
| }, | ||
| ]; | ||
|
|
||
| test.each(cases)('should $description', ({ input, expected }) => { | ||
| expect(parseSite(input)).toEqual(expected); | ||
| }); | ||
| }); | ||
| }); |
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,40 @@ | ||
| // Unless explicitly stated otherwise all files in this repository are licensed under the MIT License. | ||
| // This product includes software developed at Datadog (https://www.datadoghq.com/). | ||
| // Copyright 2019-Present Datadog, Inc. | ||
|
|
||
| import { SITES } from '@dd/core/constants'; | ||
|
|
||
| // A site value can be a bare known site (e.g. "datadoghq.com") or a single-label | ||
| // custom subdomain on top of one (e.g. "myorg.us5.datadoghq.com"), used by orgs | ||
| // with a custom Datadog URL. Picks the longest (most specific) matching base site | ||
| // so "myorg.us5.datadoghq.com" resolves to "us5.datadoghq.com", not "datadoghq.com". | ||
| // Matching is case-insensitive; the returned site and subdomain are normalized to lowercase. | ||
| export const parseSite = ( | ||
| value: string, | ||
| ): { site: (typeof SITES)[number]; subdomain?: string } | undefined => { | ||
| // Config isn't enforced by the type system at runtime (e.g. plain JS configs), | ||
| // so a non-string can reach here despite the `string` signature. | ||
| if (typeof value !== 'string') { | ||
| return undefined; | ||
| } | ||
|
|
||
| const lowerValue = value.toLowerCase(); | ||
|
|
||
| const exactMatch = SITES.find((s) => s === lowerValue); | ||
| if (exactMatch) { | ||
| return { site: exactMatch }; | ||
| } | ||
|
|
||
| const suffixMatches = SITES.filter((s) => lowerValue.endsWith(`.${s}`)); | ||
| if (!suffixMatches.length) { | ||
| return undefined; | ||
| } | ||
|
|
||
| const site = suffixMatches.reduce((longest, s) => (s.length > longest.length ? s : longest)); | ||
| const subdomain = lowerValue.slice(0, lowerValue.length - site.length - 1); | ||
| if (!subdomain || !/^[a-z0-9-]+$/.test(subdomain)) { | ||
| return undefined; | ||
| } | ||
|
|
||
| return { site, subdomain }; | ||
| }; |
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
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
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
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.
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.
Uh oh!
There was an error while loading. Please reload this page.