What is in memory authentication in spring boot?

What is in memory authentication in spring boot?

Problem Description:

How to use in Memory Authentication in Spring Boot version 5?

What are the best way to implement in memory authentication?

I wanted to know how can I implement in memory authentication in my Spring Boot Version 5 Application.

Solution – 1

By a simple google search you can find a lot of samples and documents for your question, as springs docs says you can use in memory authentication as below:

@Bean
public UserDetailsService users() {
    UserDetails user = User.builder()
        .username("user")
        .password("{bcrypt}$2a$10$GRLdNijSQMUvl/au9ofL.eDwmoohzzS7.rmNSJZ.0FxO/BTk76klW")
        .roles("USER")
        .build();
    UserDetails admin = User.builder()
        .username("admin")
        .password("{bcrypt}$2a$10$GRLdNijSQMUvl/au9ofL.eDwmoohzzS7.rmNSJZ.0FxO/BTk76klW")
        .roles("USER", "ADMIN")
        .build();
    return new InMemoryUserDetailsManager(user, admin);
}

for more details check the docs.

Rate this post
We use cookies in order to give you the best possible experience on our website. By continuing to use this site, you agree to our use of cookies.
Accept
Reject