-
-
Notifications
You must be signed in to change notification settings - Fork 801
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
reviewed authenticator, added SelfValidatedOAuthPassport, made refres…
…hToken function public, so we can refresh access token from outside (Listener), login to oauth instance with a LoginForm - 'password' grand, etc
- Loading branch information
Showing
6 changed files
with
153 additions
and
61 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
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
51 changes: 51 additions & 0 deletions
51
Security/Http/Authenticator/Passport/SelfValidatedOAuthPassport.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,51 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the HWIOAuthBundle package. | ||
* | ||
* (c) Hardware Info <opensource@hardware.info> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace HWI\Bundle\OAuthBundle\Security\Http\Authenticator\Passport; | ||
|
||
use HWI\Bundle\OAuthBundle\Security\Core\Authentication\Token\OAuthToken; | ||
use Symfony\Component\Security\Http\Authenticator\Passport\Badge\BadgeInterface; | ||
use Symfony\Component\Security\Http\Authenticator\Passport\Badge\UserBadge; | ||
use Symfony\Component\Security\Http\Authenticator\Passport\SelfValidatingPassport; | ||
|
||
/** | ||
* SelfValidatingPassport contained OAuthToken. | ||
*/ | ||
class SelfValidatedOAuthPassport extends SelfValidatingPassport | ||
{ | ||
private OAuthToken $token; | ||
|
||
/** | ||
* Token already contains authenticated user. No need to create trivial UserBadge outside. | ||
* | ||
* @param BadgeInterface[] $badges | ||
*/ | ||
public function __construct(OAuthToken $token, array $badges = []) | ||
{ | ||
$this->token = $token; | ||
|
||
$user = $token->getUser(); | ||
|
||
$userBadge = class_exists(UserBadge::class) | ||
? new UserBadge( | ||
method_exists($user, 'getUserIdentifier') ? $user->getUserIdentifier() : $user->getUsername(), | ||
static function () use ($user) { return $user; } | ||
) | ||
: $user; | ||
|
||
parent::__construct($userBadge, $badges); | ||
} | ||
|
||
public function getToken(): OAuthToken | ||
{ | ||
return $this->token; | ||
} | ||
} |
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