Spring Security Concurrency Control

Nandkumar Tekale :

I have used spring security 3.0.7 and I am implementing concurrency control in my project. But it is not working. I have used

<security:session-management>
            <security:concurrency-control error-if-maximum-exceeded="true" max-sessions="1"/>
</security:session-management>

Even I tried solution from spring security reference but it didn't work out. Here is my configuration file content :

  <session-management session-authentication-strategy-ref="sas"/>
</http>

<beans:bean id="concurrencyFilter"
   class="org.springframework.security.web.session.ConcurrentSessionFilter">
  <beans:property name="sessionRegistry" ref="sessionRegistry" />
  <beans:property name="expiredUrl" value="/session-expired.htm" />
</beans:bean>

<beans:bean id="myAuthFilter" class=
   "org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter">
  <beans:property name="sessionAuthenticationStrategy" ref="sas" />
  <beans:property name="authenticationManager" ref="authenticationManager" />
</beans:bean>

<beans:bean id="sas" class=
 "org.springframework.security.web.authentication.session.ConcurrentSessionControlStrategy">
  <beans:constructor-arg name="sessionRegistry" ref="sessionRegistry" />
  <beans:property name="maximumSessions" value="1" />
</beans:bean>

<beans:bean id="sessionRegistry"
    class="org.springframework.security.core.session.SessionRegistryImpl" />

I am getting following exception :

org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Filter beans '<myAuthFilter>' and '<org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter#0>' have the same 'order' value. When using custom filters, please make sure the positions do not conflict with default filters. Alternatively you can disable the default filters by removing the corresponding child elements from <http> and avoiding the use of <http auto-config='true'>.
Offending resource: class path resource [config/auth.xml]
    at org.springframework.beans.factory.parsing.FailFastProblemReporter.error(FailFastProblemReporter.java:68)
    at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:85)
    at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:72)
    at org.springframework.security.config.http.HttpSecurityBeanDefinitionParser.checkFilterChainOrder(HttpSecurityBeanDefinitionParser.java:196)
    at org.springframework.security.config.http.HttpSecurityBeanDefinitionParser.parse(HttpSecurityBeanDefinitionParser.java:132)
    at org.springframework.security.config.SecurityNamespaceHandler.parse(SecurityNamespaceHandler.java:86)
    at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1338)
    at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1328)
    at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:135)
    at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.registerBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:93)
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registerBeanDefinitions(XmlBeanDefinitionReader.java:493)
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:390)

Can anyone help with this question?

Nandkumar Tekale :

If you have written UserPrincipal and UserPrincipalImpl(your own implementation), you should override Object's equals() and hashCode() methods.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Spring security concurrency control with custom UsernamePasswordAuthenticationFilter

Spring Security session concurrency

Spring Security Concurrent Session Control

Spring security RESTful path based role control

Spring Security Expression Baed Access Control with JwtAuthenticationToken

Concurrency control in REST APIs

JavaFX - Control and Concurrency

Distributed Concurrency Control

Optimistic concurrency control clarification

Spring security control access - same page but with different parameter id

spring security - how to remove cache control in certain url pattern

Spring Security 5, No "Access Control Allow Origin" Header present on resource

Spring MVC: Validation, Post-Redirect-Get, Partial Updates, Optimistic Concurrency, Field Security

How to control sidekiq queues concurrency

Java Concurrency control multiple locks

MongoDB Optimistic Concurrency Control With .NET

Optimistic concurrency control and write skew

Spring @KafkaListener and concurrency

Spring Integration Concurrency of ServiceActivators

Spring StopWatch concurrency

Spring @Transactional and concurrency

Spring Cloud Stream - Concurrency

Spring Concurrency parallel request

Spring Security

ReportViewer Control Parameter Security

Spring Boot Security No 'Access-Control-Allow-Origin' header is present on the requested resource Error

Spring Boot + Security: No Access-Control-Allow-Origin header when setting allowed origins

CORS Spring Security configuration - 404 No 'Access-Control-Allow-Origin' header is present on the requested resource

How to properly use channels to control concurrency?