@@ -18,7 +18,6 @@ package org.springframework.security.config.annotation.web
1818
1919import jakarta.servlet.Filter
2020import jakarta.servlet.http.HttpServletRequest
21- import org.checkerframework.checker.units.qual.C
2221import org.springframework.context.ApplicationContext
2322import org.springframework.security.authentication.AuthenticationManager
2423import org.springframework.security.config.annotation.SecurityConfigurerAdapter
@@ -60,7 +59,7 @@ import org.springframework.security.web.util.matcher.RequestMatcher
6059 * @param httpConfiguration the configurations to apply to [HttpSecurity]
6160 */
6261operator fun HttpSecurity.invoke (httpConfiguration : HttpSecurityDsl .() -> Unit ) =
63- HttpSecurityDsl (this , httpConfiguration).build()
62+ HttpSecurityDsl (this , httpConfiguration).build()
6463
6564/* *
6665 * An [HttpSecurity] Kotlin DSL created by [`http { }`][invoke]
@@ -104,7 +103,10 @@ class HttpSecurityDsl(private val http: HttpSecurity, private val init: HttpSecu
104103 * @param configurer
105104 * the [SecurityConfigurerAdapter] for further customizations
106105 */
107- fun <C : SecurityConfigurerAdapter <DefaultSecurityFilterChain , HttpSecurity >> apply (configurer : C , configuration : C .() -> Unit = { }): C {
106+ fun <C : SecurityConfigurerAdapter <DefaultSecurityFilterChain , HttpSecurity >> apply (
107+ configurer : C ,
108+ configuration : C .() -> Unit = { }
109+ ): C {
108110 return this .http.apply (configurer).apply (configuration)
109111 }
110112
@@ -134,7 +136,10 @@ class HttpSecurityDsl(private val http: HttpSecurity, private val init: HttpSecu
134136 * the [HttpSecurity] for further customizations
135137 * @since 6.2
136138 */
137- fun <C : SecurityConfigurerAdapter <DefaultSecurityFilterChain , HttpSecurity >> with (configurer : C , configuration : C .() -> Unit = { }): HttpSecurity ? {
139+ fun <C : SecurityConfigurerAdapter <DefaultSecurityFilterChain , HttpSecurity >> with (
140+ configurer : C ,
141+ configuration : C .() -> Unit = { }
142+ ): HttpSecurity ? {
138143 return this .http.with (configurer, configuration)
139144 }
140145
@@ -299,7 +304,8 @@ class HttpSecurityDsl(private val http: HttpSecurity, private val init: HttpSecu
299304 * @since 5.7
300305 */
301306 fun authorizeHttpRequests (authorizeHttpRequestsConfiguration : AuthorizeHttpRequestsDsl .() -> Unit ) {
302- val authorizeHttpRequestsCustomizer = AuthorizeHttpRequestsDsl (this .context).apply (authorizeHttpRequestsConfiguration).get()
307+ val authorizeHttpRequestsCustomizer =
308+ AuthorizeHttpRequestsDsl (this .context).apply (authorizeHttpRequestsConfiguration).get()
303309 this .http.authorizeHttpRequests(authorizeHttpRequestsCustomizer)
304310 }
305311
@@ -772,42 +778,42 @@ class HttpSecurityDsl(private val http: HttpSecurity, private val init: HttpSecu
772778 this .http.saml2Logout(saml2LogoutCustomizer)
773779 }
774780
775- /* *
776- * Configures a SAML 2.0 relying party metadata endpoint.
777- *
778- * A [RelyingPartyRegistrationRepository] is required and must be registered with
779- * the [ApplicationContext] or configured via
780- * [Saml2Dsl.relyingPartyRegistrationRepository]
781- *
782- * Example:
783- *
784- * The following example shows the minimal configuration required, using a
785- * hypothetical asserting party.
786- *
787- * ```
788- * @Configuration
789- * @EnableWebSecurity
790- * class SecurityConfig {
791- *
792- * @Bean
793- * fun securityFilterChain(http: HttpSecurity): SecurityFilterChain {
794- * http {
795- * saml2Login { }
796- * saml2Metadata { }
797- * }
798- * return http.build()
799- * }
800- * }
801- * ```
802- * @param saml2MetadataConfiguration custom configuration to configure the
803- * SAML2 relying party metadata endpoint
804- * @see [Saml2MetadataDsl]
805- * @since 6.1
806- */
807- fun saml2Metadata (saml2MetadataConfiguration : Saml2MetadataDsl .() -> Unit ) {
808- val saml2MetadataCustomizer = Saml2MetadataDsl ().apply (saml2MetadataConfiguration).get()
809- this .http.saml2Metadata(saml2MetadataCustomizer)
810- }
781+ /* *
782+ * Configures a SAML 2.0 relying party metadata endpoint.
783+ *
784+ * A [RelyingPartyRegistrationRepository] is required and must be registered with
785+ * the [ApplicationContext] or configured via
786+ * [Saml2Dsl.relyingPartyRegistrationRepository]
787+ *
788+ * Example:
789+ *
790+ * The following example shows the minimal configuration required, using a
791+ * hypothetical asserting party.
792+ *
793+ * ```
794+ * @Configuration
795+ * @EnableWebSecurity
796+ * class SecurityConfig {
797+ *
798+ * @Bean
799+ * fun securityFilterChain(http: HttpSecurity): SecurityFilterChain {
800+ * http {
801+ * saml2Login { }
802+ * saml2Metadata { }
803+ * }
804+ * return http.build()
805+ * }
806+ * }
807+ * ```
808+ * @param saml2MetadataConfiguration custom configuration to configure the
809+ * SAML2 relying party metadata endpoint
810+ * @see [Saml2MetadataDsl]
811+ * @since 6.1
812+ */
813+ fun saml2Metadata (saml2MetadataConfiguration : Saml2MetadataDsl .() -> Unit ) {
814+ val saml2MetadataCustomizer = Saml2MetadataDsl ().apply (saml2MetadataConfiguration).get()
815+ this .http.saml2Metadata(saml2MetadataCustomizer)
816+ }
811817
812818 /* *
813819 * Allows configuring how an anonymous user is represented.
@@ -965,6 +971,36 @@ class HttpSecurityDsl(private val http: HttpSecurity, private val init: HttpSecu
965971 this .http.oidcLogout(oidcLogoutCustomizer)
966972 }
967973
974+ /* *
975+ * Configures One-Time Token Login Support.
976+ *
977+ * Example:
978+ *
979+ * ```
980+ * @Configuration
981+ * @EnableWebSecurity
982+ * class SecurityConfig {
983+ *
984+ * @Bean
985+ * fun securityFilterChain(http: HttpSecurity): SecurityFilterChain {
986+ * http {
987+ * oneTimeTokenLogin {
988+ * generatedOneTimeTokenHandler = MyMagicLinkGeneratedOneTimeTokenHandler()
989+ * }
990+ * }
991+ * return http.build()
992+ * }
993+ * }
994+ *
995+ * ```
996+ * @since 6.4
997+ * @param oneTimeTokenLoginConfiguration custom configuration to configure one-time token login
998+ */
999+ fun oneTimeTokenLogin (oneTimeTokenLoginConfiguration : OneTimeTokenLoginDsl .() -> Unit ) {
1000+ val oneTimeTokenLoginCustomizer = OneTimeTokenLoginDsl ().apply (oneTimeTokenLoginConfiguration).get()
1001+ this .http.oneTimeTokenLogin(oneTimeTokenLoginCustomizer)
1002+ }
1003+
9681004 /* *
9691005 * Configures Remember Me authentication.
9701006 *
@@ -1050,7 +1086,7 @@ class HttpSecurityDsl(private val http: HttpSecurity, private val init: HttpSecu
10501086 * (i.e. known) with Spring Security.
10511087 */
10521088 @Suppress(" DEPRECATION" )
1053- inline fun <reified T : Filter > addFilterAt (filter : Filter ) {
1089+ inline fun <reified T : Filter > addFilterAt (filter : Filter ) {
10541090 this .addFilterAt(filter, T ::class .java)
10551091 }
10561092
@@ -1109,7 +1145,7 @@ class HttpSecurityDsl(private val http: HttpSecurity, private val init: HttpSecu
11091145 * (i.e. known) with Spring Security.
11101146 */
11111147 @Suppress(" DEPRECATION" )
1112- inline fun <reified T : Filter > addFilterAfter (filter : Filter ) {
1148+ inline fun <reified T : Filter > addFilterAfter (filter : Filter ) {
11131149 this .addFilterAfter(filter, T ::class .java)
11141150 }
11151151
@@ -1168,7 +1204,7 @@ class HttpSecurityDsl(private val http: HttpSecurity, private val init: HttpSecu
11681204 * (i.e. known) with Spring Security.
11691205 */
11701206 @Suppress(" DEPRECATION" )
1171- inline fun <reified T : Filter > addFilterBefore (filter : Filter ) {
1207+ inline fun <reified T : Filter > addFilterBefore (filter : Filter ) {
11721208 this .addFilterBefore(filter, T ::class .java)
11731209 }
11741210
0 commit comments