@Override protected void configure(AuthenticationManagerBuilder auth) { try { auth.jdbcAuthentication() .dataSource(dataSource) .usersByUsernameQuery( "SELECT username, password, enabled " + "FROM users " + "WHERE username = ?" ) .authoritiesByUsernameQuery( "SELECT x.username, y.roles " + "FROM users x, user_entity_roles y " + "WHERE x.username = ? and y.user_entity_username = x.username " ) /* Note: in BCrypt, the "password" field also contains the salt */ .passwordEncoder(passwordEncoder); } catch (Exception e) { throw new RuntimeException(e); } }
@Autowired public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception { if (ShepherConstants.LOGIN_TYPE_LDAP.equals(loginType.toUpperCase())) { auth.ldapAuthentication() .userDnPatterns("uid={0},ou=people") .groupSearchBase("ou=groups") .contextSource() .url(ldapUrl) .managerPassword(ldapPassword) .managerDn(ldapDn); } else if (ShepherConstants.LOGIN_TYPE_DEMO.equals(loginType.toUpperCase())) { auth.inMemoryAuthentication() .withUser(demoAdminName) .password(demoAdminPassword) .roles("USER"); } }
@Override protected void configure(AuthenticationManagerBuilder auth) throws Exception { auth.userDetailsService(userDetailsService) .passwordEncoder(passwordEncoder()); /* auth.inMemoryAuthentication() .withUser("admin").password("yigepingguo.com").roles("ADMIN", "USER") .and() .withUser("user").password("user").roles("USER");*/ }
@Override protected void configure(AuthenticationManagerBuilder auth) throws Exception { AuthenticationProvider[] providers = primaryAuthProviders(); for (AuthenticationProvider provider : providers) { auth = auth.authenticationProvider(provider); } auth.authenticationProvider(tokenProvider); }
/**Configures the {@link #predefinedUsernames} as known users with their password equal to the user name.*/ @Autowired public void configureGlobal(final AuthenticationManagerBuilder auth) throws Exception { final InMemoryUserDetailsManagerConfigurer<AuthenticationManagerBuilder> inMemoryAuthentication = auth.inMemoryAuthentication(); for(final String username: predefinedUsernames) { final String role = username.equalsIgnoreCase(BANK_ROLE) ? BANK_ROLE : CLIENT_ROLE; inMemoryAuthentication.withUser(username).password("").roles(role); } }
/** * Initializes the {@link AuthenticationManagerBuilder}. Creates an * {@link InMemoryUserDetailsManager} with the provided {@link FileAuthenticationConfiguration#getUsers()}. * {@link FileAuthenticationConfiguration#getUsers()} must contain at least 1 user. * * @throws IllegalArgumentException if {@link FileAuthenticationConfiguration#getUsers()} is empty. */ @Override public void init(AuthenticationManagerBuilder auth) throws Exception { Assert.notEmpty(this.users, String.format("No user specified. Please specify at least 1 user (e.g. via '%s')", CONFIGURATION_PROPERTIES_PREFIX + ".users")); final InMemoryUserDetailsManager inMemory = new InMemoryUserDetailsManager(getUsers()); auth.userDetailsService(inMemory); }
@Override public void configure(final AuthenticationManagerBuilder auth) throws Exception { auth // Define our custom user details service. .userDetailsService(new CustomUserDetailsService(userRepository)) .passwordEncoder(getPasswordEncoder()); }
@Autowired public void configAuthentication(AuthenticationManagerBuilder auth) throws Exception { // Authentication via JDBC, look up PostgreSQL database auth.jdbcAuthentication() .dataSource(dataSource) .usersByUsernameQuery("SELECT username, password, enabled FROM users WHERE username = ?") .authoritiesByUsernameQuery("SELECT username, role FROM user_roles WHERE username = ?"); }
@Autowired public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception { auth .jdbcAuthentication() .dataSource(dataSource) .passwordEncoder(passwordEncoder()) ;// END AUTH CONFIG }
@Autowired public void configureAuthentication(AuthenticationManagerBuilder authenticationManagerBuilder) throws Exception { authenticationManagerBuilder // 设置UserDetailsService .userDetailsService(this.userDetailsService) // 使用BCrypt进行密码的hash .passwordEncoder(passwordEncoder()); }
@Autowired public void configureGlobal(AuthenticationManagerBuilder authManagerBuilder) throws Exception { authManagerBuilder .inMemoryAuthentication() .withUser("user").password("password").roles("USER") .and().withUser("admin").password("password").roles("ADMIN", "USER"); }
@Autowired public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception { String username = environment.getRequiredProperty("user.login"); String password = environment.getRequiredProperty("user.password"); auth .inMemoryAuthentication() .withUser(username).password(password).roles("ADMIN"); }
@Autowired public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception { auth .eraseCredentials(false) // Add an LDAP authentication provider instead of this to support LDAP .userDetailsService(userDetailsService()).and() // Required to allow JWT .authenticationProvider(jwtConfig.jwtAuthenticationProvider()); }
public SecurityConfiguration(AuthenticationManagerBuilder authenticationManagerBuilder, UserDetailsService userDetailsService, TokenProvider tokenProvider, CorsFilter corsFilter) { this.authenticationManagerBuilder = authenticationManagerBuilder; this.userDetailsService = userDetailsService; this.tokenProvider = tokenProvider; this.corsFilter = corsFilter; }
/** * Configures the authentication manager bean which processes authentication * requests. */ @Override protected void configure(AuthenticationManagerBuilder auth) throws Exception { auth .userDetailsService(userDetailsService()) .passwordEncoder(passwordEncoder()); }
@Autowired public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception { auth .inMemoryAuthentication() .withUser("user").password("password").roles("USER") .and().withUser("admin").password("admin").roles("ADMIN"); }
@Autowired public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception { auth.inMemoryAuthentication().withUser("user").password("").roles("USER"); auth.inMemoryAuthentication().withUser("apollo").password("").roles("USER", "ADMIN"); auth.inMemoryAuthentication().withUser("created").password("").roles("TEST"); auth.inMemoryAuthentication().withUser("updated").password("").roles("TEST"); auth.inMemoryAuthentication().withUser("deleted").password("").roles("TEST"); }
@Override protected void configure(AuthenticationManagerBuilder auth) throws Exception { //noinspection ConstantConditions if(ldapAuthentication != null) { auth.authenticationProvider(userAuthenticationProvider); ldapAuthentication.enable(auth); } else { auth.userDetailsService(userDetailsService()); } }
/** * This section defines the user accounts which can be used for authentication as well as the roles each user has. * * @see org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter#configure(org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder) */ @Override protected void configure(AuthenticationManagerBuilder auth) throws Exception { auth.inMemoryAuthentication().// withUser("greg").password("turnquist").roles("USER").and().// withUser("ollie").password("gierke").roles("USER", "ADMIN"); }
@Inject public void configureGlobal(AuthenticationManagerBuilder auth) { try { auth .userDetailsService(userDetailsService) .passwordEncoder(passwordEncoder()); } catch (Exception e) { throw new BeanInitializationException("Security configuration failed", e); } }
@Test public void testInitAuthenticationManagerBuilder() throws Exception { try { final FileAuthenticationConfiguration fileAuthenticationConfiguration = new FileAuthenticationConfiguration(); fileAuthenticationConfiguration.init(mock(AuthenticationManagerBuilder.class)); } catch (IllegalArgumentException anIllegalArgumentException) { assertThat(anIllegalArgumentException.getMessage(), is("No user specified. Please specify at least 1 user (e.g. " + "via 'dataflow.security.authentication.file.users')")); } }
/** * Setup 2 users with different roles */ @Override public void init(AuthenticationManagerBuilder auth) throws Exception { // @formatter:off auth.jdbcAuthentication().dataSource(dataSource).withUser("dave").password("secret").roles("USER").and() .withUser("anil").password("password").roles("ADMIN", "USER").and().getUserDetailsService(); // @formatter:on // Add the default service jdbcUserDetailsService.addService(auth.getDefaultUserDetailsService()); }
@Autowired public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception { auth.inMemoryAuthentication() .withUser(secondOpinionSecurityProperties.getUsername()) .password(secondOpinionSecurityProperties.getPassword()) .roles("USER"); }
@Override protected void configure(AuthenticationManagerBuilder auth) throws Exception { auth.userDetailsService(userDetailsService) .passwordEncoder(passwordEncoder); }
@Autowired public void globalUserDetails(AuthenticationManagerBuilder auth) throws Exception { auth.userDetailsService(userDetailsService).passwordEncoder(new BCryptPasswordEncoder()); }
@Override protected void configure(AuthenticationManagerBuilder authBuilder) { authBuilder.authenticationProvider(this.authProvider); }
@Autowired public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception { auth .authenticationProvider(casAuthenticationProvider()); }
@Autowired public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception { auth.userDetailsService(userDetailsService).passwordEncoder(passwordEncoder()); }
@Override protected void configure(AuthenticationManagerBuilder auth) throws Exception { auth .userDetailsService(userDetailsService) .passwordEncoder(passwordEncoder); }
@Autowired public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception { auth .inMemoryAuthentication() .withUser("root").password("password").roles("ADMIN"); }
/** * @param amBuilder new value of {@link #getAmBuilder}. */ @Inject public void setAmBuilder(AuthenticationManagerBuilder amBuilder) { this.amBuilder = amBuilder; }
@Override protected void configure(AuthenticationManagerBuilder auth) throws Exception { auth.inMemoryAuthentication() .withUser("sjctrags").password("sjctrags").roles("USER"); }
@Override protected void configure(AuthenticationManagerBuilder authenticationManagerBuilder) { authenticationManagerBuilder.authenticationProvider(authenticationProvider()); }
@Override protected void configure(AuthenticationManagerBuilder auth) throws Exception { auth.authenticationProvider(authProvider()); auth.eraseCredentials(false); }
@Override protected void configure(AuthenticationManagerBuilder auth) throws Exception { auth.userDetailsService(userDetailsService()) .passwordEncoder(passwordEncoder()); }
@Override protected void configure(AuthenticationManagerBuilder auth) throws Exception { }