mirror of
https://github.com/spring-projects/spring-security.git
synced 2025-06-24 21:12:18 +00:00
Polish
Formatting as well as adding a missing defer Issue gh-15699
This commit is contained in:
parent
2ca2e56383
commit
b26f2af5d5
@ -292,7 +292,8 @@ public class OneTimeTokenLoginSpecTests {
|
|||||||
http
|
http
|
||||||
.authorizeExchange((authorize) -> authorize
|
.authorizeExchange((authorize) -> authorize
|
||||||
.anyExchange()
|
.anyExchange()
|
||||||
.authenticated())
|
.authenticated()
|
||||||
|
)
|
||||||
.oneTimeTokenLogin((ott) -> ott
|
.oneTimeTokenLogin((ott) -> ott
|
||||||
.generatedOneTimeTokenHandler(new TestServerGeneratedOneTimeTokenHandler())
|
.generatedOneTimeTokenHandler(new TestServerGeneratedOneTimeTokenHandler())
|
||||||
);
|
);
|
||||||
@ -314,7 +315,8 @@ public class OneTimeTokenLoginSpecTests {
|
|||||||
http
|
http
|
||||||
.authorizeExchange((authorize) -> authorize
|
.authorizeExchange((authorize) -> authorize
|
||||||
.anyExchange()
|
.anyExchange()
|
||||||
.authenticated())
|
.authenticated()
|
||||||
|
)
|
||||||
.oneTimeTokenLogin((ott) -> ott
|
.oneTimeTokenLogin((ott) -> ott
|
||||||
.generateTokenUrl("/generateurl")
|
.generateTokenUrl("/generateurl")
|
||||||
.generatedOneTimeTokenHandler(new TestServerGeneratedOneTimeTokenHandler("/redirected"))
|
.generatedOneTimeTokenHandler(new TestServerGeneratedOneTimeTokenHandler("/redirected"))
|
||||||
@ -339,7 +341,8 @@ public class OneTimeTokenLoginSpecTests {
|
|||||||
http
|
http
|
||||||
.authorizeExchange((authorize) -> authorize
|
.authorizeExchange((authorize) -> authorize
|
||||||
.anyExchange()
|
.anyExchange()
|
||||||
.authenticated())
|
.authenticated()
|
||||||
|
)
|
||||||
.formLogin(Customizer.withDefaults())
|
.formLogin(Customizer.withDefaults())
|
||||||
.oneTimeTokenLogin((ott) -> ott
|
.oneTimeTokenLogin((ott) -> ott
|
||||||
.generatedOneTimeTokenHandler(new TestServerGeneratedOneTimeTokenHandler())
|
.generatedOneTimeTokenHandler(new TestServerGeneratedOneTimeTokenHandler())
|
||||||
@ -362,7 +365,8 @@ public class OneTimeTokenLoginSpecTests {
|
|||||||
http
|
http
|
||||||
.authorizeExchange((authorize) -> authorize
|
.authorizeExchange((authorize) -> authorize
|
||||||
.anyExchange()
|
.anyExchange()
|
||||||
.authenticated())
|
.authenticated()
|
||||||
|
)
|
||||||
.oneTimeTokenLogin(Customizer.withDefaults());
|
.oneTimeTokenLogin(Customizer.withDefaults());
|
||||||
// @formatter:on
|
// @formatter:on
|
||||||
return http.build();
|
return http.build();
|
||||||
|
@ -54,7 +54,7 @@ public final class OneTimeTokenReactiveAuthenticationManager implements Reactive
|
|||||||
return Mono.empty();
|
return Mono.empty();
|
||||||
}
|
}
|
||||||
return this.oneTimeTokenService.consume(otpAuthenticationToken)
|
return this.oneTimeTokenService.consume(otpAuthenticationToken)
|
||||||
.switchIfEmpty(Mono.error(new InvalidOneTimeTokenException("Invalid token")))
|
.switchIfEmpty(Mono.defer(() -> Mono.error(new InvalidOneTimeTokenException("Invalid token"))))
|
||||||
.flatMap((consumed) -> this.userDetailsService.findByUsername(consumed.getUsername()))
|
.flatMap((consumed) -> this.userDetailsService.findByUsername(consumed.getUsername()))
|
||||||
.map(onSuccess(otpAuthenticationToken));
|
.map(onSuccess(otpAuthenticationToken));
|
||||||
}
|
}
|
||||||
|
@ -58,8 +58,9 @@ public final class GenerateOneTimeTokenWebFilter implements WebFilter {
|
|||||||
// @formatter:off
|
// @formatter:off
|
||||||
return this.matcher.matches(exchange)
|
return this.matcher.matches(exchange)
|
||||||
.filter(ServerWebExchangeMatcher.MatchResult::isMatch)
|
.filter(ServerWebExchangeMatcher.MatchResult::isMatch)
|
||||||
.flatMap((mathResult) -> exchange.getFormData())
|
.switchIfEmpty(chain.filter(exchange).then(Mono.empty()))
|
||||||
.flatMap((data) -> Mono.justOrEmpty(data.getFirst(USERNAME)))
|
.then(exchange.getFormData())
|
||||||
|
.mapNotNull((data) -> data.getFirst(USERNAME))
|
||||||
.switchIfEmpty(chain.filter(exchange).then(Mono.empty()))
|
.switchIfEmpty(chain.filter(exchange).then(Mono.empty()))
|
||||||
.flatMap((username) -> this.oneTimeTokenService.generate(new GenerateOneTimeTokenRequest(username)))
|
.flatMap((username) -> this.oneTimeTokenService.generate(new GenerateOneTimeTokenRequest(username)))
|
||||||
.flatMap((token) -> this.generatedOneTimeTokenHandler.handle(exchange, token));
|
.flatMap((token) -> this.generatedOneTimeTokenHandler.handle(exchange, token));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user