-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(providers): add SimpleLogin oidc (#10491)
Co-authored-by: Kawahara Shotaro <121674121+k-taro56@users.noreply.github.com> Co-authored-by: Nico Domino <yo@ndo.dev>
- Loading branch information
1 parent
f1bf7ae
commit 0b321a0
Showing
4 changed files
with
223 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 |
---|---|---|
|
@@ -73,6 +73,7 @@ body: | |
- "Pipedrive" | ||
- "Reddit" | ||
- "Salesforce" | ||
- "SimpleLogin" | ||
- "Slack" | ||
- "Spotify" | ||
- "Strava" | ||
|
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,95 @@ | ||
import { Callout } from "nextra/components" | ||
import { Code } from "@/components/Code" | ||
|
||
<img | ||
align="right" | ||
src="/img/providers/simplelogin.svg" | ||
height="64" | ||
width="64" | ||
/> | ||
|
||
# SimpleLogin Provider | ||
|
||
## Resources | ||
|
||
- [Sign in with SimpleLogin](https://simplelogin.io/developer/) | ||
- [SimpleLogin OAuth documentation](https://simplelogin.io/docs/siwsl/intro/) | ||
- [SimpleLogin OAuth Configuration](https://app.simplelogin.io/developer) | ||
|
||
## Setup | ||
|
||
### Callback URL | ||
|
||
<Code> | ||
<Code.Next> | ||
|
||
```bash | ||
https://example.com/api/auth/callback/simplelogin | ||
``` | ||
|
||
</Code.Next> | ||
<Code.Svelte> | ||
|
||
```bash | ||
https://example.com/auth/callback/simplelogin | ||
``` | ||
|
||
</Code.Svelte> | ||
</Code> | ||
|
||
### Environment Variables | ||
|
||
``` | ||
AUTH_SIMPLELOGIN_ID | ||
AUTH_SIMPLELOGIN_SECRET | ||
``` | ||
|
||
### Configuration | ||
|
||
<Code> | ||
<Code.Next> | ||
|
||
```ts filename="@/auth.ts" | ||
import NextAuth from "next-auth" | ||
import SimpleLogin from "next-auth/providers/simplelogin" | ||
|
||
export const { handlers, auth, signIn, signOut } = NextAuth({ | ||
providers: [SimpleLogin], | ||
}) | ||
``` | ||
|
||
</Code.Next> | ||
<Code.Svelte> | ||
|
||
```ts filename="/src/auth.ts" | ||
import { SvelteKitAuth } from "@auth/sveltekit" | ||
import SimpleLogin from "@auth/sveltekit/providers/simplelogin" | ||
|
||
export const { handle, signIn, signOut } = SvelteKitAuth({ | ||
providers: [SimpleLogin], | ||
}) | ||
``` | ||
|
||
</Code.Svelte> | ||
<Code.Express> | ||
|
||
```ts filename="/src/app.ts" | ||
import { ExpressAuth } from "@auth/express" | ||
import SimpleLogin from "@auth/express/providers/simplelogin" | ||
|
||
app.use("/auth/*", ExpressAuth({ providers: [SimpleLogin] })) | ||
``` | ||
|
||
</Code.Express> | ||
</Code> | ||
|
||
## Notes | ||
|
||
### Authorized Redirect URIs | ||
|
||
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; | ||
|
||
- For production: `https://{YOUR_DOMAIN}/api/auth/callback/simplelogin` | ||
- For development: By default **localhost** is whitelisted. | ||
|
||
**Authorized Redirect URIs** must be **HTTPS** for security reason (except for `localhost`). |
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,107 @@ | ||
/** | ||
* <div style={{backgroundColor: "#000", display: "flex", justifyContent: "space-between", color: "#fff", padding: 16}}> | ||
* <span>Built-in <b>SimpleLogin</b> integration.</span> | ||
* <a href="https://simplelogin.io"> | ||
* <img style={{display: "block"}} src="https://authjs.dev/img/providers/simplelogin.svg" height="48" width="48"/> | ||
* </a> | ||
* </div> | ||
* | ||
* @module providers/simplelogin | ||
*/ | ||
import type { OAuthConfig, OAuthUserConfig } from "./index.js" | ||
|
||
export interface SimpleLoginProfile { | ||
id: number | ||
sub: string | ||
email: string | ||
email_verified: boolean | ||
name: string | ||
avatar_url: string | undefined | ||
client: string | ||
} | ||
|
||
/** | ||
* Add SimpleLogin login to your page. | ||
* | ||
* ### Setup | ||
* | ||
* #### Callback URL | ||
* ``` | ||
* https://example.com/api/auth/callback/simplelogin | ||
* ``` | ||
* | ||
* #### Configuration | ||
*```ts | ||
* import Auth from "@auth/core" | ||
* import SimpleLogin from "@auth/core/providers/simplelogin" | ||
* | ||
* const request = new Request(origin) | ||
* const response = await Auth(request, { | ||
* providers: [ | ||
* SimpleLogin({ | ||
* clientId: SIMPLELOGIN_CLIENT_ID, | ||
* clientSecret: SIMPLELOGIN_CLIENT_SECRET, | ||
* }), | ||
* ], | ||
* }) | ||
* ``` | ||
* | ||
* ### Resources | ||
* | ||
* - [Sign in with SimpleLogin](https://simplelogin.io/developer/) | ||
* - [SimpleLogin OAuth documentation](https://simplelogin.io/docs/siwsl/intro/) | ||
* - [SimpleLogin OAuth Configuration](https://app.simplelogin.io/developer) | ||
* | ||
* ### Notes | ||
* | ||
* By default, Auth.js assumes that the SimpleLogin provider is | ||
* based on the [Open ID Connect](https://openid.net/specs/openid-connect-core-1_0.html) specification. | ||
* | ||
* 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; | ||
* | ||
* - For production: `https://{YOUR_DOMAIN}/api/auth/callback/simplelogin` | ||
* - For development: By default **localhost** is whitelisted. | ||
* | ||
* :::warning | ||
* | ||
* **Authorized Redirect URIs** must be **HTTPS** for security reason (except for `localhost`). | ||
* | ||
* ::: | ||
* | ||
* :::tip | ||
* | ||
* The SimpleLogin provider comes with a [default configuration](https://github.com/nextauthjs/next-auth/blob/main/packages/core/src/providers/simplelogin.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 **Disclaimer** | ||
* | ||
* 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 SimpleLogin<P extends SimpleLoginProfile>( | ||
options: OAuthUserConfig<P> | ||
): OAuthConfig<P> { | ||
return { | ||
id: "simplelogin", | ||
name: "SimpleLogin", | ||
type: "oidc", | ||
issuer: "https://app.simplelogin.io", | ||
profile(profile) { | ||
return { | ||
id: profile.sub, | ||
name: profile.name, | ||
email: profile.email, | ||
image: profile.avatar_url, | ||
} | ||
}, | ||
style: { brandColor: "#e3156a" }, | ||
options, | ||
} | ||
} |