mirror of
https://github.com/jupyterhub/jupyterhub.git
synced 2025-10-09 19:13:03 +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("Failed to close PAM session for %s: %s", user.name, e)
|
||||||
self.log.warning("Disabling PAM sessions from now on.")
|
self.log.warning("Disabling PAM sessions from now on.")
|
||||||
self.open_sessions = False
|
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
|
"""sample jupyterhub config file for testing
|
||||||
|
|
||||||
configures jupyterhub with dummyauthenticator and simplespawner
|
configures jupyterhub with dummyauthenticator and simplespawner
|
||||||
@@ -5,12 +7,6 @@ to enable testing without administrative privileges.
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
c = get_config() # noqa
|
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:
|
try:
|
||||||
|
Reference in New Issue
Block a user