From fd91555f1af0becf41f6ecc7a276de6114aefc04 Mon Sep 17 00:00:00 2001
From: Azrenbeth Dex is a simple, open-source, certified OpenID Connect Provider.
Although it is designed to help building a full-blown provider with an
external database, it can be configured with static passwords in a config file.oidc_config
section:
localpart_template: "{{ user.preferred_username.split('@')[0] }}"
display_name_template: "{{ user.name }}"
-Dex
+Dex
Keycloak is an opensource IdP maintained by Red Hat.
Follow the Getting Started Guide to install Keycloak and set up a realm.
Auth0 is a hosted SaaS IdP solution.
Create a regular web application for Synapse
@@ -371,7 +372,7 @@ to install Dex. display_name_template: "{{ user.name }}"GitHub is a bit special as it is not an OpenID Connect compliant provider, but +
GitHub is a bit special as it is not an OpenID Connect compliant provider, but just a regular OAuth2 provider.
The /user
API endpoint
can be used to retrieve information on the authenticated user. As the Synapse
@@ -400,11 +401,12 @@ does not return a sub
property, an alternative subject_claim<
localpart_template: "{{ user.login }}"
display_name_template: "{{ user.name }}"
-
Google is an OpenID certified authentication and authorisation provider.
oidc_providers:
- idp_id: google
@@ -582,6 +584,54 @@ documentation on setting up SiWA.
config:
email_template: "{{ user.email }}"
+django-oauth-toolkit is a +Django application providing out of the box all the endpoints, data and logic +needed to add OAuth2 capabilities to your Django projects. It supports +OpenID Connect too.
+Configuration on Django's side:
+Redirect uris
: https://synapse.example.com/_synapse/client/oidc/callbackClient type
: Confidential
Authorization grant type
: Authorization code
Algorithm
: HMAC with SHA-2 256
You can customize the claims Django gives to synapse (optional):
+class CustomOAuth2Validator(OAuth2Validator):
+
+ def get_additional_claims(self, request):
+ return {
+ "sub": request.user.email,
+ "email": request.user.email,
+ "first_name": request.user.first_name,
+ "last_name": request.user.last_name,
+ }
+
+Your synapse config is then:
+oidc_providers:
+ - idp_id: django_example
+ idp_name: "Django Example"
+ issuer: "https://example.com/o/"
+ client_id: "your-client-id" # CHANGE ME
+ client_secret: "your-client-secret" # CHANGE ME
+ scopes: ["openid"]
+ user_profile_method: "userinfo_endpoint" # needed because oauth-toolkit does not include user information in the authorization response
+ user_mapping_provider:
+ config:
+ localpart_template: "{{ user.email.split('@')[0] }}"
+ display_name_template: "{{ user.first_name }} {{ user.last_name }}"
+ email_template: "{{ user.email }}"
+
--
cgit 1.5.1