File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ public class FafApiProperties {
1616 * The API version.
1717 */
1818 private String version ;
19+ private boolean allowAnonymous ;
1920 private Jwt jwt = new Jwt ();
2021 private OAuth2 oAuth2 = new OAuth2 ();
2122 private Async async = new Async ();
@@ -258,11 +259,6 @@ public static class Smtp {
258259 private String password ;
259260 }
260261
261- @ Data
262- public static class Anope {
263- private String databaseName ;
264- }
265-
266262 @ Data
267263 public static class Rating {
268264 private int defaultMean ;
Original file line number Diff line number Diff line change 11package com .faforever .api .config .security ;
22
33import com .faforever .api .security .method .CustomMethodSecurityExpressionHandler ;
4+ import org .springframework .boot .autoconfigure .condition .ConditionalOnProperty ;
45import org .springframework .context .annotation .Bean ;
56import org .springframework .context .annotation .Configuration ;
67import org .springframework .security .access .expression .method .MethodSecurityExpressionHandler ;
78import org .springframework .security .config .annotation .method .configuration .EnableMethodSecurity ;
89
910@ Configuration
11+ @ ConditionalOnProperty (
12+ value = "faf-api.allow-anonymous" ,
13+ havingValue = "false" ,
14+ matchIfMissing = true
15+ )
1016@ EnableMethodSecurity (securedEnabled = true )
1117public class MethodSecurityConfig {
1218 @ Bean
Original file line number Diff line number Diff line change @@ -24,7 +24,7 @@ public String getName() {
2424
2525 @ Override
2626 public boolean isInRole (String role ) {
27- return fafAuthentication .hasRole (role );
27+ return fafAuthentication != null && fafAuthentication .hasRole (role );
2828 }
2929
3030 public Optional <Integer > getFafUserId () {
Original file line number Diff line number Diff line change 11faf-api :
2+ allow-anonymous : true
23 jwt :
34 secretKeyPath : ${JWT_PRIVATE_KEY_PATH:test-pki-private.key}
45 publicKeyPath : ${JWT_PUBLIC_KEY_PATH:test-pki-public.key}
@@ -86,8 +87,8 @@ spring:
8687 oauth2 :
8788 resourceserver :
8889 jwt :
89- jwk-set-uri : https ://hydra.faforever.com /.well-known/jwks.json
90- issuer-uri : https ://hydra.faforever.com /
90+ jwk-set-uri : http ://hydra.faforever.localhost /.well-known/jwks.json
91+ issuer-uri : http ://ory- hydra:4444 /
9192logging :
9293 level :
9394 com.faforever.api : debug
You can’t perform that action at this time.
0 commit comments