类org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder源码实例Demo

下面列出了怎么用org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: SpringBootLearn   文件: WebSecurityConfig.java
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
    auth
            // 设置UserDetailsService
            .userDetailsService(userDetailsService())
            // 使用BCrypt进行密码的hash
            .passwordEncoder(passwordEncoder());
    auth.eraseCredentials(false);
}
 
/**
 * 模拟数据库查询,判断尝试登陆用户是否满足认证条件
 *
 * @param auth AuthenticationManagerBuilder
 * @throws Exception 异常
 */
@Override
protected void configure(final AuthenticationManagerBuilder auth) throws Exception {
    auth.inMemoryAuthentication()
        .withUser("user1").password(passwordEncoder().encode("123456")).roles("USER")
        .and()
        .withUser("user2").password(passwordEncoder().encode("qweasd")).roles("USER")
        .and()
        .withUser("admin").password(passwordEncoder().encode("admin")).roles("ADMIN");
}
 
源代码3 项目: tutorials   文件: SecurityConfig.java
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
    auth.inMemoryAuthentication()
        .passwordEncoder(passwordEncoder())
        .withUser("user1")
        .password(passwordEncoder().encode("user"))
        .roles("USER")
        .and()
        .withUser("admin")
        .password(passwordEncoder().encode("admin"))
        .roles("ADMIN");
}
 
源代码4 项目: blog   文件: PersonApplication.java
/**
 * Registers the KeycloakAuthenticationProvider with the authentication manager.
 */
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
    KeycloakAuthenticationProvider keycloakAuthenticationProvider = keycloakAuthenticationProvider();

    // adding proper authority mapper for prefixing role with "ROLE_"
    keycloakAuthenticationProvider.setGrantedAuthoritiesMapper(new SimpleAuthorityMapper());

    auth.authenticationProvider(keycloakAuthenticationProvider);
}
 
/**
 * 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");
	auth.jdbcAuthentication().dataSource(dataSource).withUser("anil")
			.password("password").roles("ADMIN");
	// @formatter:on
}
 
源代码6 项目: gaia   文件: StateApiSecurityConfig.java
@Override
public void configure(AuthenticationManagerBuilder auth) throws Exception {
    logger.info(String.format("%n%nUsing generated security password for state API: %s%n", properties().getPassword()));

    // configure default backend user
    auth
            .inMemoryAuthentication()
            .withUser(properties().getUsername()).password(bCrypt.encode(properties().getPassword())).authorities("ROLE_STATE");
}
 
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
    auth
      .inMemoryAuthentication()
      .withUser("user1")
      .password(passwordEncoder().encode("user1Pass"))
      .authorities("ROLE_USER");
}
 
源代码8 项目: jump-the-queue   文件: BaseWebSecurityConfig.java
@SuppressWarnings("javadoc")
@Inject
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {

  auth.inMemoryAuthentication().withUser("waiter").password(this.passwordEncoder.encode("waiter")).roles("Waiter")
      .and().withUser("cook").password(this.passwordEncoder.encode("cook")).roles("Cook").and().withUser("barkeeper")
      .password(this.passwordEncoder.encode("barkeeper")).roles("Barkeeper").and().withUser("chief")
      .password(this.passwordEncoder.encode("chief")).roles("Chief");
}
 
源代码9 项目: JiwhizBlogWeb   文件: SecurityConfig.java
@Override
protected void configure(AuthenticationManagerBuilder builder) throws Exception{
    builder
    	.authenticationProvider(socialAuthenticationProvider())
    	.authenticationProvider(rememberMeAuthenticationProvider())
    	.userDetailsService(userAccountService);
}
 
源代码10 项目: Milkomeda   文件: CrustConfigurerAdapter.java
@Override
public void configure(AuthenticationManagerBuilder auth) {
    CrustAuthenticationProvider authenticationProvider = new CrustAuthenticationProvider(props, passwordEncoder);
    configureProvider(authenticationProvider);
    // 添加自定义身份验证组件
    auth.authenticationProvider(authenticationProvider);
}
 
public SecurityConfiguration(AuthenticationManagerBuilder authenticationManagerBuilder, UserDetailsService userDetailsService,TokenProvider tokenProvider,CorsFilter corsFilter, SecurityProblemSupport problemSupport) {
    this.authenticationManagerBuilder = authenticationManagerBuilder;
    this.userDetailsService = userDetailsService;
    this.tokenProvider = tokenProvider;
    this.corsFilter = corsFilter;
    this.problemSupport = problemSupport;
}
 
public SecurityConfiguration(AuthenticationManagerBuilder authenticationManagerBuilder, UserDetailsService userDetailsService, TokenProvider tokenProvider, CorsFilter corsFilter, SecurityProblemSupport problemSupport) {
    this.authenticationManagerBuilder = authenticationManagerBuilder;
    this.userDetailsService = userDetailsService;
    this.tokenProvider = tokenProvider;
    this.corsFilter = corsFilter;
    this.problemSupport = problemSupport;
}
 
源代码13 项目: Spring5Tutorial   文件: SecurityConfig.java
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
	PasswordEncoder pwdEncoder = new BCryptPasswordEncoder();
	auth.inMemoryAuthentication() 
	    .passwordEncoder(pwdEncoder)
			.withUser("admin") 
			    .password(pwdEncoder.encode("admin12345678"))
			    .roles("ADMIN", "MEMBER")
		.and()
			.withUser("caterpillar")
			    .password(pwdEncoder.encode("12345678"))
			    .roles("MEMBER");
}
 
@Override
protected void configure(AuthenticationManagerBuilder authMgrBldr) throws Exception {
	authMgrBldr.inMemoryAuthentication()
			.passwordEncoder(org.springframework.security.crypto.password.NoOpPasswordEncoder.getInstance())
			.withUser(DEFAULT_USER_ID).password(DEFAULT_USER_SECRET).authorities(DEFAULT_USER_ROLE).and()
			.withUser(DEFAULT_ADMIN_ID).password(DEFAULT_ADMIN_SECRET)
			.authorities(DEFAULT_USER_ROLE, DEFAULT_ADMIN_ROLE);
}
 
@Override
    protected void configure(AuthenticationManagerBuilder auth) throws Exception {
// Store in memory
//        auth
//                .inMemoryAuthentication()
//                .withUser("john.carnell").password("password1").roles("USER")                 // Define the first user: john.carnell with the password "password1" and the role "USER"
//                .and()
//                .withUser("william.woodward").password("password2").roles("USER", "ADMIN");   // Define the second user: william.woodward with the password "password2" and the role "ADMIN"

// Store in databse
    	auth.jdbcAuthentication().dataSource(dataSource).passwordEncoder(passwordEncoder);
    }
 
源代码16 项目: mogu_blog_v2   文件: WebSecurityConfig.java
@Autowired
public void configureAuthentication(AuthenticationManagerBuilder authenticationManagerBuilder) throws Exception {
    authenticationManagerBuilder
            // 设置UserDetailsService
            .userDetailsService(this.userDetailsService)
            // 使用BCrypt进行密码的hash
            .passwordEncoder(passwordEncoder());
    //remember me
    authenticationManagerBuilder.eraseCredentials(false);
}
 
源代码17 项目: Spring5Tutorial   文件: SecurityConfig.java
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
	auth.jdbcAuthentication()
   		.passwordEncoder(new BCryptPasswordEncoder())
	    .dataSource(dataSource())
	    .usersByUsernameQuery("select name, password, enabled from t_account where name=?")
	    .authoritiesByUsernameQuery("select name, role from t_account_role where name=?");
}
 
源代码18 项目: tutorials   文件: BasicAuthConfiguration.java
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
    auth
      .inMemoryAuthentication()
      .withUser("user")
      .password("password")
      .roles("USER");
}
 
源代码19 项目: SpringCloud   文件: WebServerSecurityConfig.java
/**
 * 注入自定义的userDetailsService实现,获取用户信息,设置密码加密方式
 *
 * @param authenticationManagerBuilder
 * @throws Exception
 */
@Override
protected void configure(AuthenticationManagerBuilder authenticationManagerBuilder) throws Exception {
    authenticationManagerBuilder
            .userDetailsService(userDetailsService)
            .passwordEncoder(passwordEncoder());
    // 设置手机验证码登陆的AuthenticationProvider
    authenticationManagerBuilder.authenticationProvider(mobileAuthenticationProvider());
}
 
源代码20 项目: tutorials   文件: SecurityConfiguration.java
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
    auth.jdbcAuthentication()
        .dataSource(dataSource)
        .usersByUsernameQuery("select email,password,enabled "
            + "from bael_users "
            + "where email = ?")
        .authoritiesByUsernameQuery("select email,authority "
            + "from authorities "
            + "where email = ?");
}
 
源代码21 项目: mall-swarm   文件: SecurityConfig.java
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
    auth.userDetailsService(userDetailsService())
            .passwordEncoder(passwordEncoder());
}
 
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
    auth.userDetailsService(userRepository);
}
 
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
        auth.inMemoryAuthentication().withUser("user").password("password").roles("USER")
                        .and().withUser("admin").password("password").roles("USER", "ADMIN");
}
 
源代码24 项目: Spring-5.0-Cookbook   文件: AppSecurityModelF.java
@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);
}
 
源代码26 项目: blog-sample   文件: WebSecurityConfig.java
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
    // 指定 provider
    auth.authenticationProvider(customAuthenticationProvider);
}
 
源代码27 项目: AIDR   文件: SecurityConfig.java
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
    auth
            .userDetailsService(userDetailsService())
            .passwordEncoder(passwordEncoder());
}
 
源代码28 项目: Spring-Boot-Book   文件: SecurityConfig.java
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
    auth.userDetailsService(Service()).passwordEncoder(new BCryptPasswordEncoder() {
    });
}
 
源代码29 项目: Spring-Boot-Book   文件: WebSecurityConfig.java
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
    auth.userDetailsService(Service()).passwordEncoder(new BCryptPasswordEncoder() {
    });
}
 
源代码30 项目: lolibox   文件: SecurityConfig.java
@Autowired
public void configureGlobalSecurity(AuthenticationManagerBuilder auth) throws Exception {
    auth.userDetailsService(userDetailsService);
    auth.authenticationProvider(authProvider());
}