1
1
package eu .solven .kumite .security ;
2
2
3
+ import java .util .Set ;
4
+ import java .util .UUID ;
5
+
6
+ import org .springframework .beans .factory .annotation .Qualifier ;
3
7
import org .springframework .context .annotation .Bean ;
4
8
import org .springframework .context .annotation .Import ;
5
9
import org .springframework .context .annotation .Profile ;
6
10
import org .springframework .core .env .Environment ;
7
11
import org .springframework .core .env .Profiles ;
8
12
import org .springframework .web .bind .annotation .RestController ;
9
- import org .springframework .web .server .WebExceptionHandler ;
10
13
11
14
import eu .solven .kumite .account .JwtUserContextHolder ;
15
+ import eu .solven .kumite .account .KumiteUser ;
12
16
import eu .solven .kumite .app .IKumiteSpringProfiles ;
13
17
import eu .solven .kumite .app .webflux .KumiteWebExceptionHandler ;
14
18
import eu .solven .kumite .app .webflux .api .KumiteLoginController ;
15
19
import eu .solven .kumite .app .webflux .api .KumitePublicController ;
16
20
import eu .solven .kumite .app .webflux .api .MetadataController ;
21
+ import eu .solven .kumite .login .RefreshTokenWrapper ;
17
22
import eu .solven .kumite .oauth2 .authorizationserver .KumiteTokenService ;
18
23
import eu .solven .kumite .oauth2 .resourceserver .KumiteResourceServerConfiguration ;
24
+ import eu .solven .kumite .player .IAccountPlayersRegistry ;
19
25
import lombok .extern .slf4j .Slf4j ;
20
26
21
27
// https://docs.spring.io/spring-security/reference/reactive/oauth2/login/advanced.html#webflux-oauth2-login-advanced-userinfo-endpoint
33
39
34
40
JwtUserContextHolder .class ,
35
41
42
+ KumiteWebExceptionHandler .class ,
43
+
36
44
})
37
45
@ Slf4j
38
46
public class KumiteSecurity {
@@ -71,13 +79,18 @@ public Void checkSpringProfilesConsistency(Environment env) {
71
79
return null ;
72
80
}
73
81
74
- // @Bean
75
- // WebFilter kumiteExceptionRoutingWebFilter() {
76
- // return new KumiteExceptionRoutingWebFilter();
77
- // }
78
-
82
+ // We print a refreshToken at startup, as it makes it easier to configure a player
79
83
@ Bean
80
- WebExceptionHandler kumiteWebExceptionHandler () {
81
- return new KumiteWebExceptionHandler ();
84
+ public Void printRandomPlayerRefreshToken (@ Qualifier ("random" ) KumiteUser user ,
85
+ KumiteTokenService tokenService ,
86
+ IAccountPlayersRegistry accountPlayersRegistry ) {
87
+ UUID accountId = user .getAccountId ();
88
+
89
+ Set <UUID > playerIds = accountPlayersRegistry .makeDynamicHasPlayers (accountId ).getPlayerIds ();
90
+ RefreshTokenWrapper refreshToken = tokenService .wrapInJwtRefreshToken (user , playerIds );
91
+
92
+ log .info ("refresh_token for accountId={}: {}" , user .getAccountId (), refreshToken );
93
+
94
+ return null ;
82
95
}
83
96
}
0 commit comments