Skip to content

Commit d37d41c

Browse files
franticticktickjzheaux
authored andcommitted
Polish One-Time Token API Names and Doc
The names of variables and methods have been adjusted in accordance with the names of the one-time token login API components. Issue gh-15114
1 parent e9fe636 commit d37d41c

File tree

11 files changed

+268
-64
lines changed

11 files changed

+268
-64
lines changed

config/src/main/java/org/springframework/security/config/annotation/web/builders/HttpSecurity.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3003,8 +3003,8 @@ public HttpSecurity oauth2ResourceServer(
30033003
* }
30043004
*
30053005
* @Bean
3006-
* public GeneratedOneTimeTokenHandler generatedOneTimeTokenHandler() {
3007-
* return new MyMagicLinkGeneratedOneTimeTokenHandler();
3006+
* public OneTimeTokenGenerationSuccessHandler oneTimeTokenGenerationSuccessHandler() {
3007+
* return new MyMagicLinkOneTimeTokenGenerationSuccessHandler();
30083008
* }
30093009
*
30103010
* }

config/src/main/java/org/springframework/security/config/annotation/web/configurers/ott/OneTimeTokenLoginConfigurer.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,19 +133,19 @@ private SecurityContextRepository getSecurityContextRepository(H http) {
133133

134134
private void configureOttGenerateFilter(H http) {
135135
GenerateOneTimeTokenFilter generateFilter = new GenerateOneTimeTokenFilter(getOneTimeTokenService(http),
136-
getGeneratedOneTimeTokenHandler(http));
136+
getOneTimeTokenGenerationSuccessHandler(http));
137137
generateFilter.setRequestMatcher(antMatcher(HttpMethod.POST, this.tokenGeneratingUrl));
138138
http.addFilter(postProcess(generateFilter));
139139
http.addFilter(DefaultResourcesFilter.css());
140140
}
141141

142-
private OneTimeTokenGenerationSuccessHandler getGeneratedOneTimeTokenHandler(H http) {
142+
private OneTimeTokenGenerationSuccessHandler getOneTimeTokenGenerationSuccessHandler(H http) {
143143
if (this.oneTimeTokenGenerationSuccessHandler == null) {
144144
this.oneTimeTokenGenerationSuccessHandler = getBeanOrNull(http, OneTimeTokenGenerationSuccessHandler.class);
145145
}
146146
if (this.oneTimeTokenGenerationSuccessHandler == null) {
147147
throw new IllegalStateException("""
148-
A GeneratedOneTimeTokenHandler is required to enable oneTimeTokenLogin().
148+
A OneTimeTokenGenerationSuccessHandler is required to enable oneTimeTokenLogin().
149149
Please provide it as a bean or pass it to the oneTimeTokenLogin() DSL.
150150
""");
151151
}
@@ -200,7 +200,7 @@ public OneTimeTokenLoginConfigurer<H> tokenGeneratingUrl(String tokenGeneratingU
200200
*/
201201
public OneTimeTokenLoginConfigurer<H> tokenGenerationSuccessHandler(
202202
OneTimeTokenGenerationSuccessHandler oneTimeTokenGenerationSuccessHandler) {
203-
Assert.notNull(oneTimeTokenGenerationSuccessHandler, "generatedOneTimeTokenHandler cannot be null");
203+
Assert.notNull(oneTimeTokenGenerationSuccessHandler, "oneTimeTokenGenerationSuccessHandler cannot be null");
204204
this.oneTimeTokenGenerationSuccessHandler = oneTimeTokenGenerationSuccessHandler;
205205
return this;
206206
}

config/src/main/java/org/springframework/security/config/web/server/ServerHttpSecurity.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1578,8 +1578,8 @@ public ServerHttpSecurity authenticationManager(ReactiveAuthenticationManager ma
15781578
* }
15791579
*
15801580
* &#064;Bean
1581-
* public ServerGeneratedOneTimeTokenHandler generatedOneTimeTokenHandler() {
1582-
* return new MyMagicLinkServerGeneratedOneTimeTokenHandler();
1581+
* public ServerOneTimeTokenGenerationSuccessHandler oneTimeTokenGenerationSuccessHandler() {
1582+
* return new MyMagicLinkServerOneTimeTokenGenerationSuccessHandler();
15831583
* }
15841584
*
15851585
* }
@@ -6151,12 +6151,12 @@ public OneTimeTokenLoginSpec defaultSubmitPageUrl(String submitPageUrl) {
61516151

61526152
/**
61536153
* Specifies strategy to be used to handle generated one-time tokens.
6154-
* @param generatedOneTimeTokenHandler
6154+
* @param oneTimeTokenGenerationSuccessHandler
61556155
*/
61566156
public OneTimeTokenLoginSpec tokenGenerationSuccessHandler(
6157-
ServerOneTimeTokenGenerationSuccessHandler generatedOneTimeTokenHandler) {
6158-
Assert.notNull(generatedOneTimeTokenHandler, "generatedOneTimeTokenHandler cannot be null");
6159-
this.tokenGenerationSuccessHandler = generatedOneTimeTokenHandler;
6157+
ServerOneTimeTokenGenerationSuccessHandler oneTimeTokenGenerationSuccessHandler) {
6158+
Assert.notNull(oneTimeTokenGenerationSuccessHandler, "oneTimeTokenGenerationSuccessHandler cannot be null");
6159+
this.tokenGenerationSuccessHandler = oneTimeTokenGenerationSuccessHandler;
61606160
return this;
61616161
}
61626162

@@ -6193,7 +6193,7 @@ private ServerOneTimeTokenGenerationSuccessHandler getTokenGenerationSuccessHand
61936193
}
61946194
if (this.tokenGenerationSuccessHandler == null) {
61956195
throw new IllegalStateException("""
6196-
A ServerGeneratedOneTimeTokenHandler is required to enable oneTimeTokenLogin().
6196+
A ServerOneTimeTokenGenerationSuccessHandler is required to enable oneTimeTokenLogin().
61976197
Please provide it as a bean or pass it to the oneTimeTokenLogin() DSL.
61986198
""");
61996199
}

config/src/main/kotlin/org/springframework/security/config/annotation/web/HttpSecurityDsl.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -985,7 +985,7 @@ class HttpSecurityDsl(private val http: HttpSecurity, private val init: HttpSecu
985985
* fun securityFilterChain(http: HttpSecurity): SecurityFilterChain {
986986
* http {
987987
* oneTimeTokenLogin {
988-
* generatedOneTimeTokenHandler = MyMagicLinkGeneratedOneTimeTokenHandler()
988+
* oneTimeTokenGenerationSuccessHandler = MyMagicLinkOneTimeTokenGenerationSuccessHandler()
989989
* }
990990
* }
991991
* return http.build()

config/src/test/java/org/springframework/security/config/annotation/web/configurers/ott/OneTimeTokenLoginConfigurerTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ void oneTimeTokenWhenNoTokenGenerationSuccessHandlerThenException() {
189189
.havingRootCause()
190190
.isInstanceOf(IllegalStateException.class)
191191
.withMessage("""
192-
A GeneratedOneTimeTokenHandler is required to enable oneTimeTokenLogin().
192+
A OneTimeTokenGenerationSuccessHandler is required to enable oneTimeTokenLogin().
193193
Please provide it as a bean or pass it to the oneTimeTokenLogin() DSL.
194194
""");
195195
}

config/src/test/java/org/springframework/security/config/web/server/OneTimeTokenLoginSpecTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,13 +269,13 @@ void oneTimeTokenWhenFormLoginConfiguredThenRendersRequestTokenForm() {
269269
}
270270

271271
@Test
272-
void oneTimeTokenWhenNoGeneratedOneTimeTokenHandlerThenException() {
272+
void oneTimeTokenWhenNoOneTimeTokenGenerationSuccessHandlerThenException() {
273273
assertThatException()
274274
.isThrownBy(() -> this.spring.register(OneTimeTokenNotGeneratedOttHandlerConfig.class).autowire())
275275
.havingRootCause()
276276
.isInstanceOf(IllegalStateException.class)
277277
.withMessage("""
278-
A ServerGeneratedOneTimeTokenHandler is required to enable oneTimeTokenLogin().
278+
A ServerOneTimeTokenGenerationSuccessHandler is required to enable oneTimeTokenLogin().
279279
Please provide it as a bean or pass it to the oneTimeTokenLogin() DSL.
280280
""");
281281
}

config/src/test/kotlin/org/springframework/security/config/annotation/web/OneTimeTokenLoginDslTests.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ class OneTimeTokenLoginDslTests {
6969
.redirectedUrl("/login/ott")
7070
)
7171

72-
val token = TestGeneratedOneTimeTokenHandler.lastToken?.tokenValue
72+
val token = TestOneTimeTokenGenerationSuccessHandler.lastToken?.tokenValue
7373

7474
this.mockMvc.perform(
7575
MockMvcRequestBuilders.post("/login/ott").param("token", token)
@@ -91,7 +91,7 @@ class OneTimeTokenLoginDslTests {
9191
)
9292
.andExpectAll(MockMvcResultMatchers.status().isFound(), MockMvcResultMatchers.redirectedUrl("/redirected"))
9393

94-
val token = TestGeneratedOneTimeTokenHandler.lastToken?.tokenValue
94+
val token = TestOneTimeTokenGenerationSuccessHandler.lastToken?.tokenValue
9595

9696
this.mockMvc.perform(
9797
MockMvcRequestBuilders.post("/loginprocessingurl").param("token", token)
@@ -117,7 +117,7 @@ class OneTimeTokenLoginDslTests {
117117
authorize(anyRequest, authenticated)
118118
}
119119
oneTimeTokenLogin {
120-
oneTimeTokenGenerationSuccessHandler = TestGeneratedOneTimeTokenHandler()
120+
oneTimeTokenGenerationSuccessHandler = TestOneTimeTokenGenerationSuccessHandler()
121121
}
122122
}
123123
// @formatter:on
@@ -138,7 +138,7 @@ class OneTimeTokenLoginDslTests {
138138
}
139139
oneTimeTokenLogin {
140140
tokenGeneratingUrl = "/generateurl"
141-
oneTimeTokenGenerationSuccessHandler = TestGeneratedOneTimeTokenHandler("/redirected")
141+
oneTimeTokenGenerationSuccessHandler = TestOneTimeTokenGenerationSuccessHandler("/redirected")
142142
loginProcessingUrl = "/loginprocessingurl"
143143
authenticationSuccessHandler = SimpleUrlAuthenticationSuccessHandler("/authenticated")
144144
}
@@ -156,7 +156,7 @@ class OneTimeTokenLoginDslTests {
156156
InMemoryUserDetailsManager(PasswordEncodedUser.user(), PasswordEncodedUser.admin())
157157
}
158158

159-
private class TestGeneratedOneTimeTokenHandler :
159+
private class TestOneTimeTokenGenerationSuccessHandler :
160160
OneTimeTokenGenerationSuccessHandler {
161161
private val delegate: OneTimeTokenGenerationSuccessHandler
162162

0 commit comments

Comments
 (0)