spring-projects-experimental / spring-fu

Configuration DSLs for Spring Boot
Apache License 2.0
1.67k stars 139 forks source link

add spring security DSL #319

Closed pull-vert closed 3 years ago

pull-vert commented 4 years ago

fixes #16

For webFlux

webFlux {
    port = 0
    router {
        GET("/public-view") { ok().build() }
        GET("/view") { ok().build() }
    }

    security {
        authenticationManager = repoAuthenticationManager

        http {
            authorizeExchange {
                authorize("/public-view", permitAll)
                authorize("/view", hasRole("USER"))
            }
            httpBasic {}
        }
    }
}

For webMvc

webMvc {
    port = 0
    router {
        GET("/public-view") { ok().build() }
        GET("/view") { ok().build() }
    }

    security {
        authenticationManager = repoAuthenticationManager

        http {
            authorizeRequests {
                authorize("/public-view", permitAll)
                authorize("/view", hasRole("USER"))
            }
            httpBasic {}
        }
    }
}
sdeleuze commented 3 years ago

Nice one @pull-vert, thanks a lot for that, I will merge it in our upcoming 0.4.2 release.

sdeleuze commented 3 years ago

Merged thanks!