參考文章:
html
http://my.oschina.net/indestiny/blog/200768#comments
java
http://wenku.baidu.com/view/0bcc0d01e87101f69e319595.htmlgit
SSO原理很少反覆,需要理解的就一點,一個複雜系統需要一個惟一的驗證服務。github
這就是CAS(Central Authentication Service) Server。web
系統內的各類服務(Web站點)apache
可以做爲CAS Server的client,CAS Client。而用戶訪問的服務事實上就是這些ubuntu
CAS Client。一個典型的支持SSO的Web站點例如如下圖:瀏覽器
Browser--------->B服務器:WebServer(CAS Client)=======>A服務器:CAS SERVERtomcat
如下第一步就是搭建這個CAS SERVER。利用開源碼jasig cas來實現SSO的服務服務器
器。jasig cas是一套現成的代碼,首先是瞭解它。而後才幹定製它。如下全部內容在A服務器上
運行,服務器: RHEL6.4。
cas sso服務端配置. sso服務器:
IP: 192.168.1.142
hostname: ubuntu64
tomcat 8
java 7
http://downloads.jasig.org/cas/cas-server-4.0.0-release.tar.gz
或者(不需要):
$ git clone https://github.com/Jasig/cas/tree/v4.0.0-RC3
$ keytool -genkey -alias ssotest -keyalg RSA
Enter keystore password: 123456
Re-enter new password: 123456
What is your first and last name?
[Unknown]: ubuntu64
What is the name of your organizational unit?
[Unknown]: dev
What is the name of your organization?
[Unknown]: pepstack.com
What is the name of your City or Locality?
[Unknown]: SHA
What is the name of your State or Province?
[Unknown]: SHA
What is the two-letter country code for this unit?
[Unknown]: CN
Is CN=ubuntu64, OU=dev, O=pepstack.com, L=SHA, ST=SHA, C=CN correct?
[no]: yes
生成文件:
~/.keystore
$ keytool -export -file ~/ssotest.crt -alias ssotest -keystore ~/.keystore
Enter keystore password:123456
Certificate stored in file </home/cl/ssotest.crt>
ssotest.crt 將要部署在client的jre環境中,本文中暫未使用。
添加如下的段落:
<!-- Define a SSL/TLS HTTP/1.1 Connector on port 8443 This connector uses the NIO implementation that requires the JSSE style configuration. When using the APR/native implementation, the OpenSSL style configuration is required as described in the APR/native documentation --> <!-- https --> <Connector port="8443" protocol="org.apache.coyote.http11.Http11NioProtocol" maxThreads="150" SSLEnabled="true" scheme="https" secure="true" clientAuth="false" sslProtocol="TLS" URIEncoding="UTF-8" keystoreFile="/root/.keystore" keystorePass="123456" sslEnabledProtocols="TLSv1,TLSv1.1,TLSv1.2" ciphers="TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA, TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384, TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA, TLS_ECDHE_RSA_WITH_RC4_128_SHA, TLS_RSA_WITH_AES_128_CBC_SHA256, TLS_RSA_WITH_AES_128_CBC_SHA, TLS_RSA_WITH_AES_256_CBC_SHA256, TLS_RSA_WITH_AES_256_CBC_SHA, SSL_RSA_WITH_RC4_128_SHA" />
解壓:cas-server-4.0.0-release.tar.gz
將modules/cas-server-webapp-4.0.0.war更名爲cas.war,
拷貝到${TOMCAT_HOME}/webapps/下.
${TOMCAT_HOME}/webapps/cas.war
啓動tomcat,這時打開瀏覽器, 進入如下的地址,如圖:
https://192.168.1.142:8443/cas/
服務端已經配置ok!
登陸名在如下文件裏找到:deployerConfigContext.xml
<!--
| Authentication handler beans
-->
<bean id="acceptUsersAuthenticationHandler"
class="org.jasig.cas.authentication.AcceptUsersAuthenticationHandler">
<property name="users">
<map>
<entry key="casuser" value="Mellon"/>
</map>
</property>
</bean>
casuser/Mellon