Guest User

Untitled

a guest
Feb 8th, 2019
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.56 KB | None | 0 0
  1. class JsonSuccessHandler extends SimpleUrlAuthenticationSuccessHandler {
  2. override def onAuthenticationSuccess(request: HttpServletRequest, response: HttpServletResponse, authentication: Authentication) = {
  3. val responseWrapper = new HttpServletResponseWrapper(response);
  4. val out = responseWrapper.getWriter
  5. out.write("{success: true}")
  6. out.close
  7. }
  8. }
  9.  
  10. @Repository class JsonEntryPoint extends AuthenticationEntryPoint {
  11. def commence(request: HttpServletRequest, response: HttpServletResponse, ae: AuthenticationException) = {
  12. response.sendError(HttpServletResponse.SC_UNAUTHORIZED, "Unauthorized")
  13. }
  14. }
  15.  
  16. <http use-expressions="true" entry-point-ref="jsonAuthenticationEntryPoint">
  17. <custom-filter ref="myFilter" position="FORM_LOGIN_FILTER"/>
  18. <custom-filter ref="rememberMeFilter" position="REMEMBER_ME_FILTER"/>
  19.  
  20. <logout logout-url="/resources/j_spring_security_logout"/>
  21.  
  22. <intercept-url pattern="/backend/**" access="isAuthenticated()" />
  23. <intercept-url pattern="/resources/**" access="permitAll" />
  24. <intercept-url pattern="/admin/**" access="hasRole('ROLE_ADMIN')" />
  25. <intercept-url pattern="/**" access="permitAll" />
  26. </http>
  27.  
  28.  
  29. <beans:bean id="rememberMeFilter" class="org.springframework.security.web.authentication.rememberme.RememberMeAuthenticationFilter">
  30. <beans:property name="rememberMeServices" ref="rememberMeServices"/>
  31. <beans:property name="authenticationManager" ref="authenticationManager" />
  32. </beans:bean>
  33.  
  34. <beans:bean id="rememberMeServices" class="org.springframework.security.web.authentication.rememberme.JdbcTokenBasedRememberMeServices">
  35. <beans:property name="userDetailsService" ref="userServiceDb"/>
  36. <beans:property name="tokenRepository" ref="tokenRepository"/>
  37. <beans:property name="key" value="reservation" />
  38. </beans:bean>
  39.  
  40. <beans:bean id="tokenRepository" class="org.springframework.security.web.authentication.rememberme.JdbcTokenRepositoryImpl">
  41. <beans:property name="dataSource" ref="dataSource"/>
  42. </beans:bean>
  43.  
  44.  
  45. <beans:bean id="myFilter" class="org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter">
  46. <beans:property name="authenticationManager" ref="authenticationManager" />
  47. <beans:property name="authenticationSuccessHandler" ref="mySuccessHandler" />
  48. <beans:property name="rememberMeServices" ref="rememberMeServices" />
  49. <beans:property name="usernameParameter" value="email" />
  50. <beans:property name="passwordParameter" value="password" />
  51. </beans:bean>
  52. <beans:bean id="mySuccessHandler" class="JsonSuccessHandler"/>
  53. <beans:bean id="jsonAuthenticationEntryPoint" class="JsonEntryPoint" />
  54.  
  55. [INFO] Started Jetty Server
  56. 17:19:15.867 [qtp1943091306-38] DEBUG o.s.security.web.FilterChainProxy - / at position 1 of 10 in additional filter chain; firing Filter: 'SecurityContextPersistenceFilter'
  57. 17:19:15.875 [qtp1943091306-38] DEBUG o.s.s.w.c.HttpSessionSecurityContextRepository - No HttpSession currently exists
  58. 17:19:15.875 [qtp1943091306-38] DEBUG o.s.s.w.c.HttpSessionSecurityContextRepository - No SecurityContext was available from the HttpSession: null. A new one will be created.
  59. 17:19:15.877 [qtp1943091306-38] DEBUG o.s.security.web.FilterChainProxy - / at position 2 of 10 in additional filter chain; firing Filter: 'LogoutFilter'
  60. 17:19:15.878 [qtp1943091306-38] DEBUG o.s.security.web.FilterChainProxy - / at position 3 of 10 in additional filter chain; firing Filter: 'UsernamePasswordAuthenticationFilter'
  61. 17:19:15.878 [qtp1943091306-38] DEBUG o.s.security.web.FilterChainProxy - / at position 4 of 10 in additional filter chain; firing Filter: 'RequestCacheAwareFilter'
  62. 17:19:15.878 [qtp1943091306-38] DEBUG o.s.security.web.FilterChainProxy - / at position 5 of 10 in additional filter chain; firing Filter: 'SecurityContextHolderAwareRequestFilter'
  63. 17:19:15.879 [qtp1943091306-38] DEBUG o.s.security.web.FilterChainProxy - / at position 6 of 10 in additional filter chain; firing Filter: 'RememberMeAuthenticationFilter'
  64. 17:19:15.879 [qtp1943091306-38] DEBUG o.s.s.w.a.r.PersistentTokenBasedRememberMeServices - Remember-me cookie detected
  65. 17:19:15.895 [qtp1943091306-38] DEBUG o.s.jdbc.core.JdbcTemplate - Executing prepared SQL query
  66. 17:19:15.895 [qtp1943091306-38] DEBUG o.s.jdbc.core.JdbcTemplate - Executing prepared SQL statement [select username,series,token,last_used from persistent_logins where series = ?]
  67. 17:19:15.896 [qtp1943091306-38] DEBUG o.s.jdbc.datasource.DataSourceUtils - Fetching JDBC Connection from DataSource
  68. 17:19:15.922 [qtp1943091306-38] DEBUG o.s.jdbc.datasource.DataSourceUtils - Returning JDBC Connection to DataSource
  69. 17:19:15.938 [qtp1943091306-38] DEBUG o.s.s.w.a.r.PersistentTokenBasedRememberMeServices - Refreshing persistent login token for user 'physio1@physio-termin.at', series 'oLmZMQbnFsfyTziANriMKw=='
  70. 17:19:15.939 [qtp1943091306-38] DEBUG o.s.jdbc.core.JdbcTemplate - Executing prepared SQL update
  71. 17:19:15.944 [qtp1943091306-38] DEBUG o.s.jdbc.core.JdbcTemplate - Executing prepared SQL statement [update persistent_logins set token = ?, last_used = ? where series = ?]
  72. 17:19:15.944 [qtp1943091306-38] DEBUG o.s.jdbc.datasource.DataSourceUtils - Fetching JDBC Connection from DataSource
  73. 17:19:15.984 [qtp1943091306-38] DEBUG o.s.jdbc.core.JdbcTemplate - SQL update affected 1 rows
  74. 17:19:15.992 [qtp1943091306-38] DEBUG o.s.jdbc.datasource.DataSourceUtils - Returning JDBC Connection to DataSource
  75. 17:19:15.996 [qtp1943091306-38] DEBUG o.s.jdbc.core.JdbcTemplate - Executing prepared SQL query
  76. 17:19:15.996 [qtp1943091306-38] DEBUG o.s.jdbc.core.JdbcTemplate - Executing prepared SQL statement [select email username, password, isactive enabled from principal where email = ?]
  77. 17:19:15.996 [qtp1943091306-38] DEBUG o.s.jdbc.datasource.DataSourceUtils - Fetching JDBC Connection from DataSource
  78. 17:19:16.001 [qtp1943091306-38] DEBUG o.s.jdbc.datasource.DataSourceUtils - Returning JDBC Connection to DataSource
  79. 17:19:16.013 [qtp1943091306-38] DEBUG o.s.jdbc.core.JdbcTemplate - Executing prepared SQL query
  80. 17:19:16.013 [qtp1943091306-38] DEBUG o.s.jdbc.core.JdbcTemplate - Executing prepared SQL statement [select p.email username, a.authority from principal p inner join principal_authority apa on p.id = apa.principal_id inner join authority a on a.id = apa.authorities_id where p.email = ?]
  81. 17:19:16.013 [qtp1943091306-38] DEBUG o.s.jdbc.datasource.DataSourceUtils - Fetching JDBC Connection from DataSource
  82. 17:19:16.015 [qtp1943091306-38] DEBUG o.s.jdbc.datasource.DataSourceUtils - Returning JDBC Connection to DataSource
  83. 17:19:16.021 [qtp1943091306-38] DEBUG o.s.s.w.a.r.PersistentTokenBasedRememberMeServices - Remember-me cookie accepted
  84. 17:19:16.036 [qtp1943091306-38] DEBUG o.s.b.f.s.DefaultListableBeanFactory - Returning cached instance of singleton bean 'org.springframework.context.annotation.internalScheduledAnnotationProcessor'
  85. 17:19:16.042 [qtp1943091306-38] DEBUG o.s.s.w.a.r.RememberMeAuthenticationFilter - SecurityContextHolder not populated with remember-me token, as AuthenticationManager rejected Authentication returned by RememberMeServices: 'org.springframework.security.authentication.RememberMeAuthenticationToken@2fb6ff6b: Principal: org.springframework.security.core.userdetails.User@d45302c2: Username: physio1@physio-termin.at; Password: [PROTECTED]; Enabled: true; AccountNonExpired: true; credentialsNonExpired: true; AccountNonLocked: true; Granted Authorities: ROLE_PHYSIOTHERAPEUT; Credentials: [PROTECTED]; Authenticated: true; Details: org.springframework.security.web.authentication.WebAuthenticationDetails@957e: RemoteIpAddress: 127.0.0.1; SessionId: null; Granted Authorities: ROLE_PHYSIOTHERAPEUT'; invalidating remember-me token
  86. org.springframework.security.authentication.ProviderNotFoundException: No AuthenticationProvider found for org.springframework.security.authentication.RememberMeAuthenticationToken
  87. at org.springframework.security.authentication.ProviderManager.authenticate(ProviderManager.java:196) ~[spring-security-core-3.1.0.RELEASE.jar:3.1.0.RELEASE]
  88. at org.springframework.security.web.authentication.rememberme.RememberMeAuthenticationFilter.doFilter(RememberMeAuthenticationFilter.java:102) ~[spring-security-web-3.1.0.RELEASE.jar:3.1.0.RELEASE]
  89. at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323) [spring-security-web-3.1.0.RELEASE.jar:3.1.0.RELEASE]
  90.  
  91. <authentication-manager>
  92. <authentication-provider ref="yourRegularAuthenticationProvider" />
  93. <authentication-provider ref="rememberMeAuthenticationProvider" />
  94. </authentication-manager>
  95.  
  96. <beans:bean id="rememberMeAuthenticationProvider" class="org.springframework.security.authentication.RememberMeAuthenticationProvider">
  97. <beans:property name="key" value="reservation" />
  98. </beans:bean>
Add Comment
Please, Sign In to add comment