forked from FriendsOfSymfony/FOSOAuthServerBundle
-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Symfony 5.3 new authenticator system compliant
- Loading branch information
1 parent
fe553a2
commit 565d05f
Showing
5 changed files
with
116 additions
and
33 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 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,13 @@ | ||
<?php | ||
|
||
|
||
namespace FOS\OAuthServerBundle\Security\Authenticator; | ||
|
||
|
||
use Symfony\Component\Security\Http\Authenticator\Passport\PassportInterface; | ||
use Symfony\Component\Security\Http\Authenticator\Passport\PassportTrait; | ||
|
||
class OAuth2Passport implements PassportInterface | ||
{ | ||
use PassportTrait; | ||
} |
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
56 changes: 56 additions & 0 deletions
56
Security/Authenticator/Passport/Badge/AccessTokenBadge.php
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,56 @@ | ||
<?php | ||
|
||
|
||
namespace FOS\OAuthServerBundle\Security\Authenticator\Passport\Badge; | ||
|
||
|
||
use FOS\OAuthServerBundle\Model\AccessToken; | ||
use Symfony\Component\Security\Http\Authenticator\Passport\Badge\BadgeInterface; | ||
|
||
class AccessTokenBadge implements BadgeInterface | ||
{ | ||
/** | ||
* @var AccessToken | ||
*/ | ||
private $AccessToken; | ||
|
||
/** | ||
* @var array | ||
*/ | ||
private $roles; | ||
|
||
/** | ||
* AccessTokenBadge constructor. | ||
* @param AccessToken $AccessToken | ||
* @param array $roles | ||
*/ | ||
public function __construct( AccessToken $AccessToken, array $roles ) | ||
{ | ||
$this->AccessToken = $AccessToken; | ||
$this->roles = $roles; | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public function isResolved(): bool | ||
{ | ||
return ! empty ( $this->roles ); | ||
} | ||
|
||
/** | ||
* @return AccessToken | ||
*/ | ||
public function getAccessToken(): AccessToken | ||
{ | ||
return $this->AccessToken; | ||
} | ||
|
||
/** | ||
* @return array | ||
*/ | ||
public function getRoles(): array | ||
{ | ||
return $this->roles; | ||
} | ||
} |
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
I belive here should be used
$user->getUserIdentifier()
which is username or email, and then the UserBadge can be resolved at the end with User entity. Instead$client->getUserIdentifier()
returns randomId which doesn't have to represent the username/email but... randomId, and as a result at the end non user is found by the randomId.