Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Idiomatic Kotlin DSL for configuring HTTP security #5558

Closed
joshlong opened this issue Jul 22, 2018 · 3 comments
Closed

Idiomatic Kotlin DSL for configuring HTTP security #5558

joshlong opened this issue Jul 22, 2018 · 3 comments
Assignees
Labels
in: config An issue in spring-security-config type: enhancement A general enhancement
Milestone

Comments

@joshlong
Copy link
Member

there are some exciting options for DSL designers in the Kotlin world. It'd be nice to support a Kotlin-DSL that does in a more idiomatic way what Spring Security does.

It would be able to take advantage of nested builder DSLs, like this

@rwinch rwinch self-assigned this May 6, 2019
@rwinch rwinch added the status: duplicate A duplicate of another issue label May 6, 2019
@rwinch rwinch closed this as completed May 6, 2019
@rwinch rwinch added in: config An issue in spring-security-config and removed status: duplicate A duplicate of another issue labels May 6, 2019
@rwinch rwinch reopened this May 6, 2019
@rwinch rwinch removed their assignment Jul 29, 2019
@eleftherias eleftherias self-assigned this Aug 1, 2019
@eleftherias eleftherias added the type: enhancement A general enhancement label Jan 3, 2020
eleftherias added a commit to eleftherias/spring-security that referenced this issue Jan 7, 2020
@metacubed
Copy link

@eleftherias and @joshlong, what do you think about simplifying this further?

override fun configure(http: HttpSecurity) {
    http {
        authorizeRequests {
            + "/path" to permitAll
            + "/user/{userName}" to "#userName == 'user'"
            + RegexRequestMatcher(".*", null) to authenticated
        }
    }
}

This option implements a + operator as an alternative to the authorize method.
This would only be executed at config/startup time, so the additional Pair creation would probably be ok.

eleftherias added a commit to eleftherias/spring-security that referenced this issue Jan 22, 2020
eleftherias added a commit that referenced this issue Jan 22, 2020
eleftherias added a commit that referenced this issue Feb 26, 2020
@eleftherias
Copy link
Contributor

Thanks for the suggestion @metacubed.
I would refrain from using the + operator in this context, because it is already a well defined infix binary operator.
Using it at the start of the line with only one parameter strays from its intended use-case and may confuse users.

eleftherias added a commit that referenced this issue Mar 4, 2020
eleftherias added a commit that referenced this issue Apr 7, 2020
eleftherias added a commit that referenced this issue Apr 7, 2020
@eleftherias
Copy link
Contributor

A native Kotlin DSL for servlet based applications is available as of Spring Security 5.3.
The native Kotlin DSL for WebFlux based applications will be part of Spring Security 5.4.
Spring Security 5.4.0.M1 is scheduled for 2020/05/06.

@eleftherias eleftherias added this to the 5.4.0.M1 milestone Apr 24, 2020
@eleftherias eleftherias changed the title Please support using Kotlin in a DSL Idiomatic Kotlin DSL for configuring HTTP security Apr 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: config An issue in spring-security-config type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

4 participants