make oauth endpoints openid compliant
This commit is contained in:
7 files changed
+306
-134
No files matched your search
@@ -7,10 +7,14 @@ class OAuthToken extends Model
|
||||
{
|
||||
protected static string $table = 'oauth_tokens';
|
||||
|
||||
protected static array $fields = ['nonce', 'user_id', 'code', 'created', 'expires'];
|
||||
protected static array $fields = ['scope', 'nonce', 'user_id', 'code', 'access_token', 'created', 'expires'];
|
||||
|
||||
protected static array $relations = ['user' => User::class];
|
||||
|
||||
private static array $possibleScopeValues = ['openid', 'email', 'profile'];
|
||||
|
||||
private array $scope = [];
|
||||
|
||||
private string $nonce = '';
|
||||
|
||||
private ?User $user = null;
|
||||
@@ -19,10 +23,22 @@ class OAuthToken extends Model
|
||||
|
||||
private string $code = '';
|
||||
|
||||
private string $accessToken = '';
|
||||
|
||||
private DateTime $created;
|
||||
|
||||
private DateTime $expires;
|
||||
|
||||
public function setScopeArray(array $scope): void
|
||||
{
|
||||
$this->scope = array_intersect($scope, self::$possibleScopeValues);
|
||||
}
|
||||
|
||||
public function setScope(string $scope): void
|
||||
{
|
||||
$this->setScopeArray(explode(' ', $scope));
|
||||
}
|
||||
|
||||
public function setNonce(string $nonce): void
|
||||
{
|
||||
$this->nonce = $nonce;
|
||||
@@ -43,6 +59,11 @@ class OAuthToken extends Model
|
||||
$this->code = $code;
|
||||
}
|
||||
|
||||
public function setAccessToken(string $accessToken): void
|
||||
{
|
||||
$this->accessToken = $accessToken;
|
||||
}
|
||||
|
||||
public function setCreatedDate(DateTime $created): void
|
||||
{
|
||||
$this->created = $created;
|
||||
@@ -63,6 +84,16 @@ class OAuthToken extends Model
|
||||
$this->expires = new DateTime($expires);
|
||||
}
|
||||
|
||||
public function getScope(): string
|
||||
{
|
||||
return implode(' ', $this->scope);
|
||||
}
|
||||
|
||||
public function getScopeArray(): array
|
||||
{
|
||||
return $this->scope;
|
||||
}
|
||||
|
||||
public function getNonce(): string
|
||||
{
|
||||
return $this->nonce;
|
||||
@@ -83,6 +114,11 @@ class OAuthToken extends Model
|
||||
return $this->code;
|
||||
}
|
||||
|
||||
public function getAccessToken(): string
|
||||
{
|
||||
return $this->accessToken;
|
||||
}
|
||||
|
||||
public function getCreatedDate(): DateTime
|
||||
{
|
||||
return $this->created;
|
||||
|
||||
Reference in new issue
Block a user