@@ -18,7 +18,6 @@ package org.springframework.security.config.annotation.web
18
18
19
19
import jakarta.servlet.Filter
20
20
import jakarta.servlet.http.HttpServletRequest
21
- import org.checkerframework.checker.units.qual.C
22
21
import org.springframework.context.ApplicationContext
23
22
import org.springframework.security.authentication.AuthenticationManager
24
23
import org.springframework.security.config.annotation.SecurityConfigurerAdapter
@@ -60,7 +59,7 @@ import org.springframework.security.web.util.matcher.RequestMatcher
60
59
* @param httpConfiguration the configurations to apply to [HttpSecurity]
61
60
*/
62
61
operator fun HttpSecurity.invoke (httpConfiguration : HttpSecurityDsl .() -> Unit ) =
63
- HttpSecurityDsl (this , httpConfiguration).build()
62
+ HttpSecurityDsl (this , httpConfiguration).build()
64
63
65
64
/* *
66
65
* An [HttpSecurity] Kotlin DSL created by [`http { }`][invoke]
@@ -104,7 +103,10 @@ class HttpSecurityDsl(private val http: HttpSecurity, private val init: HttpSecu
104
103
* @param configurer
105
104
* the [SecurityConfigurerAdapter] for further customizations
106
105
*/
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 {
108
110
return this .http.apply (configurer).apply (configuration)
109
111
}
110
112
@@ -134,7 +136,10 @@ class HttpSecurityDsl(private val http: HttpSecurity, private val init: HttpSecu
134
136
* the [HttpSecurity] for further customizations
135
137
* @since 6.2
136
138
*/
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 ? {
138
143
return this .http.with (configurer, configuration)
139
144
}
140
145
@@ -299,7 +304,8 @@ class HttpSecurityDsl(private val http: HttpSecurity, private val init: HttpSecu
299
304
* @since 5.7
300
305
*/
301
306
fun authorizeHttpRequests (authorizeHttpRequestsConfiguration : AuthorizeHttpRequestsDsl .() -> Unit ) {
302
- val authorizeHttpRequestsCustomizer = AuthorizeHttpRequestsDsl (this .context).apply (authorizeHttpRequestsConfiguration).get()
307
+ val authorizeHttpRequestsCustomizer =
308
+ AuthorizeHttpRequestsDsl (this .context).apply (authorizeHttpRequestsConfiguration).get()
303
309
this .http.authorizeHttpRequests(authorizeHttpRequestsCustomizer)
304
310
}
305
311
@@ -772,42 +778,42 @@ class HttpSecurityDsl(private val http: HttpSecurity, private val init: HttpSecu
772
778
this .http.saml2Logout(saml2LogoutCustomizer)
773
779
}
774
780
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
+ }
811
817
812
818
/* *
813
819
* Allows configuring how an anonymous user is represented.
@@ -965,6 +971,36 @@ class HttpSecurityDsl(private val http: HttpSecurity, private val init: HttpSecu
965
971
this .http.oidcLogout(oidcLogoutCustomizer)
966
972
}
967
973
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
+
968
1004
/* *
969
1005
* Configures Remember Me authentication.
970
1006
*
@@ -1050,7 +1086,7 @@ class HttpSecurityDsl(private val http: HttpSecurity, private val init: HttpSecu
1050
1086
* (i.e. known) with Spring Security.
1051
1087
*/
1052
1088
@Suppress(" DEPRECATION" )
1053
- inline fun <reified T : Filter > addFilterAt (filter : Filter ) {
1089
+ inline fun <reified T : Filter > addFilterAt (filter : Filter ) {
1054
1090
this .addFilterAt(filter, T ::class .java)
1055
1091
}
1056
1092
@@ -1109,7 +1145,7 @@ class HttpSecurityDsl(private val http: HttpSecurity, private val init: HttpSecu
1109
1145
* (i.e. known) with Spring Security.
1110
1146
*/
1111
1147
@Suppress(" DEPRECATION" )
1112
- inline fun <reified T : Filter > addFilterAfter (filter : Filter ) {
1148
+ inline fun <reified T : Filter > addFilterAfter (filter : Filter ) {
1113
1149
this .addFilterAfter(filter, T ::class .java)
1114
1150
}
1115
1151
@@ -1168,7 +1204,7 @@ class HttpSecurityDsl(private val http: HttpSecurity, private val init: HttpSecu
1168
1204
* (i.e. known) with Spring Security.
1169
1205
*/
1170
1206
@Suppress(" DEPRECATION" )
1171
- inline fun <reified T : Filter > addFilterBefore (filter : Filter ) {
1207
+ inline fun <reified T : Filter > addFilterBefore (filter : Filter ) {
1172
1208
this .addFilterBefore(filter, T ::class .java)
1173
1209
}
1174
1210
0 commit comments