feat(auth): include the token entity in TokenInvalidatedEvent

Signed-off-by: Julien Veyssier <julien-nc@posteo.net>
pull/54545/head
Julien Veyssier 2 months ago
parent 4a35837741
commit 3d36834284
No known key found for this signature in database
GPG Key ID: 4141FEE162030638
  1. 4
      lib/private/Authentication/Token/PublicKeyTokenProvider.php
  2. 19
      lib/public/Authentication/Events/TokenInvalidatedEvent.php

@ -279,7 +279,7 @@ class PublicKeyTokenProvider implements IProvider {
$this->mapper->invalidate($this->hashTokenWithEmptySecret($token));
$this->cacheInvalidHash($tokenHash);
if ($tokenEntry !== null) {
$this->eventDispatcher->dispatchTyped(new TokenInvalidatedEvent($tokenEntry->getUID(), $tokenEntry->getId()));
$this->eventDispatcher->dispatchTyped(new TokenInvalidatedEvent($tokenEntry));
}
}
@ -290,7 +290,7 @@ class PublicKeyTokenProvider implements IProvider {
}
$this->mapper->invalidate($token->getToken());
$this->cacheInvalidHash($token->getToken());
$this->eventDispatcher->dispatchTyped(new TokenInvalidatedEvent($uid, $id));
$this->eventDispatcher->dispatchTyped(new TokenInvalidatedEvent($token));
}
public function invalidateOldTokens() {

@ -8,6 +8,7 @@ declare(strict_types=1);
*/
namespace OCP\Authentication\Events;
use OCP\Authentication\Token\IToken;
use OCP\EventDispatcher\Event;
/**
@ -21,27 +22,17 @@ class TokenInvalidatedEvent extends Event {
* @since 32.0.0
*/
public function __construct(
private string $userId,
private int $tokenId,
private IToken $token,
) {
parent::__construct();
}
/**
* returns the uid of the user associated with the invalidated token
* returns the token that has been invalidated
*
* @since 32.0.0
*/
public function getUserId(): string {
return $this->userId;
}
/**
* returns the ID of the token that is being invalidated
*
* @since 32.0.0
*/
public function getTokenId(): int {
return $this->tokenId;
public function getToken(): IToken {
return $this->token;
}
}

Loading…
Cancel
Save