-
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.
Apps that depend on servlet-security now starts using DollyHttpSecuri…
…ty, for less boilerplate and variances in security configuration.
- Loading branch information
Showing
49 changed files
with
264 additions
and
492 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
30 changes: 9 additions & 21 deletions
30
...resse-service/src/main/java/no/nav/testnav/apps/adresseservice/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,37 +1,25 @@ | ||
package no.nav.testnav.apps.adresseservice.config; | ||
|
||
import no.nav.dolly.libs.security.config.DollyHttpSecurity; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.core.annotation.Order; | ||
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; | ||
|
||
@EnableWebSecurity | ||
@Configuration | ||
@Order(1) | ||
public class SecurityConfig { | ||
class SecurityConfig { | ||
|
||
@Bean | ||
public SecurityFilterChain filterChain(HttpSecurity httpSecurity) throws Exception { | ||
|
||
httpSecurity.sessionManagement(sessionConfig -> sessionConfig.sessionCreationPolicy(SessionCreationPolicy.STATELESS)) | ||
SecurityFilterChain filterChain(HttpSecurity httpSecurity) throws Exception { | ||
return 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().requestMatchers("/api/**").fullyAuthenticated()) | ||
.oauth2ResourceServer(oauth2RSConfig -> oauth2RSConfig.jwt(Customizer.withDefaults())); | ||
|
||
return httpSecurity.build(); | ||
.authorizeHttpRequests(DollyHttpSecurity.withDefaultHttpRequests()) | ||
.oauth2ResourceServer(oauth2RSConfig -> oauth2RSConfig.jwt(Customizer.withDefaults())) | ||
.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
28 changes: 8 additions & 20 deletions
28
.../src/main/java/no/nav/registre/testnorge/arbeidsforholdservice/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,26 @@ | ||
package no.nav.registre.testnorge.arbeidsforholdservice.config; | ||
|
||
import no.nav.dolly.libs.security.config.DollyHttpSecurity; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.core.annotation.Order; | ||
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; | ||
|
||
@Order(1) | ||
@EnableWebSecurity | ||
@Configuration | ||
class SecurityConfig { | ||
|
||
@Bean | ||
public SecurityFilterChain filterChain(HttpSecurity httpSecurity) throws Exception { | ||
|
||
httpSecurity.sessionManagement(sessionConfig -> sessionConfig.sessionCreationPolicy(SessionCreationPolicy.STATELESS)) | ||
SecurityFilterChain filterChain(HttpSecurity httpSecurity) throws Exception { | ||
return 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().requestMatchers("/api/**").fullyAuthenticated()) | ||
.oauth2ResourceServer(oauth2RSConfig -> oauth2RSConfig.jwt(Customizer.withDefaults())); | ||
|
||
return httpSecurity.build(); | ||
.authorizeHttpRequests(DollyHttpSecurity.withDefaultHttpRequests()) | ||
.oauth2ResourceServer(oauth2RSConfig -> oauth2RSConfig.jwt(Customizer.withDefaults())) | ||
.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
26 changes: 8 additions & 18 deletions
26
...src/main/java/no/nav/registre/testnorge/batchbestillingservice/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,35 +1,25 @@ | ||
package no.nav.registre.testnorge.batchbestillingservice.config; | ||
|
||
import no.nav.dolly.libs.security.config.DollyHttpSecurity; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
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; | ||
|
||
@EnableWebSecurity | ||
@Configuration | ||
class SecurityConfig { | ||
|
||
@Bean | ||
public SecurityFilterChain filterChain(HttpSecurity httpSecurity) throws Exception { | ||
|
||
httpSecurity.sessionManagement(sessionConfig -> sessionConfig.sessionCreationPolicy(SessionCreationPolicy.STATELESS)) | ||
SecurityFilterChain filterChain(HttpSecurity httpSecurity) throws Exception { | ||
return 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().requestMatchers("/api/**").fullyAuthenticated()) | ||
.oauth2ResourceServer(oauth2RSConfig -> oauth2RSConfig.jwt(Customizer.withDefaults())); | ||
|
||
return httpSecurity.build(); | ||
.authorizeHttpRequests(DollyHttpSecurity.withDefaultHttpRequests()) | ||
.oauth2ResourceServer(oauth2RSConfig -> oauth2RSConfig.jwt(Customizer.withDefaults())) | ||
.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
28 changes: 9 additions & 19 deletions
28
apps/dolly-backend/src/main/java/no/nav/dolly/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,35 +1,25 @@ | ||
package no.nav.dolly.config; | ||
|
||
import no.nav.dolly.libs.security.config.DollyHttpSecurity; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
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; | ||
|
||
@Configuration | ||
@EnableWebSecurity | ||
public class SecurityConfig { | ||
class SecurityConfig { | ||
|
||
@Bean | ||
public SecurityFilterChain filterChain(HttpSecurity httpSecurity) throws Exception { | ||
|
||
httpSecurity.sessionManagement(sessionConfig -> sessionConfig.sessionCreationPolicy(SessionCreationPolicy.STATELESS)) | ||
SecurityFilterChain filterChain(HttpSecurity httpSecurity) throws Exception { | ||
return 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().requestMatchers("/api/**").fullyAuthenticated()) | ||
.oauth2ResourceServer(oauth2RSConfig -> oauth2RSConfig.jwt(Customizer.withDefaults())); | ||
|
||
return httpSecurity.build(); | ||
.authorizeHttpRequests(DollyHttpSecurity.withDefaultHttpRequests()) | ||
.oauth2ResourceServer(oauth2RSConfig -> oauth2RSConfig.jwt(Customizer.withDefaults())) | ||
.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
26 changes: 8 additions & 18 deletions
26
...ice/src/main/java/no/nav/registre/testnorge/generernavnservice/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,36 +1,26 @@ | ||
package no.nav.registre.testnorge.generernavnservice.config; | ||
|
||
import no.nav.dolly.libs.security.config.DollyHttpSecurity; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
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; | ||
|
||
@EnableWebSecurity | ||
@Configuration | ||
class SecurityConfig { | ||
|
||
@Bean | ||
public SecurityFilterChain filterChain(HttpSecurity httpSecurity) throws Exception { | ||
|
||
httpSecurity.sessionManagement(sessionConfig -> sessionConfig.sessionCreationPolicy(SessionCreationPolicy.STATELESS)) | ||
SecurityFilterChain filterChain(HttpSecurity httpSecurity) throws Exception { | ||
return 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().requestMatchers("/api/**").fullyAuthenticated()) | ||
.oauth2ResourceServer(oauth2RSConfig -> oauth2RSConfig.jwt(Customizer.withDefaults())); | ||
|
||
return httpSecurity.build(); | ||
.authorizeHttpRequests(DollyHttpSecurity.withDefaultHttpRequests()) | ||
.oauth2ResourceServer(oauth2RSConfig -> oauth2RSConfig.jwt(Customizer.withDefaults())) | ||
.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
28 changes: 8 additions & 20 deletions
28
...a/no/nav/registre/testnav/genererorganisasjonpopulasjonservice/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,26 @@ | ||
package no.nav.registre.testnav.genererorganisasjonpopulasjonservice.config; | ||
|
||
import no.nav.dolly.libs.security.config.DollyHttpSecurity; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.core.annotation.Order; | ||
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; | ||
|
||
@Order(1) | ||
@EnableWebSecurity | ||
@Configuration | ||
class SecurityConfig { | ||
|
||
@Bean | ||
public SecurityFilterChain filterChain(HttpSecurity httpSecurity) throws Exception { | ||
|
||
httpSecurity.sessionManagement(sessionConfig -> sessionConfig.sessionCreationPolicy(SessionCreationPolicy.STATELESS)) | ||
SecurityFilterChain filterChain(HttpSecurity httpSecurity) throws Exception { | ||
return 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().requestMatchers("/api/**").fullyAuthenticated()) | ||
.oauth2ResourceServer(oauth2RSConfig -> oauth2RSConfig.jwt(Customizer.withDefaults())); | ||
|
||
return httpSecurity.build(); | ||
.authorizeHttpRequests(DollyHttpSecurity.withDefaultHttpRequests()) | ||
.oauth2ResourceServer(oauth2RSConfig -> oauth2RSConfig.jwt(Customizer.withDefaults())) | ||
.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
29 changes: 9 additions & 20 deletions
29
...main/java/no/nav/registre/testnorge/generersyntameldingservice/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,27 @@ | ||
package no.nav.registre.testnorge.generersyntameldingservice.config; | ||
|
||
import no.nav.dolly.libs.security.config.DollyHttpSecurity; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
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; | ||
|
||
@EnableWebSecurity | ||
@Configuration | ||
@Profile({ "prod", "dev" }) | ||
public class SecurityConfig { | ||
@Profile({"prod", "local"}) | ||
class SecurityConfig { | ||
|
||
@Bean | ||
public SecurityFilterChain filterChain(HttpSecurity httpSecurity) throws Exception { | ||
|
||
httpSecurity.sessionManagement(sessionConfig -> sessionConfig.sessionCreationPolicy(SessionCreationPolicy.STATELESS)) | ||
SecurityFilterChain filterChain(HttpSecurity httpSecurity) throws Exception { | ||
return 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().requestMatchers("/api/**").fullyAuthenticated()) | ||
.oauth2ResourceServer(oauth2RSConfig -> oauth2RSConfig.jwt(Customizer.withDefaults())); | ||
|
||
return httpSecurity.build(); | ||
.authorizeHttpRequests(DollyHttpSecurity.withDefaultHttpRequests()) | ||
.oauth2ResourceServer(oauth2RSConfig -> oauth2RSConfig.jwt(Customizer.withDefaults())) | ||
.build(); | ||
} | ||
|
||
} |
Oops, something went wrong.