You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/4.auth/7.sso/1.index.md
-49Lines changed: 0 additions & 49 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -29,55 +29,6 @@ Here are the configurations allowed for each one: [SSO configuration](/configura
29
29
30
30
In order to use these mechanisms you need to create an application/configuration on your preferred external provider, set the environment variables to configure the external provider and optionally, set the environment variables to configure cookies.
31
31
32
-
### OpenID
33
-
34
-
In this section, we provide some guides to help you set up SSO with OpenID.
35
-
36
-
#### Google
37
-
38
-
To be able to use Google OpenID as your external provider you'll need to:
39
-
40
-
1. Go into [Google Cloud Console](https://console.cloud.google.com)
41
-
2. Select or Create a new project
42
-
3. Go to [APIs & Services -> OAuth consent screen](https://console.cloud.google.com/apis/credentials/consent) on side
43
-
bar
44
-
1. Select the access you desire
45
-
- Select **Internal** if you only want people within your organization to be able to access
46
-
- Select **External** to allow everyone with a Google account
47
-
2. Fill the fields according to your preferences
48
-
- The **Authorized domains** add an extra layer of security, but it is not required. In case you fill it, should
49
-
be the domain where your Directus instance is
50
-
3. On Scopes, you need to choose `.../auth/userinfo.email`, `.../auth/userinfo.profile` and `openid`
51
-
4. On side bar, go to [Credentials](https://console.cloud.google.com/apis/credentials)
52
-
5. Click on [Create Credentials -> OAuth Client ID](https://console.cloud.google.com/apis/credentials/oauthclient)
53
-
1. Choose `Web Application` on **Application Type**
54
-
2. The **Authorized JavaScript origins** adds an extra layer of security, but it is not required. In case you fill
55
-
it, should be the address of your Directus instance. For example, `https://directus.myserver.com`
56
-
3. On **Authorized redirect URIs** put your Directus instance address plus `/auth/login/google/callback`. For
57
-
example, you should put `https://directus.myserver.com/auth/login/google/callback` where
58
-
`https://directus.myserver.com` should be the address of your Directus instance. If you are testing locally you
59
-
should add `http://localhost:8055/auth/login/google/callback` too
60
-
6. On click **Create**, a modal will appear with **Client ID** and **Client Secret**. Save both somewhere to use later.
61
-
62
-
7. Now on Directus side, you need to add the following configuration to your `.env` file located on root folder of your
63
-
project:
64
-
65
-
```sh
66
-
AUTH_PROVIDERS="google"
67
-
68
-
AUTH_GOOGLE_DRIVER="openid"
69
-
AUTH_GOOGLE_CLIENT_ID="XXXX"# Replace XXXX with the Client ID from Step 6
70
-
AUTH_GOOGLE_CLIENT_SECRET="XXXX"# Replace XXXX with the Client Secret from Step 6
AUTH_GOOGLE_ALLOW_PUBLIC_REGISTRATION="true"# This allows users to be automatically created on logins. Use "false" if you want to create users manually
76
-
AUTH_GOOGLE_DEFAULT_ROLE_ID="XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"# Replace this with the Directus Role ID you would want for new users. If this is not properly configured, new users will not have access to Directus
77
-
```
78
-
79
-
8. Now you can see a nice functional `Login with Google` button on Directus login page.
80
-
81
32
## SSO with Directus behind Proxy
82
33
83
34
If Directus is running behind an HTTP(S) proxy, the instance might not be able to reach the configured SSO provider. In
Copy file name to clipboardExpand all lines: content/4.auth/7.sso/2.seamless.md
+69-66Lines changed: 69 additions & 66 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,98 +4,101 @@ description:
4
4
5
5
# Seamless SSO
6
6
7
-
While sometimes you want your users to directly have access to the Directus Application, in other cases you may need to
7
+
While sometimes you want your users to directly have access to the Directus project, in other cases you may need to
8
8
fetch private data from Directus in your client using external providers. For such cases, a special configuration is
9
-
required to work across domains:
9
+
required to work across domains.
10
10
11
-
1. Setup an external provider. You'll find some examples under [Supported SSO mechanisms](#supported-sso-mechanisms).
12
-
2. Allow the cookie to be accessible across domains. For that, use the following configuration:
11
+
## Implementing Seamless SSO
13
12
14
-
**Authentication Mode: session**
13
+
Setup an external provider. You'll find some examples further down below. Allow the cookie to be accessible across domains. There are two authentication mechanisms for this.
15
14
16
-
```sh
17
-
AUTH_<PROVIDER>_MODE="session"
18
-
SESSION_COOKIE_DOMAIN="XXXX"# Replace XXXX with the domain of your Directus instance. For example "directus.myserver.com"
19
-
SESSION_COOKIE_SECURE="true"
20
-
SESSION_COOKIE_SAME_SITE="None"
21
-
```
15
+
**Authentication Mode: session**
16
+
17
+
```sh
18
+
AUTH_<PROVIDER>_MODE="session"
19
+
SESSION_COOKIE_DOMAIN="XXXX"
20
+
SESSION_COOKIE_SECURE="true"
21
+
SESSION_COOKIE_SAME_SITE="None"
22
+
```
23
+
24
+
**Authentication Mode: cookie (legacy)**
25
+
26
+
```sh
27
+
AUTH_<PROVIDER>_MODE="cookie"
28
+
REFRESH_TOKEN_COOKIE_DOMAIN="XXXX"#
29
+
REFRESH_TOKEN_COOKIE_SECURE="true"
30
+
REFRESH_TOKEN_COOKIE_SAME_SITE="None"
31
+
```
22
32
23
-
**Authentication Mode: cookie (legacy)**
33
+
Replace XXXX for either of these modes with the domain of your Directus instance. For example "directus.myserver.com"
24
34
25
-
```sh
26
-
AUTH_<PROVIDER>_MODE="cookie"
27
-
REFRESH_TOKEN_COOKIE_DOMAIN="XXXX"# Replace XXXX with the domain of your Directus instance. For example "directus.myserver.com"
28
-
REFRESH_TOKEN_COOKIE_SECURE="true"
29
-
REFRESH_TOKEN_COOKIE_SAME_SITE="None"
30
-
```
35
+
On your client, the login button should conform to the following format:
31
36
32
-
3. On your client, the login button should conform to the following format:
In the above, `https://directus.myserver.com` should be the address of your Directus instance, while `https://client.myserver.com/login` should be the address of your client application. The `/login` path is not necessary, but helps to separate concerns.
40
45
41
-
- Where `https://directus.myserver.com` should be the address of your Directus instance
42
-
- While `https://client.myserver.com/login` should be the address of your client application. The `/login` path is
43
-
not necessary, but helps to separate concerns.
46
+
On your login page, following the example of `https://client.myserver.com/login`, you need to call the refresh
47
+
endpoint either via REST API or via SDK in order to have a session cookie or an `access_token`. Here are some
48
+
examples:
44
49
45
-
4. On your login page, following the example of `https://client.myserver.com/login`, you need to call the refresh
46
-
endpoint either via REST API or via SDK in order to have a session cookie or an `access_token`. Here are some
credentials:"include", // this is required in order to send the refresh/session token cookie
55
-
headers: {
56
-
Accept:"application/json",
57
-
"Content-Type":"application/json",
58
-
},
59
-
body:JSON.stringify({ mode:"session" }), // using 'session' mode, but can also be 'cookie' or 'json'
60
-
});
61
-
```
64
+
In the above, `credentials` is required in order to send the refresh/session token cookie. This is using `'session'` mode, but it can also be 'cookie' or 'json'.
62
65
63
-
- via SDKin`session`authentication mode
66
+
**Via SDK in `session`Authentication Mode**
64
67
65
-
```js
66
-
import { createDirectus, authentication } from "@directus/sdk";
0 commit comments