33import com .faforever .api .config .FafApiProperties ;
44import com .faforever .api .security .FafMultiTokenStore ;
55import com .faforever .api .security .FafUserAuthenticationConverter ;
6+ import org .springframework .beans .factory .annotation .Qualifier ;
67import org .springframework .context .annotation .Bean ;
78import org .springframework .context .annotation .Configuration ;
89import org .springframework .context .annotation .Primary ;
@@ -33,11 +34,16 @@ public DefaultTokenServices tokenServices(TokenStore tokenStore) {
3334 }
3435
3536 @ Bean
36- public TokenStore tokenStore (FafApiProperties properties , JwtAccessTokenConverter jwtAccessTokenConverter ) {
37- return new FafMultiTokenStore (properties , jwtAccessTokenConverter );
37+ public TokenStore tokenStore (FafApiProperties properties ,
38+ @ Qualifier ("classicAccessTokenConverter" )
39+ JwtAccessTokenConverter jwtAccessTokenConverter ,
40+ @ Qualifier ("hydraAccessTokenConverter" )
41+ JwtAccessTokenConverter hydraAccessTokenConverter ) {
42+ return new FafMultiTokenStore (properties , jwtAccessTokenConverter , hydraAccessTokenConverter );
3843 }
3944
40- @ Bean
45+ @ Bean (name = "classicAccessTokenConverter" )
46+ @ Primary
4147 protected JwtAccessTokenConverter jwtAccessTokenConverter () throws IOException {
4248 String secretKey = Files .readString (fafApiProperties .getJwt ().getSecretKeyPath ());
4349 String publicKey = Files .readString (fafApiProperties .getJwt ().getPublicKeyPath ());
@@ -48,4 +54,17 @@ protected JwtAccessTokenConverter jwtAccessTokenConverter() throws IOException {
4854 ((DefaultAccessTokenConverter ) jwtAccessTokenConverter .getAccessTokenConverter ()).setUserTokenConverter (new FafUserAuthenticationConverter ());
4955 return jwtAccessTokenConverter ;
5056 }
57+
58+ @ Bean (name = "hydraAccessTokenConverter" )
59+ protected JwtAccessTokenConverter hydraAccessTokenConverter () throws IOException {
60+ String secretKey = Files .readString (fafApiProperties .getJwt ().getSecretKeyPath ());
61+ String publicKey = Files .readString (fafApiProperties .getJwt ().getPublicKeyPath ());
62+
63+ JwtAccessTokenConverter jwtAccessTokenConverter = new JwtAccessTokenConverter ();
64+ jwtAccessTokenConverter .setSigningKey (secretKey );
65+ jwtAccessTokenConverter .setVerifierKey (publicKey );
66+ ((DefaultAccessTokenConverter ) jwtAccessTokenConverter .getAccessTokenConverter ()).setUserTokenConverter (new FafUserAuthenticationConverter ());
67+ ((DefaultAccessTokenConverter ) jwtAccessTokenConverter .getAccessTokenConverter ()).setScopeAttribute ("scp" );
68+ return jwtAccessTokenConverter ;
69+ }
5170}
0 commit comments