Remove exceptions from lambda security configuration
Fixes: gh-7128
This commit is contained in:
committed by
Rob Winch
parent
b55322b2cb
commit
0b4502b2c5
@@ -162,7 +162,7 @@ public class HttpsRedirectSpecTests {
|
||||
@EnableWebFluxSecurity
|
||||
static class RedirectToHttpsInLambdaConfig {
|
||||
@Bean
|
||||
SecurityWebFilterChain springSecurity(ServerHttpSecurity http) throws Exception {
|
||||
SecurityWebFilterChain springSecurity(ServerHttpSecurity http) {
|
||||
// @formatter:off
|
||||
http
|
||||
.redirectToHttps(withDefaults());
|
||||
@@ -192,7 +192,7 @@ public class HttpsRedirectSpecTests {
|
||||
@EnableWebFluxSecurity
|
||||
static class SometimesRedirectToHttpsInLambdaConfig {
|
||||
@Bean
|
||||
SecurityWebFilterChain springSecurity(ServerHttpSecurity http) throws Exception {
|
||||
SecurityWebFilterChain springSecurity(ServerHttpSecurity http) {
|
||||
// @formatter:off
|
||||
http
|
||||
.redirectToHttps(redirectToHttps ->
|
||||
@@ -229,7 +229,7 @@ public class HttpsRedirectSpecTests {
|
||||
@EnableWebFluxSecurity
|
||||
static class RedirectToHttpsViaCustomPortsInLambdaConfig {
|
||||
@Bean
|
||||
SecurityWebFilterChain springSecurity(ServerHttpSecurity http) throws Exception {
|
||||
SecurityWebFilterChain springSecurity(ServerHttpSecurity http) {
|
||||
// @formatter:off
|
||||
http
|
||||
.redirectToHttps(redirectToHttps ->
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -219,7 +219,7 @@ public class OAuth2ClientSpecTests {
|
||||
ServerAuthenticationConverter authenticationConverter = mock(ServerAuthenticationConverter.class);
|
||||
|
||||
@Bean
|
||||
public SecurityWebFilterChain springSecurityFilter(ServerHttpSecurity http) throws Exception {
|
||||
public SecurityWebFilterChain springSecurityFilter(ServerHttpSecurity http) {
|
||||
http
|
||||
.oauth2Client(oauth2Client ->
|
||||
oauth2Client
|
||||
|
||||
@@ -324,7 +324,7 @@ public class OAuth2LoginTests {
|
||||
ServerAuthenticationSuccessHandler successHandler = mock(ServerAuthenticationSuccessHandler.class);
|
||||
|
||||
@Bean
|
||||
public SecurityWebFilterChain springSecurityFilter(ServerHttpSecurity http) throws Exception {
|
||||
public SecurityWebFilterChain springSecurityFilter(ServerHttpSecurity http) {
|
||||
http
|
||||
.authorizeExchange(exchanges ->
|
||||
exchanges
|
||||
|
||||
@@ -461,7 +461,7 @@ public class OAuth2ResourceServerSpecTests {
|
||||
@EnableWebFluxSecurity
|
||||
static class PublicKeyConfig {
|
||||
@Bean
|
||||
SecurityWebFilterChain springSecurity(ServerHttpSecurity http) throws Exception {
|
||||
SecurityWebFilterChain springSecurity(ServerHttpSecurity http) {
|
||||
// @formatter:off
|
||||
http
|
||||
.authorizeExchange()
|
||||
@@ -481,7 +481,7 @@ public class OAuth2ResourceServerSpecTests {
|
||||
@EnableWebFluxSecurity
|
||||
static class PublicKeyInLambdaConfig {
|
||||
@Bean
|
||||
SecurityWebFilterChain springSecurity(ServerHttpSecurity http) throws Exception {
|
||||
SecurityWebFilterChain springSecurity(ServerHttpSecurity http) {
|
||||
// @formatter:off
|
||||
http
|
||||
.authorizeExchange(exchanges ->
|
||||
@@ -508,7 +508,7 @@ public class OAuth2ResourceServerSpecTests {
|
||||
RSAPublicKey key;
|
||||
|
||||
@Bean
|
||||
SecurityWebFilterChain springSecurity(ServerHttpSecurity http) throws Exception {
|
||||
SecurityWebFilterChain springSecurity(ServerHttpSecurity http) {
|
||||
// @formatter:off
|
||||
http
|
||||
.authorizeExchange()
|
||||
@@ -560,7 +560,7 @@ public class OAuth2ResourceServerSpecTests {
|
||||
private MockWebServer mockWebServer = new MockWebServer();
|
||||
|
||||
@Bean
|
||||
SecurityWebFilterChain springSecurity(ServerHttpSecurity http) throws Exception {
|
||||
SecurityWebFilterChain springSecurity(ServerHttpSecurity http) {
|
||||
String jwkSetUri = mockWebServer().url("/.well-known/jwks.json").toString();
|
||||
|
||||
// @formatter:off
|
||||
@@ -614,7 +614,7 @@ public class OAuth2ResourceServerSpecTests {
|
||||
@EnableWebFluxSecurity
|
||||
static class DenyAllConfig {
|
||||
@Bean
|
||||
SecurityWebFilterChain authorization(ServerHttpSecurity http) throws Exception {
|
||||
SecurityWebFilterChain authorization(ServerHttpSecurity http) {
|
||||
// @formatter:off
|
||||
http
|
||||
.authorizeExchange()
|
||||
@@ -654,7 +654,7 @@ public class OAuth2ResourceServerSpecTests {
|
||||
@EnableWebFluxSecurity
|
||||
static class CustomAuthenticationManagerInLambdaConfig {
|
||||
@Bean
|
||||
SecurityWebFilterChain springSecurity(ServerHttpSecurity http) throws Exception {
|
||||
SecurityWebFilterChain springSecurity(ServerHttpSecurity http) {
|
||||
// @formatter:off
|
||||
http
|
||||
.oauth2ResourceServer(oauth2ResourceServer ->
|
||||
@@ -707,7 +707,7 @@ public class OAuth2ResourceServerSpecTests {
|
||||
@EnableWebFluxSecurity
|
||||
static class CustomBearerTokenServerAuthenticationConverter {
|
||||
@Bean
|
||||
SecurityWebFilterChain springSecurity(ServerHttpSecurity http) throws Exception {
|
||||
SecurityWebFilterChain springSecurity(ServerHttpSecurity http) {
|
||||
// @formatter:off
|
||||
http
|
||||
.authorizeExchange()
|
||||
@@ -733,7 +733,7 @@ public class OAuth2ResourceServerSpecTests {
|
||||
@EnableWebFluxSecurity
|
||||
static class CustomJwtAuthenticationConverterConfig {
|
||||
@Bean
|
||||
SecurityWebFilterChain springSecurity(ServerHttpSecurity http) throws Exception {
|
||||
SecurityWebFilterChain springSecurity(ServerHttpSecurity http) {
|
||||
// @formatter:off
|
||||
http
|
||||
.authorizeExchange()
|
||||
@@ -765,7 +765,7 @@ public class OAuth2ResourceServerSpecTests {
|
||||
@EnableWebFluxSecurity
|
||||
static class CustomErrorHandlingConfig {
|
||||
@Bean
|
||||
SecurityWebFilterChain springSecurity(ServerHttpSecurity http) throws Exception {
|
||||
SecurityWebFilterChain springSecurity(ServerHttpSecurity http) {
|
||||
// @formatter:off
|
||||
http
|
||||
.authorizeExchange()
|
||||
@@ -820,7 +820,7 @@ public class OAuth2ResourceServerSpecTests {
|
||||
private MockWebServer mockWebServer = new MockWebServer();
|
||||
|
||||
@Bean
|
||||
SecurityWebFilterChain springSecurity(ServerHttpSecurity http) throws Exception {
|
||||
SecurityWebFilterChain springSecurity(ServerHttpSecurity http) {
|
||||
String introspectionUri = mockWebServer().url("/introspect").toString();
|
||||
|
||||
// @formatter:off
|
||||
@@ -889,13 +889,19 @@ public class OAuth2ResourceServerSpecTests {
|
||||
return new MockResponse().setResponseCode(401);
|
||||
}
|
||||
|
||||
private static RSAPublicKey publicKey() throws NoSuchAlgorithmException, InvalidKeySpecException {
|
||||
private static RSAPublicKey publicKey() {
|
||||
String modulus = "26323220897278656456354815752829448539647589990395639665273015355787577386000316054335559633864476469390247312823732994485311378484154955583861993455004584140858982659817218753831620205191028763754231454775026027780771426040997832758235764611119743390612035457533732596799927628476322029280486807310749948064176545712270582940917249337311592011920620009965129181413510845780806191965771671528886508636605814099711121026468495328702234901200169245493126030184941412539949521815665744267183140084667383643755535107759061065656273783542590997725982989978433493861515415520051342321336460543070448417126615154138673620797";
|
||||
String exponent = "65537";
|
||||
|
||||
RSAPublicKeySpec spec = new RSAPublicKeySpec(new BigInteger(modulus), new BigInteger(exponent));
|
||||
KeyFactory factory = KeyFactory.getInstance("RSA");
|
||||
return (RSAPublicKey) factory.generatePublic(spec);
|
||||
RSAPublicKey rsaPublicKey = null;
|
||||
try {
|
||||
KeyFactory factory = KeyFactory.getInstance("RSA");
|
||||
rsaPublicKey = (RSAPublicKey) factory.generatePublic(spec);
|
||||
} catch (NoSuchAlgorithmException | InvalidKeySpecException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return rsaPublicKey;
|
||||
}
|
||||
|
||||
private GenericWebApplicationContext autowireWebServerGenericWebApplicationContext() {
|
||||
|
||||
Reference in New Issue
Block a user