From 35bf12a5b8f2a25e63b5a02512a70127df11b4c2 Mon Sep 17 00:00:00 2001
From: Olav Morken <olav.morken@uninett.no>
Date: Thu, 30 Aug 2012 11:39:38 +0000
Subject: [PATCH] consent: New option: showNoConsentAboutService

Since the "about service"-link takes the user away from the IdP, the
user will still have an session on the IdP. This option allows us to
disable that link.

git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@3158 44740490-163a-0410-bde0-09ae8108e29a
---
 modules/consent/docs/consent.txt             |  3 +++
 modules/consent/lib/Auth/Process/Consent.php | 16 ++++++++++++++++
 modules/consent/www/noconsent.php            |  6 ++++--
 3 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/modules/consent/docs/consent.txt b/modules/consent/docs/consent.txt
index bd78b73b0..93ee0dc05 100644
--- a/modules/consent/docs/consent.txt
+++ b/modules/consent/docs/consent.txt
@@ -160,6 +160,9 @@ The following options can be used when configuring the Consent module
     the attributes that should have it value hidden. Default behaviour is that 
     all attribute values are shown
 
+`showNoConsentAboutService`
+:   Whether we will show a link to more information about the service from the
+    no consent page. Defaults to `TRUE`.
 
 External options
 ----------------
diff --git a/modules/consent/lib/Auth/Process/Consent.php b/modules/consent/lib/Auth/Process/Consent.php
index cf57ba3c2..25067ec97 100644
--- a/modules/consent/lib/Auth/Process/Consent.php
+++ b/modules/consent/lib/Auth/Process/Consent.php
@@ -52,6 +52,13 @@ class sspmod_consent_Auth_Process_Consent extends SimpleSAML_Auth_ProcessingFilt
      */
     private $_noconsentattributes = array();
 
+    /**
+     * Whether we should show the "about service"-link on the no consent page.
+     *
+     * @var bool
+     */
+    private $_showNoConsentAboutService = true;
+
     /**
      * Initialize consent filter
      *
@@ -125,6 +132,14 @@ class sspmod_consent_Auth_Process_Consent extends SimpleSAML_Auth_ProcessingFilt
                 );
             }
         } 
+
+        if (array_key_exists('showNoConsentAboutService', $config)) {
+            if (!is_bool($config['showNoConsentAboutService'])) {
+                throw new SimpleSAML_Error_Exception('Consent: showNoConsentAboutService must be a boolean.');
+            }
+            $this->_showNoConsentAboutService = $config['showNoConsentAboutService'];
+        }
+
     }
 
     /**
@@ -250,6 +265,7 @@ class sspmod_consent_Auth_Process_Consent extends SimpleSAML_Auth_ProcessingFilt
         $state['consent:checked']             = $this->_checked;
         $state['consent:hiddenAttributes']    = $this->_hiddenAttributes;
         $state['consent:noconsentattributes'] = $this->_noconsentattributes;
+        $state['consent:showNoConsentAboutService'] = $this->_showNoConsentAboutService;
 
         // User interaction nessesary. Throw exception on isPassive request	
         if (isset($state['isPassive']) && $state['isPassive'] == true) {
diff --git a/modules/consent/www/noconsent.php b/modules/consent/www/noconsent.php
index 258b0ceb5..06e5554c0 100644
--- a/modules/consent/www/noconsent.php
+++ b/modules/consent/www/noconsent.php
@@ -26,8 +26,10 @@ $logoutLink = SimpleSAML_Module::getModuleURL(
 
 
 $aboutService = null;
-if (isset($state['Destination']['url.about'])) {
-    $aboutService = $state['Destination']['url.about'];
+if (!isset($state['consent:showNoConsentAboutService']) || $state['consent:showNoConsentAboutService']) {
+	if (isset($state['Destination']['url.about'])) {
+		$aboutService = $state['Destination']['url.about'];
+	}
 }
 
 $statsInfo = array();
-- 
GitLab