- 修改Tomcat conf/server.xml 打開SSO支持
<Host> 節點下增加一個Value節點
<Valve className=
debug= requireReauthentication=/>
</Host>
- container認證realm: user、role、server.xml的<Realm...>設置.
- user 是區別一個個用戶的唯一識別了。
- role 就是一些抽象的權限級別,比如“admin”、“manager”、“member”、“guest”等等,都是可以自己定義的.一個user可以擁有多種role.
<Realm className= debug= driverName= connectionURL= connectionName= connectionPassword= userTable= userNameCol= userCredCol= userRoleTable= roleNameCol= />
- webapp使用SSO:
- 告訴tomcat這個webapp要通過container的認證
具體做法: 在web.xml裏面加上如下的配置: <security-constraint> <web-resource-collection> <web-resource-name>Protected Webapp Example</web-resource-name> <url-pattern>/*</url-pattern> </web-resource-collection> <auth-constraint> <!-- role name 指定哪個role可以訪問,可以爲多個role --> <role-name>intrauser</role-name> </auth-constraint> </security-constraint>
- 選擇一種認證方法
在web.xml裏面加上如下的配置: <login-config> <auth-method>BASIC</auth-method> <realm-name>Intra Web Application</realm-name> </login-config> <security-role> <description>The role that is required to access intrasites</description> <role-name>intrauser</role-name> </security-role>
- auth-method
- realm-name
- 如何取得當前的User信息
userid = request.gerRemoteUser();
以上是在一個Tomcat Container上的SSO實現.
如果是不同的Container上的webapp要做SSO,這種時候一種可行的方案是,最前面架一個webserver(比如apache),在webserver這層承擔SSO的認證任務,後面內部就可用掛多個container了. 具體都用到的時候再調查吧.