Polish One-Time Token Component Names
Aligning parts of speech so that names are using nouns/verbs where comparable components are using nouns/verbs. Issue gh-15114
This commit is contained in:
@@ -40,8 +40,8 @@ import org.springframework.security.core.userdetails.UserDetailsService;
|
||||
import org.springframework.security.provisioning.InMemoryUserDetailsManager;
|
||||
import org.springframework.security.web.SecurityFilterChain;
|
||||
import org.springframework.security.web.authentication.SimpleUrlAuthenticationSuccessHandler;
|
||||
import org.springframework.security.web.authentication.ott.GeneratedOneTimeTokenHandler;
|
||||
import org.springframework.security.web.authentication.ott.RedirectGeneratedOneTimeTokenHandler;
|
||||
import org.springframework.security.web.authentication.ott.OneTimeTokenGenerationSuccessHandler;
|
||||
import org.springframework.security.web.authentication.ott.RedirectOneTimeTokenGenerationSuccessHandler;
|
||||
import org.springframework.security.web.csrf.CsrfToken;
|
||||
import org.springframework.security.web.csrf.DefaultCsrfToken;
|
||||
import org.springframework.security.web.csrf.HttpSessionCsrfTokenRepository;
|
||||
@@ -72,7 +72,7 @@ public class OneTimeTokenLoginConfigurerTests {
|
||||
this.mvc.perform(post("/ott/generate").param("username", "user").with(csrf()))
|
||||
.andExpectAll(status().isFound(), redirectedUrl("/login/ott"));
|
||||
|
||||
String token = TestGeneratedOneTimeTokenHandler.lastToken.getTokenValue();
|
||||
String token = TestOneTimeTokenGenerationSuccessHandler.lastToken.getTokenValue();
|
||||
|
||||
this.mvc.perform(post("/login/ott").param("token", token).with(csrf()))
|
||||
.andExpectAll(status().isFound(), redirectedUrl("/"), authenticated());
|
||||
@@ -84,7 +84,7 @@ public class OneTimeTokenLoginConfigurerTests {
|
||||
this.mvc.perform(post("/generateurl").param("username", "user").with(csrf()))
|
||||
.andExpectAll(status().isFound(), redirectedUrl("/redirected"));
|
||||
|
||||
String token = TestGeneratedOneTimeTokenHandler.lastToken.getTokenValue();
|
||||
String token = TestOneTimeTokenGenerationSuccessHandler.lastToken.getTokenValue();
|
||||
|
||||
this.mvc.perform(post("/loginprocessingurl").param("token", token).with(csrf()))
|
||||
.andExpectAll(status().isFound(), redirectedUrl("/authenticated"), authenticated());
|
||||
@@ -96,7 +96,7 @@ public class OneTimeTokenLoginConfigurerTests {
|
||||
this.mvc.perform(post("/ott/generate").param("username", "user").with(csrf()))
|
||||
.andExpectAll(status().isFound(), redirectedUrl("/login/ott"));
|
||||
|
||||
String token = TestGeneratedOneTimeTokenHandler.lastToken.getTokenValue();
|
||||
String token = TestOneTimeTokenGenerationSuccessHandler.lastToken.getTokenValue();
|
||||
|
||||
this.mvc.perform(post("/login/ott").param("token", token).with(csrf()))
|
||||
.andExpectAll(status().isFound(), redirectedUrl("/"), authenticated());
|
||||
@@ -183,7 +183,7 @@ public class OneTimeTokenLoginConfigurerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void oneTimeTokenWhenNoGeneratedOneTimeTokenHandlerThenException() {
|
||||
void oneTimeTokenWhenNoTokenGenerationSuccessHandlerThenException() {
|
||||
assertThatException()
|
||||
.isThrownBy(() -> this.spring.register(OneTimeTokenNoGeneratedOttHandlerConfig.class).autowire())
|
||||
.havingRootCause()
|
||||
@@ -207,7 +207,7 @@ public class OneTimeTokenLoginConfigurerTests {
|
||||
.anyRequest().authenticated()
|
||||
)
|
||||
.oneTimeTokenLogin((ott) -> ott
|
||||
.generatedOneTimeTokenHandler(new TestGeneratedOneTimeTokenHandler())
|
||||
.tokenGenerationSuccessHandler(new TestOneTimeTokenGenerationSuccessHandler())
|
||||
);
|
||||
// @formatter:on
|
||||
return http.build();
|
||||
@@ -228,8 +228,8 @@ public class OneTimeTokenLoginConfigurerTests {
|
||||
.anyRequest().authenticated()
|
||||
)
|
||||
.oneTimeTokenLogin((ott) -> ott
|
||||
.generateTokenUrl("/generateurl")
|
||||
.generatedOneTimeTokenHandler(new TestGeneratedOneTimeTokenHandler("/redirected"))
|
||||
.tokenGeneratingUrl("/generateurl")
|
||||
.tokenGenerationSuccessHandler(new TestOneTimeTokenGenerationSuccessHandler("/redirected"))
|
||||
.loginProcessingUrl("/loginprocessingurl")
|
||||
.authenticationSuccessHandler(new SimpleUrlAuthenticationSuccessHandler("/authenticated"))
|
||||
);
|
||||
@@ -253,7 +253,7 @@ public class OneTimeTokenLoginConfigurerTests {
|
||||
)
|
||||
.formLogin(Customizer.withDefaults())
|
||||
.oneTimeTokenLogin((ott) -> ott
|
||||
.generatedOneTimeTokenHandler(new TestGeneratedOneTimeTokenHandler())
|
||||
.tokenGenerationSuccessHandler(new TestOneTimeTokenGenerationSuccessHandler())
|
||||
);
|
||||
// @formatter:on
|
||||
return http.build();
|
||||
@@ -280,18 +280,18 @@ public class OneTimeTokenLoginConfigurerTests {
|
||||
|
||||
}
|
||||
|
||||
static class TestGeneratedOneTimeTokenHandler implements GeneratedOneTimeTokenHandler {
|
||||
static class TestOneTimeTokenGenerationSuccessHandler implements OneTimeTokenGenerationSuccessHandler {
|
||||
|
||||
private static OneTimeToken lastToken;
|
||||
|
||||
private final GeneratedOneTimeTokenHandler delegate;
|
||||
private final OneTimeTokenGenerationSuccessHandler delegate;
|
||||
|
||||
TestGeneratedOneTimeTokenHandler() {
|
||||
this.delegate = new RedirectGeneratedOneTimeTokenHandler("/login/ott");
|
||||
TestOneTimeTokenGenerationSuccessHandler() {
|
||||
this.delegate = new RedirectOneTimeTokenGenerationSuccessHandler("/login/ott");
|
||||
}
|
||||
|
||||
TestGeneratedOneTimeTokenHandler(String redirectUrl) {
|
||||
this.delegate = new RedirectGeneratedOneTimeTokenHandler(redirectUrl);
|
||||
TestOneTimeTokenGenerationSuccessHandler(String redirectUrl) {
|
||||
this.delegate = new RedirectOneTimeTokenGenerationSuccessHandler(redirectUrl);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -40,8 +40,8 @@ import org.springframework.security.core.userdetails.User;
|
||||
import org.springframework.security.test.web.reactive.server.SecurityMockServerConfigurers;
|
||||
import org.springframework.security.web.server.SecurityWebFilterChain;
|
||||
import org.springframework.security.web.server.authentication.RedirectServerAuthenticationSuccessHandler;
|
||||
import org.springframework.security.web.server.authentication.ott.ServerGeneratedOneTimeTokenHandler;
|
||||
import org.springframework.security.web.server.authentication.ott.ServerRedirectGeneratedOneTimeTokenHandler;
|
||||
import org.springframework.security.web.server.authentication.ott.ServerOneTimeTokenGenerationSuccessHandler;
|
||||
import org.springframework.security.web.server.authentication.ott.ServerRedirectOneTimeTokenGenerationSuccessHandler;
|
||||
import org.springframework.test.web.reactive.server.WebTestClient;
|
||||
import org.springframework.web.reactive.config.EnableWebFlux;
|
||||
import org.springframework.web.reactive.function.BodyInserters;
|
||||
@@ -107,7 +107,7 @@ public class OneTimeTokenLoginSpecTests {
|
||||
.expectHeader().valueEquals("Location", "/login/ott");
|
||||
// @formatter:on
|
||||
|
||||
String token = TestServerGeneratedOneTimeTokenHandler.lastToken.getTokenValue();
|
||||
String token = TestServerOneTimeTokenGenerationSuccessHandler.lastToken.getTokenValue();
|
||||
|
||||
// @formatter:off
|
||||
this.client.mutateWith(SecurityMockServerConfigurers.csrf())
|
||||
@@ -143,7 +143,7 @@ public class OneTimeTokenLoginSpecTests {
|
||||
.expectHeader().valueEquals("Location", "/redirected");
|
||||
// @formatter:on
|
||||
|
||||
String token = TestServerGeneratedOneTimeTokenHandler.lastToken.getTokenValue();
|
||||
String token = TestServerOneTimeTokenGenerationSuccessHandler.lastToken.getTokenValue();
|
||||
|
||||
// @formatter:off
|
||||
this.client.mutateWith(SecurityMockServerConfigurers.csrf())
|
||||
@@ -179,7 +179,7 @@ public class OneTimeTokenLoginSpecTests {
|
||||
.expectHeader().valueEquals("Location", "/login/ott");
|
||||
// @formatter:on
|
||||
|
||||
String token = TestServerGeneratedOneTimeTokenHandler.lastToken.getTokenValue();
|
||||
String token = TestServerOneTimeTokenGenerationSuccessHandler.lastToken.getTokenValue();
|
||||
|
||||
// @formatter:off
|
||||
this.client.mutateWith(SecurityMockServerConfigurers.csrf())
|
||||
@@ -295,7 +295,7 @@ public class OneTimeTokenLoginSpecTests {
|
||||
.authenticated()
|
||||
)
|
||||
.oneTimeTokenLogin((ott) -> ott
|
||||
.generatedOneTimeTokenHandler(new TestServerGeneratedOneTimeTokenHandler())
|
||||
.tokenGenerationSuccessHandler(new TestServerOneTimeTokenGenerationSuccessHandler())
|
||||
);
|
||||
// @formatter:on
|
||||
return http.build();
|
||||
@@ -318,8 +318,8 @@ public class OneTimeTokenLoginSpecTests {
|
||||
.authenticated()
|
||||
)
|
||||
.oneTimeTokenLogin((ott) -> ott
|
||||
.generateTokenUrl("/generateurl")
|
||||
.generatedOneTimeTokenHandler(new TestServerGeneratedOneTimeTokenHandler("/redirected"))
|
||||
.tokenGeneratingUrl("/generateurl")
|
||||
.tokenGenerationSuccessHandler(new TestServerOneTimeTokenGenerationSuccessHandler("/redirected"))
|
||||
.loginProcessingUrl("/loginprocessingurl")
|
||||
.authenticationSuccessHandler(new RedirectServerAuthenticationSuccessHandler("/authenticated"))
|
||||
);
|
||||
@@ -345,7 +345,7 @@ public class OneTimeTokenLoginSpecTests {
|
||||
)
|
||||
.formLogin(Customizer.withDefaults())
|
||||
.oneTimeTokenLogin((ott) -> ott
|
||||
.generatedOneTimeTokenHandler(new TestServerGeneratedOneTimeTokenHandler())
|
||||
.tokenGenerationSuccessHandler(new TestServerOneTimeTokenGenerationSuccessHandler())
|
||||
);
|
||||
// @formatter:on
|
||||
return http.build();
|
||||
@@ -385,18 +385,19 @@ public class OneTimeTokenLoginSpecTests {
|
||||
|
||||
}
|
||||
|
||||
private static class TestServerGeneratedOneTimeTokenHandler implements ServerGeneratedOneTimeTokenHandler {
|
||||
private static class TestServerOneTimeTokenGenerationSuccessHandler
|
||||
implements ServerOneTimeTokenGenerationSuccessHandler {
|
||||
|
||||
private static OneTimeToken lastToken;
|
||||
|
||||
private final ServerGeneratedOneTimeTokenHandler delegate;
|
||||
private final ServerOneTimeTokenGenerationSuccessHandler delegate;
|
||||
|
||||
TestServerGeneratedOneTimeTokenHandler() {
|
||||
this.delegate = new ServerRedirectGeneratedOneTimeTokenHandler("/login/ott");
|
||||
TestServerOneTimeTokenGenerationSuccessHandler() {
|
||||
this.delegate = new ServerRedirectOneTimeTokenGenerationSuccessHandler("/login/ott");
|
||||
}
|
||||
|
||||
TestServerGeneratedOneTimeTokenHandler(String redirectUrl) {
|
||||
this.delegate = new ServerRedirectGeneratedOneTimeTokenHandler(redirectUrl);
|
||||
TestServerOneTimeTokenGenerationSuccessHandler(String redirectUrl) {
|
||||
this.delegate = new ServerRedirectOneTimeTokenGenerationSuccessHandler(redirectUrl);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user