From acd78cf17e05aa267594a5898fc8a15519d27617 Mon Sep 17 00:00:00 2001 From: Sebastian Mendel Date: Wed, 21 Jun 2017 18:09:22 +0200 Subject: [PATCH] =?UTF-8?q?add=20support=20for=20variable=20namespace=20al?= =?UTF-8?q?ias=20for=20SREG=20attributes=20-=20fixes=20=E2=80=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit …SREG attributes not extracted if SREG namespace attribute name is not "openid_ns_sreg" Support SREG attributes if namespace attribute name is NOT "openid_ns_sreg" by replacing hard coded SREG namespace attribute name with SREG namespace detection (see getAxAttributes()). Makes working: openid_ns_ext1=http://openid.net/extensions/sreg/1.1 openid_ext1_nickname=sebastian.mendel --- openid.php | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/openid.php b/openid.php index 14e684b..b81cbdb 100644 --- a/openid.php +++ b/openid.php @@ -979,17 +979,19 @@ protected function getSregAttributes() { $attributes = array(); $sreg_to_ax = array_flip(self::$ax_to_sreg); - foreach (explode(',', $this->data['openid_signed']) as $key) { - $keyMatch = 'sreg.'; - if (strncmp($key, $keyMatch, strlen($keyMatch)) !== 0) { - continue; - } - $key = substr($key, strlen($keyMatch)); - if (!isset($sreg_to_ax[$key])) { - # The field name isn't part of the SREG spec, so we ignore it. - continue; + if ($alias = $this->getNamespaceAlias('http://openid.net/extensions/sreg/1.1', 'sreg')) { + foreach (explode(',', $this->data['openid_signed']) as $key) { + $keyMatch = $alias . '.'; + if (strncmp($key, $keyMatch, strlen($keyMatch)) !== 0) { + continue; + } + $key = substr($key, strlen($keyMatch)); + if (!isset($sreg_to_ax[$key])) { + # The field name isn't part of the SREG spec, so we ignore it. + continue; + } + $attributes[$sreg_to_ax[$key]] = $this->data['openid_' . $alias . '_' . $key]; } - $attributes[$sreg_to_ax[$key]] = $this->data['openid_sreg_' . $key]; } return $attributes; }