Add DummyAuthenticator

This commit is contained in:
Kyla Harper
2018-09-25 15:44:05 -05:00
parent 451dccfbf4
commit b43125e9e8
2 changed files with 23 additions and 7 deletions

View File

@@ -686,3 +686,23 @@ class PAMAuthenticator(LocalAuthenticator):
self.log.warning("Failed to close PAM session for %s: %s", user.name, e)
self.log.warning("Disabling PAM sessions from now on.")
self.open_sessions = False
class DummyAuthenticator(Authenticator):
password = Unicode(
None,
allow_none=True,
config=True,
help="""
Set a global password for all users wanting to log in.
This allows users with any username to log in with the same static password.
"""
)
@gen.coroutine
def authenticate(self, handler, data):
if self.password:
if data['password'] == self.password:
return data['username']
return None
return data['username']

View File

@@ -1,3 +1,5 @@
from jupyterhub.auth import DummyAuthenticator
"""sample jupyterhub config file for testing
configures jupyterhub with dummyauthenticator and simplespawner
@@ -5,13 +7,7 @@ to enable testing without administrative privileges.
"""
c = get_config() # noqa
try:
from dummyauthenticator import DummyAuthenticator
except ImportError:
print("dummyauthenticator not available. Try: `pip install jupyterhub-dummyauthenticator`")
else:
c.JupyterHub.authenticator_class = DummyAuthenticator
c.JupyterHub.authenticator_class = DummyAuthenticator
try:
from simplespawner import SimpleLocalProcessSpawner