Skip to content

Commit

Permalink
feat(providers): add OneLogin (#2345)
Browse files Browse the repository at this point in the history
Co-authored-by: Lluis Agusti <[email protected]>
  • Loading branch information
PrabhdeepSingh and ubbe-xyz authored Jul 14, 2021
1 parent d595857 commit 2155c93
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 1 deletion.
19 changes: 19 additions & 0 deletions src/providers/onelogin.js
Original file line number Diff line number Diff line change
@@ -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,
}
}
1 change: 1 addition & 0 deletions types/providers.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ export type OAuthProviderType =
| "Naver"
| "Netlify"
| "Okta"
| "OneLogin"
| "Osso"
| "Reddit"
| "Salesforce"
Expand Down
9 changes: 8 additions & 1 deletion types/tests/providers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Providers.Credentials({
type: "password",
},
},
authorize: async ({username, password}) => {
authorize: async ({ username, password }) => {
const user = {
/* fetched user */
}
Expand Down Expand Up @@ -152,6 +152,13 @@ Providers.Okta({
domain: "https://foo.auth0.com",
})

// $ExpectType OAuthConfig<Profile>
Providers.OneLogin({
clientId: "foo123",
clientSecret: "bar123",
domain: "foo.onelogin.com",
})

// $ExpectType OAuthConfig<Profile>
Providers.BattleNet({
clientId: "foo123",
Expand Down
31 changes: 31 additions & 0 deletions www/docs/providers/onelogin.md
Original file line number Diff line number Diff line change
@@ -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
})
]
...
```

1 comment on commit 2155c93

@vercel
Copy link

@vercel vercel bot commented on 2155c93 Jul 14, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.