默认情况下,Conan在server.conf文件中提供一个简单的user: password用户列表。
还有一个用于设置其他身份验证方法的插件机制。安装其中任何一个的过程都是一个简单的两步过程:
将身份验证器源文件复制到
.conan_server/plugins/authenticator文件夹。将
custom_authenticator: authenticator_name添加到server.conf[server] 部分。
这是可用身份验证器的列表,访问其url以检索它们,还可以报告问题并进行协作:
- htpasswd:使用您的服务器Apache htpasswd文件对用户进行身份验证。 获取:https://github.com/d-schiffner/conan-htpasswd
- LDAP:使用您的LDAP服务器对用户进行身份验证。获取:https://github.com/uilianries/conan-ldap-authentication
创建您自己的自定义身份验证器
如果要创建自己的身份验证器,创建一个Python模块: ~/.conan_server/plugins/authenticator/my_authenticator.py
Example:
def get_class():return MyAuthenticator()class MyAuthenticator(object):def valid_user(self, username, plain_password):return username == "foo" and plain_password == "bar"
该模块必须实施:
- 一个工厂函数
get_class(),它返回一个具有valid_user()方法实例的类。 - 包含
valid_user()的类,如果用户和密码有效,则必须返回True,否则返回False。
