Search in sources :

Example 1 with InMemoryUserDetailsManager

use of org.springframework.security.provisioning.InMemoryUserDetailsManager in project pentaho-platform by pentaho.

the class InMemoryUserRoleListServiceTest method setUp.

@Before
public void setUp() throws Exception {
    dao = new InMemoryUserRoleListService();
    dao.setUserRoleListEnhancedUserMap(makeUserRoleListEnhancedUserMap());
    dao.setAllRoles(makeAllAuthorities());
    Properties prop = new Properties();
    prop.load(new ByteArrayInputStream("scott=wombat,ROLE_THREE,ROLE_ONE,enabled\r\nmarissa=koala,ROLE_ONE,ROLE_TWO,enabled".getBytes()));
    InMemoryUserDetailsManager wrapped = new InMemoryUserDetailsManager(prop);
    // wrapped.setUserMap( makeUserMap() );
    // wrapped.afterPropertiesSet();
    dao.setUserDetailsService(wrapped);
    dao.afterPropertiesSet();
}
Also used : InMemoryUserRoleListService(org.pentaho.platform.plugin.services.security.userrole.memory.InMemoryUserRoleListService) ByteArrayInputStream(java.io.ByteArrayInputStream) InMemoryUserDetailsManager(org.springframework.security.provisioning.InMemoryUserDetailsManager) Properties(java.util.Properties) Before(org.junit.Before)

Example 2 with InMemoryUserDetailsManager

use of org.springframework.security.provisioning.InMemoryUserDetailsManager in project tutorials by eugenp.

the class MultipleLoginSecurityConfig method userDetailsService.

@Bean
public UserDetailsService userDetailsService() throws Exception {
    InMemoryUserDetailsManager manager = new InMemoryUserDetailsManager();
    manager.createUser(User.withUsername("user").password("userPass").roles("USER").build());
    manager.createUser(User.withUsername("admin").password("adminPass").roles("ADMIN").build());
    return manager;
}
Also used : InMemoryUserDetailsManager(org.springframework.security.provisioning.InMemoryUserDetailsManager) Bean(org.springframework.context.annotation.Bean)

Example 3 with InMemoryUserDetailsManager

use of org.springframework.security.provisioning.InMemoryUserDetailsManager in project promregator by promregator.

the class SecurityConfig method userDetailsService.

// see also
// https://www.boraji.com/spring-security-4-http-basic-authentication-example
// and
// https://stackoverflow.com/questions/46999940/spring-boot-passwordencoder-error
@Bean
public UserDetailsService userDetailsService() {
    InMemoryUserDetailsManager manager = new InMemoryUserDetailsManager();
    String password = this.basicAuthPassword;
    if (password == null) {
        password = UUID.randomUUID().toString();
        // NB: Logging does not work here properly yet; better use stderr
        System.err.println();
        System.err.println(String.format("Using generated password for user %s: %s", this.basicAuthUsername, password));
        System.err.println();
    }
    manager.createUser(User.withUsername(this.basicAuthUsername).password(String.format("{noop}%s", password)).roles("USER").build());
    return manager;
}
Also used : InMemoryUserDetailsManager(org.springframework.security.provisioning.InMemoryUserDetailsManager) Bean(org.springframework.context.annotation.Bean)

Example 4 with InMemoryUserDetailsManager

use of org.springframework.security.provisioning.InMemoryUserDetailsManager in project alien4cloud by alien4cloud.

the class SecurityConfiguration method demoAuthenticationProvider.

@Bean
@Profile("security-demo")
public DaoAuthenticationProvider demoAuthenticationProvider() {
    log.warn("ALIEN 4 CLOUD is Running in DEMO mode. This includes demo users and MUST NOT BE USED in PRODUCTION");
    DaoAuthenticationProvider provider = new DaoAuthenticationProvider();
    List<UserDetails> users = getUsers(new String[] { "user", "componentManager", "componentBrowser", "applicationManager", "appManager", "admin", "architect" }, new String[] { "COMPONENTS_BROWSER", "COMPONENTS_BROWSER, COMPONENTS_MANAGER", "COMPONENTS_BROWSER", "APPLICATIONS_MANAGER, COMPONENTS_BROWSER, COMPONENTS_MANAGER", "APPLICATIONS_MANAGER, COMPONENTS_BROWSER, COMPONENTS_MANAGER", "ADMIN", "ARCHITECT, COMPONENTS_BROWSER" });
    InMemoryUserDetailsManager detailsManager = new InMemoryUserDetailsManager(users);
    provider.setUserDetailsService(detailsManager);
    return provider;
}
Also used : UserDetails(org.springframework.security.core.userdetails.UserDetails) DaoAuthenticationProvider(org.springframework.security.authentication.dao.DaoAuthenticationProvider) InMemoryUserDetailsManager(org.springframework.security.provisioning.InMemoryUserDetailsManager) Profile(org.springframework.context.annotation.Profile) Bean(org.springframework.context.annotation.Bean)

Example 5 with InMemoryUserDetailsManager

use of org.springframework.security.provisioning.InMemoryUserDetailsManager in project spring-security by spring-projects.

the class SecurityConfig method userDetailsService.

// @formatter:off
@Bean
public UserDetailsService userDetailsService() throws Exception {
    InMemoryUserDetailsManager manager = new InMemoryUserDetailsManager();
    manager.createUser(User.withUsername("user").password("password").roles("USER").build());
    return manager;
}
Also used : InMemoryUserDetailsManager(org.springframework.security.provisioning.InMemoryUserDetailsManager) Bean(org.springframework.context.annotation.Bean)

Aggregations

InMemoryUserDetailsManager (org.springframework.security.provisioning.InMemoryUserDetailsManager)8 Bean (org.springframework.context.annotation.Bean)7 ByteArrayInputStream (java.io.ByteArrayInputStream)1 Arrays (java.util.Arrays)1 Arrays.asList (java.util.Arrays.asList)1 List (java.util.List)1 Properties (java.util.Properties)1 Collectors (java.util.stream.Collectors)1 Before (org.junit.Before)1 InMemoryUserRoleListService (org.pentaho.platform.plugin.services.security.userrole.memory.InMemoryUserRoleListService)1 Logger (org.slf4j.Logger)1 LoggerFactory (org.slf4j.LoggerFactory)1 Autowired (org.springframework.beans.factory.annotation.Autowired)1 Configuration (org.springframework.context.annotation.Configuration)1 Profile (org.springframework.context.annotation.Profile)1 DaoAuthenticationProvider (org.springframework.security.authentication.dao.DaoAuthenticationProvider)1 AuthenticationManagerBuilder (org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder)1 HttpSecurity (org.springframework.security.config.annotation.web.builders.HttpSecurity)1 EnableWebSecurity (org.springframework.security.config.annotation.web.configuration.EnableWebSecurity)1 WebSecurityConfigurerAdapter (org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter)1