Page MenuHomePhorge

IdentityEntity.php
No OneTemporary

Authored By
Unknown
Size
1 KB
Referenced Files
None
Subscribers
None

IdentityEntity.php

<?php
namespace App\Auth;
use App\User;
use League\OAuth2\Server\Entities\Traits\EntityTrait;
use OpenIDConnect\Claims\Traits\WithClaims;
use OpenIDConnect\Interfaces\IdentityEntityInterface;
class IdentityEntity implements IdentityEntityInterface
{
use EntityTrait;
use WithClaims;
/**
* The user to collect the additional information for
*/
protected User $user;
/**
* The identity repository creates this entity and provides the user id
*
* @param mixed $identifier
*/
public function setIdentifier($identifier): void
{
$this->identifier = $identifier;
$this->user = User::findOrFail($identifier);
}
/**
* When building the id_token, this entity's claims are collected
*
* @param string[] $scopes Optional scope filter
*/
public function getClaims(array $scopes = []): array
{
$claims = [];
if (in_array('email', $scopes)) {
$claims['email'] = $this->user->email;
}
// Short living password for IMAP/SMTP
// We use same TTL as for the OAuth tokens, so clients can get a new password on token refresh
if (in_array('auth.token', $scopes)) {
$ttl = config('auth.token_expiry_minutes') * 60;
$claims['auth.token'] = Utils::tokenCreate((string) $this->user->id, $ttl);
}
return $claims;
}
}

File Metadata

Mime Type
text/x-php
Expires
Fri, Apr 24, 10:05 AM (5 d, 59 m ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
18849970
Default Alt Text
IdentityEntity.php (1 KB)

Event Timeline