Skip to content

Commit 0b321a0

Browse files
alexaka1k-taro56ndom91
authored
feat(providers): add SimpleLogin oidc (#10491)
Co-authored-by: Kawahara Shotaro <[email protected]> Co-authored-by: Nico Domino <[email protected]>
1 parent f1bf7ae commit 0b321a0

File tree

4 files changed

+223
-0
lines changed

4 files changed

+223
-0
lines changed

.github/ISSUE_TEMPLATE/2_bug_provider.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ body:
7373
- "Pipedrive"
7474
- "Reddit"
7575
- "Salesforce"
76+
- "SimpleLogin"
7677
- "Slack"
7778
- "Spotify"
7879
- "Strava"
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
import { Callout } from "nextra/components"
2+
import { Code } from "@/components/Code"
3+
4+
<img
5+
align="right"
6+
src="/img/providers/simplelogin.svg"
7+
height="64"
8+
width="64"
9+
/>
10+
11+
# SimpleLogin Provider
12+
13+
## Resources
14+
15+
- [Sign in with SimpleLogin](https://simplelogin.io/developer/)
16+
- [SimpleLogin OAuth documentation](https://simplelogin.io/docs/siwsl/intro/)
17+
- [SimpleLogin OAuth Configuration](https://app.simplelogin.io/developer)
18+
19+
## Setup
20+
21+
### Callback URL
22+
23+
<Code>
24+
<Code.Next>
25+
26+
```bash
27+
https://example.com/api/auth/callback/simplelogin
28+
```
29+
30+
</Code.Next>
31+
<Code.Svelte>
32+
33+
```bash
34+
https://example.com/auth/callback/simplelogin
35+
```
36+
37+
</Code.Svelte>
38+
</Code>
39+
40+
### Environment Variables
41+
42+
```
43+
AUTH_SIMPLELOGIN_ID
44+
AUTH_SIMPLELOGIN_SECRET
45+
```
46+
47+
### Configuration
48+
49+
<Code>
50+
<Code.Next>
51+
52+
```ts filename="@/auth.ts"
53+
import NextAuth from "next-auth"
54+
import SimpleLogin from "next-auth/providers/simplelogin"
55+
56+
export const { handlers, auth, signIn, signOut } = NextAuth({
57+
providers: [SimpleLogin],
58+
})
59+
```
60+
61+
</Code.Next>
62+
<Code.Svelte>
63+
64+
```ts filename="/src/auth.ts"
65+
import { SvelteKitAuth } from "@auth/sveltekit"
66+
import SimpleLogin from "@auth/sveltekit/providers/simplelogin"
67+
68+
export const { handle, signIn, signOut } = SvelteKitAuth({
69+
providers: [SimpleLogin],
70+
})
71+
```
72+
73+
</Code.Svelte>
74+
<Code.Express>
75+
76+
```ts filename="/src/app.ts"
77+
import { ExpressAuth } from "@auth/express"
78+
import SimpleLogin from "@auth/express/providers/simplelogin"
79+
80+
app.use("/auth/*", ExpressAuth({ providers: [SimpleLogin] }))
81+
```
82+
83+
</Code.Express>
84+
</Code>
85+
86+
## Notes
87+
88+
### Authorized Redirect URIs
89+
90+
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;
91+
92+
- For production: `https://{YOUR_DOMAIN}/api/auth/callback/simplelogin`
93+
- For development: By default **localhost** is whitelisted.
94+
95+
**Authorized Redirect URIs** must be **HTTPS** for security reason (except for `localhost`).
Lines changed: 20 additions & 0 deletions
Loading
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
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

Comments
 (0)