最近刚学,怎么也查不到解释,求各位赐教
就这么简单的一段code:
@Autowired
public void configAuthentication(AuthenticationManagerBuilder auth) throws Exception {
auth.jdbcAuthentication().dataSource(dataSource)
.usersByUsernameQuery( "select username,password, enabled from users where username=?") .authoritiesByUsernameQuery( "select username, role from user_roles where username=?");
}
我以前没用过这么简化的framework,所以我连基本概念都含糊,我的问题是:
认证的话,我的脑海里至少得拿到client传来的信息,和数据库里指定的信息对比,然后判断ok不ok
但是这里,干脆就叫了一个query,都不用指定去拿什么和什么对比?
我想知道query来的database里的数据(包括user table的username,password和enabled。user_roles table里的username和role),被拿来和什么作比较了?spring怎么知道拿什么和什么去作比较?最重要的是,如果我想自定义一个authentication怎么办,比如我想不仅用户名和密码存在,而且用户的“昵称”(假设有这个属性)必须是“xxx”,那怎么写?
请赐教,多谢多谢!
就这么简单的一段code:
@Autowired
public void configAuthentication(AuthenticationManagerBuilder auth) throws Exception {
auth.jdbcAuthentication().dataSource(dataSource)
.usersByUsernameQuery( "select username,password, enabled from users where username=?") .authoritiesByUsernameQuery( "select username, role from user_roles where username=?");
}
我以前没用过这么简化的framework,所以我连基本概念都含糊,我的问题是:
认证的话,我的脑海里至少得拿到client传来的信息,和数据库里指定的信息对比,然后判断ok不ok
但是这里,干脆就叫了一个query,都不用指定去拿什么和什么对比?
我想知道query来的database里的数据(包括user table的username,password和enabled。user_roles table里的username和role),被拿来和什么作比较了?spring怎么知道拿什么和什么去作比较?最重要的是,如果我想自定义一个authentication怎么办,比如我想不仅用户名和密码存在,而且用户的“昵称”(假设有这个属性)必须是“xxx”,那怎么写?
请赐教,多谢多谢!