Skip to content

Commit af3a150

Browse files
committed
Expose actuator to anonymous for health and readiness checks
1 parent 52dd19e commit af3a150

4 files changed

Lines changed: 11 additions & 8 deletions

File tree

src/main/java/com/faforever/api/config/FafApiProperties.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff 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;

src/main/java/com/faforever/api/config/security/MethodSecurityConfig.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
11
package com.faforever.api.config.security;
22

33
import com.faforever.api.security.method.CustomMethodSecurityExpressionHandler;
4+
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
45
import org.springframework.context.annotation.Bean;
56
import org.springframework.context.annotation.Configuration;
67
import org.springframework.security.access.expression.method.MethodSecurityExpressionHandler;
78
import 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)
1117
public class MethodSecurityConfig {
1218
@Bean

src/main/java/com/faforever/api/security/ElideUser.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff 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() {

src/main/resources/config/application-local.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
faf-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/
9192
logging:
9293
level:
9394
com.faforever.api: debug

0 commit comments

Comments
 (0)