Liferay 的单点登录绝对是个难啃的骨头,更何况网上能搜到的基本都是些滥竽充数的文章,很不负责任。

于是在自己搭通单点登录一条线之后,决定整理下思路并写出来,希望各位能别重蹈覆辙。

本文不介绍概念。仅仅注重实现

软件版本号:

Liferay : 6.1.1 CE GA2
OpenLdap for Windows :openldap-2.4.38-x86
Apache Directory Studio : Apache Directory Studio 2.0.0-M3
CAS : cas-server-3.5.2
Windows : 7 x64

第一篇 OpenLDAP

不再讲述 LDAP 概念,仅仅需知道 OpenLDAP 是 LDAP 协议的几个主流实现之中的一个,重点是介绍怎样在 windows 平台上安装和配置 OpenLDAP。

下载

openLDAP官方站点:http://www.openldap.org/

openLDAP官网仅仅提供了linux平台的相关安装文件,windows平台的安装包能够到下面一些站点下载:

http://www.userbooster.de/download/openldap-for-windows.aspx

http://sourceforge.jp/projects/openldapwin32/releases/

http://sourceforge.net/projects/openldapwindows/files/

http://sourceforge.net/projects/openldapwindows/(本文所用的版本号)



以上四个地址中第一个安装完毕之后 LDAP server 启动总是异常,并没有详细分析原因,直接卸载安装最后一个链接中的版本号,好使。

安装

watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvUGFyYW5vaWRfQW5kcm9pZA==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast" alt="">


一路点击 next 就可以,注意默认的 backend engine 为 BDB,意思也就是 LDAP 使用 BDB 存储数据,能够依据需求自行配置如 SQL Server 等。

安装完毕之后找到安装路径下的E:\OpenLDAP\etc\openldap。打开slapd.conf,替换整个内容为

include   ../etc/openldap/schema/core.schema
include ../etc/openldap/schema/cosine.schema
include ../etc/openldap/schema/inetorgperson.schema pidfile ../var/run/slapd.pid loglevel -1 moduleload back_bdb.la database bdb
suffix "dc=example, dc=com" rootdn "cn=jimbob, dc=example, dc=com"
rootpw dirtysecret directory ../var/openldap-data # Indices to maintain for this directory
# unique id so equality match only
index uid eq
# allows general searching on commonname, givenname and email
index cn,gn,mail eq,sub
# allows multiple variants on surname searching
index sn eq,sub
# sub above includes subintial,subany,subfinal
# optimise department searches
index ou eq
# if searches will include objectClass uncomment following
# index objectClass eq
# shows use of default index parameter
index default eq,sub
# indices missing - uses default eq,sub
index telephonenumber # other database parameters
# read more in slapd.conf reference section
cachesize 10000
checkpoint 128 15

当中



suffix "dc=example, dc=com"
能够理解为整个 LDAP 的跟文件夹地址。能够自行配置

rootdn "cn=jimbob, dc=example, dc=com" rootpw dirtysecret
管理员用户的 DN 以及password,能够自行配置

directory       ../var/openldap-data
LDAP 数据库文件夹


至于其它參数我临时也不关心是什么意思。

启动 LDAP server

这个安装版本号中。不须要通过命令行启动,開始菜单里找到 OpenLDAP。并启动



看到例如以下内容就算是启动成功了



一般教程到这里都会提示须要新建个 .ldif 文件,用来加入用户或者组织,事实上刚開始大可不必纠结于这个文件以及里面的语法。由于全然能够使用 LDAP 可视化工具完毕相同的工作。

但毕竟写文档。这部分还是得写。

LDIF 文件

DIT 结构 – 例如以下图,能够理解为LDAP 的结构文件夹,就比方 Java Web应用的文件夹。



在E:\OpenLDAP 文件夹创建demo.ldif 文件。粘贴下面的 内容,用来创建 DIT 结构。并加入用户

dn: dc=example,dc=com
dc: example
description: text whatever you want for description
objectClass: dcObject
objectClass: organization
o: Example, Inc. dn: ou=people, dc=example,dc=com
ou: people
description: All people in organisation
objectclass: organizationalunit dn: cn=Robert Smith,ou=people,dc=example,dc=com
objectclass: inetOrgPerson
cn: Robert Smith
sn: smith
uid: rjsmith
userpassword: rJsmitH
mail: rsmith@example.com
description: swell guy
ou: Human Resources

在E:\OpenLDAP\bin文件夹下输入下面指令用来导入 LDIF 文件。为什么要到这个文件夹。由于这个文件夹底下有ldapadd.exe,不然使用 ldapadd 指令会提示提示:’ldapadd’ 不是内部或外部命令。也不是可执行的程序或批处理文件

ldapadd -x -D "cn=jimbob,dc=example,dc=com" -f ./mydemo.ldif -w dirtysecret

接下来通过下面search 指令确认是否导入成功

ldapsearch -x -b "dc=example,dc=com" "(objectclass=*)"

LDAP client Apache Directory Studio

LDAP 有多种client,本文使用的是Apache Directory Studio,没什么特别原因,就是认为 Apache 相对照较亲切一点。

下载地址 :http://directory.apache.org/studio/downloads.html

下载最新版的就可以。

安装以及配置步骤能够參考官方文档https://directory.apache.org/studio/users-guide/ldap_browser/gettingstarted_download_install.html

左下 Connection 区域点击右键加入 Connection。

注意 OpenLdap 的 Port 为 389。




Bind DN or User :slapd.conf 文件内的rootdn

Bind password : slapd.conf 文件内的rootpw

点解 Check Authentication 确认验证成功


watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvUGFyYW5vaWRfQW5kcm9pZA==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast" alt="">


之后点击 Finish,配置成功。能够在左側 LDAPBrowser 里看到整个 DIT 结构。


Liferay 配置 LDAP

在 Liferay 的 Crontrol Panel 找到 LDAP 配置界面,点击加入 LDAP Server。

Server Name – 没什么可说的

Default Values – 仅仅有当你想切换 LDAP 工具时。依据详细的 LDAP 实现工具来重置底下全部属性

Connection : 配置用来连接 LDAP server

watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvUGFyYW5vaWRfQW5kcm9pZA==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast" alt="">


Users

User Mapping – 用来映射 LDAP 内 user 属性与 Liferay 内user属性

watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvUGFyYW5vaWRfQW5kcm9pZA==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast" alt="">


Groups – 相应于  LDAP 里的 group

watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvUGFyYW5vaWRfQW5kcm9pZA==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast" alt="">


Export – 这个必须配置,不然无法将 Liferay 用户到处到 LDAP server,导致配置完毕之后, Liferay 用户反而不能成功登录



保存,回到LDAP主界面,确认选择 Enabled 与 Required, Liferay 官方对这两个属性解释例如以下:

ldap.auth.enabled=true

Set ldap.auth.enabled = true to enable LDAP Authentication


ldap.auth.required=true

Setting required = true means that you must successfully bind with the record in the LDAP server before Liferay will allow the user to log in


确认选择 Import / Export



Liferay 官方解释例如以下:

ldap.import.enabled=true

If set to true, then Liferay will do a mass import of users on the specified interval



ldap.import.on.startup=true

If set to true, Liferay will do a mass import of all LDAP users according to the import method (that match the user specified search filter) on startup





ldap.export.enabled=true

If set to true, Liferay will export the user to LDAP. Liferay uses a listener to track any changes made to the User object and will push these changes out to the LDAP server whenever the User object is updated. Note that on every login, fields such as "LastLoginDate"
are updated and so if export is enabled, logging in with a user will export the user to LDAP.

上述步骤仅仅是单点登录的准备工作而已。仅仅要能在 Liferay 配置 LDAP 界面 Test 成功就算是配置正确。




[Liferay] Liferay 实现单点登录 - OpenLDAP的更多相关文章

  1. CAS 单点登录【1】入门

    1. CAS 的引入的前提和好处 很早期的公司,一家公司可能只有一个应用,慢慢的应用开始变多,如员工报销系统.审核系统.学习系统...... 每个应用都要进行注册登录,退出的时候又要一个个退出,用户操 ...

  2. Liferay7.0与cas单点登录配置

    1.简介     Liferay7.0支持多种登录方式,包括:常规的.opensso.cas.ntlm.ldap.openid.Facebook.Google等. 其中, (1) 常规:则是默认Lif ...

  3. SSO单点登录和CAS

    一.单点登录流程 =====客户端====== 1.拦截客户端的请求判断是否有局部的session 2.1如果有局部的session,放行请求. 2.2如果没有局部session 2.2.1请求中有携 ...

  4. Docker 创建 Crowd3.3.2 以及打通 Jira Software7.12.3和Confluence6.12.2 SSO 单点登录

    目录 目录 1.介绍 1.1.什么是Crowd? 2.Crowd 的官网在哪里? 3.如何下载安装? 4.对 Crowd 进行配置 4.1.破解 Crowd 第一步 4.2.破解 Crowd 第二步, ...

  5. Spring Security安全以及单点登录

    1.单点登录:多个系统,只需在一个系统登录以后,其他系统可以直接访问. 2.CAS(认证服务器),Apache Httpd,OpenLdap,OpenSSL(生成证书)几个工具实现 3.原理:登录通过 ...

  6. 轻型目录访问协议 ldap 公司内部网站的登录 单点登录

    https://zh.wikipedia.org/wiki/轻型目录访问协议 轻型目录访问协议(英文:Lightweight Directory Access Protocol,缩写:LDAP,/ˈɛ ...

  7. 著名ERP厂商的SSO单点登录解决方案介绍一

          SSO英文全称Single Sign On,单点登录.SSO是在多个应用系统中,用户只需要登录一次就可以访问所有相互信任的应用系统.它包括可以将这次主要的登录映射到其他应用中用于同一个用户 ...

  8. 看图理解JWT如何用于单点登录

    单点登录是我比较喜欢的一个技术解决方案,一方面他能够提高产品使用的便利性,另一方面他分离了各个应用都需要的登录服务,对性能以及工作量都有好处.自从上次研究过JWT如何应用于会话管理,加之以前的项目中也 ...

  9. 细说SSO单点登录

    什么是SSO? 如果你已知道,请略过本节! SSO核心意义就一句话:一处登录,处处登录:一处注销,处处注销.即:在多个应用系统中,用户只需要登录一次就可以访问所有相互信任的应用系统. 很多人容易把SS ...

随机推荐

  1. hdu 5172(线段树||HASH)

    GTY's gay friends Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others ...

  2. SQL 建立多个字段唯一性校验

    由于在做压力测试,同一时间占用的问题. 两个用户同时下同一时间的订单,需要增加校验,第一个能保存的用户保存,第二个就不能让保存了. 问题是通过代码,怎么都做不到毫秒级校验,所以解决办法就只能是通过数据 ...

  3. 计蒜客 30999.Sum-筛无平方因数的数 (ACM-ICPC 2018 南京赛区网络预赛 J)

    J. Sum 26.87% 1000ms 512000K   A square-free integer is an integer which is indivisible by any squar ...

  4. [USACO06DEC] Milk Patterns

    题目描述 Farmer John has noticed that the quality of milk given by his cows varies from day to day. On f ...

  5. [CF678F]Lena and Queries

    题意: 初始有一个空集合$n$个操作有三种操作,如下:$1\ a\ b$表示向集合中插入二元组$(a,b)$$2\ i$表示删除第$i$次操作时所插入的二元组$3\ q$表示询问当前集合的二元组中,$ ...

  6. 【推导】Codeforces Round #402 (Div. 2) A. Pupils Redistribution

    一次交换,会让Group A里面的某个数字的数量-1,另一个数字的数量+1:对Group B恰好相反. 于是答案就是xigma(i=1~5,numA[i]-numB[i]>0)(numA[i]- ...

  7. 【枚举】【前缀和】【map】ICM Technex 2017 and Codeforces Round #400 (Div. 1 + Div. 2, combined) C. Molly's Chemicals

    处理出前缀和,枚举k的幂,然后从前往后枚举,把前面的前缀和都塞进map,可以方便的查询对于某个右端点,有多少个左端点满足该段区间的和为待查询的值. #include<cstdio> #in ...

  8. 【dfs】【哈希表】bzoj2783 [JLOI2012]树

    因为所有点权都是正的,所以对每个结点u来说,每条从根到它的路径上只有最多一个结点v符合d(u,v)=S. 所以我们可以边dfs边把每个结点的前缀和pre[u]存到一个数据结构里面,同时查询pre[u] ...

  9. (转)[Unity3D]关于Assets资源目录结构管理

    分享个我们项目常用的目录结构,微调过很多次,最终到了这个版本.个人认为这种管理资源方式是不错的.欢迎探讨各个细节~ 更新于2013.5.30   Asserts   --Editor 自写的灵活方便插 ...

  10. Eclipse / Pycharm | 使用过程中的一些问题笔记

    最近有比较多的用到这两款工具,其中也遇到一些问题,知道了一些快捷键 快捷键什么的这里就不讲了,去网上搜搜,经常使用下,自然就熟悉了 主要记录一下我遇到的几个问题 文章目录 Pycharm出现的部分快捷 ...