|
| 1 | +/** |
| 2 | + * <div style={{backgroundColor: "#000", display: "flex", justifyContent: "space-between", color: "#fff", padding: 16}}> |
| 3 | + * <span>Built-in <b>SimpleLogin</b> integration.</span> |
| 4 | + * <a href="https://simplelogin.io"> |
| 5 | + * <img style={{display: "block"}} src="https://authjs.dev/img/providers/simplelogin.svg" height="48" width="48"/> |
| 6 | + * </a> |
| 7 | + * </div> |
| 8 | + * |
| 9 | + * @module providers/simplelogin |
| 10 | + */ |
| 11 | +import type { OAuthConfig, OAuthUserConfig } from "./index.js" |
| 12 | + |
| 13 | +export interface SimpleLoginProfile { |
| 14 | + id: number |
| 15 | + sub: string |
| 16 | + email: string |
| 17 | + email_verified: boolean |
| 18 | + name: string |
| 19 | + avatar_url: string | undefined |
| 20 | + client: string |
| 21 | +} |
| 22 | + |
| 23 | +/** |
| 24 | + * Add SimpleLogin login to your page. |
| 25 | + * |
| 26 | + * ### Setup |
| 27 | + * |
| 28 | + * #### Callback URL |
| 29 | + * ``` |
| 30 | + * https://example.com/api/auth/callback/simplelogin |
| 31 | + * ``` |
| 32 | + * |
| 33 | + * #### Configuration |
| 34 | + *```ts |
| 35 | + * import Auth from "@auth/core" |
| 36 | + * import SimpleLogin from "@auth/core/providers/simplelogin" |
| 37 | + * |
| 38 | + * const request = new Request(origin) |
| 39 | + * const response = await Auth(request, { |
| 40 | + * providers: [ |
| 41 | + * SimpleLogin({ |
| 42 | + * clientId: SIMPLELOGIN_CLIENT_ID, |
| 43 | + * clientSecret: SIMPLELOGIN_CLIENT_SECRET, |
| 44 | + * }), |
| 45 | + * ], |
| 46 | + * }) |
| 47 | + * ``` |
| 48 | + * |
| 49 | + * ### Resources |
| 50 | + * |
| 51 | + * - [Sign in with SimpleLogin](https://simplelogin.io/developer/) |
| 52 | + * - [SimpleLogin OAuth documentation](https://simplelogin.io/docs/siwsl/intro/) |
| 53 | + * - [SimpleLogin OAuth Configuration](https://app.simplelogin.io/developer) |
| 54 | + * |
| 55 | + * ### Notes |
| 56 | + * |
| 57 | + * By default, Auth.js assumes that the SimpleLogin provider is |
| 58 | + * based on the [Open ID Connect](https://openid.net/specs/openid-connect-core-1_0.html) specification. |
| 59 | + * |
| 60 | + * The "Authorized redirect URIs" used must include your full domain and end in the callback path. By default, SimpleLogin whitelists all `http[s]://localhost:*` address to facilitate local development. For example; |
| 61 | + * |
| 62 | + * - For production: `https://{YOUR_DOMAIN}/api/auth/callback/simplelogin` |
| 63 | + * - For development: By default **localhost** is whitelisted. |
| 64 | + * |
| 65 | + * :::warning |
| 66 | + * |
| 67 | + * **Authorized Redirect URIs** must be **HTTPS** for security reason (except for `localhost`). |
| 68 | + * |
| 69 | + * ::: |
| 70 | + * |
| 71 | + * :::tip |
| 72 | + * |
| 73 | + * The SimpleLogin provider comes with a [default configuration](https://github.com/nextauthjs/next-auth/blob/main/packages/core/src/providers/simplelogin.ts). |
| 74 | + * To override the defaults for your use case, check out [customizing a built-in OAuth provider](https://authjs.dev/guides/configuring-oauth-providers). |
| 75 | + * |
| 76 | + * ::: |
| 77 | + * |
| 78 | + * :::info **Disclaimer** |
| 79 | + * |
| 80 | + * If you think you found a bug in the default configuration, you can [open an issue](https://authjs.dev/new/provider-issue). |
| 81 | + * |
| 82 | + * Auth.js strictly adheres to the specification and it cannot take responsibility for any deviation from |
| 83 | + * the spec by the provider. You can open an issue, but if the problem is non-compliance with the spec, |
| 84 | + * we might not pursue a resolution. You can ask for more help in [Discussions](https://authjs.dev/new/github-discussions). |
| 85 | + * |
| 86 | + * ::: |
| 87 | + */ |
| 88 | +export default function SimpleLogin<P extends SimpleLoginProfile>( |
| 89 | + options: OAuthUserConfig<P> |
| 90 | +): OAuthConfig<P> { |
| 91 | + return { |
| 92 | + id: "simplelogin", |
| 93 | + name: "SimpleLogin", |
| 94 | + type: "oidc", |
| 95 | + issuer: "https://app.simplelogin.io", |
| 96 | + profile(profile) { |
| 97 | + return { |
| 98 | + id: profile.sub, |
| 99 | + name: profile.name, |
| 100 | + email: profile.email, |
| 101 | + image: profile.avatar_url, |
| 102 | + } |
| 103 | + }, |
| 104 | + style: { brandColor: "#e3156a" }, |
| 105 | + options, |
| 106 | + } |
| 107 | +} |
0 commit comments