-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add support for
openIdConnect
security scheme (#70)
- Loading branch information
1 parent
dcce966
commit 9a5d1f0
Showing
10 changed files
with
85 additions
and
12 deletions.
There are no files selected for viewing
This file contains 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,7 @@ | ||
releases: | ||
"@typoas/cli": minor | ||
"@typoas/generator": minor | ||
"@typoas/runtime": minor | ||
|
||
declined: | ||
- "@typoas/react-query" |
This file contains 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 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 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 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 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 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 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 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,34 @@ | ||
import type { | ||
AuthProvider, | ||
BaseFlowConfig, | ||
SecurityAuthentication, | ||
} from './base'; | ||
import type { RequestContext } from '../fetcher'; | ||
|
||
// We don't actually need to have any configuration for OpenIdConnect | ||
// because we only use the already generated accessToken. | ||
export type OpenIdConnectConfiguration = Record<string, never>; | ||
|
||
export class OpenIdConnectSecurityAuthentication | ||
implements SecurityAuthentication | ||
{ | ||
constructor( | ||
private config: OpenIdConnectConfiguration, | ||
private provider?: AuthProvider<BaseFlowConfig>, | ||
) {} | ||
|
||
async applySecurityAuthentication(context: RequestContext): Promise<void> { | ||
if (!this.provider) return; | ||
|
||
const res = await this.provider.getConfig(); | ||
if (res === null) { | ||
return; | ||
} | ||
|
||
const { accessToken, tokenType } = res; | ||
return context.setHeaderParam( | ||
'Authorization', | ||
`${tokenType || 'Bearer'} ${accessToken}`, | ||
); | ||
} | ||
} |
This file contains 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