We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
return mono .filter(Authentication::isAuthenticated) .flatMapIterable(Authentication::getAuthorities) .map(GrantedAuthority::getAuthority)
这段怎么理解
The text was updated successfully, but these errors were encountered:
说说我的理解: return mono //jwt一定是需要鉴权的,".filter(Authentication::isAuthenticated)"一句可以不加 //猜测:jwt传进来后,jwt中的authorities字段对应的内容(也就是用户拥有roles),一个个都被封装成GrantedAuthority的一 //个实现,比如SimpleGrantedAuthority //(猜测来源: 从SimpleGrantedAuthority看到,getAuthority返回的是“role”,也就是jwt中用户所拥有的角色) //---------------------------------------------------------------------------------------- //Authentication::getAuthorities返回:Collection<? extends GrantedAuthority> //猜测"flatMapIterable(Authentication::getAuthorities)"这一句 得到当前用户拥有的"role"列表 //只不过这时,这些"role"被包装成了类似SimpleGrantedAuthority这样的东西 .flatMapIterable(Authentication::getAuthorities) //".map(GrantedAuthority::getAuthority)"这句对每个SimpleGrantedAuthority进行拆包,获取到里面的"role" .map(GrantedAuthority::getAuthority) //从redis中查询访问当前路径"需要"用户是哪些"role"(这些role记为roles),只要当前用户具备的"role"中存在一项在这个roles里面 .any(authorities::contains) //就返回鉴权成功 .map(AuthorizationDecision::new) //否则鉴权失败 .defaultIfEmpty(new AuthorizationDecision(false));
Sorry, something went wrong.
No branches or pull requests
这段怎么理解
The text was updated successfully, but these errors were encountered: