]> BookStack Code Mirror - bookstack/commitdiff
Fixed SAML logout for ADFS.
authorFranke <redacted>
Mon, 30 Aug 2021 12:35:11 +0000 (14:35 +0200)
committerFranke <redacted>
Mon, 30 Aug 2021 12:35:11 +0000 (14:35 +0200)
.env.example.complete
app/Auth/Access/Saml2Service.php
app/Config/saml2.php

index 26df8f3cb8e918102ddc73fe8fae0a812bc1d33e..58e4e47543d9df1b0d9fbc7ba66c5dc5f9e9f982 100644 (file)
@@ -224,6 +224,11 @@ SAML2_ONELOGIN_OVERRIDES=null
 SAML2_DUMP_USER_DETAILS=false
 SAML2_AUTOLOAD_METADATA=false
 SAML2_IDP_AUTHNCONTEXT=true
+SAML2_SP_CERTIFICATE=null
+SAML2_SP_PRIVATEKEY=null
+SAML2_SP_NAME_ID_Format=null
+SAML2_SP_NAME_ID_SP_NAME_QUALIFIER=null
+SAML2_RETRIEVE_PARAMETERS_FROM_SERVER=false
 
 # SAML group sync configuration
 # Refer to https://www.bookstackapp.com/docs/admin/saml2-auth/
index 6cbfdac0b2808a646ea284fab404aa01dbc2fa21..e72aef97992477f627092990f5325d4b0af089c4 100644 (file)
@@ -61,8 +61,14 @@ class Saml2Service extends ExternalAuthService
         $returnRoute = url('/');
 
         try {
-            $url = $toolKit->logout($returnRoute, [], null, null, true);
+            $email = auth()->user()['email'];
+            $nameIdFormat = env('SAML2_SP_NAME_ID_Format', null);
+            $nameIdSPNameQualifier = env('SAML2_SP_NAME_ID_SP_NAME_QUALIFIER', null);
+
+
+            $url = $toolKit->logout($returnRoute, [], $email, null, true, $nameIdFormat, null, $nameIdSPNameQualifier);
             $id = $toolKit->getLastRequestID();
+
         } catch (Error $error) {
             if ($error->getCode() !== Error::SAML_SINGLE_LOGOUT_NOT_SUPPORTED) {
                 throw $error;
@@ -117,7 +123,9 @@ class Saml2Service extends ExternalAuthService
     public function processSlsResponse(?string $requestId): ?string
     {
         $toolkit = $this->getToolkit();
-        $redirect = $toolkit->processSLO(true, $requestId, false, null, true);
+        $retrieveParametersFromServer = env('SAML2_RETRIEVE_PARAMETERS_FROM_SERVER', false);
+
+        $redirect = $toolkit->processSLO(true, $requestId, $retrieveParametersFromServer, null, true);
 
         $errors = $toolkit->getErrors();
 
index fe311057c1b1a3a14507334f2f422747de9e573c..709931fc6e504b1a9a473ad625350e11427b5657 100644 (file)
@@ -80,8 +80,8 @@ return [
             'NameIDFormat' => 'urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress',
             // Usually x509cert and privateKey of the SP are provided by files placed at
             // the certs folder. But we can also provide them with the following parameters
-            'x509cert'   => '',
-            'privateKey' => '',
+            'x509cert'   => env('SAML2_SP_CERTIFICATE', ''),
+            'privateKey' => env('SAML2_SP_PRIVATEKEY', ''),
         ],
         // Identity Provider Data that we want connect with our SP
         'idp' => [
@@ -147,6 +147,9 @@ return [
             // Multiple forced values can be passed via a space separated array, For example:
             // SAML2_IDP_AUTHNCONTEXT="urn:federation:authentication:windows urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport"
             'requestedAuthnContext' => is_string($SAML2_IDP_AUTHNCONTEXT) ? explode(' ', $SAML2_IDP_AUTHNCONTEXT) : $SAML2_IDP_AUTHNCONTEXT,
+            'logoutRequestSigned' => env('', false),
+            'logoutResponseSigned' => env('', false),
+            'lowercaseUrlencoding' => env('', false)
         ],
     ],
 
Morty Proxy This is a proxified and sanitized view of the page, visit original site.