mirror of
https://github.com/jupyterhub/jupyterhub.git
synced 2025-10-08 10:34:10 +00:00
Add DummyAuthenticator
This commit is contained in:
@@ -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']
|
||||
|
@@ -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
|
||||
|
Reference in New Issue
Block a user