Skip to content

Commit 2155c93

Browse files
feat(providers): add OneLogin (#2345)
Co-authored-by: Lluis Agusti <[email protected]>
1 parent d595857 commit 2155c93

File tree

4 files changed

+59
-1
lines changed

4 files changed

+59
-1
lines changed

src/providers/onelogin.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
export default function OneLogin(options) {
2+
return {
3+
id: "onelogin",
4+
name: "OneLogin",
5+
type: "oauth",
6+
version: "2.0",
7+
scope: "openid profile name email",
8+
params: { grant_type: "authorization_code" },
9+
// These will be different depending on the Org.
10+
accessTokenUrl: `https://${options.domain}/oidc/2/token`,
11+
requestTokenUrl: `https://${options.domain}/oidc/2/auth`,
12+
authorizationUrl: `https://${options.domain}/oidc/2/auth?response_type=code`,
13+
profileUrl: `https://${options.domain}/oidc/2/me`,
14+
profile(profile) {
15+
return { ...profile, id: profile.sub }
16+
},
17+
...options,
18+
}
19+
}

types/providers.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ export type OAuthProviderType =
8888
| "Naver"
8989
| "Netlify"
9090
| "Okta"
91+
| "OneLogin"
9192
| "Osso"
9293
| "Reddit"
9394
| "Salesforce"

types/tests/providers.test.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ Providers.Credentials({
3333
type: "password",
3434
},
3535
},
36-
authorize: async ({username, password}) => {
36+
authorize: async ({ username, password }) => {
3737
const user = {
3838
/* fetched user */
3939
}
@@ -152,6 +152,13 @@ Providers.Okta({
152152
domain: "https://foo.auth0.com",
153153
})
154154

155+
// $ExpectType OAuthConfig<Profile>
156+
Providers.OneLogin({
157+
clientId: "foo123",
158+
clientSecret: "bar123",
159+
domain: "foo.onelogin.com",
160+
})
161+
155162
// $ExpectType OAuthConfig<Profile>
156163
Providers.BattleNet({
157164
clientId: "foo123",

www/docs/providers/onelogin.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
---
2+
id: onelogin
3+
title: OneLogin
4+
---
5+
6+
## Documentation
7+
8+
https://developers.onelogin.com/openid-connect
9+
10+
## Options
11+
12+
The **OneLogin Provider** comes with a set of default options:
13+
14+
- [OneLogin Provider options](https://github.com/nextauthjs/next-auth/blob/main/src/providers/onelogin.js)
15+
16+
You can override any of the options to suit your own use case.
17+
18+
## Example
19+
20+
```js
21+
import Providers from `next-auth/providers`
22+
...
23+
providers: [
24+
Providers.OneLogin({
25+
clientId: process.env.ONELOGIN_CLIENT_ID,
26+
clientSecret: process.env.ONELOGIN_CLIENT_SECRET,
27+
domain: process.env.ONELOGIN_DOMAIN
28+
})
29+
]
30+
...
31+
```

0 commit comments

Comments
 (0)