Skip to content

Commit

Permalink
fix(providers): refactor FusionAuth to v4 (#3376)
Browse files Browse the repository at this point in the history
* 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
alessandrojcm and balazsorban44 committed Dec 9, 2021
1 parent ac35d9f commit 8b9a109
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 20 deletions.
20 changes: 0 additions & 20 deletions src/providers/fusionauth.js

This file was deleted.

52 changes: 52 additions & 0 deletions src/providers/fusionauth.ts
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,
}
}

0 comments on commit 8b9a109

Please sign in to comment.