Spring Boot OAuth示例未对

时间:2016-04-11 21:06:16

标签: java spring spring-security spring-boot spring-cloud

我正在尝试通过遵循the instructions in this link来学习如何使用Spring Boot和Spring Cloud设置OAuth2,这是大型教程的第5部分。在多次阅读本教程并逐步完成后,我决定只需下载the completed version from github at this link再次学习它。

authserverresourceui个应用启动,但当我尝试登录时,授权应用不接受教程中提供的凭据。我希望在分解它并测试小变化的影响之前,让我的devbox上的示例正常工作。

调试日志中指明Spring向视图发送的错误的特定行是:

o.s.security.web.FilterChainProxy        : 
/login?error reached end of additional filter chain;   
proceeding with original chain

需要采取哪些具体步骤才能1.)下载并安装应用程序,以及2.)使用身份验证服务器成功登录?

这是我到目前为止所做的:

在我的CentOS 7 devbox终端上,我输入了:

cd /home/user/spring_boot_apps/
mkdir whole_security_tutorial && cd whole_security_tutorial
git clone https://github.com/spring-guides/tut-spring-security-and-angular-js
cd /home/user/spring_boot_apps/whole_security_tutorial/tut-spring-security-and-angular-js/oauth2/authserver
mvn spring-boot:run
cd /home/user/spring_boot_apps/whole_security_tutorial/tut-spring-security-and-angular-js/oauth2/resource
mvn spring-boot:run
cd /home/user/spring_boot_apps/whole_security_tutorial/tut-spring-security-and-angular-js/oauth2/ui
mvn spring-boot:run

然后,在FireFox中,我键入了http://localhost:8080。这导致加载页面包括预期的主页和登录链接,因此我单击登录链接,该链接重定向到授权应用程序,该应用程序显示登录页面。

我输入acme作为用户名,acmesecret作为密码输入,但身份验证失败并显示消息There was a problem logging in. Please try again.

我做错了什么?

注意:我没有在/home/user/spring_boot_apps/whole_security_tutorial/tut-spring-security-and-angular-js/oauth2启动该应用,因为在之前的尝试中这样做无法访问其他子应用,同时也导致其他应用由于port 9000无法启动已经在使用中的错误。

登录尝试的Spring Boot调试日志如下:

2016-04-11 01:56:10.805 DEBUG 17850 --- [nio-9999-exec-7] o.s.s.web.util.matcher.OrRequestMatcher  : Trying to match using Ant [pattern='/css/**']
2016-04-11 01:56:10.805 DEBUG 17850 --- [nio-9999-exec-7] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/login'; against '/css/**'
2016-04-11 01:56:10.805 DEBUG 17850 --- [nio-9999-exec-7] o.s.s.web.util.matcher.OrRequestMatcher  : Trying to match using Ant [pattern='/js/**']
2016-04-11 01:56:10.805 DEBUG 17850 --- [nio-9999-exec-7] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/login'; against '/js/**'
2016-04-11 01:56:10.805 DEBUG 17850 --- [nio-9999-exec-7] o.s.s.web.util.matcher.OrRequestMatcher  : Trying to match using Ant [pattern='/images/**']
2016-04-11 01:56:10.805 DEBUG 17850 --- [nio-9999-exec-7] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/login'; against '/images/**'
2016-04-11 01:56:10.805 DEBUG 17850 --- [nio-9999-exec-7] o.s.s.web.util.matcher.OrRequestMatcher  : Trying to match using Ant [pattern='/**/favicon.ico']
2016-04-11 01:56:10.805 DEBUG 17850 --- [nio-9999-exec-7] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/login'; against '/**/favicon.ico'
2016-04-11 01:56:10.805 DEBUG 17850 --- [nio-9999-exec-7] o.s.s.web.util.matcher.OrRequestMatcher  : Trying to match using Ant [pattern='/error']
2016-04-11 01:56:10.805 DEBUG 17850 --- [nio-9999-exec-7] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/login'; against '/error'
2016-04-11 01:56:10.805 DEBUG 17850 --- [nio-9999-exec-7] o.s.s.web.util.matcher.OrRequestMatcher  : No matches found
2016-04-11 01:56:10.805 DEBUG 17850 --- [nio-9999-exec-7] o.s.s.web.util.matcher.OrRequestMatcher  : Trying to match using Ant [pattern='/login']
2016-04-11 01:56:10.805 DEBUG 17850 --- [nio-9999-exec-7] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/login'; against '/login'
2016-04-11 01:56:10.805 DEBUG 17850 --- [nio-9999-exec-7] o.s.s.web.util.matcher.OrRequestMatcher  : matched
2016-04-11 01:56:10.805 DEBUG 17850 --- [nio-9999-exec-7] o.s.security.web.FilterChainProxy        : /login at position 1 of 12 in additional filter chain; firing Filter: 'WebAsyncManagerIntegrationFilter'
2016-04-11 01:56:10.805 DEBUG 17850 --- [nio-9999-exec-7] o.s.security.web.FilterChainProxy        : /login at position 2 of 12 in additional filter chain; firing Filter: 'SecurityContextPersistenceFilter'
2016-04-11 01:56:10.805 DEBUG 17850 --- [nio-9999-exec-7] w.c.HttpSessionSecurityContextRepository : HttpSession returned null object for SPRING_SECURITY_CONTEXT
2016-04-11 01:56:10.805 DEBUG 17850 --- [nio-9999-exec-7] w.c.HttpSessionSecurityContextRepository : No SecurityContext was available from the HttpSession: org.apache.catalina.session.StandardSessionFacade@2f575638. A new one will be created.
2016-04-11 01:56:10.805 DEBUG 17850 --- [nio-9999-exec-7] o.s.security.web.FilterChainProxy        : /login at position 3 of 12 in additional filter chain; firing Filter: 'HeaderWriterFilter'
2016-04-11 01:56:10.805 DEBUG 17850 --- [nio-9999-exec-7] o.s.s.w.header.writers.HstsHeaderWriter  : Not injecting HSTS header since it did not match the requestMatcher org.springframework.security.web.header.writers.HstsHeaderWriter$SecureRequestMatcher@63eea474
2016-04-11 01:56:10.805 DEBUG 17850 --- [nio-9999-exec-7] o.s.security.web.FilterChainProxy        : /login at position 4 of 12 in additional filter chain; firing Filter: 'CsrfFilter'
2016-04-11 01:56:10.805 DEBUG 17850 --- [nio-9999-exec-7] o.s.security.web.FilterChainProxy        : /login at position 5 of 12 in additional filter chain; firing Filter: 'LogoutFilter'
2016-04-11 01:56:10.805 DEBUG 17850 --- [nio-9999-exec-7] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/login'; against '/logout'
2016-04-11 01:56:10.805 DEBUG 17850 --- [nio-9999-exec-7] o.s.security.web.FilterChainProxy        : /login at position 6 of 12 in additional filter chain; firing Filter: 'UsernamePasswordAuthenticationFilter'
2016-04-11 01:56:10.806 DEBUG 17850 --- [nio-9999-exec-7] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/login'; against '/login'
2016-04-11 01:56:10.806 DEBUG 17850 --- [nio-9999-exec-7] w.a.UsernamePasswordAuthenticationFilter : Request is to process authentication
2016-04-11 01:56:10.806 DEBUG 17850 --- [nio-9999-exec-7] o.s.s.authentication.ProviderManager     : Authentication attempt using org.springframework.security.authentication.dao.DaoAuthenticationProvider
2016-04-11 01:56:10.806 DEBUG 17850 --- [nio-9999-exec-7] o.s.s.a.dao.DaoAuthenticationProvider    : User 'acme' not found
2016-04-11 01:56:10.806 DEBUG 17850 --- [nio-9999-exec-7] w.a.UsernamePasswordAuthenticationFilter : Authentication request failed: org.springframework.security.authentication.BadCredentialsException: Bad credentials
2016-04-11 01:56:10.806 DEBUG 17850 --- [nio-9999-exec-7] w.a.UsernamePasswordAuthenticationFilter : Updated SecurityContextHolder to contain null Authentication
2016-04-11 01:56:10.806 DEBUG 17850 --- [nio-9999-exec-7] w.a.UsernamePasswordAuthenticationFilter : Delegating to authentication failure handler org.springframework.security.web.authentication.SimpleUrlAuthenticationFailureHandler@15daee11
2016-04-11 01:56:10.806 DEBUG 17850 --- [nio-9999-exec-7] .a.SimpleUrlAuthenticationFailureHandler : Redirecting to /login?error
2016-04-11 01:56:10.806 DEBUG 17850 --- [nio-9999-exec-7] o.s.s.web.DefaultRedirectStrategy        : Redirecting to '/uaa/login?error'
2016-04-11 01:56:10.806 DEBUG 17850 --- [nio-9999-exec-7] w.c.HttpSessionSecurityContextRepository : SecurityContext is empty or contents are anonymous - context will not be stored in HttpSession.
2016-04-11 01:56:10.806 DEBUG 17850 --- [nio-9999-exec-7] s.s.w.c.SecurityContextPersistenceFilter : SecurityContextHolder now cleared, as request processing completed
2016-04-11 01:56:10.824 DEBUG 17850 --- [nio-9999-exec-8] o.s.s.web.util.matcher.OrRequestMatcher  : Trying to match using Ant [pattern='/css/**']
2016-04-11 01:56:10.824 DEBUG 17850 --- [nio-9999-exec-8] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/login'; against '/css/**'
2016-04-11 01:56:10.824 DEBUG 17850 --- [nio-9999-exec-8] o.s.s.web.util.matcher.OrRequestMatcher  : Trying to match using Ant [pattern='/js/**']
2016-04-11 01:56:10.824 DEBUG 17850 --- [nio-9999-exec-8] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/login'; against '/js/**'
2016-04-11 01:56:10.824 DEBUG 17850 --- [nio-9999-exec-8] o.s.s.web.util.matcher.OrRequestMatcher  : Trying to match using Ant [pattern='/images/**']
2016-04-11 01:56:10.824 DEBUG 17850 --- [nio-9999-exec-8] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/login'; against '/images/**'
2016-04-11 01:56:10.824 DEBUG 17850 --- [nio-9999-exec-8] o.s.s.web.util.matcher.OrRequestMatcher  : Trying to match using Ant [pattern='/**/favicon.ico']
2016-04-11 01:56:10.824 DEBUG 17850 --- [nio-9999-exec-8] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/login'; against '/**/favicon.ico'
2016-04-11 01:56:10.824 DEBUG 17850 --- [nio-9999-exec-8] o.s.s.web.util.matcher.OrRequestMatcher  : Trying to match using Ant [pattern='/error']
2016-04-11 01:56:10.824 DEBUG 17850 --- [nio-9999-exec-8] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/login'; against '/error'
2016-04-11 01:56:10.824 DEBUG 17850 --- [nio-9999-exec-8] o.s.s.web.util.matcher.OrRequestMatcher  : No matches found
2016-04-11 01:56:10.824 DEBUG 17850 --- [nio-9999-exec-8] o.s.s.web.util.matcher.OrRequestMatcher  : Trying to match using Ant [pattern='/login']
2016-04-11 01:56:10.824 DEBUG 17850 --- [nio-9999-exec-8] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/login'; against '/login'
2016-04-11 01:56:10.824 DEBUG 17850 --- [nio-9999-exec-8] o.s.s.web.util.matcher.OrRequestMatcher  : matched
2016-04-11 01:56:10.824 DEBUG 17850 --- [nio-9999-exec-8] o.s.security.web.FilterChainProxy        : /login?error at position 1 of 12 in additional filter chain; firing Filter: 'WebAsyncManagerIntegrationFilter'
2016-04-11 01:56:10.824 DEBUG 17850 --- [nio-9999-exec-8] o.s.security.web.FilterChainProxy        : /login?error at position 2 of 12 in additional filter chain; firing Filter: 'SecurityContextPersistenceFilter'
2016-04-11 01:56:10.824 DEBUG 17850 --- [nio-9999-exec-8] w.c.HttpSessionSecurityContextRepository : HttpSession returned null object for SPRING_SECURITY_CONTEXT
2016-04-11 01:56:10.824 DEBUG 17850 --- [nio-9999-exec-8] w.c.HttpSessionSecurityContextRepository : No SecurityContext was available from the HttpSession: org.apache.catalina.session.StandardSessionFacade@2f575638. A new one will be created.
2016-04-11 01:56:10.824 DEBUG 17850 --- [nio-9999-exec-8] o.s.security.web.FilterChainProxy        : /login?error at position 3 of 12 in additional filter chain; firing Filter: 'HeaderWriterFilter'
2016-04-11 01:56:10.824 DEBUG 17850 --- [nio-9999-exec-8] o.s.s.w.header.writers.HstsHeaderWriter  : Not injecting HSTS header since it did not match the requestMatcher org.springframework.security.web.header.writers.HstsHeaderWriter$SecureRequestMatcher@63eea474
2016-04-11 01:56:10.824 DEBUG 17850 --- [nio-9999-exec-8] o.s.security.web.FilterChainProxy        : /login?error at position 4 of 12 in additional filter chain; firing Filter: 'CsrfFilter'
2016-04-11 01:56:10.824 DEBUG 17850 --- [nio-9999-exec-8] o.s.security.web.FilterChainProxy        : /login?error at position 5 of 12 in additional filter chain; firing Filter: 'LogoutFilter'
2016-04-11 01:56:10.824 DEBUG 17850 --- [nio-9999-exec-8] o.s.s.w.u.matcher.AntPathRequestMatcher  : Request 'GET /login' doesn't match 'POST /logout
2016-04-11 01:56:10.824 DEBUG 17850 --- [nio-9999-exec-8] o.s.security.web.FilterChainProxy        : /login?error at position 6 of 12 in additional filter chain; firing Filter: 'UsernamePasswordAuthenticationFilter'
2016-04-11 01:56:10.828 DEBUG 17850 --- [nio-9999-exec-8] o.s.s.w.u.matcher.AntPathRequestMatcher  : Request 'GET /login' doesn't match 'POST /login
2016-04-11 01:56:10.828 DEBUG 17850 --- [nio-9999-exec-8] o.s.security.web.FilterChainProxy        : /login?error at position 7 of 12 in additional filter chain; firing Filter: 'RequestCacheAwareFilter'
2016-04-11 01:56:10.828 DEBUG 17850 --- [nio-9999-exec-8] o.s.s.w.s.DefaultSavedRequest            : pathInfo: both null (property equals)
2016-04-11 01:56:10.828 DEBUG 17850 --- [nio-9999-exec-8] o.s.s.w.s.DefaultSavedRequest            : queryString: arg1=client_id=acme&redirect_uri=http://localhost:8080/login&response_type=code&state=q0YqtY; arg2=error (property not equals)
2016-04-11 01:56:10.828 DEBUG 17850 --- [nio-9999-exec-8] o.s.s.w.s.HttpSessionRequestCache        : saved request doesn't match
2016-04-11 01:56:10.828 DEBUG 17850 --- [nio-9999-exec-8] o.s.security.web.FilterChainProxy        : /login?error at position 8 of 12 in additional filter chain; firing Filter: 'SecurityContextHolderAwareRequestFilter'
2016-04-11 01:56:10.828 DEBUG 17850 --- [nio-9999-exec-8] o.s.security.web.FilterChainProxy        : /login?error at position 9 of 12 in additional filter chain; firing Filter: 'AnonymousAuthenticationFilter'
2016-04-11 01:56:10.865 DEBUG 17850 --- [nio-9999-exec-8] o.s.s.w.a.AnonymousAuthenticationFilter  : Populated SecurityContextHolder with anonymous token: 'org.springframework.security.authentication.AnonymousAuthenticationToken@905571d8: Principal: anonymousUser; Credentials: [PROTECTED]; Authenticated: true; Details: org.springframework.security.web.authentication.WebAuthenticationDetails@0: RemoteIpAddress: 127.0.0.1; SessionId: 49C866D11F4CC5AF4ACDC58145A672BA; Granted Authorities: ROLE_ANONYMOUS'
2016-04-11 01:56:10.865 DEBUG 17850 --- [nio-9999-exec-8] o.s.security.web.FilterChainProxy        : /login?error at position 10 of 12 in additional filter chain; firing Filter: 'SessionManagementFilter'
2016-04-11 01:56:10.865 DEBUG 17850 --- [nio-9999-exec-8] o.s.security.web.FilterChainProxy        : /login?error at position 11 of 12 in additional filter chain; firing Filter: 'ExceptionTranslationFilter'
2016-04-11 01:56:10.865 DEBUG 17850 --- [nio-9999-exec-8] o.s.security.web.FilterChainProxy        : /login?error at position 12 of 12 in additional filter chain; firing Filter: 'FilterSecurityInterceptor'
2016-04-11 01:56:10.865 DEBUG 17850 --- [nio-9999-exec-8] o.s.s.w.a.i.FilterSecurityInterceptor    : Secure object: FilterInvocation: URL: /login?error; Attributes: [permitAll]
2016-04-11 01:56:10.865 DEBUG 17850 --- [nio-9999-exec-8] o.s.s.w.a.i.FilterSecurityInterceptor    : Previously Authenticated: org.springframework.security.authentication.AnonymousAuthenticationToken@905571d8: Principal: anonymousUser; Credentials: [PROTECTED]; Authenticated: true; Details: org.springframework.security.web.authentication.WebAuthenticationDetails@0: RemoteIpAddress: 127.0.0.1; SessionId: 49C866D11F4CC5AF4ACDC58145A672BA; Granted Authorities: ROLE_ANONYMOUS
2016-04-11 01:56:10.865 DEBUG 17850 --- [nio-9999-exec-8] o.s.s.access.vote.AffirmativeBased       : Voter: org.springframework.security.web.access.expression.WebExpressionVoter@5cb57e17, returned: 1
2016-04-11 01:56:10.865 DEBUG 17850 --- [nio-9999-exec-8] o.s.s.w.a.i.FilterSecurityInterceptor    : Authorization successful
2016-04-11 01:56:10.865 DEBUG 17850 --- [nio-9999-exec-8] o.s.s.w.a.i.FilterSecurityInterceptor    : RunAsManager did not change Authentication object
2016-04-11 01:56:10.865 DEBUG 17850 --- [nio-9999-exec-8] o.s.security.web.FilterChainProxy        : /login?error reached end of additional filter chain; proceeding with original chain
2016-04-11 01:56:10.867 DEBUG 17850 --- [nio-9999-exec-8] w.c.HttpSessionSecurityContextRepository : SecurityContext is empty or contents are anonymous - context will not be stored in HttpSession.
2016-04-11 01:56:10.867 DEBUG 17850 --- [nio-9999-exec-8] o.s.s.w.a.ExceptionTranslationFilter     : Chain processed normally
2016-04-11 01:56:10.867 DEBUG 17850 --- [nio-9999-exec-8] s.s.w.c.SecurityContextPersistenceFilter : SecurityContextHolder now cleared, as request processing completed
2016-04-11 01:56:10.958 DEBUG 17850 --- [nio-9999-exec-9] o.s.s.web.util.matcher.OrRequestMatcher  : Trying to match using Ant [pattern='/css/**']
2016-04-11 01:56:10.958 DEBUG 17850 --- [nio-9999-exec-9] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/css/wro.css'; against '/css/**'
2016-04-11 01:56:10.958 DEBUG 17850 --- [nio-9999-exec-9] o.s.s.web.util.matcher.OrRequestMatcher  : matched
2016-04-11 01:56:10.958 DEBUG 17850 --- [nio-9999-exec-9] o.s.security.web.FilterChainProxy        : /css/wro.css has an empty filter list
2016-04-11 01:56:10.959 DEBUG 17850 --- [nio-9999-exec-9] .s.o.p.e.FrameworkEndpointHandlerMapping : Looking up handler method for path /css/wro.css
2016-04-11 01:56:10.959 DEBUG 17850 --- [nio-9999-exec-9] .s.o.p.e.FrameworkEndpointHandlerMapping : Did not find handler method for [/css/wro.css]
2016-04-11 01:56:10.961 DEBUG 17850 --- [io-9999-exec-10] o.s.s.web.util.matcher.OrRequestMatcher  : Trying to match using Ant [pattern='/css/**']
2016-04-11 01:56:10.961 DEBUG 17850 --- [io-9999-exec-10] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/js/wro.js'; against '/css/**'
2016-04-11 01:56:10.961 DEBUG 17850 --- [io-9999-exec-10] o.s.s.web.util.matcher.OrRequestMatcher  : Trying to match using Ant [pattern='/js/**']
2016-04-11 01:56:10.961 DEBUG 17850 --- [io-9999-exec-10] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/js/wro.js'; against '/js/**'
2016-04-11 01:56:10.961 DEBUG 17850 --- [io-9999-exec-10] o.s.s.web.util.matcher.OrRequestMatcher  : matched
2016-04-11 01:56:10.961 DEBUG 17850 --- [io-9999-exec-10] o.s.security.web.FilterChainProxy        : /js/wro.js has an empty filter list
2016-04-11 01:56:10.962 DEBUG 17850 --- [io-9999-exec-10] .s.o.p.e.FrameworkEndpointHandlerMapping : Looking up handler method for path /js/wro.js
2016-04-11 01:56:10.962 DEBUG 17850 --- [io-9999-exec-10] .s.o.p.e.FrameworkEndpointHandlerMapping : Did not find handler method for [/js/wro.js]

或者,根据user提供凭据passwordapplication.properties会导致重定向到localhost:9000/uaa,并出现xml错误消息,指出{{1} }。

0 个答案:

没有答案