Implemented features to revoke access for previously authorized OAuth 2.0 clients

This commit is contained in:
ErickSkrauch
2020-09-30 20:30:04 +03:00
parent 2a4f29801d
commit b904d5d314
12 changed files with 240 additions and 34 deletions

View File

@@ -16,10 +16,14 @@ use yii\db\ActiveRecord;
* @property array $scopes
* @property int $created_at
* @property int|null $revoked_at
* @property int $last_used_at
*
* Relations:
* @property-read OauthClient $client
* @property-read OauthClient|null $client
* @property-read Account $account
*
* Mixins:
* @mixin TimestampBehavior
*/
class OauthSession extends ActiveRecord {
@@ -36,6 +40,10 @@ class OauthSession extends ActiveRecord {
];
}
public function isRevoked(): bool {
return $this->revoked_at > $this->last_used_at;
}
public function getClient(): ActiveQuery {
return $this->hasOne(OauthClient::class, ['id' => 'client_id']);
}