- 論壇徽章:
- 0
|
【引用】
jobesky 2011-03-18 10:11 NEW
版主 你好
再次打擾到你確實不好意思,不過最近項目確實碰到幾個棘手的問題?
我想問一下courier-authlib和sasl2認(rèn)證到底有什么不一樣呢?
為什么有必須有mysql又必須有l(wèi)dap,到底分別是做什么的認(rèn)證呢?
一個CUer的提問,回答提問的同時順便跟大家分享。
第一問:
The Courier Authentication Library is a generic authentication API that encapsulates the process of validating account passwords. In addition to reading the traditional account passwords from /etc/passwd, the account information can alternatively be obtained from an LDAP directory; a MySQL or a PostgreSQL database; or a GDBM or a DB file. The Courier authentication library must be installed before building any Courier packages that needs direct access to mailboxes .
簡單的說是給Courier mail server 提供好了驗證API接口,能允許訪問/etc/passwd,Mysql,LDAP等數(shù)據(jù)庫。
詳細(xì)說,可以看這個
- /tmp/courier-authlib-0.63.0$ ls *.c
- authcustom.c authldaplib.c authpgsql.c authsaslclientcrammd5.c authsasltobase64.c checkpasswordsha1.c preauthpgsql.c
- authdaemon.c authmksock.c authpgsqllib.c authsaslclientcramsha1.c authshadow.c cramlib.c preauthpwd.c
- authdaemond.c authmoduser2.c authpipe.c authsaslclientexternal.c authsyschangepwd.c cryptpassword.c preauthshadow.c
- authdaemonlib.c authmoduser3.c authpipelib.c authsaslclientlogin.c authsyscommon.c debug.c preauthuserdb.c
- authdaemontest.c authmysql.c authpwd.c authsaslclientplain.c authtest.c preauthcustom.c preauthuserdbcommon.c
- authenumerate.c authmysqllib.c authpwdenumerate.c authsaslcram.c authuserdb.c preauthdaemon.c
- authinfo.c authoption.c authsasl.c authsaslfrombase64.c authuserdbpwd.c preauthldap.c
- authldap.c authpam.c authsaslclient.c authsasllogin.c checkpassword.c preauthmysql.c
- authldapescape.c authpasswd.c authsaslclientcram.c authsaslplain.c checkpasswordmd5.c preauthpam.c
復(fù)制代碼 這些都是C源碼文件,以這幾個 authmysql.c authmysql.h authmysqllib.c 為例,他們主要作用就是訪問MYSQL數(shù)據(jù)庫中賬戶資料。那其它的有 authpam.c authpgsql.c authsasl.c等等這些有訪問pam 、pgsql 、sasl ,有的是數(shù)據(jù)庫,有的是本地數(shù)據(jù)文件,有的驗證應(yīng)用接口。好比你買了一個手機(jī)萬能沖,對不同電池要更換不同接口。這里可以看到SASL也是接口之一。
SASL is the Simple Authentication and Security Layer, a method for adding authentication support to connection-based protocols. To use SASL, a protocol includes a command for identifying and authenticating a user to a server and for optionally negotiating protection of subsequent protocol interactions. If its use is negotiated, a security layer is inserted between the protocol and the connection.
簡單的說SASL使用一個協(xié)議,其作用提供驗證支持。- #ls /var/run/saslauthd/* -l
- srwxrwxrwx 1 root root 0 Mar 22 19:00 /var/run/saslauthd/mux
- -rw------- 1 root root 0 Mar 22 19:00 /var/run/saslauthd/mux.accept
- -rw------- 1 root root 5 Mar 22 19:00 /var/run/saslauthd/saslauthd.pid
復(fù)制代碼- #saslauthd -v
- saslauthd 2.1.22
- authentication mechanisms: getpwent kerberos5 pam rimap shadow ldap
復(fù)制代碼 先說點別的,有一個老板想看電影,叫秘書去買票,秘書買票的時候可以有很多選擇,例如網(wǎng)購、電話訂購、影院排隊等。最后老板拿到兩張票,但是絲毫不關(guān)心票是怎么買的。
通過這個小故事你不難發(fā)現(xiàn),老板<---->秘書是很簡單關(guān)系。秘書->(網(wǎng)購、電話訂購、影院排隊)復(fù)雜了一些。
正題拓?fù)潢P(guān)系:
Client -------用戶密碼請求-------> Service App (老板)
| ^
v |
---SASL----/var/run/saslauthd/mux (秘書)
------------- /etc/init.d/saslauthd
| ^
v |
getpwent kerberos5 pam rimap shadow ldap (網(wǎng)購、電話訂購、影院排隊)
沒什么多說的,應(yīng)該看的明白。Service App 不知道用戶密碼真?zhèn),把驗證的事情交給saslauthd,而saslauthd又著其它機(jī)制來驗證這個用戶密碼。
第二個問題
選擇那一個都可以,不是必須兩都具備。
PS:以上如有錯誤,歡迎大家指正。 |
|