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
首先非常感谢博主的几篇文章。看完那几篇文章后,我在使用博主demo的过程中遇到两个问题想请教下: 1 例如我想根据用户id查询用户的所有Permission。我调用的是UserRoleResource类的@path("/userPermissions") 方法。postman的get请求: localhost:10101/authserver/userPermissions?access_token="太长,略去"&userId=af6ef7a9-413c-4727-9ca9-0ea00aed99bc&client=frontend 响应结果: { "timestamp": 1524385914909, "status": 404, "error": "Not Found", "message": "No message available", "path": "/authserver/userPermissions" } 是参数哪里有问题吗? 2 使用资源的数据库中定义,要打开代码中的哪些注释? 我尝试打开类ResourceServerConfig的注释,发现不起作用,打开哪些注释权限的校验会进入到SecurityAccessDecisionManager里的decide方法去判断用户是否有权限访问资源。
localhost:10101/authserver/userPermissions?access_token="太长,略去"&userId=af6ef7a9-413c-4727-9ca9-0ea00aed99bc&client=frontend
{ "timestamp": 1524385914909, "status": 404, "error": "Not Found", "message": "No message available", "path": "/authserver/userPermissions" }
The text was updated successfully, but these errors were encountered:
第一个问题中,请求参数的问题可以参考backend-server中的定义的FeignAuthClient类,上述访问中失败的原因是路径错误了,通过网关直接访问路径应该http://localhost:10101/auth/api/userPermissions,直接访问的地址为http://localhost:9091/api/userPermissions。
http://localhost:10101/auth/api/userPermissions
http://localhost:9091/api/userPermissions
第二问题中,我们的后端服务不是资源服务器,如果想在后端服务中使用权限控制的行为,可以尝试使用项目中定义的@preauth注解开启鉴权切面。如果想使用资源服务器的中的鉴权功能,需要配置资源服务器(使用@EnableResourceServer和ResourceServerConfigurerAdapter配置资源服务器 )的HttpSecurity,比如下面的例子,将会配置对应的FilterSecurityInterceptor进行权限拦截(其内使用AccessDecisionManager进行判定)。
@Override public void configure(HttpSecurity http) throws Exception { http.csrf().disable() .requestMatchers().antMatchers("/**") .and() .authorizeRequests() .anyRequest().authenticated() .antMatchers("/user/**").hasRole("user") .antMatchers("/admin/**").hasAuthority("ROLE_ADMIN") .antMatchers("/resource/**").access("hasRole('ADMIN') and hasAuthority('ROLE_ADMIN')") ; }
Sorry, something went wrong.
No branches or pull requests
首先非常感谢博主的几篇文章。看完那几篇文章后,我在使用博主demo的过程中遇到两个问题想请教下:
1 例如我想根据用户id查询用户的所有Permission。我调用的是UserRoleResource类的@path("/userPermissions") 方法。postman的get请求:
localhost:10101/authserver/userPermissions?access_token="太长,略去"&userId=af6ef7a9-413c-4727-9ca9-0ea00aed99bc&client=frontend
响应结果:
{ "timestamp": 1524385914909, "status": 404, "error": "Not Found", "message": "No message available", "path": "/authserver/userPermissions" }
是参数哪里有问题吗?
2 使用资源的数据库中定义,要打开代码中的哪些注释?
我尝试打开类ResourceServerConfig的注释,发现不起作用,打开哪些注释权限的校验会进入到SecurityAccessDecisionManager里的decide方法去判断用户是否有权限访问资源。
The text was updated successfully, but these errors were encountered: