我认识keydeap有几天了,它是一个非常有趣的工具。我现在遇到了一个困难,也许是因为我缺乏经验。我正在开发一个JavaSpringBoot应用程序,我想根据用户角色定义权限。我已经创建了一个领域,用户,定义的角色,基于这些角色创建了资源和权限。我还使用了权限评估工具来检查不同用户的不同权限。
当我在keydepowebsecurityconfigureadapt类中定义静态路由时,一切都正常,但我希望我可以这样做
@Override
protected void configure(HttpSecurity http) throws Exception {
super.configure(http);
ExpressionUrlAuthorizationConfigurer<HttpSecurity>.ExpressionInterceptUrlRegistry expressionInterceptUrlRegistry = http.cors() //
.and()
.csrf().disable()
.anonymous().disable()
.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS)
.and()
.authorizeRequests();
for(String role : getRoles(KeycloakClientOrKeycloakRealm)) {
for(String ressource : getAllowedRessourcesList(role)) {
expressionInterceptUrlRegistry = expressionInterceptUrlRegistry.antMatchers(ressource).hasRole(role);
}
}
expressionInterceptUrlRegistry.anyRequest().authenticated();
}
对getroles(keydovetclientorkeycloakrealm)和getallowedressourceslist(role)函数有什么建议吗?我非常感谢你花时间阅读
暂无答案!
目前还没有任何答案,快来回答吧!