Skip to content
Snippets Groups Projects
Commit f15764b4 authored by Olav Morken's avatar Olav Morken
Browse files

openid: Make requested attributes configurable.

git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@1488 44740490-163a-0410-bde0-09ae8108e29a
parent 322fd9d5
No related branches found
No related tags found
No related merge requests found
...@@ -53,6 +53,8 @@ $config = array( ...@@ -53,6 +53,8 @@ $config = array(
'openid' => array( 'openid' => array(
'openid:OpenIDConsumer', 'openid:OpenIDConsumer',
'attributes.required' => array('nickname'),
'attributes.optional' => array('fullname', 'email',),
), ),
'feide' => array( 'feide' => array(
......
...@@ -9,6 +9,17 @@ ...@@ -9,6 +9,17 @@
*/ */
class sspmod_openid_Auth_Source_OpenIDConsumer extends SimpleSAML_Auth_Source { class sspmod_openid_Auth_Source_OpenIDConsumer extends SimpleSAML_Auth_Source {
/**
* List of optional attributes.
*/
private $optionalAttributes;
/**
* List of required attributes.
*/
private $requiredAttributes;
/** /**
* Constructor for this authentication source. * Constructor for this authentication source.
...@@ -21,6 +32,11 @@ class sspmod_openid_Auth_Source_OpenIDConsumer extends SimpleSAML_Auth_Source { ...@@ -21,6 +32,11 @@ class sspmod_openid_Auth_Source_OpenIDConsumer extends SimpleSAML_Auth_Source {
/* Call the parent constructor first, as required by the interface. */ /* Call the parent constructor first, as required by the interface. */
parent::__construct($info, $config); parent::__construct($info, $config);
$cfgParse = SimpleSAML_Configuration::loadFromArray($config,
'Authentication source ' . var_export($this->authId, TRUE));
$this->optionalAttributes = $cfgParse->getArray('attributes.optional', array());
$this->requiredAttributes = $cfgParse->getArray('attributes.required', array());
} }
...@@ -40,6 +56,26 @@ class sspmod_openid_Auth_Source_OpenIDConsumer extends SimpleSAML_Auth_Source { ...@@ -40,6 +56,26 @@ class sspmod_openid_Auth_Source_OpenIDConsumer extends SimpleSAML_Auth_Source {
SimpleSAML_Utilities::redirect($url, array('AuthState' => $id)); SimpleSAML_Utilities::redirect($url, array('AuthState' => $id));
} }
/**
* Retrieve required attributes.
*
* @return array Required attributes.
*/
public function getRequiredAttributes() {
return $this->requiredAttributes;
}
/**
* Retrieve optional attributes.
*
* @return array Optional attributes.
*/
public function getOptionalAttributes() {
return $this->optionalAttributes;
}
} }
?> ?>
\ No newline at end of file
...@@ -88,6 +88,8 @@ function getTrustRoot() { ...@@ -88,6 +88,8 @@ function getTrustRoot() {
} }
function run_try_auth() { function run_try_auth() {
global $authSource;
$openid = getOpenIDURL(); $openid = getOpenIDURL();
$consumer = getConsumer(); $consumer = getConsumer();
...@@ -100,8 +102,8 @@ function run_try_auth() { ...@@ -100,8 +102,8 @@ function run_try_auth() {
} }
$sreg_request = Auth_OpenID_SRegRequest::build( $sreg_request = Auth_OpenID_SRegRequest::build(
array('nickname'), // Required $authSource->getRequiredAttributes(),
array('fullname', 'email')); // Optional $authSource->getOptionalAttributes());
if ($sreg_request) { if ($sreg_request) {
$auth_request->addExtension($sreg_request); $auth_request->addExtension($sreg_request);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment