File tree 1 file changed +18
-4
lines changed
src/Security/Http/Firewall
1 file changed +18
-4
lines changed Original file line number Diff line number Diff line change 13
13
14
14
use HWI \Bundle \OAuthBundle \Security \Core \Authentication \Token \OAuthToken ;
15
15
use HWI \Bundle \OAuthBundle \Security \Http \Authenticator \OAuthAuthenticator ;
16
+ use Symfony \Component \Security \Http \Authenticator \AuthenticatorInterface ;
17
+ use Symfony \Component \Security \Http \Authenticator \Debug \TraceableAuthenticator ;
16
18
17
19
class RefreshAccessTokenListener extends AbstractRefreshAccessTokenListener
18
20
{
19
- private OAuthAuthenticator $ oAuthAuthenticator ;
21
+ private AuthenticatorInterface $ authenticator ;
20
22
21
23
public function __construct (
22
- OAuthAuthenticator $ oAuthAuthenticator
24
+ AuthenticatorInterface $ authenticator
23
25
) {
24
- $ this ->oAuthAuthenticator = $ oAuthAuthenticator ;
26
+ $ this ->authenticator = $ authenticator ;
25
27
}
26
28
27
29
/**
@@ -33,6 +35,18 @@ public function __construct(
33
35
*/
34
36
protected function refreshToken (OAuthToken $ token ): OAuthToken
35
37
{
36
- return $ this ->oAuthAuthenticator ->refreshToken ($ token );
38
+ if ($ this ->authenticator instanceof OAuthAuthenticator) {
39
+ return $ this ->authenticator ->refreshToken ($ token );
40
+ }
41
+
42
+ if ($ this ->authenticator instanceof TraceableAuthenticator) {
43
+ $ authenticator = $ this ->authenticator ->getAuthenticator ();
44
+
45
+ if ($ authenticator instanceof OAuthAuthenticator) {
46
+ return $ authenticator ->refreshToken ($ token );
47
+ }
48
+ }
49
+
50
+ throw new \RuntimeException ('Unsupported authenticator, expecting OAuthAuthenticator, got ' . get_class ($ this ->authenticator ));
37
51
}
38
52
}
You can’t perform that action at this time.
0 commit comments