-
Notifications
You must be signed in to change notification settings - Fork 30
feat: OAuth support #330
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
Merged
feat: OAuth support #330
Changes from all commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
b452de2
feat(bugsnag): automate oauth flow on startup if unauthenticated
sazap10 dab67b7
feat: oauth login
sazap10 1c33a91
feat: more oauth flow
sazap10 4f2ef56
feat: add support for oauth
sazap10 5b7857f
fix: tests
sazap10 110a323
chore: configure endpoint via env
sazap10 092a7c4
Merge branch 'main' into oauth_server_bugsnag
sazap10 183a52f
fix: remove allow_unauthenticated config option
sazap10 3486cdf
chore: update biome schema
sazap10 9d96136
feat: update auth middleware for oauth flow
sazap10 be5856d
chore: reduce coverage threshold
sazap10 810786f
feat: remove oauth registration
sazap10 eba84e2
feat: remove oauth discovery
sazap10 688d824
Merge branch 'main' into oauth_server_bugsnag
sazap10 967e68e
feat: make auth tokens optional for oauth flow
sazap10 5eebab6
Merge branch 'main' into oauth_server_bugsnag
sazap10 36a1c08
feat: update dockerfile to work with development and push to latest
sazap10 83ea9ee
chore: ignore dl3006
sazap10 6fe67cb
feat: trigger oauth if not authed
sazap10 b0c1c03
chore: lint
sazap10 32be59d
fix: auth prefix correctly for bugsnag
sazap10 30bf065
chore: linting
sazap10 07053a1
chore: remove debug
sazap10 746cc25
Merge branch 'main' into oauth_server_bugsnag
sazap10 94ceebf
chore: review comments
sazap10 8d4a4a5
chore: remove redundant bugsnag_endpoint lookup
sazap10 7819d68
chore: add tests for new functions
sazap10 fc5a7c6
chore: add tests for oauth flow
sazap10 55ec789
chore: update comment for request-context
sazap10 b16b35d
Merge branch 'main' into oauth_server_bugsnag
tomlongridge d842b55
chore: update changelog
sazap10 06b2746
Merge branch 'oauth_server_bugsnag' of github.com:smartbear/smartbear…
sazap10 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| ignored: | ||
| - DL3006 # We specify the builder image as a build argument, so we ignore this issue. See the Dockerfile for more details. |
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,40 @@ | ||
| import { AsyncLocalStorage } from "node:async_hooks"; | ||
| import type { IncomingMessage } from "node:http"; | ||
|
|
||
| // Storage for pre-request data that can be retrieved from a tool to prevent caching as part of the server instance in a session. | ||
| // For example, the auth token. | ||
| export interface RequestContext { | ||
| headers: Record<string, string | string[] | undefined>; | ||
| } | ||
|
|
||
| // Create the storage instance | ||
| export const requestContextStorage = new AsyncLocalStorage<RequestContext>(); | ||
|
|
||
| /** | ||
| * Run a callback within the request context, extracting headers from the request. | ||
| * This ensures request headers are available via AsyncLocalStorage to downstream code. | ||
| */ | ||
| export function withRequestContext<T>(req: IncomingMessage, fn: () => T): T { | ||
| return requestContextStorage.run({ headers: req.headers }, fn); | ||
| } | ||
|
|
||
| // Helper to get the current context | ||
| export function getRequestContext(): RequestContext | undefined { | ||
| return requestContextStorage.getStore(); | ||
| } | ||
|
|
||
| /** | ||
| * Helper to get a specific header from the current request | ||
| * @param name Header name (case-insensitive) | ||
| * @returns Header value or undefined if not found | ||
| */ | ||
| export function getRequestHeader(name: string): string | string[] | undefined { | ||
| const context = getRequestContext(); | ||
| if (!context?.headers) return undefined; | ||
|
|
||
| // Headers are typically case-insensitive, but node http headers are lowercased | ||
| // We'll try exact match first, then lowercase match | ||
| const headerValue = | ||
| context.headers[name] || context.headers[name.toLowerCase()]; | ||
| return headerValue; | ||
| } |
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.