-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Endret kodeverk-service til å støtte token fra idporten og route de…
…nne korrekt videre til kodeverk-api #deploy-kodeverk-service
- Loading branch information
Showing
6 changed files
with
47 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 4 additions & 4 deletions
8
apps/kodeverk-service/src/main/java/no/nav/testnav/kodeverkservice/config/AppConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 20 additions & 21 deletions
41
.../kodeverk-service/src/main/java/no/nav/testnav/kodeverkservice/config/SecurityConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,37 @@ | ||
package no.nav.testnav.kodeverkservice.config; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import no.nav.testnav.libs.reactivesecurity.manager.JwtReactiveAuthenticationManager; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.security.config.annotation.method.configuration.EnableReactiveMethodSecurity; | ||
import org.springframework.security.config.annotation.web.reactive.EnableWebFluxSecurity; | ||
import org.springframework.security.config.web.server.ServerHttpSecurity; | ||
import org.springframework.security.web.server.SecurityWebFilterChain; | ||
import org.springframework.context.annotation.Profile; | ||
import org.springframework.security.config.Customizer; | ||
import org.springframework.security.config.annotation.web.builders.HttpSecurity; | ||
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; | ||
import org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer; | ||
import org.springframework.security.config.http.SessionCreationPolicy; | ||
import org.springframework.security.web.SecurityFilterChain; | ||
|
||
@Slf4j | ||
@EnableWebSecurity | ||
@Configuration | ||
@EnableWebFluxSecurity | ||
@EnableReactiveMethodSecurity | ||
@RequiredArgsConstructor | ||
@Profile({ "prod", "dev" }) | ||
public class SecurityConfig { | ||
|
||
private final JwtReactiveAuthenticationManager jwtReactiveAuthenticationManager; | ||
|
||
@Bean | ||
public SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity httpSecurity) { | ||
return httpSecurity | ||
.csrf(ServerHttpSecurity.CsrfSpec::disable) | ||
.authorizeExchange(authorizeConfig -> authorizeConfig.pathMatchers( | ||
public SecurityFilterChain filterChain(HttpSecurity httpSecurity) throws Exception { | ||
|
||
httpSecurity.sessionManagement(sessionConfig -> sessionConfig.sessionCreationPolicy(SessionCreationPolicy.STATELESS)) | ||
.csrf(AbstractHttpConfigurer::disable) | ||
.authorizeHttpRequests(authorizeConfig -> authorizeConfig.requestMatchers( | ||
"/internal/**", | ||
"/webjars/**", | ||
"/swagger-resources/**", | ||
"/v3/api-docs/**", | ||
"/swagger-ui/**", | ||
"/swagger", | ||
"/error", | ||
"/swagger-ui.html" | ||
).permitAll().anyExchange().authenticated()) | ||
.oauth2ResourceServer(oauth2RSConfig -> oauth2RSConfig.jwt(jwtSpec -> jwtSpec.authenticationManager(jwtReactiveAuthenticationManager))) | ||
.build(); | ||
).permitAll().requestMatchers("/api/**").fullyAuthenticated()) | ||
.oauth2ResourceServer(oauth2RSConfig -> oauth2RSConfig.jwt(Customizer.withDefaults())); | ||
|
||
return httpSecurity.build(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters