Skip to content

Commit c403343

Browse files
committed
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
1 parent b8aa788 commit c403343

File tree

19 files changed

+158
-142
lines changed

19 files changed

+158
-142
lines changed

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

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@
4141
import org.springframework.security.web.authentication.SavedRequestAwareAuthenticationSuccessHandler;
4242
import org.springframework.security.web.authentication.SimpleUrlAuthenticationFailureHandler;
4343
import org.springframework.security.web.authentication.ott.GenerateOneTimeTokenFilter;
44-
import org.springframework.security.web.authentication.ott.GeneratedOneTimeTokenHandler;
4544
import org.springframework.security.web.authentication.ott.OneTimeTokenAuthenticationConverter;
45+
import org.springframework.security.web.authentication.ott.OneTimeTokenGenerationSuccessHandler;
4646
import org.springframework.security.web.authentication.ui.DefaultLoginPageGeneratingFilter;
4747
import org.springframework.security.web.authentication.ui.DefaultOneTimeTokenSubmitPageGeneratingFilter;
4848
import org.springframework.security.web.authentication.ui.DefaultResourcesFilter;
@@ -73,9 +73,9 @@ public final class OneTimeTokenLoginConfigurer<H extends HttpSecurityBuilder<H>>
7373

7474
private String loginProcessingUrl = "/login/ott";
7575

76-
private String generateTokenUrl = "/ott/generate";
76+
private String tokenGeneratingUrl = "/ott/generate";
7777

78-
private GeneratedOneTimeTokenHandler generatedOneTimeTokenHandler;
78+
private OneTimeTokenGenerationSuccessHandler oneTimeTokenGenerationSuccessHandler;
7979

8080
private AuthenticationProvider authenticationProvider;
8181

@@ -97,7 +97,7 @@ private void configureDefaultLoginPage(H http) {
9797
return;
9898
}
9999
loginPageGeneratingFilter.setOneTimeTokenEnabled(true);
100-
loginPageGeneratingFilter.setGenerateOneTimeTokenUrl(this.generateTokenUrl);
100+
loginPageGeneratingFilter.setOneTimeTokenGenerationUrl(this.tokenGeneratingUrl);
101101
if (this.authenticationFailureHandler == null
102102
&& StringUtils.hasText(loginPageGeneratingFilter.getLoginPageUrl())) {
103103
this.authenticationFailureHandler = new SimpleUrlAuthenticationFailureHandler(
@@ -134,22 +134,22 @@ private SecurityContextRepository getSecurityContextRepository(H http) {
134134
private void configureOttGenerateFilter(H http) {
135135
GenerateOneTimeTokenFilter generateFilter = new GenerateOneTimeTokenFilter(getOneTimeTokenService(http),
136136
getGeneratedOneTimeTokenHandler(http));
137-
generateFilter.setRequestMatcher(antMatcher(HttpMethod.POST, this.generateTokenUrl));
137+
generateFilter.setRequestMatcher(antMatcher(HttpMethod.POST, this.tokenGeneratingUrl));
138138
http.addFilter(postProcess(generateFilter));
139139
http.addFilter(DefaultResourcesFilter.css());
140140
}
141141

142-
private GeneratedOneTimeTokenHandler getGeneratedOneTimeTokenHandler(H http) {
143-
if (this.generatedOneTimeTokenHandler == null) {
144-
this.generatedOneTimeTokenHandler = getBeanOrNull(http, GeneratedOneTimeTokenHandler.class);
142+
private OneTimeTokenGenerationSuccessHandler getGeneratedOneTimeTokenHandler(H http) {
143+
if (this.oneTimeTokenGenerationSuccessHandler == null) {
144+
this.oneTimeTokenGenerationSuccessHandler = getBeanOrNull(http, OneTimeTokenGenerationSuccessHandler.class);
145145
}
146-
if (this.generatedOneTimeTokenHandler == null) {
146+
if (this.oneTimeTokenGenerationSuccessHandler == null) {
147147
throw new IllegalStateException("""
148148
A GeneratedOneTimeTokenHandler is required to enable oneTimeTokenLogin().
149149
Please provide it as a bean or pass it to the oneTimeTokenLogin() DSL.
150150
""");
151151
}
152-
return this.generatedOneTimeTokenHandler;
152+
return this.oneTimeTokenGenerationSuccessHandler;
153153
}
154154

155155
private void configureSubmitPage(H http) {
@@ -186,22 +186,22 @@ public OneTimeTokenLoginConfigurer<H> authenticationProvider(AuthenticationProvi
186186
/**
187187
* Specifies the URL that a One-Time Token generate request will be processed.
188188
* Defaults to {@code /ott/generate}.
189-
* @param generateTokenUrl
189+
* @param tokenGeneratingUrl
190190
*/
191-
public OneTimeTokenLoginConfigurer<H> generateTokenUrl(String generateTokenUrl) {
192-
Assert.hasText(generateTokenUrl, "generateTokenUrl cannot be null or empty");
193-
this.generateTokenUrl = generateTokenUrl;
191+
public OneTimeTokenLoginConfigurer<H> tokenGeneratingUrl(String tokenGeneratingUrl) {
192+
Assert.hasText(tokenGeneratingUrl, "tokenGeneratingUrl cannot be null or empty");
193+
this.tokenGeneratingUrl = tokenGeneratingUrl;
194194
return this;
195195
}
196196

197197
/**
198198
* Specifies strategy to be used to handle generated one-time tokens.
199-
* @param generatedOneTimeTokenHandler
199+
* @param oneTimeTokenGenerationSuccessHandler
200200
*/
201-
public OneTimeTokenLoginConfigurer<H> generatedOneTimeTokenHandler(
202-
GeneratedOneTimeTokenHandler generatedOneTimeTokenHandler) {
203-
Assert.notNull(generatedOneTimeTokenHandler, "generatedOneTimeTokenHandler cannot be null");
204-
this.generatedOneTimeTokenHandler = generatedOneTimeTokenHandler;
201+
public OneTimeTokenLoginConfigurer<H> tokenGenerationSuccessHandler(
202+
OneTimeTokenGenerationSuccessHandler oneTimeTokenGenerationSuccessHandler) {
203+
Assert.notNull(oneTimeTokenGenerationSuccessHandler, "generatedOneTimeTokenHandler cannot be null");
204+
this.oneTimeTokenGenerationSuccessHandler = oneTimeTokenGenerationSuccessHandler;
205205
return this;
206206
}
207207

@@ -248,7 +248,7 @@ public OneTimeTokenLoginConfigurer<H> defaultSubmitPageUrl(String submitPageUrl)
248248
* {@link OneTimeToken}
249249
* @param oneTimeTokenService
250250
*/
251-
public OneTimeTokenLoginConfigurer<H> oneTimeTokenService(OneTimeTokenService oneTimeTokenService) {
251+
public OneTimeTokenLoginConfigurer<H> tokenService(OneTimeTokenService oneTimeTokenService) {
252252
Assert.notNull(oneTimeTokenService, "oneTimeTokenService cannot be null");
253253
this.oneTimeTokenService = oneTimeTokenService;
254254
return this;

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

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,8 @@
157157
import org.springframework.security.web.server.authentication.logout.ServerLogoutHandler;
158158
import org.springframework.security.web.server.authentication.logout.ServerLogoutSuccessHandler;
159159
import org.springframework.security.web.server.authentication.ott.GenerateOneTimeTokenWebFilter;
160-
import org.springframework.security.web.server.authentication.ott.ServerGeneratedOneTimeTokenHandler;
161160
import org.springframework.security.web.server.authentication.ott.ServerOneTimeTokenAuthenticationConverter;
161+
import org.springframework.security.web.server.authentication.ott.ServerOneTimeTokenGenerationSuccessHandler;
162162
import org.springframework.security.web.server.authorization.AuthorizationContext;
163163
import org.springframework.security.web.server.authorization.AuthorizationWebFilter;
164164
import org.springframework.security.web.server.authorization.DelegatingReactiveAuthorizationManager;
@@ -5922,7 +5922,7 @@ public final class OneTimeTokenLoginSpec {
59225922

59235923
private ReactiveAuthenticationManager authenticationManager;
59245924

5925-
private ReactiveOneTimeTokenService oneTimeTokenService;
5925+
private ReactiveOneTimeTokenService tokenService;
59265926

59275927
private ServerAuthenticationConverter authenticationConverter = new ServerOneTimeTokenAuthenticationConverter();
59285928

@@ -5936,15 +5936,15 @@ public final class OneTimeTokenLoginSpec {
59365936

59375937
private final List<ServerAuthenticationSuccessHandler> authenticationSuccessHandlers = new ArrayList<>();
59385938

5939-
private ServerGeneratedOneTimeTokenHandler generatedOneTimeTokenHandler;
5939+
private ServerOneTimeTokenGenerationSuccessHandler tokenGenerationSuccessHandler;
59405940

59415941
private ServerSecurityContextRepository securityContextRepository;
59425942

59435943
private String loginProcessingUrl = "/login/ott";
59445944

59455945
private String defaultSubmitPageUrl = "/login/ott";
59465946

5947-
private String generateTokenUrl = "/ott/generate";
5947+
private String tokenGeneratingUrl = "/ott/generate";
59485948

59495949
private boolean submitPageEnabled = true;
59505950

@@ -5981,10 +5981,10 @@ private void configureSubmitPage(ServerHttpSecurity http) {
59815981
}
59825982

59835983
private void configureOttGenerateFilter(ServerHttpSecurity http) {
5984-
GenerateOneTimeTokenWebFilter generateFilter = new GenerateOneTimeTokenWebFilter(getOneTimeTokenService(),
5985-
getGeneratedOneTimeTokenHandler());
5984+
GenerateOneTimeTokenWebFilter generateFilter = new GenerateOneTimeTokenWebFilter(getTokenService(),
5985+
getTokenGenerationSuccessHandler());
59865986
generateFilter
5987-
.setRequestMatcher(ServerWebExchangeMatchers.pathMatchers(HttpMethod.POST, this.generateTokenUrl));
5987+
.setRequestMatcher(ServerWebExchangeMatchers.pathMatchers(HttpMethod.POST, this.tokenGeneratingUrl));
59885988
http.addFilterAt(generateFilter, SecurityWebFiltersOrder.ONE_TIME_TOKEN);
59895989
}
59905990

@@ -5994,7 +5994,7 @@ private void configureDefaultLoginPage(ServerHttpSecurity http) {
59945994
OrderedWebFilter orderedWebFilter = (OrderedWebFilter) webFilter;
59955995
if (orderedWebFilter.webFilter instanceof LoginPageGeneratingWebFilter loginPageGeneratingFilter) {
59965996
loginPageGeneratingFilter.setOneTimeTokenEnabled(true);
5997-
loginPageGeneratingFilter.setGenerateOneTimeTokenUrl(this.generateTokenUrl);
5997+
loginPageGeneratingFilter.setGenerateOneTimeTokenUrl(this.tokenGeneratingUrl);
59985998
break;
59995999
}
60006000
}
@@ -6072,7 +6072,7 @@ public OneTimeTokenLoginSpec authenticationManager(ReactiveAuthenticationManager
60726072
ReactiveAuthenticationManager getAuthenticationManager() {
60736073
if (this.authenticationManager == null) {
60746074
ReactiveUserDetailsService userDetailsService = getBean(ReactiveUserDetailsService.class);
6075-
return new OneTimeTokenReactiveAuthenticationManager(getOneTimeTokenService(), userDetailsService);
6075+
return new OneTimeTokenReactiveAuthenticationManager(getTokenService(), userDetailsService);
60766076
}
60776077
return this.authenticationManager;
60786078
}
@@ -6082,22 +6082,22 @@ ReactiveAuthenticationManager getAuthenticationManager() {
60826082
* {@link OneTimeToken}
60836083
* @param oneTimeTokenService
60846084
*/
6085-
public OneTimeTokenLoginSpec oneTimeTokenService(ReactiveOneTimeTokenService oneTimeTokenService) {
6085+
public OneTimeTokenLoginSpec tokenService(ReactiveOneTimeTokenService oneTimeTokenService) {
60866086
Assert.notNull(oneTimeTokenService, "oneTimeTokenService cannot be null");
6087-
this.oneTimeTokenService = oneTimeTokenService;
6087+
this.tokenService = oneTimeTokenService;
60886088
return this;
60896089
}
60906090

6091-
ReactiveOneTimeTokenService getOneTimeTokenService() {
6092-
if (this.oneTimeTokenService != null) {
6093-
return this.oneTimeTokenService;
6091+
ReactiveOneTimeTokenService getTokenService() {
6092+
if (this.tokenService != null) {
6093+
return this.tokenService;
60946094
}
60956095
ReactiveOneTimeTokenService oneTimeTokenService = getBeanOrNull(ReactiveOneTimeTokenService.class);
60966096
if (oneTimeTokenService != null) {
60976097
return oneTimeTokenService;
60986098
}
6099-
this.oneTimeTokenService = new InMemoryReactiveOneTimeTokenService();
6100-
return this.oneTimeTokenService;
6099+
this.tokenService = new InMemoryReactiveOneTimeTokenService();
6100+
return this.tokenService;
61016101
}
61026102

61036103
/**
@@ -6153,21 +6153,21 @@ public OneTimeTokenLoginSpec defaultSubmitPageUrl(String submitPageUrl) {
61536153
* Specifies strategy to be used to handle generated one-time tokens.
61546154
* @param generatedOneTimeTokenHandler
61556155
*/
6156-
public OneTimeTokenLoginSpec generatedOneTimeTokenHandler(
6157-
ServerGeneratedOneTimeTokenHandler generatedOneTimeTokenHandler) {
6156+
public OneTimeTokenLoginSpec tokenGenerationSuccessHandler(
6157+
ServerOneTimeTokenGenerationSuccessHandler generatedOneTimeTokenHandler) {
61586158
Assert.notNull(generatedOneTimeTokenHandler, "generatedOneTimeTokenHandler cannot be null");
6159-
this.generatedOneTimeTokenHandler = generatedOneTimeTokenHandler;
6159+
this.tokenGenerationSuccessHandler = generatedOneTimeTokenHandler;
61606160
return this;
61616161
}
61626162

61636163
/**
61646164
* Specifies the URL that a One-Time Token generate request will be processed.
61656165
* Defaults to {@code /ott/generate}.
6166-
* @param generateTokenUrl
6166+
* @param tokenGeneratingUrl
61676167
*/
6168-
public OneTimeTokenLoginSpec generateTokenUrl(String generateTokenUrl) {
6169-
Assert.hasText(generateTokenUrl, "generateTokenUrl cannot be null or empty");
6170-
this.generateTokenUrl = generateTokenUrl;
6168+
public OneTimeTokenLoginSpec tokenGeneratingUrl(String tokenGeneratingUrl) {
6169+
Assert.hasText(tokenGeneratingUrl, "tokenGeneratingUrl cannot be null or empty");
6170+
this.tokenGeneratingUrl = tokenGeneratingUrl;
61716171
return this;
61726172
}
61736173

@@ -6187,17 +6187,17 @@ public OneTimeTokenLoginSpec securityContextRepository(
61876187
return this;
61886188
}
61896189

6190-
private ServerGeneratedOneTimeTokenHandler getGeneratedOneTimeTokenHandler() {
6191-
if (this.generatedOneTimeTokenHandler == null) {
6192-
this.generatedOneTimeTokenHandler = getBeanOrNull(ServerGeneratedOneTimeTokenHandler.class);
6190+
private ServerOneTimeTokenGenerationSuccessHandler getTokenGenerationSuccessHandler() {
6191+
if (this.tokenGenerationSuccessHandler == null) {
6192+
this.tokenGenerationSuccessHandler = getBeanOrNull(ServerOneTimeTokenGenerationSuccessHandler.class);
61936193
}
6194-
if (this.generatedOneTimeTokenHandler == null) {
6194+
if (this.tokenGenerationSuccessHandler == null) {
61956195
throw new IllegalStateException("""
61966196
A ServerGeneratedOneTimeTokenHandler is required to enable oneTimeTokenLogin().
61976197
Please provide it as a bean or pass it to the oneTimeTokenLogin() DSL.
61986198
""");
61996199
}
6200-
return this.generatedOneTimeTokenHandler;
6200+
return this.tokenGenerationSuccessHandler;
62016201
}
62026202

62036203
}

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

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,40 +23,40 @@ import org.springframework.security.config.annotation.web.configurers.ott.OneTim
2323
import org.springframework.security.web.authentication.AuthenticationConverter
2424
import org.springframework.security.web.authentication.AuthenticationFailureHandler
2525
import org.springframework.security.web.authentication.AuthenticationSuccessHandler
26-
import org.springframework.security.web.authentication.ott.GeneratedOneTimeTokenHandler
26+
import org.springframework.security.web.authentication.ott.OneTimeTokenGenerationSuccessHandler
2727

2828
/**
2929
* A Kotlin DSL to configure [HttpSecurity] OAuth 2.0 login using idiomatic Kotlin code.
3030
*
3131
* @author Max Batischev
3232
* @since 6.4
33-
* @property oneTimeTokenService configures the [OneTimeTokenService] used to generate and consume
33+
* @property tokenService configures the [OneTimeTokenService] used to generate and consume
3434
* @property authenticationConverter Use this [AuthenticationConverter] when converting incoming requests to an authentication
3535
* @property authenticationFailureHandler the [AuthenticationFailureHandler] to use when authentication
3636
* @property authenticationSuccessHandler the [AuthenticationSuccessHandler] to be used
3737
* @property defaultSubmitPageUrl sets the URL that the default submit page will be generated
3838
* @property showDefaultSubmitPage configures whether the default one-time token submit page should be shown
3939
* @property loginProcessingUrl the URL to process the login request
40-
* @property generateTokenUrl the URL that a One-Time Token generate request will be processed
41-
* @property generatedOneTimeTokenHandler the strategy to be used to handle generated one-time tokens
40+
* @property tokenGeneratingUrl the URL that a One-Time Token generate request will be processed
41+
* @property oneTimeTokenGenerationSuccessHandler the strategy to be used to handle generated one-time tokens
4242
* @property authenticationProvider the [AuthenticationProvider] to use when authenticating the user
4343
*/
4444
@SecurityMarker
4545
class OneTimeTokenLoginDsl {
46-
var oneTimeTokenService: OneTimeTokenService? = null
46+
var tokenService: OneTimeTokenService? = null
4747
var authenticationConverter: AuthenticationConverter? = null
4848
var authenticationFailureHandler: AuthenticationFailureHandler? = null
4949
var authenticationSuccessHandler: AuthenticationSuccessHandler? = null
5050
var defaultSubmitPageUrl: String? = null
5151
var loginProcessingUrl: String? = null
52-
var generateTokenUrl: String? = null
52+
var tokenGeneratingUrl: String? = null
5353
var showDefaultSubmitPage: Boolean? = true
54-
var generatedOneTimeTokenHandler: GeneratedOneTimeTokenHandler? = null
54+
var oneTimeTokenGenerationSuccessHandler: OneTimeTokenGenerationSuccessHandler? = null
5555
var authenticationProvider: AuthenticationProvider? = null
5656

5757
internal fun get(): (OneTimeTokenLoginConfigurer<HttpSecurity>) -> Unit {
5858
return { oneTimeTokenLoginConfigurer ->
59-
oneTimeTokenService?.also { oneTimeTokenLoginConfigurer.oneTimeTokenService(oneTimeTokenService) }
59+
tokenService?.also { oneTimeTokenLoginConfigurer.tokenService(tokenService) }
6060
authenticationConverter?.also { oneTimeTokenLoginConfigurer.authenticationConverter(authenticationConverter) }
6161
authenticationFailureHandler?.also {
6262
oneTimeTokenLoginConfigurer.authenticationFailureHandler(
@@ -71,10 +71,10 @@ class OneTimeTokenLoginDsl {
7171
defaultSubmitPageUrl?.also { oneTimeTokenLoginConfigurer.defaultSubmitPageUrl(defaultSubmitPageUrl) }
7272
showDefaultSubmitPage?.also { oneTimeTokenLoginConfigurer.showDefaultSubmitPage(showDefaultSubmitPage!!) }
7373
loginProcessingUrl?.also { oneTimeTokenLoginConfigurer.loginProcessingUrl(loginProcessingUrl) }
74-
generateTokenUrl?.also { oneTimeTokenLoginConfigurer.generateTokenUrl(generateTokenUrl) }
75-
generatedOneTimeTokenHandler?.also {
76-
oneTimeTokenLoginConfigurer.generatedOneTimeTokenHandler(
77-
generatedOneTimeTokenHandler
74+
tokenGeneratingUrl?.also { oneTimeTokenLoginConfigurer.tokenGeneratingUrl(tokenGeneratingUrl) }
75+
oneTimeTokenGenerationSuccessHandler?.also {
76+
oneTimeTokenLoginConfigurer.tokenGenerationSuccessHandler(
77+
oneTimeTokenGenerationSuccessHandler
7878
)
7979
}
8080
authenticationProvider?.also { oneTimeTokenLoginConfigurer.authenticationProvider(authenticationProvider) }

0 commit comments

Comments
 (0)