-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(providers): refactor FusionAuth to v4 (#3376)
* feat: updated fusionauth provider * Updated fusionauth profile interface docstring Co-authored-by: Balázs Orbán <info@balazsorban.com> * Refactored openid well know logic Co-authored-by: Balázs Orbán <info@balazsorban.com> * Removed jwks endpoint property Co-authored-by: Balázs Orbán <info@balazsorban.com>
- Loading branch information
1 parent
ac35d9f
commit 8b9a109
Showing
2 changed files
with
52 additions
and
20 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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,52 @@ | ||
import { OAuthConfig, OAuthUserConfig } from "./oauth" | ||
|
||
/** This is the default openid signature returned from FusionAuth | ||
* it can be customized using [lambda functions](https://fusionauth.io/docs/v1/tech/lambdas) | ||
*/ | ||
export interface FusionAuthProfile { | ||
aud: string | ||
exp: number | ||
iat: number | ||
iss: string | ||
sub: string | ||
jti: string | ||
authenticationType: string | ||
email: string | ||
email_verified: boolean | ||
preferred_username: string | ||
at_hash: string | ||
c_hash: string | ||
scope: string | ||
sid: string | ||
} | ||
|
||
export default function FusionAuth< | ||
P extends Record<string, any> = FusionAuthProfile | ||
>( | ||
// tenantId only needed if there is more than one tenant configured on the server | ||
options: OAuthUserConfig<P> & { tenantId?: string } | ||
): OAuthConfig<P> { | ||
return { | ||
id: "fusionauth", | ||
name: "FusionAuth", | ||
type: "oauth", | ||
wellKnown: options?.tenantId | ||
? `${options.issuer}/.well-known/openid-configuration?tenantId=${options.tenantId}` | ||
: `${options.issuer}/.well-known/openid-configuration`, | ||
authorization: { | ||
params: { | ||
scope: "openid offline_access", | ||
...(options?.tenantId && { tenantId: options.tenantId }), | ||
}, | ||
}, | ||
checks: ["pkce", "state"], | ||
profile(profile) { | ||
return { | ||
id: profile.sub, | ||
email: profile.email, | ||
name: profile?.preferred_username, | ||
} | ||
}, | ||
options, | ||
} | ||
} |