mirror of
https://github.com/spring-projects/spring-security.git
synced 2025-05-31 09:12:14 +00:00
Java 8: Statement lambda can be replaced with expression lambda
This commit is contained in:
parent
7b2a7847e5
commit
38de737663
@ -1184,9 +1184,7 @@ public class ServerHttpSecurity {
|
|||||||
return Collections.emptyMap();
|
return Collections.emptyMap();
|
||||||
}
|
}
|
||||||
Map<String, String> result = new HashMap<>();
|
Map<String, String> result = new HashMap<>();
|
||||||
registrations.iterator().forEachRemaining(r -> {
|
registrations.iterator().forEachRemaining(r -> result.put("/oauth2/authorization/" + r.getRegistrationId(), r.getClientName()));
|
||||||
result.put("/oauth2/authorization/" + r.getRegistrationId(), r.getClientName());
|
|
||||||
});
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -117,16 +117,14 @@ public class DefaultReactiveOAuth2UserService implements ReactiveOAuth2UserServi
|
|||||||
}
|
}
|
||||||
Mono<Map<String, Object>> userAttributes = requestHeadersSpec
|
Mono<Map<String, Object>> userAttributes = requestHeadersSpec
|
||||||
.retrieve()
|
.retrieve()
|
||||||
.onStatus(s -> s != HttpStatus.OK, response -> {
|
.onStatus(s -> s != HttpStatus.OK, response -> parse(response).map(userInfoErrorResponse -> {
|
||||||
return parse(response).map(userInfoErrorResponse -> {
|
String description = userInfoErrorResponse.getErrorObject().getDescription();
|
||||||
String description = userInfoErrorResponse.getErrorObject().getDescription();
|
OAuth2Error oauth2Error = new OAuth2Error(
|
||||||
OAuth2Error oauth2Error = new OAuth2Error(
|
INVALID_USER_INFO_RESPONSE_ERROR_CODE, description,
|
||||||
INVALID_USER_INFO_RESPONSE_ERROR_CODE, description,
|
null);
|
||||||
null);
|
throw new OAuth2AuthenticationException(oauth2Error,
|
||||||
throw new OAuth2AuthenticationException(oauth2Error,
|
oauth2Error.toString());
|
||||||
oauth2Error.toString());
|
}))
|
||||||
});
|
|
||||||
})
|
|
||||||
.bodyToMono(typeReference);
|
.bodyToMono(typeReference);
|
||||||
|
|
||||||
return userAttributes.map(attrs -> {
|
return userAttributes.map(attrs -> {
|
||||||
|
@ -255,12 +255,10 @@ public final class ServletOAuth2AuthorizedClientExchangeFilterFunction
|
|||||||
* @return the {@link Consumer} to populate the attributes
|
* @return the {@link Consumer} to populate the attributes
|
||||||
*/
|
*/
|
||||||
public Consumer<WebClient.RequestHeadersSpec<?>> defaultRequest() {
|
public Consumer<WebClient.RequestHeadersSpec<?>> defaultRequest() {
|
||||||
return spec -> {
|
return spec -> spec.attributes(attrs -> {
|
||||||
spec.attributes(attrs -> {
|
populateDefaultRequestResponse(attrs);
|
||||||
populateDefaultRequestResponse(attrs);
|
populateDefaultAuthentication(attrs);
|
||||||
populateDefaultAuthentication(attrs);
|
});
|
||||||
});
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -114,10 +114,8 @@ public class OAuth2AuthorizationRequestRedirectWebFilter implements WebFilter {
|
|||||||
public Mono<Void> filter(ServerWebExchange exchange, WebFilterChain chain) {
|
public Mono<Void> filter(ServerWebExchange exchange, WebFilterChain chain) {
|
||||||
return this.authorizationRequestResolver.resolve(exchange)
|
return this.authorizationRequestResolver.resolve(exchange)
|
||||||
.switchIfEmpty(chain.filter(exchange).then(Mono.empty()))
|
.switchIfEmpty(chain.filter(exchange).then(Mono.empty()))
|
||||||
.onErrorResume(ClientAuthorizationRequiredException.class, e -> {
|
.onErrorResume(ClientAuthorizationRequiredException.class, e -> this.requestCache.saveRequest(exchange)
|
||||||
return this.requestCache.saveRequest(exchange)
|
.then(this.authorizationRequestResolver.resolve(exchange, e.getClientRegistrationId())))
|
||||||
.then(this.authorizationRequestResolver.resolve(exchange, e.getClientRegistrationId()));
|
|
||||||
})
|
|
||||||
.flatMap(clientRegistration -> sendRedirectForAuthorization(exchange, clientRegistration));
|
.flatMap(clientRegistration -> sendRedirectForAuthorization(exchange, clientRegistration));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,9 +69,7 @@ public class UnAuthenticatedServerOAuth2AuthorizedClientRepository implements Se
|
|||||||
Assert.notNull(clientRegistrationId, "clientRegistrationId cannot be null");
|
Assert.notNull(clientRegistrationId, "clientRegistrationId cannot be null");
|
||||||
Assert.isNull(serverWebExchange, "serverWebExchange " + serverWebExchange + "must be null");
|
Assert.isNull(serverWebExchange, "serverWebExchange " + serverWebExchange + "must be null");
|
||||||
Assert.isTrue(isUnauthenticated(authentication), "The user " + authentication + " should not be authenticated");
|
Assert.isTrue(isUnauthenticated(authentication), "The user " + authentication + " should not be authenticated");
|
||||||
return Mono.fromRunnable(() -> {
|
return Mono.fromRunnable(() -> this.clientRegistrationIdToAuthorizedClient.remove(clientRegistrationId));
|
||||||
this.clientRegistrationIdToAuthorizedClient.remove(clientRegistrationId);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isUnauthenticated(Authentication authentication) {
|
private boolean isUnauthenticated(Authentication authentication) {
|
||||||
|
@ -67,9 +67,7 @@ public class SecurityMockServerConfigurers {
|
|||||||
public static MockServerConfigurer springSecurity() {
|
public static MockServerConfigurer springSecurity() {
|
||||||
return new MockServerConfigurer() {
|
return new MockServerConfigurer() {
|
||||||
public void beforeServerCreated(WebHttpHandlerBuilder builder) {
|
public void beforeServerCreated(WebHttpHandlerBuilder builder) {
|
||||||
builder.filters( filters -> {
|
builder.filters( filters -> filters.add(0, new MutatorFilter()));
|
||||||
filters.add(0, new MutatorFilter());
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -62,9 +62,7 @@ public final class CookieClearingLogoutHandler implements LogoutHandler {
|
|||||||
List<Function<HttpServletRequest, Cookie>> cookieList = new ArrayList<>();
|
List<Function<HttpServletRequest, Cookie>> cookieList = new ArrayList<>();
|
||||||
for (Cookie cookie : cookiesToClear) {
|
for (Cookie cookie : cookiesToClear) {
|
||||||
Assert.isTrue(cookie.getMaxAge() == 0, "Cookie maxAge must be 0");
|
Assert.isTrue(cookie.getMaxAge() == 0, "Cookie maxAge must be 0");
|
||||||
Function<HttpServletRequest, Cookie> f = (request) -> {
|
Function<HttpServletRequest, Cookie> f = (request) -> cookie;
|
||||||
return cookie;
|
|
||||||
};
|
|
||||||
cookieList.add(f);
|
cookieList.add(f);
|
||||||
}
|
}
|
||||||
this.cookiesToClear = cookieList;
|
this.cookiesToClear = cookieList;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user