diff --git a/src/providers/onelogin.js b/src/providers/onelogin.js new file mode 100644 index 0000000000..8895ba61d6 --- /dev/null +++ b/src/providers/onelogin.js @@ -0,0 +1,19 @@ +export default function OneLogin(options) { + return { + id: "onelogin", + name: "OneLogin", + type: "oauth", + version: "2.0", + scope: "openid profile name email", + params: { grant_type: "authorization_code" }, + // These will be different depending on the Org. + accessTokenUrl: `https://${options.domain}/oidc/2/token`, + requestTokenUrl: `https://${options.domain}/oidc/2/auth`, + authorizationUrl: `https://${options.domain}/oidc/2/auth?response_type=code`, + profileUrl: `https://${options.domain}/oidc/2/me`, + profile(profile) { + return { ...profile, id: profile.sub } + }, + ...options, + } +} diff --git a/types/providers.d.ts b/types/providers.d.ts index 236d57e6af..fd854d8378 100644 --- a/types/providers.d.ts +++ b/types/providers.d.ts @@ -88,6 +88,7 @@ export type OAuthProviderType = | "Naver" | "Netlify" | "Okta" + | "OneLogin" | "Osso" | "Reddit" | "Salesforce" diff --git a/types/tests/providers.test.ts b/types/tests/providers.test.ts index 8003c26bb5..ee36662440 100644 --- a/types/tests/providers.test.ts +++ b/types/tests/providers.test.ts @@ -33,7 +33,7 @@ Providers.Credentials({ type: "password", }, }, - authorize: async ({username, password}) => { + authorize: async ({ username, password }) => { const user = { /* fetched user */ } @@ -152,6 +152,13 @@ Providers.Okta({ domain: "https://foo.auth0.com", }) +// $ExpectType OAuthConfig +Providers.OneLogin({ + clientId: "foo123", + clientSecret: "bar123", + domain: "foo.onelogin.com", +}) + // $ExpectType OAuthConfig Providers.BattleNet({ clientId: "foo123", diff --git a/www/docs/providers/onelogin.md b/www/docs/providers/onelogin.md new file mode 100644 index 0000000000..4cf8d34b68 --- /dev/null +++ b/www/docs/providers/onelogin.md @@ -0,0 +1,31 @@ +--- +id: onelogin +title: OneLogin +--- + +## Documentation + +https://developers.onelogin.com/openid-connect + +## Options + +The **OneLogin Provider** comes with a set of default options: + +- [OneLogin Provider options](https://github.com/nextauthjs/next-auth/blob/main/src/providers/onelogin.js) + +You can override any of the options to suit your own use case. + +## Example + +```js +import Providers from `next-auth/providers` +... +providers: [ + Providers.OneLogin({ + clientId: process.env.ONELOGIN_CLIENT_ID, + clientSecret: process.env.ONELOGIN_CLIENT_SECRET, + domain: process.env.ONELOGIN_DOMAIN + }) +] +... +```