List of usage examples for org.springframework.security.config.annotation.authentication.builders AuthenticationManagerBuilder inMemoryAuthentication
public InMemoryUserDetailsManagerConfigurer<AuthenticationManagerBuilder> inMemoryAuthentication() throws Exception
From source file:io.convergencia.training.Application.java
@Autowired @Order(Ordered.HIGHEST_PRECEDENCE + 10)//from ww w .ja v a 2s . c o m public void configureSimpleAuthUsers(AuthenticationManagerBuilder auth) throws Exception { auth.inMemoryAuthentication().withUser("admin").password("admin").roles("ADMIN", "USER").and() .withUser("user").password("user").roles("USER"); }
From source file:eu.trentorise.game.config.SecurityConfig.java
@Autowired public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception { for (AuthUser user : usersProvider.getUsers()) { auth.inMemoryAuthentication().withUser(user.getUsername()).password(user.getPassword()) .roles(user.getRole());/*from ww w. j a v a 2s . c o m*/ LogHub.info(null, logger, "Loaded auth user {}", user.getUsername()); } }
From source file:com.orange.clara.cloud.servicedbdumper.config.SecurityConfig.java
@Autowired public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception { auth.inMemoryAuthentication().withUser(brokerUsername).password(brokerPassword).roles("API"); auth.inMemoryAuthentication().withUser(defaultUserUsername).password(defaultUserPassword).roles("USER"); auth.inMemoryAuthentication().withUser(adminUsername).password(adminPassword).roles("ADMIN", "SPRING_BOOT_ADMIN", "USER"); auth.inMemoryAuthentication().withUser(springBootAdminUsername).password(springBootAdminPassword) .roles("SPRING_BOOT_ADMIN"); }
From source file:cn.net.withub.demo.bootsec.hello.config.WebSecurityConfig.java
/** * /*from w ww . j a va2 s.co m*/ * * @param auth * @throws Exception */ @Autowired public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception { //?roles()??ROLE_ //? auth.inMemoryAuthentication().withUser("admin").password("admin").roles("ADMIN", "A");//?ROLE_ADMIN, ROLE_A //? auth.authenticationProvider(authenticationProvider()); }
From source file:com.mycompany.springboot.config.WebSecurityConfig.java
@Autowired public void configGlobal(AuthenticationManagerBuilder auth) throws Exception { //AuthenticationManagerBuilder spring bean ? spring autowired auth.inMemoryAuthentication().withUser("user").password("password").roles("USER").and().withUser("admin") .password("password").roles("ADMIN"); // auth // .userDetailsService(userService); }
From source file:org.vaadin.spring.samples.mvp.security.config.InMemoryAuthenticationBuilder.java
void build(Environment env, AuthenticationManagerBuilder auth) throws Exception { String username = env.getProperty("app.user.name", "admin"); String password = env.getProperty("app.user.password", "admin"); InMemoryUserDetailsManagerConfigurer<?> inmem = auth.inMemoryAuthentication(); // remember to annotate service methods with @org.springframework.security.access.annotation.Secured inmem.withUser(username).password(password).authorities(FunctionalRole.ADMIN.getRoleName()); // other "fake" accounts; for demonstration purposes inmem.withUser("user").password("user").authorities(FunctionalRole.PUBLIC.getRoleName()); }
From source file:net.orpiske.tcs.service.config.SecurityConfig.java
@Override protected void configure(AuthenticationManagerBuilder auth) throws Exception { String user = System.getenv("TCS_USER"); String password = System.getenv("TCS_PASSWORD"); if (user == null) { logger.fatal("The system username is not provided"); System.exit(-1);// w ww .ja va 2 s . c om } if (password == null) { logger.fatal("The system password is not provided"); System.exit(-1); } auth.inMemoryAuthentication().withUser(user).password(password).roles("USER"); }
From source file:org.dawnsci.marketplace.config.SecurityConfiguration.java
@Autowired public void registerAuthentication(AuthenticationManagerBuilder auth) throws Exception { String password = UUID.randomUUID().toString(); if (environment.containsProperty("marketplace.admin-password")) { password = environment.getProperty("marketplace.admin-password"); } else {//from www .ja v a 2s . c o m logger.info("Using generated administrator password: " + password); } // create a default administrator account auth.inMemoryAuthentication().withUser(ADMINISTRATOR_ID).password(password) // this particular administrator user has full access .roles("USER", "ADMIN", "UPLOAD").and() // and use accounts stored in the database for the rest .and().jdbcAuthentication().dataSource(dataSource) .usersByUsernameQuery("select username, password, true from Account where username = ?") .authoritiesByUsernameQuery("select username, authority from Authorities where username = ?") .passwordEncoder(passwordEncoder()); }
From source file:com.muk.spring.config.SpringSecurityConfig.java
@Override protected void configure(AuthenticationManagerBuilder auth) throws Exception { // Don't clear credentials from the authorization. This is our oauth access token auth.eraseCredentials(false);/*from ww w.j av a2 s.c o m*/ // Add custom provider for a bearer token auth.authenticationProvider(bearerTokenAuthenticationProvider()); // In memory users for basic auth final InMemoryUserDetailsManagerConfigurer<AuthenticationManagerBuilder> authBuilder = auth .inMemoryAuthentication(); String decodedPrincipal = null; String[] principalParts = null; for (final String creds : environment.getProperty("app.principals").split(",")) { decodedPrincipal = new String(Base64.decodeBase64(creds)); principalParts = decodedPrincipal.split(":"); authBuilder.withUser(principalParts[0]).password(principalParts[1]).roles("USER"); } }
From source file:de.interseroh.report.webconfig.SecurityConfig.java
@Override public void configure(AuthenticationManagerBuilder auth) throws Exception { logger.debug("configureGlobal: mapping login to LDAP"); // LDAP or InMemory String ldapAuth = prepareLdapAuth(); if (!ldapAuth.equalsIgnoreCase("true")) { // In memory authentication String inMemoryUser = prepareInMemoryUser(); String inMemoryPassword = prepareInMemoryPassword(); auth.inMemoryAuthentication().withUser(inMemoryUser).password(inMemoryPassword).roles("USER"); } else {//from w w w .j a v a 2s . com // LDAP authentication String ldapUrl = prepareLdapUrl(); String managerDn = prepareManagerDn(); String managerPassword = prepareManagerPassword(); auth.ldapAuthentication().userSearchFilter(USER_SEARCH_FILTER).contextSource().managerDn(managerDn) .managerPassword(managerPassword).url(ldapUrl); } }