Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
package org.entur.jwt.spring;

import org.entur.jwt.spring.actuate.ListJwksHealthIndicator;
import org.entur.jwt.spring.decode.BoundedJwtHeaderToIssuerMapper;
import org.entur.jwt.spring.decode.DefaultJwtHeaderToIssuerMapperDecider;
import org.entur.jwt.spring.decode.JwtHeaderToIssuerMapperDecider;
import org.entur.jwt.spring.decode.JwtHeaderToIssuerMapper;
import org.entur.jwt.spring.properties.JwtProperties;
import org.entur.jwt.spring.properties.SecurityProperties;
import org.entur.jwt.spring.properties.jwk.JwtTenantProperties;
Expand Down Expand Up @@ -67,6 +71,19 @@ public List<OAuth2TokenValidator<Jwt>> claimConstraints(SecurityProperties prope
return oAuth2TokenValidatorFactory.create(properties.getJwt().getClaims());
}

@Bean
@ConditionalOnProperty(name = "entur.jwt.decode.header.map-to-issuer.enabled", havingValue = "true")
@ConditionalOnMissingBean(JwtHeaderToIssuerMapper.class)
public JwtHeaderToIssuerMapper jwtHeaderToIssuerMapper(SecurityProperties securityProperties) {
int maxSize = securityProperties.getJwt().getDecode().getHeader().getMapToIssuer().getMaxSize();
return maxSize != -1 ? new BoundedJwtHeaderToIssuerMapper(maxSize) : new JwtHeaderToIssuerMapper();
}

@Bean
@ConditionalOnProperty(name = "entur.jwt.decode.header.map-to-issuer.enabled", havingValue = "true")
@ConditionalOnMissingBean(JwtHeaderToIssuerMapperDecider.class)
public JwtHeaderToIssuerMapperDecider jwtHeaderToIssuerMapperDecider() {
return new DefaultJwtHeaderToIssuerMapperDecider();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
import org.entur.jwt.spring.JwtAutoConfiguration;
import org.entur.jwt.spring.KeycloakJwtAuthorityEnricher;
import org.entur.jwt.spring.NoUserDetailsService;
import org.entur.jwt.spring.decode.BoundedJwtHeaderToIssuerMapper;
import org.entur.jwt.spring.decode.DefaultJwtHeaderToIssuerMapperDecider;
import org.entur.jwt.spring.decode.JwtHeaderToIssuerMapperDecider;
import org.entur.jwt.spring.decode.JwtHeaderToIssuerMapper;
import org.entur.jwt.spring.grpc.properties.GrpcPermitAll;
Expand Down Expand Up @@ -100,21 +98,6 @@ public JwtAuthorityEnricher jwtAuthorityEnricher() {
return new DefaultJwtAuthorityEnricher();
}

@Bean
@ConditionalOnProperty(name = "entur.jwt.decode.header.map-to-issuer.enabled", havingValue = "true")
@ConditionalOnMissingBean(JwtHeaderToIssuerMapper.class)
public JwtHeaderToIssuerMapper jwtHeaderToIssuerMapper() {
int maxSize = securityProperties.getJwt().getDecode().getHeader().getMapToIssuer().getMaxSize();
return maxSize != -1 ? new BoundedJwtHeaderToIssuerMapper(maxSize) : new JwtHeaderToIssuerMapper();
}

@Bean
@ConditionalOnProperty(name = "entur.jwt.decode.header.map-to-issuer.enabled", havingValue = "true")
@ConditionalOnMissingBean(JwtHeaderToIssuerMapperDecider.class)
public JwtHeaderToIssuerMapperDecider jwtHeaderToIssuerMapperDecider() {
return new DefaultJwtHeaderToIssuerMapperDecider();
}

@Bean
@GlobalServerInterceptor
public AuthenticationProcessInterceptor jwtSecurityFilterChain(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
import org.entur.jwt.spring.config.EnturAuthorizeHttpRequestsCustomizer;
import org.entur.jwt.spring.config.EnturOauth2ResourceServerCustomizer;
import org.entur.jwt.spring.config.JwtMappedDiagnosticContextFilter;
import org.entur.jwt.spring.decode.BoundedJwtHeaderToIssuerMapper;
import org.entur.jwt.spring.decode.DefaultJwtHeaderToIssuerMapperDecider;
import org.entur.jwt.spring.decode.JwtHeaderToIssuerMapperDecider;
import org.entur.jwt.spring.decode.JwtHeaderToIssuerMapper;
import org.entur.jwt.spring.filter.log.JwtMappedDiagnosticContextMapper;
Expand Down Expand Up @@ -101,21 +99,6 @@ public CompositeWebSecurityConfigurerAdapter(SecurityProperties securityProperti
this.securityProperties = securityProperties;
}

@Bean
@ConditionalOnProperty(name = "entur.jwt.decode.header.map-to-issuer.enabled", havingValue = "true")
@ConditionalOnMissingBean(JwtHeaderToIssuerMapper.class)
public JwtHeaderToIssuerMapper jwtHeaderToIssuerMapper(SecurityProperties securityProperties) {
int maxSize = securityProperties.getJwt().getDecode().getHeader().getMapToIssuer().getMaxSize();
return maxSize != -1 ? new BoundedJwtHeaderToIssuerMapper(maxSize) : new JwtHeaderToIssuerMapper();
}

@Bean
@ConditionalOnProperty(name = "entur.jwt.decode.header.map-to-issuer.enabled", havingValue = "true")
@ConditionalOnMissingBean(JwtHeaderToIssuerMapperDecider.class)
public JwtHeaderToIssuerMapperDecider jwtHeaderToIssuerHeaderMapperDecider() {
return new DefaultJwtHeaderToIssuerMapperDecider();
}

@Bean
@ConditionalOnExpression("${entur.authorization.enabled:true} && !${entur.jwt.enabled:true}")
public SecurityFilterChain securityWebFilterChain(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

import org.entur.jwt.spring.config.EnturAuthorizeHttpRequestsCustomizer;
import org.entur.jwt.spring.config.EnturOauth2ResourceServerCustomizer;
import org.entur.jwt.spring.decode.BoundedJwtHeaderToIssuerMapper;
import org.entur.jwt.spring.decode.DefaultJwtHeaderToIssuerMapperDecider;
import org.entur.jwt.spring.decode.JwtHeaderToIssuerMapperDecider;
import org.entur.jwt.spring.decode.JwtHeaderToIssuerMapper;
import org.entur.jwt.spring.properties.Auth0Flavour;
Expand Down Expand Up @@ -81,21 +79,6 @@ public JwtAuthorityEnricher jwtAuthorityEnricher() {
return new DefaultJwtAuthorityEnricher();
}

@Bean
@ConditionalOnProperty(name = "entur.jwt.decode.header.map-to-issuer.enabled", havingValue = "true")
@ConditionalOnMissingBean(JwtHeaderToIssuerMapper.class)
public JwtHeaderToIssuerMapper jwtHeaderToIssuerMapper(SecurityProperties securityProperties) {
int maxSize = securityProperties.getJwt().getDecode().getHeader().getMapToIssuer().getMaxSize();
return maxSize != -1 ? new BoundedJwtHeaderToIssuerMapper(maxSize) : new JwtHeaderToIssuerMapper();
}

@Bean
@ConditionalOnProperty(name = "entur.jwt.decode.header.map-to-issuer.enabled", havingValue = "true")
@ConditionalOnMissingBean(JwtHeaderToIssuerMapperDecider.class)
public JwtHeaderToIssuerMapperDecider jwtHeaderToIssuerHeaderMapperDecider() {
return new DefaultJwtHeaderToIssuerMapperDecider();
}

@Configuration
@ConditionalOnMissingBean(name = BeanIds.SPRING_SECURITY_FILTER_CHAIN)
@ConditionalOnExpression("${entur.authorization.enabled:true} || ${entur.jwt.enabled:true}")
Expand Down