From 31ca1afc03eeb016ffe3048d47ef934161cf6069 Mon Sep 17 00:00:00 2001
From: Tim van Dijen <tvdijen@gmail.com>
Date: Mon, 4 Feb 2019 10:06:40 +0100
Subject: [PATCH] Fixes for modules/exampleauth

---
 .../exampleattributeserver/www/attributeserver.php   | 10 +++++++---
 .../exampleauth/lib/Auth/Process/RedirectTest.php    |  2 +-
 modules/exampleauth/lib/Auth/Source/External.php     | 12 ++++++++++--
 modules/exampleauth/lib/Auth/Source/StaticSource.php |  3 ++-
 4 files changed, 20 insertions(+), 7 deletions(-)

diff --git a/modules/exampleattributeserver/www/attributeserver.php b/modules/exampleattributeserver/www/attributeserver.php
index 9bdbe415a..84aad77dd 100644
--- a/modules/exampleattributeserver/www/attributeserver.php
+++ b/modules/exampleattributeserver/www/attributeserver.php
@@ -10,10 +10,13 @@ if (!($query instanceof \SAML2\AttributeQuery)) {
 
 $idpEntityId = $metadata->getMetaDataCurrentEntityID('saml20-idp-hosted');
 
-
-$spEntityId = $query->getIssuer();
-if ($spEntityId === null) {
+$issuer = $query->getIssuer();
+if ($issuer === null) {
     throw new \SimpleSAML\Error\BadRequest('Missing <saml:Issuer> in <samlp:AttributeQuery>.');
+} elseif (is_string($issuer)) {
+    $spEntityId = $issuer;
+} else {
+    $spEntityId = $issuer->getValue();
 }
 
 $idpMetadata = $metadata->getMetaDataConfig($idpEntityId, 'saml20-idp-hosted');
@@ -41,6 +44,7 @@ if (count($returnAttributes) === 0) {
     $returnAttributes = [];
 } else {
     foreach ($returnAttributes as $name => $values) {
+        /** @var array $values */
         if (!array_key_exists($name, $attributes)) {
             // We don't have this attribute
             unset($returnAttributes[$name]);
diff --git a/modules/exampleauth/lib/Auth/Process/RedirectTest.php b/modules/exampleauth/lib/Auth/Process/RedirectTest.php
index 13ff82dbd..e72c5459e 100644
--- a/modules/exampleauth/lib/Auth/Process/RedirectTest.php
+++ b/modules/exampleauth/lib/Auth/Process/RedirectTest.php
@@ -6,13 +6,13 @@ namespace SimpleSAML\Module\exampleautth\Auth\Process;
  * A simple processing filter for testing that redirection works as it should.
  *
  */
-
 class RedirectTest extends \SimpleSAML\Auth\ProcessingFilter
 {
     /**
      * Initialize processing of the redirect test.
      *
      * @param array &$state  The state we should update.
+     * @return void
      */
     public function process(&$state)
     {
diff --git a/modules/exampleauth/lib/Auth/Source/External.php b/modules/exampleauth/lib/Auth/Source/External.php
index fef113edb..409b4ea42 100644
--- a/modules/exampleauth/lib/Auth/Source/External.php
+++ b/modules/exampleauth/lib/Auth/Source/External.php
@@ -22,7 +22,6 @@ namespace SimpleSAML\Module\exampleauth\Auth\Source;
  *
  * @package SimpleSAMLphp
  */
-
 class External extends \SimpleSAML\Auth\Source
 {
     /**
@@ -47,10 +46,11 @@ class External extends \SimpleSAML\Auth\Source
         // Do any other configuration we need here
     }
 
+
     /**
      * Retrieve attributes for the user.
      *
-     * @return array|NULL  The user's attributes, or NULL if the user isn't authenticated.
+     * @return array|null  The user's attributes, or NULL if the user isn't authenticated.
      */
     private function getUser()
     {
@@ -91,10 +91,12 @@ class External extends \SimpleSAML\Auth\Source
         return $attributes;
     }
 
+
     /**
      * Log in using an external authentication helper.
      *
      * @param array &$state  Information about the current authentication.
+     * @return void
      */
     public function authenticate(&$state)
     {
@@ -172,6 +174,7 @@ class External extends \SimpleSAML\Auth\Source
         assert(false);
     }
 
+
     /**
      * Resume authentication process.
      *
@@ -179,6 +182,9 @@ class External extends \SimpleSAML\Auth\Source
      * entered his or her credentials.
      *
      * @param array &$state  The authentication state.
+     * @return void
+     * @throws \SimpleSAML\Error\BadRequest
+     * @throws \SimpleSAML\Error\Exception
      */
     public static function resume()
     {
@@ -248,11 +254,13 @@ class External extends \SimpleSAML\Auth\Source
         assert(false);
     }
 
+
     /**
      * This function is called when the user start a logout operation, for example
      * by logging out of a SP that supports single logout.
      *
      * @param array &$state  The logout state array.
+     * @return void
      */
     public function logout(&$state)
     {
diff --git a/modules/exampleauth/lib/Auth/Source/StaticSource.php b/modules/exampleauth/lib/Auth/Source/StaticSource.php
index d81dd3256..607a2e496 100644
--- a/modules/exampleauth/lib/Auth/Source/StaticSource.php
+++ b/modules/exampleauth/lib/Auth/Source/StaticSource.php
@@ -11,7 +11,6 @@ namespace SimpleSAML\Module\exampleauth\Auth\Source;
  * @author Olav Morken, UNINETT AS.
  * @package SimpleSAMLphp
  */
-
 class StaticSource extends \SimpleSAML\Auth\Source
 {
     /**
@@ -42,10 +41,12 @@ class StaticSource extends \SimpleSAML\Auth\Source
         }
     }
 
+
     /**
      * Log in using static attributes.
      *
      * @param array &$state  Information about the current authentication.
+     * @return void
      */
     public function authenticate(&$state)
     {
-- 
GitLab