Does Micronaut have an equivalent to the spring "formLogin" feature?
When creating a spring boot application, we can add a method (bean) to a @Configuration
annotated class like
@Bean
public SecurityFilterChain sfc(HttpSecurity s) {
return s.csrf()
.disable()
.authorizeRequests().antMatchers("/**").authenticated()
.formLogin()
.build();
}
And that is enough to have my app secured, and the password will be checked against the environment variables SPRING_SECURITY_USER_{NAME,PASSWORD}
. This makes it very easy to add security to an application.
Was curious if the Micronaut project had a similar way to get up and running with a couple lines of code.
Edit: it also displays this form using bootstrap css: https://github.com/spring-projects/spring-security/blob/main/web/src/main/java/org/springframework/security/web/authentication/ui/DefaultLoginPageGeneratingFilter.java
All you got to do in Micronaut is to go through the steps described in the Micronaut Security Guide.
TL;DR
The Spring Boot feature you're mentioning is not available in Micronaut. But the following easy steps will provide to get there as close as possible.
Mainly that's following these steps:
build.gradle
application.yml
You can either secure your controller by using the @Secured annotation or define intercepted urls in your
application.yml
Then you write a simple authentication provider that does the login verifcation.
That does the job for a good start.