Skip to content

Commit b558c32

Browse files
committed
Update to Latest One-Time Token API Names
Issue gh-15887
1 parent 57f07b4 commit b558c32

File tree

2 files changed

+20
-21
lines changed

2 files changed

+20
-21
lines changed

config/src/main/kotlin/org/springframework/security/config/web/server/ServerOneTimeTokenLoginDsl.kt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import org.springframework.security.authentication.ott.reactive.ReactiveOneTimeT
2121
import org.springframework.security.web.server.authentication.ServerAuthenticationConverter
2222
import org.springframework.security.web.server.authentication.ServerAuthenticationFailureHandler
2323
import org.springframework.security.web.server.authentication.ServerAuthenticationSuccessHandler
24-
import org.springframework.security.web.server.authentication.ott.ServerGeneratedOneTimeTokenHandler
24+
import org.springframework.security.web.server.authentication.ott.ServerOneTimeTokenGenerationSuccessHandler
2525
import org.springframework.security.web.server.context.ServerSecurityContextRepository
2626

2727

@@ -39,7 +39,7 @@ import org.springframework.security.web.server.context.ServerSecurityContextRepo
3939
* @property showDefaultSubmitPage configures whether the default one-time token submit page should be shown
4040
* @property loginProcessingUrl the URL to process the login request
4141
* @property generateTokenUrl the URL that a One-Time Token generate request will be processed
42-
* @property generatedOneTimeTokenHandler the strategy to be used to handle generated one-time tokens
42+
* @property tokenGenerationSuccessHandler the strategy to be used to handle generated one-time tokens
4343
* @property securityContextRepository the [ServerSecurityContextRepository] used to save the [Authentication]. For the [SecurityContext] to be loaded on subsequent requests the [ReactorContextWebFilter] must be configured to be able to load the value (they are not implicitly linked).
4444
*/
4545
@ServerSecurityMarker
@@ -49,7 +49,7 @@ class ServerOneTimeTokenLoginDsl {
4949
var authenticationConverter: ServerAuthenticationConverter? = null
5050
var authenticationFailureHandler: ServerAuthenticationFailureHandler? = null
5151
var authenticationSuccessHandler: ServerAuthenticationSuccessHandler? = null
52-
var generatedOneTimeTokenHandler: ServerGeneratedOneTimeTokenHandler? = null
52+
var tokenGenerationSuccessHandler: ServerOneTimeTokenGenerationSuccessHandler? = null
5353
var securityContextRepository: ServerSecurityContextRepository? = null
5454
var defaultSubmitPageUrl: String? = null
5555
var loginProcessingUrl: String? = null
@@ -59,7 +59,7 @@ class ServerOneTimeTokenLoginDsl {
5959
internal fun get(): (ServerHttpSecurity.OneTimeTokenLoginSpec) -> Unit {
6060
return { oneTimeTokenLogin ->
6161
authenticationManager?.also { oneTimeTokenLogin.authenticationManager(authenticationManager) }
62-
oneTimeTokenService?.also { oneTimeTokenLogin.oneTimeTokenService(oneTimeTokenService) }
62+
oneTimeTokenService?.also { oneTimeTokenLogin.tokenService(oneTimeTokenService) }
6363
authenticationConverter?.also { oneTimeTokenLogin.authenticationConverter(authenticationConverter) }
6464
authenticationFailureHandler?.also {
6565
oneTimeTokenLogin.authenticationFailureHandler(
@@ -75,10 +75,10 @@ class ServerOneTimeTokenLoginDsl {
7575
defaultSubmitPageUrl?.also { oneTimeTokenLogin.defaultSubmitPageUrl(defaultSubmitPageUrl) }
7676
showDefaultSubmitPage?.also { oneTimeTokenLogin.showDefaultSubmitPage(showDefaultSubmitPage!!) }
7777
loginProcessingUrl?.also { oneTimeTokenLogin.loginProcessingUrl(loginProcessingUrl) }
78-
generateTokenUrl?.also { oneTimeTokenLogin.generateTokenUrl(generateTokenUrl) }
79-
generatedOneTimeTokenHandler?.also {
80-
oneTimeTokenLogin.generatedOneTimeTokenHandler(
81-
generatedOneTimeTokenHandler
78+
generateTokenUrl?.also { oneTimeTokenLogin.tokenGeneratingUrl(generateTokenUrl) }
79+
tokenGenerationSuccessHandler?.also {
80+
oneTimeTokenLogin.tokenGenerationSuccessHandler(
81+
tokenGenerationSuccessHandler
8282
)
8383
}
8484
}

config/src/test/kotlin/org/springframework/security/config/web/server/ServerOneTimeTokenLoginDslTests.kt

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,11 @@ package org.springframework.security.config.web.server
1818

1919
import org.junit.jupiter.api.Test
2020
import org.junit.jupiter.api.extension.ExtendWith
21-
import reactor.core.publisher.Mono
22-
2321
import org.springframework.beans.factory.annotation.Autowired
22+
import org.springframework.context.ApplicationContext
2423
import org.springframework.context.annotation.Bean
2524
import org.springframework.context.annotation.Configuration
2625
import org.springframework.context.annotation.Import
27-
import org.springframework.context.ApplicationContext
2826
import org.springframework.http.MediaType
2927
import org.springframework.security.authentication.ott.OneTimeToken
3028
import org.springframework.security.config.annotation.web.reactive.EnableWebFluxSecurity
@@ -36,13 +34,14 @@ import org.springframework.security.core.userdetails.User
3634
import org.springframework.security.test.web.reactive.server.SecurityMockServerConfigurers
3735
import org.springframework.security.web.server.SecurityWebFilterChain
3836
import org.springframework.security.web.server.authentication.RedirectServerAuthenticationSuccessHandler
39-
import org.springframework.security.web.server.authentication.ott.ServerGeneratedOneTimeTokenHandler
40-
import org.springframework.security.web.server.authentication.ott.ServerRedirectGeneratedOneTimeTokenHandler
37+
import org.springframework.security.web.server.authentication.ott.ServerOneTimeTokenGenerationSuccessHandler
38+
import org.springframework.security.web.server.authentication.ott.ServerRedirectOneTimeTokenGenerationSuccessHandler
4139
import org.springframework.test.web.reactive.server.WebTestClient
4240
import org.springframework.web.reactive.config.EnableWebFlux
4341
import org.springframework.web.reactive.function.BodyInserters
4442
import org.springframework.web.server.ServerWebExchange
4543
import org.springframework.web.util.UriBuilder
44+
import reactor.core.publisher.Mono
4645

4746
/**
4847
* Tests for [ServerOneTimeTokenLoginDsl]
@@ -95,7 +94,7 @@ class ServerOneTimeTokenLoginDslTests {
9594
.is3xxRedirection()
9695
.expectHeader().valueEquals("Location", "/login/ott")
9796

98-
val token = TestServerGeneratedOneTimeTokenHandler.lastToken?.tokenValue
97+
val token = TestServerOneTimeTokenGenerationSuccessHandler.lastToken?.tokenValue
9998

10099
client.mutateWith(SecurityMockServerConfigurers.csrf())
101100
.post()
@@ -129,7 +128,7 @@ class ServerOneTimeTokenLoginDslTests {
129128
.is3xxRedirection()
130129
.expectHeader().valueEquals("Location", "/redirected")
131130

132-
val token = TestServerGeneratedOneTimeTokenHandler.lastToken?.tokenValue
131+
val token = TestServerOneTimeTokenGenerationSuccessHandler.lastToken?.tokenValue
133132

134133
client.mutateWith(SecurityMockServerConfigurers.csrf())
135134
.post()
@@ -160,7 +159,7 @@ class ServerOneTimeTokenLoginDslTests {
160159
authorize(anyExchange, authenticated)
161160
}
162161
oneTimeTokenLogin {
163-
generatedOneTimeTokenHandler = TestServerGeneratedOneTimeTokenHandler()
162+
tokenGenerationSuccessHandler = TestServerOneTimeTokenGenerationSuccessHandler()
164163
}
165164
}
166165
// @formatter:on
@@ -182,7 +181,7 @@ class ServerOneTimeTokenLoginDslTests {
182181
}
183182
oneTimeTokenLogin {
184183
generateTokenUrl = "/generateurl"
185-
generatedOneTimeTokenHandler = TestServerGeneratedOneTimeTokenHandler("/redirected")
184+
tokenGenerationSuccessHandler = TestServerOneTimeTokenGenerationSuccessHandler("/redirected")
186185
loginProcessingUrl = "/loginprocessingurl"
187186
authenticationSuccessHandler = RedirectServerAuthenticationSuccessHandler("/authenticated")
188187
}
@@ -199,19 +198,19 @@ class ServerOneTimeTokenLoginDslTests {
199198
MapReactiveUserDetailsService(User("user", "password", listOf()))
200199
}
201200

202-
private class TestServerGeneratedOneTimeTokenHandler: ServerGeneratedOneTimeTokenHandler {
203-
private var delegate: ServerRedirectGeneratedOneTimeTokenHandler? = null
201+
private class TestServerOneTimeTokenGenerationSuccessHandler: ServerOneTimeTokenGenerationSuccessHandler {
202+
private var delegate: ServerRedirectOneTimeTokenGenerationSuccessHandler? = null
204203

205204
companion object {
206205
var lastToken: OneTimeToken? = null
207206
}
208207

209208
constructor() {
210-
this.delegate = ServerRedirectGeneratedOneTimeTokenHandler("/login/ott")
209+
this.delegate = ServerRedirectOneTimeTokenGenerationSuccessHandler("/login/ott")
211210
}
212211

213212
constructor(redirectUrl: String?) {
214-
this.delegate = ServerRedirectGeneratedOneTimeTokenHandler(redirectUrl)
213+
this.delegate = ServerRedirectOneTimeTokenGenerationSuccessHandler(redirectUrl)
215214
}
216215

217216
override fun handle(exchange: ServerWebExchange?, oneTimeToken: OneTimeToken?): Mono<Void> {

0 commit comments

Comments
 (0)