如何使用ldap+nginx auth ldap搭建登陆认证系统

> 博客详情
Gerrit是用于Git版本控制系统的代码审核系统。
当前最新版本的gerrit为2.8.1,从二进制war包即可。
数据库设置
gerrit可以使用H2,PostgreSQL,MySql和Oracle数据库。这个安装使用PostgreSQL数据库。
创建gerrit使用的用户和数据库:
$&createuser&--username=postgres&-RDIElPS&gerrit2
$&createdb&--username=postgres&-E&UTF-8&-O&gerrit2&reviewdb
这里使用PostgreSQL提供的shell工具,也可以登录PostgreSQL使用psql来CREATE ROLE和CREATE DATABASE。
为gerrit创建单独的用户gerrit2,用于运行gerrit,但是禁止gerrit2用户登录系统。
#&adduser&gerrit2
#&passwd&--delete&gerrit2
切换到gerrit2用户,使用gerrit2主目录下的review目录作为gerrit site的根目录
#&sudo&su&-&gerrit2
#&java&-jar&gerrit-2.8.1.war&init&-d&review
进入交互式安装,具体的安装配置如下:
***&Gerrit&Code&Review&2.8.1
***&选项中大写字母为默认选项,如使用默认选项回车即可
Create&'/home/gerrit2/review'&&[Y/n]?&
***&Git&Repositories
***&gerrit用于存储git仓库的目录,相对于根目录review
Location&of&Git&repositories&&&[git]:&
***&SQL&Database
Database&server&type&&&&&&&&&&&[h2]:&postgresql
Server&hostname&&&&&&&&&&&&&&&&[localhost]:&
Server&port&&&&&&&&&&&&&&&&&&&&[(postgresql&default)]:&
Database&name&&&&&&&&&&&&&&&&&&[reviewdb]:&
Database&username&&&&&&&&&&&&&&[gerrit2]:&
gerrit2's&password&&&&&&&&&&&&&:&
&&&&&&&&&&&&&&confirm&password&:&
***&User&Authentication
***&使用HTTP认证,OPENID需要服务器连接互联网,还可以使用LDAP认证服务
Authentication&method&&&&&&&&&&[OPENID/?]:&http
Get&username&from&custom&HTTP&header&[y/N]?&
SSO&logout&URL&&&&&&&&&&&&&&&&&:&
***&Email&Delivery
***&gerrit发送邮件设置,可以使用本地或远程SMTP服务器,
***&只要在smtp服务器上有帐号即可。
SMTP&server&hostname&&&&&&&&&&&[localhost]:&mail.openwares.net
SMTP&server&port&&&&&&&&&&&&&&&[(default)]:&25
SMTP&encryption&&&&&&&&&&&&&&&&[NONE/?]:&tls
SMTP&username&&&&&&&&&&&&&&&&&&[gerrit2]:&
's&password&:&
&&&&&&&&&&&&&&confirm&password&:&
***&Container&Process
***&使用gerrit2用户运行gerrit
Run&as&&&&&&&&&&&&&&&&&&&&&&&&&[gerrit2]:&
Java&runtime&&&&&&&&&&&&&&&&&&&[/usr/lib/jvm/java-7-openjdk-amd64/jre]:&
Copy&gerrit-2.8.1.war&to&/home/gerrit2/review/bin/gerrit.war&[Y/n]?&
Copying&gerrit-2.8.1.war&to&/home/gerrit2/review/bin/gerrit.war
***&SSH&Daemon
***&gerrit自带的ssh服务,与服务器自身的ssh服务无关,监听默认端口即可
***&注意:如要使用低于1024的特权端口,需authbind授权,否则ssh会绑定端口失败
Listen&on&address&&&&&&&&&&&&&&[*]:&
Listen&on&port&&&&&&&&&&&&&&&&&[29418]:&
Gerrit&Code&Review&is&not&shipped&with&Bouncy&Castle&Crypto&v144
&&If&available,&Gerrit&can&take&advantage&of&features
&&in&the&library,&but&will&also&function&without&it.
Download&and&install&it&now&[Y/n]?&
Downloading&http://www.bouncycastle.org/download/bcprov-jdk16-144.jar&...&OK
Checksum&bcprov-jdk16-144.jar&OK
Generating&SSH&host&key&...&rsa...&dsa...&done
***&HTTP&Daemon
***&这里使用nginx反向代理gerrit,所以只在loop接口监听即可。
***&如果使用域名访问gerrit,最好将规范URL设置为域名形式,发送校验邮件时会使用到
Behind&reverse&proxy&&&&&&&&&&&[y/N]?&y
Proxy&uses&SSL&(https://)&&&&&&[y/N]?&
Subdirectory&on&proxy&server&&&[/]:&
Listen&on&address&&&&&&&&&&&&&&[*]:&127.0.0.1
Listen&on&port&&&&&&&&&&&&&&&&&[8081]:&
Canonical&URL&&&&&&&&&&&&&&&&&&[http://127.0.0.1/]:http://review.domain.tld/
***&Plugins
***&选装插件
Install&plugin&download-commands&version&v2.8.1&[y/N]?
Install&plugin&reviewnotes&version&v2.8.1&[y/N]?&
Install&plugin&replication&version&v2.8.1&[y/N]?&
Install&plugin&commit-message-length-validator&version&v2.8.1&[y/N]?&
Initialized&/home/gerrit2/review
Executing&/home/gerrit2/review/bin/gerrit.sh&start
Starting&Gerrit&Code&Review:&
***&因为为ssh服务选在了低于1024的端口,且没有authbind端口授权,所以会出现如下错误,高于1024端口不会。
***&FAILED
***&error:&cannot&start&Gerrit:&exit&status&1
Waiting&for&server&on&127.0.0.1:80&...&OK
***&服务器上没有X,所以使用浏览器打开连接失败
Opening&http://127.0.0.1/#/admin/projects/&...FAILED
Open&Gerrit&with&a&JavaScript&capable&browser:
http://127.0.0.1/#/admin/projects/
***&交互式安装完毕
gerrit自启动服务
添加/etc/default/gerritcodereview文件,其内容如下:GERRIT_SITE=/path/to/gerrit
#&ln&-sf&/home/gerrit2/review/bin/gerrit.sh&/etc/init.d/gerrit
#&ln&-sf&/etc/init.d/gerrit&/etc/rc3.d/S90gerrit
使用nginx反向代理gerrit,并且nginx承担http认证,gerrit不会对用户进行认证。gerrit将http认证成功后第一个 登录的用户作为管理员,其他用户皆为普通用户。用户第一次http认证成功后,gerrit会为用户生成同名的gerrit用户,只要进一步完善账户即 可。比如添加email和公钥。管理员为其他普通用户授权。
nginx反向代理配置
&&&&&&&&listen&80;
&&&&&&&&server_name&review.domain.
&&&&&&&&location&/&{
&&&&&&&&&&&&&&&&auth_basic&&&&&&&&&&&&&&"Gerrit2&Code&Review";
&&&&&&&&&&&&&&&&auth_basic_user_file&&&&/home/gerrit2/htpasswd.
&&&&&&&&&&&&&&&&proxy_pass&&&&&&&&&&&&&&http://127.0.0.1:8081;
&&&&&&&&&&&&&&&&proxy_set_header&&&&&&&&X-Forwarded-For&$remote_
&&&&&&&&&&&&&&&&proxy_set_header&&&&&&&&Host&$
&&&&&&&&location&/login/&{
&&&&&&&&&&&&&&&&proxy_pass&&&&&&&&&&&&&&http://127.0.0.1:8081;
&&&&&&&&&&&&&&&&proxy_set_header&&&&&&&&X-Forwarded-For&$remote_
&&&&&&&&&&&&&&&&proxy_set_header&&&&&&&&Host&$
http认证文件
使用htpasswd命令为管理云用户生成http认证配置文件,如果没有htpasswd文件需要安装apache2-utils包。
# htpasswd -d htpasswd.conf admin
以后添加gerrit用户时,同样需要先为其配置http认证,然后用户登录后gerrit会为其自动生成用户帐号,名字与http认证名字一致。
第一次成功登录的用户会被gerrit作为管理员用户。登录后点击右上角的”匿名懦夫”Anonymous Coward -& Settings来配置账户。
选择左侧Contact Information页签,添加用户全称。然后注册新邮件Register New Email,输入管理员的邮件地址后,gerrit会向新邮箱发送校验邮件,校验通过后才是有效的邮箱。这时候安装时配置Canonical URL就有用处了,校验邮件的域名部分就是Canonical URL,如果当时配置的是http://127.0.0.1/,那这时候就要手工修改域名部分再执行验证了。
发送校验邮件有时候不太方便,可以使用gerrit提供的远程ssh shell来为用户添加有效邮箱。当然首先管理员要添加了SSH公钥才能远程访问gerrit的ssh shell。语法如下:
#&ssh&review&gerrit&set-account&--add-email&&username
这是review是.ssh/config中配置的远程ssh主机别名。
也可以通过直接修改gerrit数据库表的方式来添加用户邮件,但这活着实有点儿脏,不建议使用。
要使用gerrit必须要提供用户的公钥。选择页面左侧的SSH Public Keys为当前用户添加公钥。直接将公钥粘贴到Add SSH Public Key框内,然后点击add即可。之后用户就可以用ssh来访问gerrit了。当然无法登录服务器,只能使用gerrit提供的shell。
添加其他普通账户
如果采用http认证,那么添加其他账户时,需要现添加http认证账户。用htpasswd创建的用户时,并没有往gerrit中添加账号,只有 当该用户通过web登陆gerrit服务器时,该账号才会被添加进gerrit数据库中。使用http认证方式,不要使用gerrit ssh shell命令来新增用户,通过http认证第一次认证成功的用户,gerrit会为其自动创建账户,之后只要完善账户就可以了。使用ssh shell创建的用户无法与http认证后自动创建的用户关联起来,即是二者的用户名是完全一样的。
其他用户帐号的配置与管理员的配置方式一样。
SSH访问gerrit
添加ssh公钥后就可以使用ssh来使用gerrit了。
# ssh -p 29418 -i ~/.ssh/id_rsa.gerrit admin@review.domain.tld
如果私钥名字为id_rsa可以不用使用-i参数。为ssh主机配置别名访问起来更简单,~/.ssh/config文件中添加:
Host&review
&&&&Hostname&&&&review.domain.tld
&&&&User&&&&&&&&admin
&&&&Port&&&&&&&&29418
&&&&#如果私钥名字为id_rsa,可以省略下面一行
&&&&IdentityFile&&&&~/.ssh/id_rsa.gerrit
这样ssh访问gerrit就可以了:
#&ssh&review
****&&&&Welcome&to&Gerrit&Code&Review&&&&****
&&Hi&username,&you&have&successfully&connected&over&SSH.
&&Unfortunately,&interactive&shells&are&disabled.
&&To&clone&a&hosted&Git&repository,&use:
&&git&clone&ssh://admin@review.domain.tld:29418/REPOSITORY_NAME.git
Connection&to&review.tafdc.org&closed.
查看gerrit shell帮助
#&ssh&review&gerrit&--help
gerrit&[COMMAND]&[ARG&...]&[--]&[--help&(-h)]
&--&&&&&&&&&&:&end&of&options
&--help&(-h)&:&display&this&help&text
Available&commands&of&gerrit&are:
&&&ban-commit&&&&&&&&&&&Ban&a&commit&from&a&project's&repository
&&&create-account&&&&&&&Create&a&new&batch/role&account
&&&create-group&&&&&&&&&Create&a&new&account&group
&&&create-project&&&&&&&Create&a&new&project&and&associated&Git&repository
&&&flush-caches&&&&&&&&&Flush&some/all&server&caches&from&memory
&&&gc&&&&&&&&&&&&&&&&&&&Run&Git&garbage&collection
&&&gsql&&&&&&&&&&&&&&&&&Administrative&interface&to&active&database
&&&ls-groups&&&&&&&&&&&&List&groups&visible&to&the&caller
&&&ls-members&&&&&&&&&&&Lists&the&members&of&a&given&group
&&&ls-projects&&&&&&&&&&List&projects&visible&to&the&caller
&&&ls-user-refs&&&&&&&&&List&refs&visible&to&a&specific&user
&&&plugin&&&&&&&&&&&&&&&
&&&query&&&&&&&&&&&&&&&&Query&the&change&database
&&&receive-pack&&&&&&&&&Standard&Git&server&side&command&for&client&side&git&push
&&&rename-group&&&&&&&&&Rename&an&account&group
&&&review&&&&&&&&&&&&&&&Verify,&approve&and/or&submit&one&or&more&patch&sets
&&&set-account&&&&&&&&&&Change&an&account's&settings
&&&set-members&&&&&&&&&&Modifies&members&of&specific&group&or&number&of&groups
&&&set-project&&&&&&&&&&Change&a&project's&settings
&&&set-project-parent&&&Change&the&project&permissions&are&inherited&from
&&&set-reviewers&&&&&&&&Add&or&remove&reviewers&on&a&change
&&&show-caches&&&&&&&&&&Display&current&cache&statistics
&&&show-connections&&&&&Display&active&client&SSH&connections
&&&show-queue&&&&&&&&&&&Display&the&background&work&queues,&including&replication
&&&stream-events&&&&&&&&Monitor&events&occurring&in&real&time
&&&test-submit&&&&&&&&&&
&&&version&&&&&&&&&&&&&&Display&gerrit&version
See&'gerrit&COMMAND&--help'&for&more&information.
导入现存git代码库
最简单的办法就是直接将现在的git裸仓库拷贝到gerrit管理的仓库目录下
#cp&-r&/path/to/old.git&/path/to/gerrit/git/
或者稍微繁琐一些的方法:在gerrit中新建一个project,不要做init commit,然后将新建的仓库做为已经存在仓库的远程仓库,然后push就可以了。可以设置gerrit该仓库不经过审核,就可以直接将整个仓库push过来了。
gitweb集成
debian系统只要安装了gitweb包, gerrit就可以自动关联到gitweb,通过gitweb来浏览git仓库。
# apt-get install gitweb
如果为gerrit配置的SMTP服务器是SSL/TLS加密的,并且SMTP服务器的证书是自签的,当gerrit试图发送邮件时会抛出异常:
sun.security.validator.ValidatorException:&PKIX&path&building&failed:&
sun.security.provider.certpath.SunCertPathBuilderException:&
unable&to&find&valid&certification&path&to&requested&target
因为自签的证书是不受信任的,最简单的解决办法就是告诉gerrit不要校验STMP服务的证书:
编辑~/review/etc/gerrit.config,添加:
[sendmail]
&&&&sslverify=false
或者更复杂的解决办法,将SMTP的SSL证书添加到JAVA的truststore里,参考[3]里有对此问题的详细描述。
使用http认证登录gerrit后,并无法通过点击”Sign Out”退出登录,只能通过直接关闭浏览器窗口来退出当前会话。
如果需要重新安装gerrit,记得将数据库drop掉再重新创建。
References:[1][2][3]
===All governments should be pressured to correct their abuses of human rights. --- Richard Stallman
支付宝支付
微信扫码支付
打赏金额: ¥
已支付成功
打赏金额: ¥首页 & 开源软件svn的安装(整合apache、ldap) 以下是centos环境下,以yum安装apache及其相关软件。svn使用源码包编译,使用官网最新的1.8.5版本。 一、安装apache openldap及其相关模块yum -y install httpd httpd-devel openldap openldap-devel mod_authz_ldap openssl
openssl-devel zlib zlib-devel apr apr-uti
二、安装sqlite 由于centos6.4上自带的sqlite 3.6.20版本太低,不符合subversion的最低要求,所以需要通过源码包安装wget http://www.sqlite.org/2013/sqlite-autoconf-3080100.tar.gz
tar zxvf sqlite-autoconf-3080100.tar.gz
cd sqlite-autoconf-3080100
./configure
make && make install 三、安装subversion 1、subversion源码包安装tar zxvf subversion-1.8.5.tar.gz
mkdir -p ./subversion-1.8.5/sqlite-amalgamation
cp ./sqlite-autoconf-3080100/sqlite3.c ./subversion-1.8.5/sqlite-amalgamation
cd subversion-1.8.5
./configure --prefix=/usr/local/subversion
make && make install 2、配置环境变量echo 'PATH=$PATH:/usr/local/subversion/bin' &&/etc/profile
'export PATH'&&/etc/profile
source /etc/profile 3、创建版本库cd /data1/svnroot
svnadmin create --pre-1.6-compatible test 注意:如果这里不写--pre-1.6-compatible,更新svn的时候会报post commit FS processing had error: Couldn’t open rep-cache database 四、subversion与apache的整合 1、复制subversion下的mod文件cp /usr/local/subversion/libexec/mod_authz_svn.so /etc/httpd/modules/
cp /usr/local/subversion/libexec/mod_dav_svn.so /etc/httpd/modules/ 2、配置subversion.conf文件vim /etc/httpd/conf.d/subversion.conf
LoadModule dav_svn_module
modules/mod_dav_svn.so
LoadModule authz_svn_module
modules/mod_authz_svn.so
&VirtualHost *:80&
ServerName
svn.361way.com
&Directory "/data1/svnroot"&
Order deny,allow
Deny from all
Allow from 115.236.xxx.xxx/29
&/Directory&
&Location /svn&
Order deny,allow
Deny from all
Allow from 115.236.xxx.xxx/29
Allow from
119.37.xxx.xxx/24
SVNParentPath /data1/svnroot
AuthBasicAuthoritative on
AuthType Basic
AuthName "csvn"
AuthBasicProvider ldap
AuthzLDAPAuthoritative
AuthLDAPURL
"ldap://127.0.0.1/ou=Users,domainName=sangame.com,o=domains,dc=sangame,dc=com?uid?sub?(|(&(objectClass=mailuser)(accountStatus=active))(cn=svnadmin))"
AuthLDAPBindDN "cn=ldapread,dc=361way,dc=com"
AuthLDAPBindPassword "123456"
#AuthUserFile /etc/httpd/conf/svn.passwd
AuthzSVNAccessFile /etc/httpd/conf/svnauthz.conf
Satisfy Any
Require valid-user
&/Location&
&/VirtualHost& 如果不使用ldap认证,而使用密码文件认证则配置文件可以改为:&Location /&
SVNParentPath /data1/svnroot/
#svn 根目录
SVNListParentPath On
SVNAutoversioning On
SVNReposName "svn"
AuthzSVNAccessFile /opt/svn/subversion/conf/authz.conf
#目录分组权限
AuthType Basic
AuthName "Subversion repository"
AuthUserFile /opt/svn/subversion/conf/passwd.conf
#密码验证文件
Require valid-user
&/Location&
3、配置SVN权限认证文件vim /etc/httpd/conf/svnauthz.conf
admin=robin,svnadmin,ybk
@admin = rw
zzy = rw 注: 1、上面的test对应的是svnadmin下create的目录。 2、@admin对应的是管理员组,可以再建其他组,如:java_team 、oam、market等。robin、svnadmin、ybk、zzy这些都是用户名 。如果要和ldap进行整合的话,确保这些用户在ldap中存在。 3、使用if-svnadmin 这类web程序做svn的用户权限管理时,需要确保svnauthz.conf文件对apache用户可写,不然在if-svnadmin修改时不生效。 4、确保/data1/svnroot目录apache用户可读写或直接属主改过apache,不然在使用TortoiseSVN等程序上传或删除时会提示权限拒绝。 以上配置完成后,就可以启动apache以http://svn.361way.com/svn/test 的方式防问了。 关于openldap的相关配置这里就不再细说。如果使用到dav方法的调用时,还要安装neon。(neon 是一个 HTTP 和 WebDAV 客户端的C语言开发包,支持 Linux/Unix。提供 HTTP/1.1 和 WebDAV 方法的高级接口以及底层的 HTTP 请求/回应处理,可轻松实现新的方法。)不过由于apache下有mod_dav_svn的模块整合,所以这里就不需要安装了。 五、其他 1、svn服务器有2种运行方式:独立服务器和借助apache。2种方式各有利弊。这里是以apache整合的;独立服务的方式为svnserve -d -r /data1/svnroot方式启动进程,监听端口为3690 。 2、svn存储版本数据也有2种方式:BDB和FSFS。因为BDB方式在服务器中断时,有可能锁住数据,所以还是FSFS方式更安全一点。默认使用的存储方式也是FSFS方式。 最后,其相关组件及用途如下:svn
命令行客户端程序。
svnversion
此工具用来显示工作拷贝的状态(用术语来说,就是当前项目的修订版本)。
直接查看Subversion版本库的工具。
建立、调整和修复Subversion版本库的工具。
svndumpfilter
过滤Subversion版本库转储数据流的工具。
mod_dav_svn
ApacheHTTP服务器的一个插件,使版本库可以通过网络访问。
一个单独运行的服务器程序,可以作为守护进程或由SSH调用。这是另一种使版本库可以通过网络访问的方式。
一个通过网络增量镜像版本库的程序 3、apache和svnserver两种方式的访问方法http://192.168.1.222/repos,采用了Apache作为服务器的话就可以以这种形式访问,权限由Apache设置。
svn://192.168.1.222/repos,采用了svnserve作为服务器的话那么就可以采用这种形式访问,它是一种基于TCP/IP的访问方式。权限由仓库的配置文件设置。 4、权限配置总结用户组格式:
用户组名 = 用户1,用户2
其中,1个用户组可以包含1个或多个用户,用户间以逗号分隔。
版本库目录格式:
[版本库:/项目目录]
@用户组名 = 权限
用户名 = 权限
其中,方框号内部分可以有多种写法:
/,表示根目录及以下。根目录是svnserve启动时指定的,我们指定为/home/svnroot/repository。这样,/就是表示对全部版本库设置权限。
test:/,表示对版本库test设置权限
权限主体可以是用户组、用户或*,用户组在前面加@,*表示全部用户。权限可以是w、r、wr和空,空表示没有任何权限。
本站的发展离不开您的资助,金额随意,欢迎来赏!
分类: 开源软件 svn您可能也喜欢ifsvnadmin的安装使用 (6)svn备份和还原 SVN版本库的备份、还原、移植(初级篇、中级篇和高级篇) 删除web路径下的.svn文件 捐助本站 如您感觉本博客有用,可扫码捐赠本站!近期文章 分享已经暴露了你的信息 BMC Bladelogic自动化平台安装 linux下不重启OS增删磁盘 Docker使用NAS存储报错解决 一个不错的php wiki程序文章归档 文章归档 选择月份 2018年二月 &(2) 2018年一月 &(5) 2017年十二月 &(3) 2017年十一月 &(2) 2017年十月 &(1) 2017年九月 &(5) 2017年八月 &(3) 2017年七月 &(4) 2017年六月 &(2) 2017年五月 &(3) 2017年三月 &(4) 2017年二月 &(6) 2017年一月 &(5) 2016年十二月 &(4) 2016年十一月 &(6) 2016年十月 &(5) 2016年九月 &(5) 2016年八月 &(9) 2016年七月 &(5) 2016年六月 &(10) 2016年五月 &(18) 2016年四月 &(5) 2016年三月 &(4) 2016年二月 &(7) 2016年一月 &(8) 2015年十二月 &(8) 2015年十一月 &(10) 2015年十月 &(17) 2015年九月 &(10) 2015年八月 &(25) 2015年七月 &(11) 2015年六月 &(15) 2015年五月 &(23) 2015年四月 &(14) 2015年三月 &(22) 2015年二月 &(15) 2015年一月 &(24) 2014年十二月 &(14) 2014年十一月 &(16) 2014年十月 &(19) 2014年九月 &(19) 2014年八月 &(18) 2014年七月 &(20) 2014年六月 &(21) 2014年五月 &(24) 2014年四月 &(18) 2014年三月 &(29) 2014年二月 &(22) 2014年一月 &(22) 2013年十二月 &(24) 2013年十一月 &(20) 2013年十月 &(18) 2013年九月 &(16) 2013年八月 &(16) 2013年七月 &(20) 2013年六月 &(21) 2013年五月 &(19) 2013年四月 &(18) 2013年三月 &(24) 2013年二月 &(21) 2013年一月 &(18) 2012年十二月 &(24) 2012年十一月 &(18) 2012年十月 &(17) 2012年九月 &(17) 2012年八月 &(18) 2012年七月 &(26) 2012年六月 &(36) 2012年五月 &(36) 2012年四月 &(28) 2012年三月 &(46) 2012年二月 &(23) 2012年一月 &(16) 2011年十二月 &(27) 2011年十一月 &(59) 2011年十月 &(19) 2011年九月 &(16) 2011年八月 &(46)Nginx&nginx-auth-ldap认证
Nginx nginx-auth-ldap认证
CentOS 7.1
nginx-1.10.0
openldap-2.4.44
一.添加nginx-auth-ldap
编译nginx-auth-ldap模块需要ldap.h头文件,所以需要先安装ldap库
yum -y install openldap-devel
在编译nginx时,添加上模块编译参数,如
cd /usr/local/src
git clone https://github.com/kvspb/nginx-auth-ldap.git
--add-module=/usr/local/src/nginx-auth-ldap
二.配置ldap认证
& ldap_server openldap {
ldap://192.168.192.20:389/dc=example,dc=com?uid?sub?(&(objectClass=account));
& binddn "cn=Manager,dc=example,dc=com";
& binddn_passwd "secret";
& group_attribute_is_
& require valid_
&location /status {
& & & access_log
& auth_ldap "Restricted Space";
& auth_ldap_
不同的ldap实现,相关的objectClass可能不一样,直接套用nginx-auth-ldap的示例配置直接在openldap上就通不过,解决方法参看
17:07:40 [error] 33552#0: *9 http_auth_ldap: Could
not find user DN, client: 192.168.192.1, server: www.jlive.com,
request: "GET /status HTTP/1.1", host: "192.168.192.20"
已投稿到:Igor, et al:
Anyone here know the internals of an XP-based network (running the
newer Active Directory-like LDAP stuff, not the old style samba domain
controller stuff) and if it would be easy to support it in nginx?
I'd love to be able to role model nginx inside of our enterprise
environment as well as externally, and what better way than to have it
support IE's built-in authentication (I don't know the exact specifics
and what to call it) - I think Firefox supports it too (it prompts you
once with an HTTP auth dialog, but then seems to remember that)
It's some challenge response mechanism. It would require nginx to
speak to a domain controller (basically I think perl's Authen::SMB at
one time worked) - I don't know if it speaks LDAP nowadays strictly or
someone knowledgable with the protocol would need to be involved
to make sure it was implemented correctly...
Just thought I'd bring it up. Maybe someone has some ideas. It's
another item on my wishlist that I'd be willing to sponsor $$ wise...
Previous message:
Next message:
Messages sorted by:CentOS 6 - OpenLDAP - Configure LDAP Server : Server World
Sponsored Link
Configure LDAP Server
Configure LDAP Server in order to share users' accounts in your local networks.
Install OpenLDAP.
[root@dlp ~]#
-y install openldap-servers openldap-clients
[root@dlp ~]#
/usr/share/openldap-servers/DB_CONFIG.example /var/lib/ldap/DB_CONFIG
[root@dlp ~]#
ldap. /var/lib/ldap/DB_CONFIG
[root@dlp ~]# /etc/rc.d/init.d/slapd start
Starting slapd: [
[root@dlp ~]#
Set OpenLDAP admin password.
# generate encrypted password
[root@dlp ~]# slappasswd
New password:
Re-enter new password:
{SSHA}xxxxxxxxxxxxxxxxxxxxxxxx
[root@dlp ~]#
chrootpw.ldif
# specify the password generated above for "olcRootPW" section
dn: olcDatabase={0}config,cn=config
changetype: modify
add: olcRootPW
olcRootPW: {SSHA}xxxxxxxxxxxxxxxxxxxxxxxx
[root@dlp ~]# ldapadd -Y EXTERNAL -H ldapi:/// -f chrootpw.ldif
SASL/EXTERNAL authentication started
SASL username: gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=auth
SASL SSF: 0
modifying entry "olcDatabase={0}config,cn=config"
Set your domain name on LDAP DB.
# generate directory manager's password
[root@dlp ~]# slappasswd
New password:
Re-enter new password:
{SSHA}xxxxxxxxxxxxxxxxxxxxxxxx
[root@dlp ~]#
chdomain.ldif
# replace to your own domain name for "dc=***,dc=***" section
# specify the password generated above for "olcRootPW" section
dn: olcDatabase={1}monitor,cn=config
changetype: modify
replace: olcAccess
olcAccess: {0}to * by dn.base="gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=auth"
read by dn.base="cn=Manager,dc=srv,dc=world" read by * none
dn: olcDatabase={2}bdb,cn=config
changetype: modify
replace: olcSuffix
olcSuffix: dc=srv,dc=world
dn: olcDatabase={2}bdb,cn=config
changetype: modify
replace: olcRootDN
olcRootDN: cn=Manager,dc=srv,dc=world
dn: olcDatabase={2}bdb,cn=config
changetype: modify
add: olcRootPW
olcRootPW: {SSHA}xxxxxxxxxxxxxxxxxxxxxxxx
dn: olcDatabase={2}bdb,cn=config
changetype: modify
add: olcAccess
olcAccess: {0}to attrs=userPassword,shadowLastChange by
dn="cn=Manager,dc=srv,dc=world" write by anonymous auth by self write by * none
olcAccess: {1}to dn.base="" by * read
olcAccess: {2}to * by dn="cn=Manager,dc=srv,dc=world" write by * read
[root@dlp ~]# ldapmodify -Y EXTERNAL -H ldapi:/// -f chdomain.ldif
SASL/EXTERNAL authentication started
SASL username: gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=auth
SASL SSF: 0
modifying entry "olcDatabase={1}monitor,cn=config"
modifying entry "olcDatabase={2}bdb,cn=config"
modifying entry "olcDatabase={2}bdb,cn=config"
modifying entry "olcDatabase={2}bdb,cn=config"
[root@dlp ~]#
basedomain.ldif
# replace to your own domain name for "dc=***,dc=***" section
dn: dc=srv,dc=world
objectClass: top
objectClass: dcObject
objectclass: organization
o: Server World
dn: cn=Manager,dc=srv,dc=world
objectClass: organizationalRole
cn: Manager
description: Directory Manager
dn: ou=People,dc=srv,dc=world
objectClass: organizationalUnit
ou: People
dn: ou=Group,dc=srv,dc=world
objectClass: organizationalUnit
[root@dlp ~]# ldapadd -x -D cn=Manager,dc=srv,dc=world -W -f basedomain.ldif
Enter LDAP Password: & & # directory manager's password
adding new entry "dc=srv,dc=world"
adding new entry "cn=Manager,dc=srv,dc=world"
adding new entry "ou=People,dc=srv,dc=world"
adding new entry "ou=Group,dc=srv,dc=world"
, allow LDAP port.
For "-I INPUT *" section below example, Replace it to your own environment.
[root@dlp ~]# iptables -I INPUT 5 -p tcp -m state --state NEW -m tcp --dport 389 -j ACCEPT
Sponsored Link

我要回帖

更多关于 centos ldap登陆认证 的文章

 

随机推荐