Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(providers): add SimpleLogin oidc #10491

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/2_bug_provider.yml
Expand Up @@ -73,6 +73,7 @@ body:
- "Pipedrive"
- "Reddit"
- "Salesforce"
- "SimpleLogin"
- "Slack"
- "Spotify"
- "Strava"
Expand Down
95 changes: 95 additions & 0 deletions docs/pages/getting-started/providers/simplelogin.mdx
@@ -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`).
20 changes: 20 additions & 0 deletions docs/public/img/providers/simplelogin.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
103 changes: 103 additions & 0 deletions packages/core/src/providers/simplelogin.ts
@@ -0,0 +1,103 @@
/**
* <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
*```js
* 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: { logo: "/simplelogin.svg", brandColor: "#e3156a" },
options,
}
}

Check warning on line 103 in packages/core/src/providers/simplelogin.ts

View check run for this annotation

Codecov / codecov/patch

packages/core/src/providers/simplelogin.ts#L1-L103

Added lines #L1 - L103 were not covered by tests