You are here

function hook_simplesamlphp_auth_allow_login in simpleSAMLphp Authentication 8.3

Same name and namespace in other branches
  1. 7.3 simplesamlphp_auth.api.php \hook_simplesamlphp_auth_allow_login()

Hook to specify if a SAML-authenticated user is allowed to login.

Allows other modules to decide whether user with the given set of attributes is allowed to log in via SSO or not.

Each implementation should take care of displaying errors, there is no message implementation at hook invocation. Implementations should return a boolean indicating the success of the access check. Access will be denied if any implementations return FALSE.

Parameters

array $attributes: The SimpleSAMLphp attributes for this user.

Return value

bool TRUE if SAML user is allowed to log in, FALSE if not.

1 invocation of hook_simplesamlphp_auth_allow_login()
SimplesamlphpAuthManager::allowUserByAttribute in src/Service/SimplesamlphpAuthManager.php
Asks all modules if current federated user is allowed to login.

File

./simplesamlphp_auth.api.php, line 52
Hooks for simpleSAMLphp Authentication module.

Code

function hook_simplesamlphp_auth_allow_login($attributes) {
  if (in_array('student', $attributes['roles'])) {
    return FALSE;
  }
  else {
    return TRUE;
  }
}