-
Notifications
You must be signed in to change notification settings - Fork 785
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[13.x] Add new
EnsureClientIsResourceOwner
middleware (#1794)
* add new middleware and rename old ones * fix tests * upgrade guide * formatting
- Loading branch information
1 parent
ef122ad
commit 6fafccc
Showing
14 changed files
with
218 additions
and
301 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
namespace Laravel\Passport\Http\Middleware; | ||
|
||
use Illuminate\Auth\AuthenticationException; | ||
use Laravel\Passport\AccessToken; | ||
use Laravel\Passport\Exceptions\MissingScopeException; | ||
|
||
class EnsureClientIsResourceOwner extends ValidateToken | ||
{ | ||
/** | ||
* Determine if the token's client is the resource owner and has all the given scopes. | ||
* | ||
* @throws \Exception | ||
*/ | ||
protected function validate(AccessToken $token, string ...$params): void | ||
{ | ||
if ($token->oauth_user_id !== $token->oauth_client_id) { | ||
throw new AuthenticationException; | ||
} | ||
|
||
foreach ($params as $scope) { | ||
if ($token->cant($scope)) { | ||
throw new MissingScopeException($scope); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.