You are here

function simplesamlphp_auth_get_attributes in simpleSAMLphp Authentication 7.3

Same name and namespace in other branches
  1. 7.2 simplesamlphp_auth.module \simplesamlphp_auth_get_attributes()

Return any attributes provided by the SAML IDP.

Parameters

$attribute: (optional) The attribute whose value to return. Can be skipped if all attribute values are requested.

Return value

If an attribute was provided, the value of the attribute is returned. Otherwise, an array of all attribute values is returned, keyed by attribute.

2 calls to simplesamlphp_auth_get_attributes()
_simplesamlphp_auth_allow_user_by_attribute in ./simplesamlphp_auth.inc
Asks all modules if current federated user is allowed to login. Returns FALSE if at least one module returns FALSE
_simplesaml_auth_login_register in ./simplesamlphp_auth.inc
Performs login and/or register actions for SAML authenticated users.

File

./simplesamlphp_auth.inc, line 308
Contains non-hook implementations.

Code

function simplesamlphp_auth_get_attributes($attribute = NULL) {
  global $_simplesamlphp_auth_saml_attributes;
  if (isset($attribute)) {

    // Initially, assume that there's nothing to return.
    $result = NULL;

    // If the specified attribute is set, grab it.
    if (isset($_simplesamlphp_auth_saml_attributes[$attribute])) {
      $result = $_simplesamlphp_auth_saml_attributes[$attribute];
    }
  }
  else {

    // Initially, assume that there's nothing to return.
    $result = array();

    // If the global array exists, return it.
    if (isset($_simplesamlphp_auth_saml_attributes)) {
      $result = $_simplesamlphp_auth_saml_attributes;
    }
  }

  // Return whatever we have.
  return $result;
}