forked from akuity/kargo
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(auth): auto attach
offline_access
only if idp supports (akuity#…
…3117) Signed-off-by: Mayursinh Sarvaiya <marvinduff97@gmail.com>
- Loading branch information
Showing
8 changed files
with
31 additions
and
22 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
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,20 @@ | ||
import { AuthorizationServer, ClientAuth } from 'oauth4webapi'; | ||
|
||
import { OIDCConfig } from '@ui/gen/service/v1alpha1/service_pb'; | ||
|
||
export const oidcClientAuth: ClientAuth = () => { | ||
// equivalent function for token_endpoint_auth_method: 'none' | ||
}; | ||
|
||
export const shouldAllowIdpHttpRequest = () => __UI_VERSION__ === 'development'; | ||
|
||
export const getOIDCScopes = (userOIDCConfig: OIDCConfig, idp: AuthorizationServer) => { | ||
const scopes = [...userOIDCConfig.scopes]; | ||
|
||
// add offline_access scope automatically only if it is supported by IDP | ||
if (!scopes.includes('offline_access') && idp.scopes_supported?.includes('offline_access')) { | ||
scopes.push('offline_access'); | ||
} | ||
|
||
return scopes; | ||
}; |
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