2017-02-11 23 views
0

Я реализовал аутентификацию SAML2 в веб-приложении. Все работает отлично в начале. Пользователь регистрируется и может использовать приложение, но через одну минуту он получает 401 и всю страницу перезагружается.Spring SAML Access запрещен через одну минуту

Это

В чем причина? Он подключен к билету SAML NotOnOrAfter атрибут? Как я могу исправить эту проблему и отключить эту перезагрузку и повторную аутентификацию?

В журналах можно увидеть:

7: 13: 55,271 ОТЛАДКА 29368 --- [HTTP-NiO-127.0.0.1-5814-Exec-7] osswaiFilterSecurityInterceptor: Безопасный объект: FilterInvocation : URL: /sw.js; Атрибуты: [аутентифицировано] 2017-02-11 17: 13: 55,271 ОТЛАДКИ 29368 --- [HTTP-NiO-127.0.0.1-5814-Exec-7] osswaiFilterSecurityInterceptor: Ранее Аутентифицированный: org.springframework. [email protected]: Руководитель: anonymousUser; Учетные данные: [ЗАЩИТА]; Authenticated: true; Подробности: org.sprin[email protected]957e: RemoteIpAddress: 127.0.0.1; SessionId: 3A25B5C297F7BCF47C70ACA09D03EEC6; Предоставленные органы: ROLE_ANONYMOUS 2017-02-11 17: 13: 55,271 DEBUG 29368 --- [HTTP-NiO-127.0.0.1-5814-Exec-7] ossaccess.vote.AffirmativeBased
: избиратель: орг .springframework.security.web.access.expression.WebExpressionVoter @ 4e54fa5d, возвращен: -1 2017-02-11 17: 13: 55.271 DEBUG 29368 --- [http-nio-127.0.0.1-5814-exec-7 ] osswaExceptionTranslationFilter : Доступ запрещен (пользователь анонимный); перенаправлении аутентификации точка входа

org.springframework.security.access.AccessDeniedException: Доступ отказано в org.springframework.security.access.vote.AffirmativeBased.decide (AffirmativeBased.java : 84) на org.springframework.security.access.intercept.AbstractSecurityInterceptor.beforeInvocation (AbstractSecurityInterceptor.java:233) на org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke (FilterSecurityI nterceptor.java:124) на org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter (FilterSecurityInterceptor.java:91) в org.springframework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter (FilterChainProxy. Java: 331) на org.springframework.security.web.access.ExceptionTranslationFilter.doFilter (ExceptionTranslationFilter.java:115) в org.springframework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter (FilterChainProxy.java:331) at org.springframework.security.web.session.SessionManagementFilter.doFilter (SessionManagementFilter.Java: 137) на org.springframework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter (FilterChainProxy.java:331) на org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter (AnonymousAuthenticationFilter.java:111) на org.springframework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter (FilterChainProxy.java:331) в org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter (SecurityContextHolderAwareRequestFilter.java:169) в орг .springframework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter (FilterChainProxy.java:331) по адресу org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter (RequestCacheAwareFilter.java:63) на org.springframework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter (FilterChainProxy.java:331) на org.springframework .security.saml.SAMLLogoutProcessingFilter.processLogout (SAMLLogoutProcessingFilter.java:206) на org.springframework.security.saml.SAMLLogoutProcessingFilter.doFilter (SAMLLogoutProcessingFilter.java:104)

2017-02-11 17: 13: 55,291 DEBUG 29368 --- [http-nio-127.0.0.1-5814-exec-7] osswsHttpSessionRequestCache
: DefaultSavedRequest добавлены к сессии: DefaultSavedRequest [https://somesite/saml/SSO/sw.js] 2017-02-11 17: 13: 55,291 DEBUG 29368 --- [HTTP-NiO-127.0.0.1-5814-Exec-7] osswaExceptionTranslationFilter: Вызов аутентификации точка входа. 2017-02-11 17: 13: 55,306 DEBUG 29368 --- [HTTP-NiO-127.0.0.1-5814-Exec-7] ossscontext.SAMLContextProviderImpl: Нет IDP указано, используя по умолчанию MINEIDP 2017-02-11 17: 13: 55.307 DEBUG 29368 --- [http-nio-127.0.0.1-5814-exec-7] ossecurity.saml.util.SAMLUtil
: Индекс для AssertionConsumerService не указан, возвращается по умолчанию 2017-02-11 17: 13: 55,308 DEBUG 29368 --- [HTTP-NiO-127.0.0.1-5814-Exec-7] ossecurity.saml.SAMLEntryPoint
: Обработка SSO с использованием профиля WebSSO 2017- 02-11 17: 13: 55,308 DEBUG 29368 --- [HTTP-NiO-127.0.0.1-5814-Exec-7] osssaml.websso.WebSSOProfileImpl: Использования по умолчанию потребителю обслуживания с связывающей урной: оазис : names: tc: SAML: 2.0: привязки: HTTP-POST 2017-02-11 17: 13: 55.308 DEBUG 29368 --- [http-nio-127.0.0.1-5814-exec-7] ossecurity. saml.util.SLF4JLogChute : ResourceManager: found /templates/saml2-post-binding.vm с загрузчиком org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader 2017-02-11 17: 13: 55.308 DEBUG 29368 - - [http-nio-127.0.0.1-5814-exec-7] ossecurity.saml.util.SLF4JLogChute : R esourceManager: найдено /templates/add-html-head-content.vm с погрузчик org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader 2017-02-11 17: 13: 55,308 DEBUG 29368 --- [ http-nio-127.0.0.1-5814-exec-7] ossecurity.saml.util.SLF4JLogChute : ResourceManager: найдено /templates/add-html-body-content.vm с загрузчиком org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader 2017-02-11 17: 13: 55,308 DEBUG 29368 - - [HTTP-NiO-127.0.0.1-5814-Exec-7] osswheader.writers.HstsHeaderWriter: не инъекционные HSTS заголовок , поскольку она не соответствовала requestMatcher org.springframework.security.web.header.writers. HstsHeaderWriter $ SecureRequestMatcher @ 66d6b7bc 2017-02-11 17: 13: 55,308 DEBUG 29368 --- [HTTP-NiO-127.0.0.1-5814-Exec-7] wcHttpSessionSecurityContextRepository: SecurityContext пуст или содержание являются анонимными - контекст будет не сохраняются в HttpSession. 2017-02-11 17: 13: 55,308 ОТЛАДКА 29368 --- [HTTP-NiO-127.0.0.1-5814-Exec-7] osssaml.storage.HttpSessionStorage : Хранение сообщений a2h65aag15ccg2d837386cch748e34h на сессии 3A25B5C297F7BCF47C70ACA09D03EEC6 2017-02 -11 17: 13: 55.308 INFO 29368 --- [http-nio-127.0.0.1-5814-exec-7] ossecurity.saml.log.SAMLDefaultLogger: AuthNRequest; SUCCESS; 127.0.0.1; https://somesite .. 2017-02-11 17: 13: 55.308 DEBUG 29368 --- [http-nio-127.0.0.1-5814-exec-7] sswcSecurityContextPersistenceFilter: SecurityContextHolder теперь очищено, так как обработка запроса завершена 2017-02 -11 17: 13: 55.308 DEBUG 29368 --- [http-nio-127.0.0.1-5814-exec-7] osbwfOrderedRequestContextFilter: очищенный связанный с потоком контекст запроса: org.apache.catalina.connector.RequestFacade @ 7bfe8944 2017-02-11 17: 13: 56,527 ОТЛАДКА 29368 --- [HTTP-NiO-127.0.0.1-5814-Exec-3] osbwfOrderedRequestContextFilter : Bound контекст запроса в теме: org.apache.catalina. [email protected] 2017-02-11 17: 13: 56.527 DEBUG 29 368 --- [http-nio-127.0.0.1-5814-exec-3] o.s.security.web.FilterChainProxy:/saml/SSO в позиции 1 16 в дополнительной цепочке фильтров; firing Фильтр: 'WebAsyncManagerIntegrationFilter' 2017-02-11 17: 13: 56.527 DEBUG 29368 --- [http-nio-127.0.0.1-5814-exec-3] ossecurity.web.FilterChainProxy:/saml/SSO в положение 2 из 16 в дополнительной цепи фильтра; Фильтр стрельбы : '' SecurityContextPersistenceFilter 2017-02-11 17: 13: 56.527 ОТЛАДКА 29368 --- [HTTP-NiO-127.0.0.1-5814-EXEC-3] wcHttpSessionSecurityContextRepository: HttpSession возвращается нуль объект для SPRING_SECURITY_CONTEXT 2017 -02-11 17: 13: 56.527 DEBUG 29368 --- [http-nio-127.0.0.1-5814-exec-3] wcHttpSessionSecurityContextRepository: Нет SecurityContext был , доступный с HttpSession: org.apache.catalina.session .StandardSessionFacade @ 491a27d7. Будет создан новый . 2017-02-11 17: 13: 56.527 DEBUG 29368 --- [http-nio-127.0.0.1-5814-exec-3] ossecurity.web.FilterChainProxy
:/saml/SSO в позиции 3 из 16 в дополнительная цепь фильтра; стрельба Фильтр: 'HeaderWriterFilter' 2017-02-11 17: 13: 56.527 DEBUG 29368 --- [http-nio-127.0.0.1-5814-exec-3] ossecurity.web.FilterChainProxy
:/saml/SSO в позиции 4 из 16 в дополнительной цепи фильтра; стрельба Фильтр: 'SAMLLogoutFilter' 2017-02-11 17: 13: 56.527 DEBUG 29368 --- [http-nio-127.0.0.1-5814-exec-3] ossecurity.web.FilterChainProxy
:/saml/SSO в позиции 5 из 16 в дополнительной цепи фильтра; стрельба Фильтр: 'MetadataGeneratorFilter' 2017-02-11 17: 13: 56.527 DEBUG 29368 --- [http-nio-127.0.0.1-5814-exec-3] o.s.security.web.FilterChainProxy:/saml/SSO в позиции 6 из 16 в дополнительной цепочке фильтров; стрельба Фильтр: 'MetadataDisplayFilter' 2017-02-11 17: 13: 56.542 DEBUG 29368 --- [http-nio-127.0.0.1-5814-exec-3] ossecurity.web.FilterChainProxy:/saml/SSO на положение 7 из 16 в дополнительной цепи фильтра; стрельба Фильтр: «XhrSamlEntryPoint» 2017-02-11 17: 13: 56.542 DEBUG 29368 --- [http-nio-127.0.0.1-5814-exec-3] ossecurity.web.FilterChainProxy
:/saml/SSO в позиции 8 из 16 в дополнительной цепи фильтра; стрельба Фильтр: 'SAMLProcessingFilter' 2017-02-11 17: 13: 56.542 DEBUG 29368 --- [http-nio-127.0.0.1-5814-exec-3] ossecurity.saml.SAMLProcessingFilter: Запрос на использование процесс аутентификации 2017-02-11 17: 13: 56,542 ОТЛАДКА 29368 --- [HTTP-NiO-127.0.0.1-5814-Exec-3] ossecurity.saml.SAMLProcessingFilter: Попытка SAML2 Аутентификация с использованием профиля urn: oasis: names: tc: SAML: 2.0: profiles: SSO: браузер 2017-02-11 17: 13: 56,542 ОТЛАДКА 29368 --- [HTTP-NiO-127.0.0.1-5814-Exec-3] osssaml.processor.SAMLProcessorImpl: Получение сообщения с использованием связывания урны: оазисные: Названия: TC: SAML: 2.0 : привязки: HTTP-POST 2017-02-11 17: 13: 56.558 INFO 29368 --- [http-nio-127.0.0.1-5814-exec-3] colMessageXMLSignatureSecurityPolicyRule: сообщение протокола SAML было не подписано, пропущено Обработка подписи XML 2017-02-11 17: 13: 56.558 DEBUG 29368 --- [http-nio-127.0.0.1-5814-exec-3] ossecurity.saml.util.SAMLUtil: найденная конечная точка org.opensaml .saml2.metadata.impl.AssertionConsumerServiceImpl @ 5e73661d для запроса URL https://somesite/saml/SSO на основе атрибута местоположения в метаданных 2017-02-11 17: 13: 56.558 DEBUG 29368 --- [http-nio-127.0.0.1-5814-exec-3] ossauthentication.ProviderManager : попытка аутентификации с использованием org .springframework.security.saml.SAMLAuthenticationProvider 2017-02-11 17: 13: 56,558 ИНФО 29368 --- [HTTP-NiO-127.0.0.1-5814-Exec-3] cpksCustomWebSSOProfileConsumerImpl: Подпись vaildation опущено. 2017-02-11 17: 13: 56.558 INFO 29368 --- [http-nio-127.0.0.1-5814-exec-3] ossecurity.saml.log.SAMLDefaultLogger: AuthNResponse; SUCCESS; 127.0.0.1 ; https://somesite ;;

ответ

0

this Показаны мне путь. Причина заключалась в том, что в токене saml был атрибут NotOnOrAfter. В методе «SAMLAuthenticationProvider» «authenticate» создавал «ExpiringUsernameAuthenticationToken», срок действия которого основан на «NotOnOrAfter». То, что я сделал, - это переопределить метод getExpirationDate и увеличить срок действия токена до ожидаемого времени.

+0

Способ SAML заключается в том, чтобы отправить «пассивный AuthnRequest» до истечения срока утверждения. Если у пользователей все еще есть сеанс с IdP, IdP выдает новое утверждение. Если сеанс с IdP не должен возвращать ошибку SAML, чтобы SP мог отправить обычный AuthnRequest, который затем приведет к аутентификации в IdP. –