0x5*_*539 8 authentication spring oauth-2.0 spring-boot
是否有人遇到错误"访问此资源需要完全身份验证"尝试使用POST请求oauth/token进行身份验证?
卷曲命令:
curl localhost:85/oauth/token -d grant_type=password -d client_id=web_app -d username=reader -d password=reader
Run Code Online (Sandbox Code Playgroud)
响应:
{"timestamp":1486841819620,"status":401,"error":"Unauthorized","message":"Full authentication is required to access this resource","path":"/oauth/token"}
Run Code Online (Sandbox Code Playgroud)
ResourceServerConfiguration配置
http .csrf().disable() .authorizeRequests() .antMatchers("/**").authenticated() .antMatchers(HttpMethod.GET, "/me").hasAuthority("FOO_READ")
Run Code Online (Sandbox Code Playgroud)
WebSecurityConfig配置
http .csrf().disable() .exceptionHandling() .authenticationEntryPoint((request, response, authException) -> response.sendError(HttpServletResponse.SC_UNAUTHORIZED))
Run Code Online (Sandbox Code Playgroud)
谢谢!
归档时间: |
|
查看次数: |
20273 次 |
最近记录: |