Skip to content

Commit

Permalink
feat(providers): add SimpleLogin oidc
Browse files Browse the repository at this point in the history
  • Loading branch information
alexaka1 committed Apr 6, 2024
1 parent 177c5ca commit 826cfbe
Show file tree
Hide file tree
Showing 3 changed files with 122 additions and 0 deletions.
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
20 changes: 20 additions & 0 deletions docs/static/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.
101 changes: 101 additions & 0 deletions packages/core/src/providers/simplelogin.ts
@@ -0,0 +1,101 @@
/**
* <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/providers/custom-provider#override-default-options).
*
* :::
*
* :::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", bg: "#fff", text: "#000" },
options,
};
}

0 comments on commit 826cfbe

Please sign in to comment.