JASIG CAS - 每个用户帐户只允许一个会话
JASIG CAS - Allow only one session per user account
在 JASIG CAS 作为身份验证服务器的帮助下,我们在我们的应用程序中取得了 "Single Sign On"。
现在我们需要一个设置,其中每个用户只能在 CAS 中创建一个 session/ticket。
如果用户尝试从其他 system/browser 登录,CAS 将使该用户的当前票证无效,并从之前的 session/browser.
注销 him/her
我终于找到了解决问题的办法。希望对其他人有帮助。
Jasig Cas 本身使用内存映射来跟踪分配给用户的票证。我正在使用类似的方法来实现要求:-
为了实现功能,在项目中添加了一些额外的功能。变更如下:-
"SingleSesionTicketRegistry" class 的实现将会话票作为默认行为维护在地图中,但是如果地图中已经有用户的票,则注册表将使之前的会话无效。
修改 Cas 配置以使用 Mysql 数据库进行身份验证,密码为 MD5 哈希。
- 修改 Cas 配置以使用自定义 Ticket Registry 而不是默认的 Ticket Registry。
以下是必须在项目中完成的配置更改:- 1. src/main/resources/application.properties
#Toggle the feature if Single Session.
is.single.sesion.per.user=true
#MySQL query to check the authentication.
user.authentication.sql=select password from user where email=? and is_active=1
/src/main/webapp/WEB-INF/spring-configuration/ticketRegistry.xml
<!--Comment the default ticket regitry. -->
<!-- <bean id="ticketRegistry" class="org.jasig.cas.ticket.registry.DefaultTicketRegistry" /> -->
<!--Add the custom ticket regitry. -->
<bean id="ticketRegistry" class="com.naval.cas.SingleSesionTicketRegistry"
p:isSingleSesionPerUser="${is.single.sesion.per.user}"
p:logoutManager-ref="logoutManager"/>
/src/main/webapp/WEB-INF/deployerConfigContext.xml
<!--Add the Following code block -->
<bean id="passwordEncoder"
class="org.jasig.cas.authentication.handler.DefaultPasswordEncoder"
c:encodingAlgorithm="MD5"
p:characterEncoding="UTF-8" />
<bean id="primaryAuthenticationHandler"
class="org.jasig.cas.adaptors.jdbc.QueryDatabaseAuthenticationHandler"
p:dataSource-ref="dataSource"
p:passwordEncoder-ref="passwordEncoder"
p:sql="${user.authentication.sql}" />
可以在下面的 github 存储库中找到单会话票证注册表 Class。
在 JASIG CAS 作为身份验证服务器的帮助下,我们在我们的应用程序中取得了 "Single Sign On"。
现在我们需要一个设置,其中每个用户只能在 CAS 中创建一个 session/ticket。
如果用户尝试从其他 system/browser 登录,CAS 将使该用户的当前票证无效,并从之前的 session/browser.
注销 him/her我终于找到了解决问题的办法。希望对其他人有帮助。
Jasig Cas 本身使用内存映射来跟踪分配给用户的票证。我正在使用类似的方法来实现要求:-
为了实现功能,在项目中添加了一些额外的功能。变更如下:-
"SingleSesionTicketRegistry" class 的实现将会话票作为默认行为维护在地图中,但是如果地图中已经有用户的票,则注册表将使之前的会话无效。
修改 Cas 配置以使用 Mysql 数据库进行身份验证,密码为 MD5 哈希。
- 修改 Cas 配置以使用自定义 Ticket Registry 而不是默认的 Ticket Registry。
以下是必须在项目中完成的配置更改:- 1. src/main/resources/application.properties
#Toggle the feature if Single Session.
is.single.sesion.per.user=true
#MySQL query to check the authentication.
user.authentication.sql=select password from user where email=? and is_active=1
/src/main/webapp/WEB-INF/spring-configuration/ticketRegistry.xml
<!--Comment the default ticket regitry. -->
<!-- <bean id="ticketRegistry" class="org.jasig.cas.ticket.registry.DefaultTicketRegistry" /> -->
<!--Add the custom ticket regitry. -->
<bean id="ticketRegistry" class="com.naval.cas.SingleSesionTicketRegistry"
p:isSingleSesionPerUser="${is.single.sesion.per.user}"
p:logoutManager-ref="logoutManager"/>
/src/main/webapp/WEB-INF/deployerConfigContext.xml
<!--Add the Following code block -->
<bean id="passwordEncoder"
class="org.jasig.cas.authentication.handler.DefaultPasswordEncoder"
c:encodingAlgorithm="MD5"
p:characterEncoding="UTF-8" />
<bean id="primaryAuthenticationHandler"
class="org.jasig.cas.adaptors.jdbc.QueryDatabaseAuthenticationHandler"
p:dataSource-ref="dataSource"
p:passwordEncoder-ref="passwordEncoder"
p:sql="${user.authentication.sql}" />
可以在下面的 github 存储库中找到单会话票证注册表 Class。