Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
en:2.0:single_sign_on:saml_dokuwiki [2025/04/25 09:36] – created kainhofer | en:2.0:single_sign_on:saml_dokuwiki [2025/05/05 20:21] (current) – kainhofer | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== Single-Sign-On into DokuWiki using Admidio as a SAML 2.0 Identity Provider ====== | ====== Single-Sign-On into DokuWiki using Admidio as a SAML 2.0 Identity Provider ====== | ||
- | Starting with version 5.0, Admidio can be used by other applications to authenticate users against Admidios user base. These instructions will guide you through the process of connecting DokuWiki to Admidio to use Admidio' | + | Starting with version 5.0, Admidio can be used by other applications to authenticate users against Admidios user base. These instructions will guide you through the process of connecting DokuWiki to Admidio to use Admidio' |
===== Prerequisites ===== | ===== Prerequisites ===== | ||
Line 8: | Line 8: | ||
As a first step, one needs to **configure Admidio to act as an SAML 2.0 Identity Provider** (IdP). This has to be done once and is not specific to DokuWiki. Please follow this guide: [[en: | As a first step, one needs to **configure Admidio to act as an SAML 2.0 Identity Provider** (IdP). This has to be done once and is not specific to DokuWiki. Please follow this guide: [[en: | ||
+ | {{ : | ||
Basically, one (1) needs to **create a cryptographic key** to sign message and **choose a unique EntityID**. | Basically, one (1) needs to **create a cryptographic key** to sign message and **choose a unique EntityID**. | ||
Line 16: | Line 17: | ||
Setting up a client (SAML " | Setting up a client (SAML " | ||
- | * At the **Service Provider (SP)** - DokuWiki in our case - **install the extension** to support SAML login with an external IdP. | + | * At the **Service Provider (SP)** - DokuWiki in our case - **install the extension** to support SAML login. |
* Configure it either with Admidio' | * Configure it either with Admidio' | ||
* Choose whether sent messages **should be signed and/or encrypted** (these features require an additional private key and certificate for the SP!), and whether received messages are checked for signatures or encryption is expected. | * Choose whether sent messages **should be signed and/or encrypted** (these features require an additional private key and certificate for the SP!), and whether received messages are checked for signatures or encryption is expected. | ||
Line 26: | Line 27: | ||
===== DokuWiki-specific instructions ===== | ===== DokuWiki-specific instructions ===== | ||
- | |||
- | - [[# | ||
- | - In the simplest case, paste the metadata URL into the client configuration | ||
- | - If the client does not support auto-setup using metadata, manually copy/enter the settings: | ||
- | - Admidio URLs for Single-sign-on (SSO) and Single-Log-Out (SLO) | ||
- | - Public key / certificate of the Admidio IdP. | ||
- | - Choose a unique client ID to identify the client to Admidio. | ||
- | - [[# | ||
- | - Create a new SAML client in Admidio' | ||
- | - Ideally, the client (" | ||
- | - If not, manually copy/enter the Client ID, theURL where the user should be redirected after login (ACS URL) as well as an optional cryptographic certificate used by the client to sign messages. | ||
- | - In many cases, the automatic setup via metadata will work, but it is possible to add further configuration, | ||
- | |||
- | This page will describe the generic setup of a Admidio and a SAML 2.0 client. It has been tested with several SAML-ready applications, | ||
- | ^ Client | ||
- | ^ Nextcloud | ||
- | ^ DokuWiki | ||
- | ^ Wordpress | ||
- | | Joomla | ||
- | | Drupal | ||
- | | Moodle | ||
- | | MediaWiki | ||
- | | Odoo | | | | ||
- | | Gitlab | ||
- | | Keycloak | ||
- | |||
- | |||
- | |||
- | ===== How does Single-Sign-On work? ===== | ||
- | ==== Traditional Log-In ==== | ||
- | |||
- | {{ : | ||
- | The default login process to an app (the " | ||
- | - User clicks on "Log In" | ||
- | - The app determines whether the user has access: It displays a login form, checks the entered Username and Password (hash), and if they exist and match, makes the decision to grant access. | ||
- | - the app now knows that the user has successfully logged in and creates an appropriate session to keep the user logged in. | ||
- | |||
- | Step 2 are done by the application in this case, but there is no technical requirement for this. In principle, the decision that a user has successfully logged in can be done by any **trusted** system. This is where single-sign-on hooks in: Rather than each app requesting and processing passwords, step 2 is delegated to a so-called identity provider (" | ||
- | |||
- | ==== Single-Sign-On using an external Identity Provider (IdP) ==== | ||
- | |||
- | There are two established technical protocols for Single-Sign-On: | ||
- | |||
- | In the SAML case, the login flow above changes to the following. But but from a user perspective, | ||
- | |||
- | {{ : | ||
- | - User clicks on "Log In" | ||
- | - The app does not determine user login itself. Instead it relies on a third party (the " | ||
- | - It creates an XML containing an XML " | ||
- | - If the user is not logged in to Admidio, it shows the login screen | ||
- | - Admidio checks the login of the user (and whether the user is member of the permitted groups) | ||
- | - If login is successful (or the user was already logged in), access should be granted. This is documented in XML data (the " | ||
- | - In addition to the username, the Assertion returned to the SP can also contain further user information (email, first/last name, etc.) and groups/ | ||
- | - The client app (Service Provider) now knows that the user has successfully logged in to Admidio and creates an appropriate session to keep the user logged in. | ||
- | |||
- | |||
- | There are some things to notice about the way SAML authentication works: | ||
- | - All **password handling** and requesting is done **by Admidio alone**. The Service Provider (client app) never receives, asks or has to handle passwords. | ||
- | - It is extremely important to ensure that the requests are really sent to the right system and the returned responses really originate from the authorized IdP. This can be assured by using **public key cryptography**, | ||
- | - The **IdP and the SP never communicate directly**, only through the user's browser! As a consequence, | ||
- | |||
- | |||
- | ===== A. Basic Setup for Admidio as a SAML ID Provider ===== | ||
- | |||
- | Admidio' | ||
- | {{ : | ||
- | ==== 1. Generating a Cryptographic Key for Signing and Encryption ==== | ||
- | |||
- | * The first thing to do is to create a cryptographic key (typically an RSA key with 2048 bit). For this, use the "SSO cryptographic Keys Administration" | ||
- | * {{ : | ||
- | * Also enter the URL of the Admidio installation as " | ||
- | {{ : | ||
- | * The key should now be listed and activated. Return | ||
- | | ||
- | ==== 2. Configuring Admidio as IdP ==== | ||
- | |||
- | * In the SSO section of the preferences, | ||
- | * **SAML Entity ID**: The URL of your installation (needs to be a **unique ID**, the URL is usually used, but not required) | ||
- | * **Key for signatures**: | ||
- | * Key for **Encryption**: | ||
- | * Select whether Admidio adivses all SPs to sign their messages in turn. This requires each client to have a cryptographic key generated for itself, which some clients (e.g. DokuWiki) do not support. Clients that do not support signatures, will still work, this is just a declaration of preference by Admidio! | ||
- | * Save | ||
- | {{ : | ||
- | |||
- | The Preferences page also lists all the relevant data to set up the client as a Service Provider. Particularly useful will be the Metadata URL, which provides all data to set up a client (SP) in XML format. You don't need to do anything, the SSO plugin for Admidio provides this out of the box. Here is an example of such a metadata xml: | ||
- | {{ : | ||
- | Notice that it contains both the public key / certificate of the signing and encryption keys, as well as the URLs to the SingleSignOnService (SSO) and the SingleLogOutService (SLO) at the admidio installation. Furthermore, | ||
- | |||
- | |||
- | Admidio is now **ready to provide single-sign-on functionality to Service Providers**. | ||
- | |||
- | Each SP first needs to be set up with the URLs (and keys) to connect to Admidio. This can ideally be done by providing the SP with the link to the metadata. After that, Admidio needs to be configured to accept login requests from the SP. Again, each SP typically provides the required data as a metadata XML, which can be loaded in Admidio to set up the client for Single-sign-on functionality. The details depend on the actual client app. | ||
- | |||
- | Here we show the setup at the examples of: | ||
- | * [[# | ||
- | * [[# | ||
- | * [[# | ||
- | |||
- | |||
- | ===== B. Configuring an App (Service Provider) to use SSO with Admidio ===== | ||
- | |||
- | Once Admidio is set up to act as a SAML 2.0 IdP, the clients (Service Providers, " | ||
- | |||
- | * **Metadata URL** (optional; for automatic setup of clients): https:// | ||
- | * If your SP supports entering and loading the metadata XML, make sure to use it. It will load the correct settings from the SAML IdP and set up most settings correctly! | ||
- | * **IdP SAML Entity ID** (unique identifier of the Admidio instance): https:// | ||
- | * **SSO Endpoint** (where the SP sends the login request): https:// | ||
- | * **SLO Endpoint** (where logout requests are sent to): https:// | ||
- | * **x509 Certificate** (to allow clients to verify the cryptographic signatures): | ||
- | |||
- | * **User attribute mapping**: Which SAML attributes returned with the login confirmation (" | ||
- | |||
- | In addition each client typically has settings to require sent or received SAML messages to be signed and/or encrypted to ensure a secure login process. The details depend on the capabilities of the client. Some clients do not support encryption, other require all SAML messages to be signed (for good reason!). | ||
- | Also, some clients offer a setting that SAML login is only possible for users that are already manually created in the SP, while others offer a setting to automatically create user accounts on successful SAML login. | ||
- | |||
- | The details always depend on the particular client. Below, we will show the configuration at the examples of DokuWiki, Nextcloud and Wordpress. | ||
- | ===== C. Configuring Admidio with the Service Provider ===== | ||
- | |||
- | Once the client is set up to send authentication requests to Admidio, Admidio needs to be configured to respond to them. All SAML clients (Service Providers) are configured in the SSO Client Administration page, which can be reached from the SSO Preferences page (https:// | ||
- | |||
- | {{ : | ||
- | |||
- | To ensure only legitimate login requests from the real client are processed, Admidio needs the entity ID, the URL for redirect as well as the x509 certificate (if messages are cryptographically signed). The following settings are needed for setup. They MUST be consistent with the settings configured in the SAML client (SP). Many SPs provide a Metadata XML link or file with all required settings included for automatic client setup. In Admidio' | ||
- | |||
- | * **Metadata URL** (for automatic setup of clients): https:// | ||
- | * If your SP supports entering and loading the metadata XML, make sure to use it. It will load the correct settings from the SAML IdP and set up most settings correctly!{{ : | ||
- | * **IdP SAML Entity ID** (unique identifier of the Admidio instance): https:// | ||
- | * **SSO Endpoint** (where the SP sends the login request): https:// | ||
- | * **SLO Endpoint** (where logout requests are sent to): https:// | ||
- | * **x509 Certificate** (to allow clients to verify the cryptographic signatures): | ||
- | |||
- | * **User ID**: Whether the client gets the numeric Admidio user id, the globally unique UUID, or the user's login name as user ID | ||
- | * Further **profile data/ | ||
- | * Which **roles / group memberships** are sent to the client on successful login. The data fields and groups can be mapped to different names, if the client cannot handle Admidio' | ||
- | |||
- | In addition each client typically has settings to require sent or received SAML messages to be signed and/or encrypted to ensure a secure login process. The details depend on the capabilities of the client. Some clients do not support encryption, other require all SAML messages to be signed (for good reason!). | ||
- | |||
- | {{: | ||
- | |||
- | |||
- | ===== D. Setting up Nextcloud for Single-Sign-On ===== | ||
- | Here we describe, how Nextcloud can be configured to use Admidio' | ||
- | |||
- | ==== Configuring the Service Provider (Nextcloud) ==== | ||
- | |||
- | SAML 2.0 login in Nextcloud is provided by the app "SSO & SAML authentication" | ||
- | {{ : | ||
- | |||
- | After installation it can be configured in Nextcloud' | ||
- | {{ : | ||
- | |||
- | Nextcloud does not support automatic configuration from IdP metadata, so one has to copy the correct settings over from the Admidio preferences. It is a good idea to keep two browser windows open so one can easily select and copy the settings. Admidio even provides little " | ||
- | |||
- | This is a typical configuration of the Nextcloud SAML plugin for Admidio as an idP: | ||
- | {{ : | ||
- | |||
- | Once these basic SAML settings are done, I would recommend to set up the SP in Admidio, and do the remaining settings (transmitted fields and roles, as well as signing/ | ||
- | |||
- | If the basic settings are valid, Nextcloud should indicate " | ||
- | {{ : | ||
- | |||
- | === Setting up encryption === | ||
- | |||
- | If encryption is desired for all SAML messages sent by Admidio to Nextcloud, or if Nextcloud should sign all its requests, then Nextcloud needs a private/ | ||
- | |||
- | {{ : | ||
- | |||
- | After downloading the .p12 file, Applications like [[https:// | ||
- | |||
- | {{: | ||
- | |||
- | {{ : | ||
- | ==== Setting up the Client (SP) in Admidio ==== | ||
- | |||
- | Now, return to Admidio' | ||
- | {{ : | ||
- | |||
- | |||
- | Paste the metadata URL copied from Nextcloud into the corresponding input field at the top and click "Load Client Metadata" | ||
- | {{ : | ||
- | |||
- | |||
- | In addition to the Entity ID and URLs to connect SP and IdP and the certificate, | ||
- | |||
- | {{ : | ||
- | |||
- | <WRAP center round todo 60%> | ||
- | TODO: Describe signing and encryption settings (synced) | ||
- | </ | ||
- | {{ : | ||
- | |||
- | |||
- | ==== Setup completed, test Single-Sign-On ==== | ||
- | Admidio and Nextcloud should now be set up to use Admidio for logging in to Nextcloud. If you log out of Nextcloud, you should see the login screen with the choice of logging in with password or via SAML. | ||
- | {{ : | ||
- | |||
- | After choosing SAML login and loggin in with a user from Admidio, you should be logged in to Nextcloud. | ||
- | {{: | ||
- | {{: | ||
- | |||
- | |||
- | |||
- | ===== E. Setting up DokuWiki for Single-Sign-On ===== | ||
- | |||
- | Here we describe, how DokuWiki can be configured to use Admidio' | ||
==== Configuring the Service Provider (DokuWiki) ==== | ==== Configuring the Service Provider (DokuWiki) ==== | ||
- | SAML 2.0 login in Nextcloud | + | SAML 2.0 login in DokuWiki |
{{ : | {{ : | ||
- | After installation it can be configured in DokuWiki' | + | After installation it can be configured in DokuWiki' |
{{ : | {{ : | ||
Line 245: | Line 41: | ||
{{ : | {{ : | ||
- | Once these basic SAML settings are done, I would recommend | + | Once these basic SAML settings are done, it's best to start setting |
Line 268: | Line 64: | ||
- | TODO: Describe signing and encryption | + | The plugin also provides |
{{ : | {{ : | ||
Line 274: | Line 70: | ||
{{ : | {{ : | ||
+ | |||
+ | ==== DokuWiki configuration as text ==== | ||
+ | |||
+ | The settings done above in the graphical interface could also be done in the '' | ||
+ | |||
+ | <code php> | ||
+ | $conf[' | ||
+ | $conf[' | ||
+ | $conf[' | ||
+ | $conf[' | ||
+ | $conf[' | ||
+ | $conf[' | ||
+ | $conf[' | ||
+ | </ | ||
==== Setup completed, test Single-Sign-On ==== | ==== Setup completed, test Single-Sign-On ==== | ||
Line 288: | Line 98: | ||
* Dokuwiki is picky about signatures. If a SAML response is not signed, login will not be possible, but no corresponding error message will be shown. After an apparent login, the user will arrive at dokuwiki with no user logged in (actually, DokuWiki even silently triggers a logout!). Make sure that in Admidio' | * Dokuwiki is picky about signatures. If a SAML response is not signed, login will not be possible, but no corresponding error message will be shown. After an apparent login, the user will arrive at dokuwiki with no user logged in (actually, DokuWiki even silently triggers a logout!). Make sure that in Admidio' | ||
- | ===== F. Setting up Wordpress for Single-Sign-On ===== | ||
- | |||
- | <WRAP center round todo 60%> | ||
- | TODO | ||
- | </ | ||
- | |||
- | ==== Configuring the Service Provider (Wordpress) ==== | ||
- | |||
- | ==== Setting up the Client (SP) in Admidio ==== | ||
- | |||
- | |||
- | |||
- | ===== G. Setting up a local Gitlab for Single-Sign-On ===== | ||
- | |||
- | ==== Configuring the Service Provider (Gitlab) ==== | ||
- | |||
- | Gitlab does not provide a graphic config interface to set up SAML. However, it is easy to set up SAML in the config file (gitlab.rb) as described in https:// | ||
- | |||
- | An example would be as follows. The URLs and the certificate can again be copied from Admidios SSO preferences page. | ||
- | < | ||
- | gitlab_rails[' | ||
- | gitlab_rails[' | ||
- | gitlab_rails[' | ||
- | gitlab_rails[' | ||
- | gitlab_rails[' | ||
- | gitlab_rails[' | ||
- | { " | ||
- | { | ||
- | " | ||
- | " | ||
- | " | ||
- | " | ||
- | " | ||
- | " | ||
- | " | ||
- | " | ||
- | ... | ||
- | -----END CERTIFICATE-----", | ||
- | " | ||
- | " | ||
- | " | ||
- | " | ||
- | " | ||
- | " | ||
- | } | ||
- | } | ||
- | ] | ||
- | </ | ||
- | |||
- | Gitlab also supports encryption, which needs its own public + private key pair configured in gitlab. To generate keys, one can use Admidio' | ||
- | |||
- | After editing gitlab.rb, one needs to reconfigure gitlab by running: | ||
- | |||
- | sudo gitlab-ctl reconfigure | ||
- | |||
- | Gitlab will provide the SP metadata as an XML at the URL | ||
- | |||
- | https:// | ||
- | |||
- | |||
- | ==== Setting up the Client (SP) in Admidio ==== | ||
- | |||
- | Now, return to Admidio' | ||
- | {{ : | ||
- | |||
- | Gitlab provides its SAML SP client settings as a metadata XML at the URL | ||
- | |||
- | https:// | ||
- | |||
- | Paste that metadata URL into the corresponding input field at the top and click "Load Client Metadata" | ||
- | |||
- | {{ : | ||
- | |||
- | In addition to the Entity ID and URLs to connect SP and IdP and the certificate, | ||
- | |||
- | {{ : | ||
- | |||
- | |||
- | ==== Setup completed, test Single-Sign-On ==== | ||
- | |||
- | Admidio and Gitlab should now be set up to use Admidio for logging in to Gitlab. If you log out of Gitlab and try to log in again, you will be shown the Admidio login screen and then redirected back to Gitlab after successful login. | ||
- | |||
- | {{: | ||
- | {{: | ||
- | {{: | ||
- | |||