From ead5067b14697643f6c1d0982746d03374167421 Mon Sep 17 00:00:00 2001 From: Julius Kiekbusch Date: Fri, 2 Aug 2024 09:46:47 +0200 Subject: [PATCH 1/3] Replace dead link in Security Policy (#1775) --- .github/SECURITY.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/SECURITY.md b/.github/SECURITY.md index dd673d428..800b8aff2 100644 --- a/.github/SECURITY.md +++ b/.github/SECURITY.md @@ -15,7 +15,7 @@ If you discover a security vulnerability within Laravel, please send an email to ``` -----BEGIN PGP PUBLIC KEY BLOCK----- Version: OpenPGP v2.0.8 -Comment: https://sela.io/pgp/ +Comment: Report Security Vulnerabilities to taylor@laravel.com xsFNBFugFSQBEACxEKhIY9IoJzcouVTIYKJfWFGvwFgbRjQWBiH3QdHId5vCrbWo s2l+4Rv03gMG+yHLJ3rWElnNdRaNdQv59+lShrZF7Bvu7Zvc0mMNmFOM/mQ/K2Lt From ca63a86697a4fa091c7dcabe88ebba91d97c785d Mon Sep 17 00:00:00 2001 From: Choraimy Kroonstuiver <3661474+axlon@users.noreply.github.com> Date: Mon, 5 Aug 2024 15:44:51 +0200 Subject: [PATCH 2/3] Add access token revoked event (#1776) --- src/Bridge/AccessTokenRepository.php | 5 +++- src/Events/AccessTokenRevoked.php | 17 +++++++++++ .../Unit/BridgeAccessTokenRepositoryTest.php | 28 +++++++++++++++++++ 3 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 src/Events/AccessTokenRevoked.php diff --git a/src/Bridge/AccessTokenRepository.php b/src/Bridge/AccessTokenRepository.php index 23572d760..a190b4d94 100644 --- a/src/Bridge/AccessTokenRepository.php +++ b/src/Bridge/AccessTokenRepository.php @@ -5,6 +5,7 @@ use DateTime; use Illuminate\Contracts\Events\Dispatcher; use Laravel\Passport\Events\AccessTokenCreated; +use Laravel\Passport\Events\AccessTokenRevoked; use Laravel\Passport\Passport; use Laravel\Passport\TokenRepository; use League\OAuth2\Server\Entities\AccessTokenEntityInterface; @@ -78,7 +79,9 @@ public function persistNewAccessToken(AccessTokenEntityInterface $accessTokenEnt */ public function revokeAccessToken($tokenId) { - $this->tokenRepository->revokeAccessToken($tokenId); + if ($this->tokenRepository->revokeAccessToken($tokenId)) { + $this->events->dispatch(new AccessTokenRevoked($tokenId)); + } } /** diff --git a/src/Events/AccessTokenRevoked.php b/src/Events/AccessTokenRevoked.php new file mode 100644 index 000000000..71a87976d --- /dev/null +++ b/src/Events/AccessTokenRevoked.php @@ -0,0 +1,17 @@ +persistNewAccessToken($accessToken); } + public function test_access_tokens_can_be_revoked() + { + $tokenRepository = m::mock(TokenRepository::class); + $events = m::mock(Dispatcher::class); + + $tokenRepository->shouldReceive('revokeAccessToken')->with('token-id')->once()->andReturn(1); + $events->shouldReceive('dispatch')->once(); + + $repository = new AccessTokenRepository($tokenRepository, $events); + $repository->revokeAccessToken('token-id'); + + $this->expectNotToPerformAssertions(); + } + + public function test_access_token_revoke_event_is_not_dispatched_when_nothing_happened() + { + $tokenRepository = m::mock(TokenRepository::class); + $events = m::mock(Dispatcher::class); + + $tokenRepository->shouldReceive('revokeAccessToken')->with('token-id')->once()->andReturn(0); + $events->shouldNotReceive('dispatch'); + + $repository = new AccessTokenRepository($tokenRepository, $events); + $repository->revokeAccessToken('token-id'); + + $this->expectNotToPerformAssertions(); + } + public function test_can_get_new_access_token() { $tokenRepository = m::mock(TokenRepository::class); From 3e96f8ea8a7a9d6b778e5a4e22bef136c0493a21 Mon Sep 17 00:00:00 2001 From: driesvints Date: Tue, 6 Aug 2024 15:11:07 +0000 Subject: [PATCH 3/3] Update CHANGELOG --- CHANGELOG.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8a7694cac..bab6b559a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,10 @@ # Release Notes -## [Unreleased](https://github.com/laravel/passport/compare/v12.2.1...12.x) +## [Unreleased](https://github.com/laravel/passport/compare/v12.3.0...12.x) + +## [v12.3.0](https://github.com/laravel/passport/compare/v12.2.1...v12.3.0) - 2024-08-05 + +* [12.x] Add access token revoked event by [@axlon](https://github.com/axlon) in https://github.com/laravel/passport/pull/1776 ## [v12.2.1](https://github.com/laravel/passport/compare/v12.2.0...v12.2.1) - 2024-07-10