如何使用Shibboleth搭建IDP服务并集成OpenLDAP

时间:2022-05-06
本文章向大家介绍如何使用Shibboleth搭建IDP服务并集成OpenLDAP,主要内容包括其使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。

温馨提示:要看高清无码套图,请使用手机打开并单击图片放大查看。 Fayson的github:https://github.com/fayson/cdhproject 提示:代码块部分可以左右滑动查看噢

1.文档编写目的


在CDH集群中Clouder Manager、Cloudera Navigator、Hue、CDSW等组件支持外部身份验证的方式登录(如:Active Directory、LDAP、外部程序以及SAML),本篇文章主要介绍如何使用Shibboleth项目搭建一个基于标注SAML协议实现的IDP服务并集成OpenLDAP。

Shibboleth是一个基于标注的,实现组织内部或跨组织的网页单点登录的开源软件包。它允许站点为处于私有保护方式下的受保护的在线资源做出被通知的认证决定。Shibboleth软件工具广泛使用联合的身份标注,主要是OASIS安全声称标记语言(SAML),来提供一个联合单点登录和属性交换框架。

我们可以将Shibboleth配置为Cloudera Manager及集群组件登录的身份提供者(IDP)。

  • 内容概述

1.环境准备

2.安装Shibboleth IDP

3.部署IDP服务到Tomcat

4.总结

  • 测试环境

1.RedHat7.3

2.使用root用户操作

2.环境准备


1.访问Shibboleth官网,下载最新的IDP包,下载地址如下:

https://shibboleth.net/downloads/identity-provider/latest/shibboleth-identity-provider-3.3.2.tar.gz

(可左右滑动)

将下载的shibbolet-identity-provider-3.3.2.tar.gz文件解压到当前目录

[root@ip-172-31-21-83 ~]# tar -zxvf shibboleth-identity-provider-3.3.2.tar.gz 

(可左右滑动)

2.配置Java环境变量,这里使用的是JDK8

在/etc/profile文件末尾增加如下配置

export JAVA_HOME=/usr/java/jdk1.8.0_131
export PATH=$JAVA_HOME/bin:$PATH
export CLASSPATH=$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tool.jar:$CLASSPATH

(可左右滑动)

保存配置,执行命令使其生效

[root@ip-172-31-21-83 ~]# source /etc/profile
[root@ip-172-31-21-83 ~]# java -version

(可左右滑动)

注意:必须为JDK安装Java加密扩展(JCE)无限强度管辖策略文件,否则可能会导致加密失败问题。

3.访问Apache官网,下载Apache-Tomcat8,下载地址如下:

http://mirrors.shu.edu.cn/apache/tomcat/tomcat-8/v8.5.28/bin/apache-tomcat-8.5.28.tar.gz

(可左右滑动)

4.OpenLDAP服务信息

LdapURL

ldap://ip-172-31-21-83.ap-southeast1.compute.internal

LdapBaseDN

dc=fayson,dc=com

useSSL

false

useStartTLS

false

这里就Fayson就不在介绍如何安装OpenLDAP服务,可以参考前面的文章

《1.如何在CentOS6.5安装OpenLDAP并配置客户端》

《2.OpenLDAP集成SSH登录并使用SSSD同步用户》

《3.如何实现OpenLDAP的主主同步》

《4.如何为Hive配置OpenLDAP认证》

《5.如何为Impala配置OpenLDAP认证》

《6.如何为Hue配置OpenLDAP认证》

《7.如何在OpenLDAP中实现将一个用户添加到多个组》

3.安装Shibboleth IDP


1.进入解压好的shibboleth-identity-provider-3.3.2的bin目录下

[root@ip-172-31-21-83 ~]# cd shibboleth-identity-provider-3.3.2/bin/

(可左右滑动)

2.在命令行执行install.sh脚本

[root@ip-172-31-21-83 bin]# ./install.sh 
Source (Distribution) Directory (press <enter> to accept default): [/root/shibboleth-identity-provider-3.3.2]
Installation Directory: [/opt/shibboleth-idp]
/opt/shibboleth-idp
Hostname: [ip-172-31-21-83.ap-southeast-1.compute.internal]
ip-172-31-21-83.ap-southeast-1.compute.internal
SAML EntityID: [https://ip-172-31-21-83.ap-southeast-1.compute.internal/idp/shibboleth]
https://ip-172-31-21-83.ap-southeast-1.compute.internal/idp/shibboleth
Attribute Scope: [ap-southeast-1.compute.internal]
ap-southeast-1.compute.internal
Backchannel PKCS12 Password: 
Re-enter password: 
Cookie Encryption Key Password: 
Re-enter password: 
Warning: /opt/shibboleth-idp/bin does not exist.
Warning: /opt/shibboleth-idp/dist does not exist.
Warning: /opt/shibboleth-idp/doc does not exist.
Warning: /opt/shibboleth-idp/system does not exist.
Warning: /opt/shibboleth-idp/webapp does not exist.
Generating Signing Key, CN = ip-172-31-21-83.ap-southeast-1.compute.internal URI = https://ip-172-31-21-83.ap-southeast-1.compute.internal/idp/shibboleth ...
...done
Creating Encryption Key, CN = ip-172-31-21-83.ap-southeast-1.compute.internal URI = https://ip-172-31-21-83.ap-southeast-1.compute.internal/idp/shibboleth ...
...done
Creating Backchannel keystore, CN = ip-172-31-21-83.ap-southeast-1.compute.internal URI = https://ip-172-31-21-83.ap-southeast-1.compute.internal/idp/shibboleth ...
...done
Creating cookie encryption key files...
...done
Rebuilding /opt/shibboleth-idp/war/idp.war ...
...done
BUILD SUCCESSFUL
Total time: 58 seconds
[root@ip-172-31-21-83 bin]# 

(可左右滑动)

在安装的过程中,需要输入安装目录(默认安装目录为/opt/shibboleth-idp)、Hostname、SAML EntityID及产生秘钥文件的密码。

3.安装成功后在/opt/shibboleth-idp目录下可以看到安装的目录及文件

[root@ip-172-31-21-83 bin]# cd /opt/shibboleth-idp/
[root@ip-172-31-21-83 shibboleth-idp]# ll

(可左右滑动)

4.部署IDP服务到Tomcat中


IDP服务部署支持的容器有Jetty、Tomcat等,这里我们使用Tomcat部署IDP服务。

1.将下载好的apache-tomcat-8.5.28.tar.gz包解压至/opt/目录下

[root@ip-172-31-21-83 ~]# tar -zxvf apache-tomcat-8.5.28.tar.gz  -C /opt/

(可左右滑动)

2.在/opt/apache-tomcat-8.5.28/conf/Catalina/localhost目录下新增idp.xml配置文件,内容如下

<Context docBase="/opt/shibboleth-idp/war/idp.war"
         privileged="true"
         antiResourceLocking="false"
         swallowOutput="true">
  <!-- Work around lack of Max-Age support in IE/Edge -->
  <CookieProcessor alwaysAddExpires="true" />
</Context>

(可左右滑动)

3.修改/opt/apache-tomcat-8.5.28/conf/server.xml文件中Tomcat端口为80和443

<Connector port="80" protocol="HTTP/1.1"
           connectionTimeout="20000"
           redirectPort="443" />

(可左右滑动)

4.安装JSTL依赖包

由于Tomcat默认是不支持Java Server Tag Library库,所以我们需要在Shibboleth工程中添加JSTL的依赖包,依赖包下载地址如下:

https://build.shibboleth.net/nexus/service/local/repositories/thirdparty/content/javax/servlet/jstl/1.2/jstl-1.2.jar

(可左右滑动)

将上述依赖包下载至/opt/shibboleth-idp/edit-webapp/WEB-INF/lib/目录下

在/opt/shibboleth-idp/bin目录下执行如下命令重新build idp服务

[root@ip-172-31-21-83 ~]# cd /opt/shibboleth-idp/bin/
[root@ip-172-31-21-83 bin]# ./build.sh 

(可左右滑动)

5.启动Tomcat服务

进入/opt/apache-tomcat-8.5.28/bin目录下执行如下命令启动Tomcat服务

[root@ip-172-31-21-83 ~]# cd /opt/apache-tomcat-8.5.28/bin/
[root@ip-172-31-21-83 bin]# sh startup.sh 

(可左右滑动)

检查Tomcat是否启动成功,在浏览器输入http://ip-172-31-21-83.ap-southeast-1.compute.internal/

在命令行执行如下名,检查IDP服务是否正常

[root@ip-172-31-21-83 bin]# /opt/shibboleth-idp/bin/status.sh 

(可左右滑动)

至此就完成了IDP服务的部署,更多信息可以参考https://wiki.shibboleth.net/confluence/display/IDP30/ApacheTomcat8

5.配置Shibboleth连接LDAP


1.修改/opt/shibboleth-idp/conf/ldap.properties配置,需要修改的配置如下

idp.authn.LDAP.ldapURL = ldap://ip-172-31-21-83.ap-southeast1.compute.internal
idp.authn.LDAP.useStartTLS = false
idp.authn.LDAP.useSSL = false
idp.authn.LDAP.baseDN = ou=people,dc=fayson,dc=com
idp.authn.LDAP.bindDN = cn=Manager,dc=fayson,dc=com
idp.authn.LDAP.bindDNCredential = 123456
idp.authn.LDAP.dnFormat = uid=%s,ou=people,dc=fayson,dc=com

(可左右滑动)

2.重新build IDP服务

[root@ip-172-31-21-83 bin]# ./build.sh 

(可左右滑动)

重启Tomcat服务

[root@ip-172-31-21-83 bin]# /opt/apache-tomcat-8.5.28/bin/shutdown.sh
[root@ip-172-31-21-83 bin]# /opt/apache-tomcat-8.5.28/bin/startup.sh

(可左右滑动)

到此就完成了Shibboleth与LDAP集成。

6.总结


本篇文章只讲述了如何安装Shibboleth IDP服务及将IDP服务部署至Tomcat,服务可正常运行,但未配置后端用户验证方式,在接下来的文章Fayson会介绍如何使用SAML配置Cloudera Manager的身份验证。

  • 在安装JDK时必须为JDK安装Java加密扩展(JCE)无限强度管辖策略文件

提示:代码块部分可以左右滑动查看噢 为天地立心,为生民立命,为往圣继绝学,为万世开太平。 温馨提示:要看高清无码套图,请使用手机打开并单击图片放大查看。

推荐关注Hadoop实操,第一时间,分享更多Hadoop干货,欢迎转发和分享。

原创文章,欢迎转载,转载请注明:转载自微信公众号Hadoop实操