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: pages/client-libraries/python.mdx
+26Lines changed: 26 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -177,6 +177,7 @@ Once the database is running and the client is installed or available in Python,
177
177
-[Connect without authentication (default)](#connect-without-authentication-default)
178
178
-[Connect with authentication](#connect-with-authentication)
179
179
-[Connect with self-signed certificate](#encrypted-database-connection-with-self-signed-certificate)
180
+
-[Connect with Single sign-on (SSO)](#connect-with-single-sign-on-sso)
180
181
181
182
#### Connect without authentication (default)
182
183
@@ -269,6 +270,31 @@ with GraphDatabase.driver(URI, auth=AUTH) as client:
269
270
print(record["name"])
270
271
```
271
272
273
+
#### Connect with Single sign-on (SSO)
274
+
275
+
<Callouttype="warning">
276
+
This is currently only supported for OIDC SSO.
277
+
</Callout>
278
+
279
+
To use SSO with the Python driver you need to get the access and id tokens yourself.
280
+
One simple way to do it is to use the authlib library and follow the official [tutorial](https://docs.authlib.org/en/latest/client/oauth2.html).
281
+
282
+
To connect to the Memgraph database you have to use the `custom_auth` class with the `scheme` parameter set as `oidc-entra-id`, `oidc-okta` or `oidc-custom` depending on which scheme you are using,
283
+
`credentials` parameter set to contain both access and id tokens in the format shown in the example below. Finally set `principal` and `realm` parameters to `None`.
284
+
285
+
Below is an example of connecting to the Memgraph database using OIDC SSO with custom auth scheme.
After connecting your client to Memgraph, you can start running queries. The simplest way to run queries is by using the `execute_query()` method which has an automatic transaction management.
Copy file name to clipboardExpand all lines: pages/database-management/authentication-and-authorization/auth-system-integrations.mdx
+31Lines changed: 31 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -295,6 +295,31 @@ Role mapping is described [here](#single-sign-on).
295
295
296
296
Issuer is `https://{your-okta-domain}.okta.com/oauth2/default/`. You can find the client ID on the Admin panel -> Applications -> General. You can find the authorization server on the Admin panel -> Security -> API -> Authorization Servers -> Audience. By default, it is set to `api://default`.
297
297
298
+
##### Custom auth
299
+
300
+
<Callouttype="warning">
301
+
This is currently only supported through the Neo4j drivers.
302
+
</Callout>
303
+
304
+
If you are using an OIDC provider which is not listed above you can use you the custom auth scheme.
305
+
The only requirement is that your OIDC provider supports verifying the tokens through RSA algorithm (public & private key).
306
+
307
+
Setup the following environmental variables:
308
+
309
+
```mdx
310
+
MEMGRAPH_SSO_CUSTOM_OIDC_PUBLIC_KEY_ENDPOINT=`URI where the public key for validating the tokens is exposed`
MEMGRAPH_SSO_CUSTOM_OIDC_ROLE_FIELD=`access token field to be used in the role mapping`
314
+
MEMGRAPH_SSO_CUSTOM_OIDC_USERNAME=
315
+
MEMGRAPH_SSO_CUSTOM_OIDC_ROLE_MAPPING=
316
+
```
317
+
318
+
Usernames are described below and role mappings are described [here](#single-sign-on).
319
+
One way to deduce the audience of the access and id tokens is to decode them using a tool like `jwt.io`, check the `aud` field and deduce what it is.
320
+
Often time access and id token will the use the same audience. For example in MS Entra ID both tokens use the client ID as audience.
321
+
322
+
298
323
##### Username
299
324
The username variable tells the OIDC module what to use as the username. It has the format `token-type:field`.
300
325
Token type can be `id` or `access` depending on whether you want to use a field from the access or the ID token for the username. See the following to learn more about [access](https://www.okta.com/identity-101/access-token/) and [id](https://developer.okta.com/docs/guides/validate-id-tokens/main/#id-tokens-vs-access-tokens) tokens.
@@ -306,6 +331,12 @@ For Okta one commonly used field is `access:sub` which is usually the email of t
306
331
OIDC is by default enabled using the Memgraph `oidc.py` module. To use a custom auth module use the `--auth-module-mappings`[flag](/database-management/configuration#auth-module) like the following:
307
332
`--auth-module-mappings=oidc-entra-id:/path/to/oidc-entra-module;oidc-okta:/path/to/oidc-okta-module` depending on the SSO provider you want to use.
308
333
334
+
#### Using OIDC SSO with the Neo4j Python driver
335
+
336
+
Connecting using SSO is supported with the Neo4j Python driver. For the
337
+
instructions on how to connect, check the [Python driver
0 commit comments