-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(provider): add Frontegg provider (#11342)
Co-authored-by: Nico Domino <yo@ndo.dev>
- Loading branch information
1 parent
c986a0d
commit 517c877
Showing
5 changed files
with
211 additions
and
0 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 |
---|---|---|
|
@@ -57,6 +57,7 @@ body: | |
- "Identity Server 4" | ||
- "Instagram" | ||
- "Kakao" | ||
- "Frontegg" | ||
- "Keycloak" | ||
- "Kinde" | ||
- "Line" | ||
|
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,90 @@ | ||
import { Callout } from "nextra/components" | ||
import { Code } from "@/components/Code" | ||
|
||
<img align="right" src="/img/providers/frontegg.svg" width="64" height="64" /> | ||
|
||
# Frontegg Provider | ||
|
||
## Resources | ||
|
||
- [Frontegg documentation](https://docs.frontegg.com/docs/how-to-use-our-docs) | ||
|
||
## Setup | ||
|
||
### Callback URL | ||
|
||
<Code> | ||
<Code.Next> | ||
|
||
```bash | ||
https://example.com/api/auth/callback/frontegg | ||
``` | ||
|
||
</Code.Next> | ||
<Code.Svelte> | ||
|
||
```bash | ||
https://example.com/auth/callback/frontegg | ||
``` | ||
|
||
</Code.Svelte> | ||
</Code> | ||
|
||
### Environment Variables | ||
|
||
``` | ||
AUTH_FRONTEGG_ID | ||
AUTH_FRONTEGG_SECRET | ||
AUTH_FRONTEGG_ISSUER | ||
``` | ||
|
||
### Configuration | ||
|
||
Follow these steps: | ||
|
||
Log into the [Frontegg portal](https://portal.frontegg.com) | ||
|
||
Get the following from the Frontegg's portal: | ||
|
||
AUTH_FRONTEGG_ID="<Client ID>" # Environments > Your environment > Env settings | ||
AUTH_FRONTEGG_SECRET="<API KEY>" # Environments > Your environment > Env settings | ||
AUTH_FRONTEGG_ISSUER="<https://[YOUR_SUBDOMAIN].frontegg.com>" # Environments > Your environment > Env settings > Domains > Domain name | ||
|
||
Add the required environment variables from above to your `.env.local` file. | ||
|
||
<Code> | ||
<Code.Next> | ||
|
||
```ts filename="/auth.ts" | ||
import NextAuth from "next-auth" | ||
import Frontegg from "next-auth/providers/frontegg" | ||
|
||
export const { handlers, auth, signIn, signOut } = NextAuth({ | ||
providers: [Frontegg], | ||
}) | ||
``` | ||
|
||
</Code.Next> | ||
<Code.Svelte> | ||
|
||
```ts filename="/src/auth.ts" | ||
import { SvelteKitAuth } from "@auth/sveltekit" | ||
import Frontegg from "@auth/sveltekit/providers/frontegg" | ||
|
||
export const { handle, signIn, signOut } = SvelteKitAuth({ | ||
providers: [Frontegg], | ||
}) | ||
``` | ||
|
||
</Code.Svelte> | ||
<Code.Express> | ||
|
||
```ts filename="/src/app.ts" | ||
import { ExpressAuth } from "@auth/express" | ||
import Frontegg from "@auth/express/providers/frontegg" | ||
|
||
app.use("/auth/*", ExpressAuth({ providers: [Frontegg] })) | ||
``` | ||
|
||
</Code.Express> | ||
</Code> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,111 @@ | ||
/** | ||
* <div style={{display: "flex", justifyContent: "space-between", alignItems: "center"}}> | ||
* <span style={{fontSize: "1.35rem" }}> | ||
* Built-in sign in with <b>Frontegg</b> integration. | ||
* </span> | ||
* <a href="https://frontegg.com" style={{backgroundColor: "black", padding: "12px", borderRadius: "100%" }}> | ||
* <img style={{display: "block"}} src="https://authjs.dev/img/providers/frontegg.svg" width="24"/> | ||
* </a> | ||
* </div> | ||
* | ||
* @module providers/frontegg | ||
*/ | ||
|
||
import type { OIDCConfig, OIDCUserConfig } from "./index.js" | ||
|
||
/** The returned user profile from Frontegg when using the profile callback. [Reference](https://docs.frontegg.com/docs/admin-portal-profile). */ | ||
export interface FronteggProfile { | ||
/** The user's unique Frontegg ID */ | ||
sub: string | ||
/** The user's name */ | ||
name: string | ||
/** The user's email */ | ||
email: string | ||
/** A boolean indicating if the user's email is verified */ | ||
email_verified: boolean | ||
/** The user's picture */ | ||
profilePictureUrl: string | ||
/** The user's roles */ | ||
roles: string[] | ||
/** The user's custom attributes */ | ||
[claim: string]: unknown | ||
} | ||
|
||
/** | ||
* | ||
* ### Setup | ||
* | ||
* #### Callback URL | ||
* ``` | ||
* https://example.com/api/auth/callback/frontegg | ||
* ``` | ||
* | ||
* #### Configuration | ||
* ```ts | ||
* import { Auth } from "@auth/core" | ||
* import Frontegg from "@auth/core/providers/frontegg" | ||
* | ||
* const request = new Request(origin) | ||
* const response = await Auth(request, { | ||
* providers: [ | ||
* Frontegg({ | ||
* clientId: AUTH_FRONTEGG_ID, | ||
* clientSecret: AUTH_FRONTEGG_SECRET, | ||
* issuer: AUTH_FRONTEGG_ISSUER | ||
* }), | ||
* ], | ||
* }) | ||
* ``` | ||
* | ||
* ### Configuring Frontegg | ||
* | ||
* Follow these steps: | ||
* | ||
* Log into the [Frontegg portal](https://portal.frontegg.com) | ||
* | ||
* Authentication > Login method > Hosted login > Add your callback url here <{{APP_URL}}/api/auth/callback/frontegg> | ||
* | ||
* Then, create a `.env.local` file in the project root add the following entries: | ||
* | ||
* Get the following from the Frontegg's portal: | ||
* ``` | ||
* AUTH_FRONTEGG_ID="<Client ID>" # Environments > Your environment > Env settings | ||
* AUTH_FRONTEGG_SECRET="<API KEY>" # Environments > Your environment > Env settings | ||
* AUTH_FRONTEGG_ISSUER="<https://[YOUR_SUBDOMAIN].frontegg.com>" # Environments > Your environment > Env settings > Domains > Domain name | ||
* ``` | ||
* | ||
* ### Resources | ||
* | ||
* - [Frontegg Docs](https://docs.frontegg.com/docs/how-to-use-our-docs) | ||
* | ||
* ### Notes | ||
* | ||
* The Frontegg provider comes with a [default configuration](https://github.com/nextauthjs/next-auth/blob/main/packages/core/src/providers/frontegg.ts). To override the defaults for your use case, check out [customizing a built-in OAuth provider](https://authjs.dev/guides/configuring-oauth-providers). | ||
* | ||
* :::info | ||
* By default, Auth.js assumes that the Frontegg provider is based on the [OIDC](https://openid.net/specs/openid-connect-core-1_0.html) spec | ||
* ::: | ||
* | ||
* ## Help | ||
* | ||
* If you think you found a bug in the default configuration, you can [open an issue](https://authjs.dev/new/provider-issue). | ||
* | ||
* Auth.js strictly adheres to the specification and it cannot take responsibility for any deviation from | ||
* the spec by the provider. You can open an issue, but if the problem is non-compliance with the spec, | ||
* we might not pursue a resolution. You can ask for more help in [Discussions](https://authjs.dev/new/github-discussions). | ||
*/ | ||
export default function Frontegg( | ||
options: OIDCUserConfig<FronteggProfile> | ||
): OIDCConfig<FronteggProfile> { | ||
return { | ||
id: "frontegg", | ||
name: "Frontegg", | ||
type: "oidc", | ||
authorization: `${options.issuer}/oauth/authorize`, | ||
token: `${options.issuer}/oauth/token`, | ||
userinfo: `${options.issuer}/identity/resources/users/v2/me`, | ||
wellKnown: `${options.issuer}/oauth/.well-known/openid-configuration`, | ||
issuer: options.issuer, | ||
options, | ||
} | ||
} |