AndreasVolkmann / spring-security-kotlin-dsl

Spring Security Kotlin DSL

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Spring Security Kotlin DSL

Note: The native Kotlin DSL for servlet based applications has been integrated into Spring Security as of version 5.3.0.M1. Servlet based applications no longer need to add this project as an additional dependency. Reactive applications should continue to use this project for a native Kotlin DSL.

Code of Conduct

This project adheres to the Contributor Covenant code of conduct. By participating, you are expected to uphold this code. Please report unacceptable behavior to spring-code-of-conduct@pivotal.io.

Dependencies

Spring Cloud Kotlin DSL is an additional dependency you can add to your Spring project. It is an extension to Spring Security, and does not replace it.

implementation("org.springframework.security.dsl:spring-security-kotlin-dsl:0.0.1.BUILD-SNAPSHOT")

implementation("org.springframework.boot:spring-boot-starter-web")
implementation("org.springframework.boot:spring-boot-starter-security")

Sample Configuration

This is a sample configuration, that enables form login for all endpoints and uses the login page "/log-in".

@Configuration
class SecurityConfig: WebSecurityConfigurerAdapter() {
    override fun configure(http: HttpSecurity?) {
        http {
            authorizeRequests {
                authorize(anyRequest, authenticated)
            }
            formLogin {
                loginPage = "/log-in"
            }
        }
    }
}

License

Spring Security is Open Source software released under the Apache 2.0 license.

About

Spring Security Kotlin DSL

License:Apache License 2.0


Languages

Language:Kotlin 100.0%