clean install

This commit is contained in:
2024-12-10 15:08:16 +01:00
commit e14eb2d8fd
31193 changed files with 3555714 additions and 0 deletions

View File

@@ -0,0 +1,63 @@
<?php
/**
* @file
* Hooks specific to the Simple OAuth module.
*/
use Drupal\simple_oauth\Entities\AccessTokenEntity;
use Drupal\user\Entity\User;
/**
* @defgroup simple_oauth Simple Oauth: Hooks
* @{
*/
use Drupal\user\UserInterface;
/**
* Alter the private claims to prepare convert to JWT token.
*
* @param array $private_claims
* The private claims array to be altered.
* @param \Drupal\simple_oauth\Entities\AccessTokenEntity $access_token_entity
* The entity for the Access token.
*
* @see \Drupal\simple_oauth\Entities\AccessTokenEntity::convertToJWT()
*/
function hook_simple_oauth_private_claims_alter(array &$private_claims, AccessTokenEntity $access_token_entity) {
$user_id = $access_token_entity->getUserIdentifier();
$user = User::load($user_id);
$private_claims = [
'mail' => $user->getEmail(),
'username' => $user->getAccountName(),
];
}
/**
* Allow injecting custom claims to the OpenID Connect responses.
*
* This will allow sites to connect their custom implementations and data model
* to the different claims supported by OpenID Connect.
*
* @param array $claim_values
* The private claims array to be altered.
* @param array $context
* Additional information relevant to the custom claims. It contains:
* - 'account': The TokenAuthUserInterface object decorating the user.
* - 'claims': The claim names to serve to the users. If you add new claims
* you will need to add them in your service container under the key
* 'simple_oauth.openid.claims'.
*
* @see \Drupal\simple_oauth\Entities\AccessTokenEntity::convertToJWT()
*/
function hook_simple_oauth_oidc_claims_alter(array &$claim_values, array &$context) {
$account = $context['account'];
assert($account instanceof UserInterface);
$value = $account->get('field_phone_number')->getValue();
$claim_values['phone_number'] = $value[0]['value'] ?? NULL;
}
/**
* @} End of "defgroup simple_oauth".
*/