HttpSecurityDsl

class HttpSecurityDsl(http: HttpSecurity, init: HttpSecurityDsl.() -> Unit)

An HttpSecurity Kotlin DSL created by http { } in order to configure HttpSecurity using idiomatic Kotlin code.

Author

Eleftheria Stein

Since

5.3

Parameters

http

the HttpSecurity which all configurations will be applied to

init

the configurations to apply to the provided HttpSecurity

Constructors

Link copied to clipboard
constructor(http: HttpSecurity, init: HttpSecurityDsl.() -> Unit)

Properties

Link copied to clipboard
var authenticationManager: AuthenticationManager?

the default AuthenticationManager to use

Link copied to clipboard
val context: ApplicationContext

Functions

Link copied to clipboard
inline fun <T : Filter> addFilterAfter(filter: Filter)

Adds the Filter after the location of the specified Filter class. Variant that is leveraging Kotlin reified type parameters.

fun addFilterAfter(filter: Filter, afterFilter: Class<out Filter>)

Adds the Filter after the location of the specified Filter class.

Link copied to clipboard
inline fun <T : Filter> addFilterAt(filter: Filter)

Adds the Filter at the location of the specified Filter class. Variant that is leveraging Kotlin reified type parameters.

fun addFilterAt(filter: Filter, atFilter: Class<out Filter>)

Adds the Filter at the location of the specified Filter class.

Link copied to clipboard
inline fun <T : Filter> addFilterBefore(filter: Filter)

Adds the Filter before the location of the specified Filter class. Variant that is leveraging Kotlin reified type parameters.

fun addFilterBefore(filter: Filter, beforeFilter: Class<out Filter>)

Adds the Filter before the location of the specified Filter class.

Link copied to clipboard
fun anonymous(anonymousConfiguration: AnonymousDsl.() -> Unit)

Allows configuring how an anonymous user is represented.

Link copied to clipboard
fun <C : SecurityConfigurerAdapter<DefaultSecurityFilterChain, HttpSecurity>> apply(configurer: C, configuration: C.() -> Unit = { }): C

Applies a SecurityConfigurerAdapter to this HttpSecurity

Link copied to clipboard
fun authorizeHttpRequests(authorizeHttpRequestsConfiguration: AuthorizeHttpRequestsDsl.() -> Unit)

Allows restricting access based upon the HttpServletRequest

Link copied to clipboard
fun cors(corsConfiguration: CorsDsl.() -> Unit)

Enables CORS.

Link copied to clipboard
fun csrf(csrfConfiguration: CsrfDsl.() -> Unit)

Enables CSRF protection.

Link copied to clipboard
fun exceptionHandling(exceptionHandlingConfiguration: ExceptionHandlingDsl.() -> Unit)

Allows configuring exception handling.

Link copied to clipboard
fun formLogin(formLoginConfiguration: FormLoginDsl.() -> Unit)

Enables form based authentication.

Link copied to clipboard
fun headers(headersConfiguration: HeadersDsl.() -> Unit)

Allows configuring response headers.

Link copied to clipboard
fun httpBasic(httpBasicConfiguration: HttpBasicDsl.() -> Unit)

Enables HTTP basic authentication.

Link copied to clipboard
fun logout(logoutConfiguration: LogoutDsl.() -> Unit)

Provides logout support.

Link copied to clipboard
fun oauth2Client(oauth2ClientConfiguration: OAuth2ClientDsl.() -> Unit)

Configures OAuth 2.0 client support.

Link copied to clipboard
fun oauth2Login(oauth2LoginConfiguration: OAuth2LoginDsl.() -> Unit)

Configures authentication support using an OAuth 2.0 and/or OpenID Connect 1.0 Provider. A ClientRegistrationRepository is required and must be registered as a Bean or configured via OAuth2LoginDsl.clientRegistrationRepository

Link copied to clipboard
fun oauth2ResourceServer(oauth2ResourceServerConfiguration: OAuth2ResourceServerDsl.() -> Unit)

Configures OAuth 2.0 resource server support.

Link copied to clipboard
fun oidcLogout(oidcLogoutConfiguration: OidcLogoutDsl.() -> Unit)

Configures OIDC 1.0 logout support.

Link copied to clipboard
fun oneTimeTokenLogin(oneTimeTokenLoginConfiguration: OneTimeTokenLoginDsl.() -> Unit)

Configures One-Time Token Login Support.

Link copied to clipboard
fun passwordManagement(passwordManagementConfiguration: PasswordManagementDsl.() -> Unit)

Enables password management.

Link copied to clipboard
fun portMapper(portMapperConfiguration: PortMapperDsl.() -> Unit)

Allows configuring a port mapper.

Link copied to clipboard
fun redirectToHttps(httpsRedirectConfiguration: HttpsRedirectDsl.() -> Unit)

Configures channel security. In order for this configuration to be useful at least one mapping to a required channel must be provided.

Link copied to clipboard
fun rememberMe(rememberMeConfiguration: RememberMeDsl.() -> Unit)

Configures Remember Me authentication.

Link copied to clipboard
fun requestCache(requestCacheConfiguration: RequestCacheDsl.() -> Unit)

Enables request caching. Specifically this ensures that requests that are saved (i.e. after authentication is required) are later replayed.

Link copied to clipboard
fun requiresChannel(requiresChannelConfiguration: RequiresChannelDsl.() -> Unit)

Allows configuring channel security based upon the HttpServletRequest

Link copied to clipboard
fun saml2Login(saml2LoginConfiguration: Saml2Dsl.() -> Unit)

Configures authentication support using a SAML 2.0 Service Provider. A RelyingPartyRegistrationRepository is required and must be registered with the ApplicationContext or configured via Saml2Dsl.relyingPartyRegistrationRepository

Link copied to clipboard
fun saml2Logout(saml2LogoutConfiguration: Saml2LogoutDsl.() -> Unit)

Configures logout support for a SAML 2.0 Service Provider.

Link copied to clipboard
fun saml2Metadata(saml2MetadataConfiguration: Saml2MetadataDsl.() -> Unit)

Configures a SAML 2.0 relying party metadata endpoint.

Link copied to clipboard
fun securityContext(securityContextConfiguration: SecurityContextDsl.() -> Unit)

Enables security context configuration.

Link copied to clipboard
fun securityMatcher(vararg pattern: String)

Allows configuring the HttpSecurity to only be invoked when matching the provided pattern. If Spring MVC is on the classpath, it will use an MVC matcher. If Spring MVC is not an the classpath, it will use an ant matcher.

fun securityMatcher(vararg requestMatcher: RequestMatcher)

Allows configuring the HttpSecurity to only be invoked when matching the provided RequestMatcher.

Link copied to clipboard
fun sessionManagement(sessionManagementConfiguration: SessionManagementDsl.() -> Unit)

Allows configuring session management.

Link copied to clipboard
fun webAuthn(webAuthnConfiguration: WebAuthnDsl.() -> Unit)

Enable WebAuthn configuration.

Link copied to clipboard
fun <C : SecurityConfigurerAdapter<DefaultSecurityFilterChain, HttpSecurity>> with(configurer: C, configuration: C.() -> Unit = { }): HttpSecurity?

Applies a SecurityConfigurerAdapter to this HttpSecurity

Link copied to clipboard
fun x509(x509Configuration: X509Dsl.() -> Unit)

Adds X509 based pre authentication to an application