File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed
Security/Authentication/Provider Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -47,6 +47,7 @@ class OAuthProvider implements AuthenticationProviderInterface
47
47
/**
48
48
* @param \Symfony\Component\Security\Core\User\UserProviderInterface $userProvider The user provider.
49
49
* @param \OAuth2\OAuth2 $serverService The OAuth2 server service.
50
+ * @param \Symfony\Component\Security\Core\User\UserCheckerInterface $userChecker The Symfony User Checker for Pre and Post auth checks
50
51
*/
51
52
public function __construct (UserProviderInterface $ userProvider , OAuth2 $ serverService , UserCheckerInterface $ userChecker )
52
53
{
@@ -71,6 +72,22 @@ public function authenticate(TokenInterface $token)
71
72
$ scope = $ accessToken ->getScope ();
72
73
$ user = $ accessToken ->getUser ();
73
74
75
+ if (null !== $ user ) {
76
+
77
+ try {
78
+ $ this ->userChecker ->checkPreAuth ($ user );
79
+ } catch (AccountStatusException $ e ) {
80
+ throw new OAuth2AuthenticateException (OAuth2::HTTP_UNAUTHORIZED ,
81
+ OAuth2::TOKEN_TYPE_BEARER ,
82
+ $ this ->serverService ->getVariable (OAuth2::CONFIG_WWW_REALM ),
83
+ 'access_denied ' ,
84
+ $ e ->getMessage ()
85
+ );
86
+ }
87
+
88
+ $ token ->setUser ($ user );
89
+ }
90
+
74
91
$ roles = (null !== $ user ) ? $ user ->getRoles () : array ();
75
92
76
93
if (!empty ($ scope )) {
You can’t perform that action at this time.
0 commit comments