添加支持 PAM 模块进行用户认证 #34
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
使用 PAM 模块认证介绍
proxy_server支持使用PAM模块进行认证(仅支持pam的linux平台,编译proxy_server时需要在cmake中添加-DENABLE_USE_PAM_AUTH=ON选项以启用PAM模块认证功能),具体使用方法如下:PAM服务,如将doc目录下pam.example下的文件proxy-service复制到/etc/pam.d/目录中,文件名即为PAM服务名称。proxy_server中指定PAM服务名称,如--pam_auth proxy-service。linux命令添加用户到PAM服务中,如useradd jack,其中jack为用户名,使用passwd jack设置密码如1111。curl -x http://jack:1111@localhost:1080/ https://google.com,如果返回200 OK则说明认证生效。PAM模块认证可以使用linux命令添加或管理用户,可以极大的方便proxy_server的用户管理,而不必依赖复杂的数据库系统,当然如果你是开发人员,也可以开发一个支持数据库认证的PAM的so模块(可参考doc下pam.example的pam_sqlite.c如何实现PAM认证模块),或者使用PAM模块认证来实现LDAP认证等等各种方式。