Skip to content

Commit 7ab04f5

Browse files
authored
Forby innkommende STS unntatt spesielt annoterte endepunkt (#1379)
1 parent 2afe408 commit 7ab04f5

File tree

1 file changed

+4
-14
lines changed

1 file changed

+4
-14
lines changed

felles/auth-filter/src/main/java/no/nav/vedtak/sikkerhet/jaxrs/AuthenticationFilterDelegate.java

+4-14
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,10 @@ public static void validerTokenSetKontekst(ResourceInfo resourceInfo, ContainerR
119119
var expiresAt = Optional.ofNullable(JwtUtil.getExpirationTime(claims)).orElseGet(() -> Instant.now().plusSeconds(300));
120120
var token = new OpenIDToken(configuration.type(), OpenIDToken.OIDC_DEFAULT_TOKEN_TYPE, tokenString, null, expiresAt.toEpochMilli());
121121

122+
if (OpenIDProvider.STS.equals(configuration.type()) && getAnnotation(resourceInfo, TillatSTS.class).isEmpty()) {
123+
throw new ValideringsFeil("Kall med STS til endepunkt som ikke eksplisitt tillater STS");
124+
}
125+
122126
// Valider
123127
var tokenValidator = OidcTokenValidatorConfig.instance().getValidator(token.provider());
124128
var validateResult = tokenValidator.validate(token.primary());
@@ -131,22 +135,8 @@ public static void validerTokenSetKontekst(ResourceInfo resourceInfo, ContainerR
131135
} else {
132136
throw new ValideringsFeil("Ugyldig token");
133137
}
134-
logStsUsage(configuration.type(), resourceInfo, resourceInfo.getResourceMethod().getName());
135138
}
136139

137-
private static void logStsUsage(OpenIDProvider type, ResourceInfo resourceInfo, String metodenavn) {
138-
if (OpenIDProvider.STS.equals(type)) {
139-
var annotertTillatSts = getAnnotation(resourceInfo, TillatSTS.class).isPresent();
140-
if (annotertTillatSts) {
141-
LOG.info("Innkommende STS - metode {} har annotering TillatSTS", metodenavn);
142-
} else {
143-
LOG.info("Innkommende STS - metode {} mangler annotering TillatSTS", metodenavn);
144-
}
145-
}
146-
}
147-
148-
149-
150140
private static class TokenFeil extends RuntimeException {
151141
TokenFeil(String message) {
152142
super(message);

0 commit comments

Comments
 (0)