spring security登入人數限制並且同一個帳號可以踢掉前一個使用者設定檔

來源:互聯網
上載者:User

標籤:設定   current   注入   maximums   exce   position   class   sas   property   

一、限制使用者登入數和session自動裝載

  1.maximumSessions:限制登入人數

  2.exceptionIfMaximumExceeded:

    • 為true同一賬戶只能登入一次,
    • 為false同一賬戶可以登入多次如果配置了org.springframework.security.web.session.ConcurrentSessionFilter則會踢出前一個登入的session

  3.sessionRegistry配置session管理

  4.concurrentSessionFilter如果不配置這個則踢不出上一個登入的session,會一個賬戶可以登入多次

<bean id="sas" class="org.springframework.security.web.authentication.session.ConcurrentSessionControlStrategy">  <property name="maximumSessions" value="1"/><property name="exceptionIfMaximumExceeded" value="false"></property> <constructor-arg>  <ref bean="sessionRegistry"/></constructor-arg></bean><bean id="sessionRegistry" class="org.springframework.security.core.session.SessionRegistryImpl"></bean> <bean id="concurrentSessionFilter"  class="org.springframework.security.web.session.ConcurrentSessionFilter">  <property name="sessionRegistry" ref="sessionRegistry"/></bean>

  

二、將配置好的bean進行注入

  將上述的bean設定好通過下述方式配置好即可

<s:http access-denied-page="/403.jsp" auto-config=‘true‘>  <s:session-management invalid-session-url="/login.jsp" session-authentication-strategy-ref="sas"/>  <s:custom-filter position="CONCURRENT_SESSION_FILTER" ref="concurrentSessionFilter" /> </s:http>

  

三、另附思路啟發參考網頁

http://www.mossle.com/docs/auth/html/ch214-smart-concurrent.html

 

spring security登入人數限制並且同一個帳號可以踢掉前一個使用者設定檔

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.