Base Authenticator
base authenticator使用简单的用户名与密码认证。
Authenticator.authenticate(handler, data)
该方法会传递Tornado的RequestHandler,以及JupyterHub登录表单的data。通常data包含两个键值:username和password。
自定义一个需要查找字典的Authenticator,只需要重写这个方法
from tornado import gen
from IPython.utils.traitlets import Dict
from jupyterhub.auth import Authenticator
class DictionaryAuthenticator(Authenticator):
passwords = Dict(config=True,
help="""dict of username:password for authentication"""
)
@gen.coroutine
def authenticate(self, handler, data):
if self.passwords.get(data['username']) == data['password']:
return data['username']