Shibboleth是一个针对SSO的开源项目,主要应用在高校之间的Web资源共享与访问控制,以及校园间的应用系统的用户身份联合认证。2006年 12月,由北京大学执行的CARSI项目即是在国内高校之间部署Shibboleth,隶属于国家863计划,目前已经有清华大学、北京邮电大学、中国电 子科技大学、华南理工大学等陆续加入,建立了CARSI-Fed(也称为CERNET-Fed),其目标是最终实现中国教育科研网内跨机构用户统一身份认 证、共享资源访问授权和审计系统。更多的详细信息可以参考:http://carsi.edu.cn/
宁波诺丁汉大学作为英国诺丁汉大学在中国的分校区,此次部署Shibboleth IdP的目的是为了加入UK Access Management Federation。
整个安装过程记录如下:
从官方网站http://www.internet2.edu 下载IdP安装文件,解开压缩包
[root@idp ~]# cd /export/home
[root@idp ~]# jar -xf shibboleth-identityprovider-2.1.5-bin.zip
需要复制一些jar文件至tomcat程序目录
[root@idp shibboleth-identityprovider-2.1.5]# cp – rf /export/home / shibboleth-identityprovider-2.1.5 / endorsed / /usr/local/apache-tomcat-6.0.18/
`/root/shibboleth-identityprovider-2.1.5/endorsed/resolver-2.9.1.jar' -> `endorsed/resolver-2.9.1.jar'
`/root/shibboleth-identityprovider-2.1.5/endorsed/serializer-2.9.1.jar' -> `endorsed/serializer-2.9.1.jar'
`/root/shibboleth-identityprovider-2.1.5/endorsed/xalan-2.7.1.jar' -> `endorsed/xalan-2.7.1.jar'
`/root/shibboleth-identityprovider-2.1.5/endorsed/xercesImpl-2.9.1.jar' -> `endorsed/xercesImpl-2.9.1.jar'
`/root/shibboleth-identityprovider-2.1.5/endorsed/xml-apis-2.9.1.jar' -> `endorsed/xml-apis-2.9.1.jar'
现在可以开始安装shibboleth IdP
[root@idp shibboleth-identityprovider-2.1.5]# cd /export/home / shibboleth-identityprovider-2.1.5
[root@idp shibboleth-identityprovider-2.1.5]# chmod a+x install.sh
[root@idp shibboleth-identityprovider-2.1.5]# ./install.sh
Buildfile: src/installer/resources/build.xml
install:
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Be sure you have read the installation/upgrade instructions on the Shibboleth website before proceeding.
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Where should the Shibboleth Identity Provider software be installed? [/opt/shibboleth-idp]
/opt/shibboleth-idp
What is the fully qualified hostname of the Shibboleth Identity Provider server? [idp.example.org]
idp.nottingham.edu.cn
A keystore is about to be generated for you. Please enter a password that will be used to protect it.
******** (为生成数字证书设置密码保护)
Updating property file: /root/shibboleth-identityprovider-2.1.5/src/installer/resources/install.properties
Created dir: /opt/shibboleth-idp
Created dir: /opt/shibboleth-idp/bin
Created dir: /opt/shibboleth-idp/conf
Created dir: /opt/shibboleth-idp/credentials
Created dir: /opt/shibboleth-idp/lib
Created dir: /opt/shibboleth-idp/lib/endorsed
Created dir: /opt/shibboleth-idp/logs
Created dir: /opt/shibboleth-idp/metadata
Created dir: /opt/shibboleth-idp/war
Generating signing and encryption key, certificate, and keystore.
Copying 5 files to /opt/shibboleth-idp/bin
Copying 8 files to /opt/shibboleth-idp/conf
Copying 1 file to /opt/shibboleth-idp/metadata
Copying 49 files to /opt/shibboleth-idp/lib
Copying 5 files to /opt/shibboleth-idp/lib/endorsed
Copying 1 file to /root/shibboleth-identityprovider-2.1.5/src/installer
Building war: /root/shibboleth-identityprovider-2.1.5/src/installer/idp.war
Copying 1 file to /opt/shibboleth-idp/war
Deleting: /root/shibboleth-identityprovider-2.1.5/src/installer/web.xml
Deleting: /root/shibboleth-identityprovider-2.1.5/src/installer/idp.war
BUILD SUCCESSFUL
Total time: 1 minute 5 seconds
至此安装程序执行成功。为配合tomcat顺利运行,进一步设置如下:
将shibboleth IdP运行日志文件链接至/var/log目录,方便管理查看
引用
[root@idp shibboleth-identityprovider-2.1.5]# ln -s /opt/shibboleth-idp/logs /var/log/shibboleth
调整一大堆文件权限,当tomcat以普通用户启动时可以顺利运行shibboleth
引用
[root@idp shibboleth-identityprovider-2.1.5]# cd /opt/shibboleth-idp/
[root@idp shibboleth-idp]# chown -R root logs metadata credentials
[root@idp shibboleth-idp]# chmod 755 logs metadata
[root@idp shibboleth-idp]# chown root conf/attribute-filter.xml
[root@idp shibboleth-idp]# chown -R root /usr/local/apache-tomcat-6.0.18/endorsed/
[root@idp shibboleth-idp]# chmod 660 conf/attribute-filter.xml
[root@idp shibboleth-idp]# cd credentials/
[root@idp credentials]# chown root : root idp.key
[root@idp credentials]# chgrp root idp.{key,crt}
[root@idp credentials]# chmod 440 idp.key
[root@idp credentials]# chmod 644 idp.crt
(下面浅色的这段不用看了)
根据官方的建议,最好是为war文件手动建立配置,这样虽然麻烦一点,但是比较直接复制war至webapps目录更便于以后管理维护。在/usr/local/apache-tomcat-6.0.18/conf/Catalina/localhost/目录下面创建idp.xml文件,写入以下内容:
docBase="/opt/shibboleth-idp/war/idp.war"
privileged="true"
antiResourceLocking="false"
antiJARLocking="false"
unpackWAR="false" />
编辑java安全配置文件,加入由internet2提供的shibboleth中间件。打开 /usr/java/jdk1.5.0/jre/lib/security/java.security 文件,在security.provider列表后面加入
security.provider.#=edu.internet2.middleware.shibboleth.DelegateToApplicationProvider
其中的#应更改为上一条记录中的对应数值加1。
编辑tomcat主配置文件,添加一段开启8443端口的配置信息:
[root@idp credentials]# vi /usr/local/apache-tomcat-6.0.18/conf/server.xml
<Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true"
maxThreads="150"
scheme="https"
secure="true"
clientAuth=" false "
sslProtocol="TLS"
sslImplementation="edu.internet2.middleware.shibboleth.tomcat.DelegateToApplicationJSSEImplementation"
keystoreFile="/opt/shibboleth-idp/credentials/idp.jks"
keystorePass="123456" />
将IPD_HOME更换为shibboleth IdP安装目录,PASSWORD更改为安装时设置的证书保护密码。
接下来要做的工作就是为服务器申请一张正式的数字证书,在购买之前最好查看一下即将加入的Fedoration网站上的相关说明,UK Access Management Federation可以支持Versign, GlobalSign等。
这里可以先自己生成一张证书做为测试使用:
[root@idp credentials]# cd /opt/shibboleth-idp/credentials
[root@idp pki]# openssl req -new -x509 -nodes -out shibidp.crt -keyout shibidp.key
Generating a 1024 bit RSA private key
........++++++
..........................++++++
writing new private key to 'shibidp.key'
-----
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [GB]: CN
State or Province Name (full name) [Berkshire]: Zhejiang
Locality Name (eg, city) [Newbury]: Ningbo
Organization Name (eg, company) [My Company Ltd]: The University of Nottingham Ningbo, China
Organizational Unit Name (eg, section) []: Information Services
Common Name (eg, your name or your server's hostname) []: idp.nottingham.edu.cn
Email Address []: [email protected]
编辑apache ssl配置文件 /etc/httpd/conf.d/ssl.conf ,启用刚才生成的数字证书。
# Server Certificate: # Point SSLCertificateFile at a PEM encoded certificate. If # the certificate is encrypted, then you will be prompted for a # pass phrase. Note that a kill -HUP will prompt again. A test # certificate can be generated with `make certificate' under # built time. Keep in mind that if you've both a RSA and a DSA # certificate you can configure both in parallel (to also allow # the use of DSA ciphers, etc.) SSLCertificateFile /etc/httpd/conf/ssl.crt/server.crt SSLCertificateFile /opt/shibboleth-idp/credentials/shibidp.crt #SSLCertificateFile /etc/httpd/conf/ssl.crt/server-dsa.crt
# Server Private Key: # If the key is not combined with the certificate, use this # directive to point at the key file. Keep in mind that if # you've both a RSA and a DSA private key you can configure # both in parallel (to also allow the use of DSA ciphers, etc.) SSLCertificateKeyFile /etc/httpd/conf/ssl.key/server.key SSLCertificateKeyFile /opt/shibboleth-idp/credentials/shibidp.key #SSLCertificateKeyFile /etc/httpd/conf/ssl.key/server-dsa.key |
重新启动tomcat, Apache,注意先后顺序
(下面浅色的这段不用看了)
[root@idp credentials]# service tomcat restart
Stopping /usr/local/apache-tomcat-6.0.18/bin/catalina.sh:
Using CATALINA_BASE: /usr/local/apache-tomcat-6.0.18
Using CATALINA_HOME: /usr/local/apache-tomcat-6.0.18
Using CATALINA_TMPDIR: /usr/local/apache-tomcat-6.0.18/temp
Using JRE_HOME: /usr/lib/jvm/java/
waiting for processes to exit
waiting for processes to exit
Starting /usr/local/apache-tomcat-6.0.18/bin/catalina.sh:
Using CATALINA_BASE: /usr/local/apache-tomcat-6.0.18
Using CATALINA_HOME: /usr/local/apache-tomcat-6.0.18
Using CATALINA_TMPDIR: /usr/local/apache-tomcat-6.0.18/temp
Using JRE_HOME: /usr/lib/jvm/java/
[root@idp credentials]# service httpd restart
Stopping httpd: [ OK ]
Starting httpd: [ OK ]
拷贝idp.war文件到tomcat应用目录下
[root@idp credentials]# cp – rf /opt/shibboleth-idp/war /idp.war /usr/local/apache-tomcat-6.0.18/webapps
启动tomcat服务器
[root@idp credentials]# cd /usr/local/apache-tomcat-6.0.18/bin
[root@idp bin ]# ./startup.sh
查看服务器运行状态:
[root@idp credentials]# links http:// localhost :8080/idp/profile/Status
由于默认的安全性设置,该页面只能在服务器上以访问localhost 方式查看,否则会给予 401 错误。
在浏览器也可测试:用链接 https://ssoldap.zju.edu.cn:8443/idp/profile/Status (或 http://ssoldap.zju.edu.cn:8 080 /idp/profile/Status )后,能显示ok就表示安装好了。