mirror of
https://github.com/jupyterhub/jupyterhub.git
synced 2025-10-08 02:24:08 +00:00
Merge pull request #3619 from manics/nullauthenticator
Add NullAuthenticator to jupyterhub
This commit is contained in:
@@ -1173,3 +1173,22 @@ class DummyAuthenticator(Authenticator):
|
|||||||
return data['username']
|
return data['username']
|
||||||
return None
|
return None
|
||||||
return data['username']
|
return data['username']
|
||||||
|
|
||||||
|
|
||||||
|
class NullAuthenticator(Authenticator):
|
||||||
|
"""Null Authenticator for JupyterHub
|
||||||
|
|
||||||
|
For cases where authentication should be disabled,
|
||||||
|
e.g. only allowing access via API tokens.
|
||||||
|
|
||||||
|
.. versionadded:: 2.0
|
||||||
|
"""
|
||||||
|
|
||||||
|
# auto_login skips 'Login with...' page on Hub 0.8
|
||||||
|
auto_login = True
|
||||||
|
|
||||||
|
# for Hub 0.7, show 'login with...'
|
||||||
|
login_service = 'null'
|
||||||
|
|
||||||
|
def get_handlers(self, app):
|
||||||
|
return []
|
||||||
|
@@ -3,6 +3,7 @@
|
|||||||
# Distributed under the terms of the Modified BSD License.
|
# Distributed under the terms of the Modified BSD License.
|
||||||
import logging
|
import logging
|
||||||
from unittest import mock
|
from unittest import mock
|
||||||
|
from urllib.parse import urlparse
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from requests import HTTPError
|
from requests import HTTPError
|
||||||
@@ -12,6 +13,8 @@ from .mocking import MockPAMAuthenticator
|
|||||||
from .mocking import MockStructGroup
|
from .mocking import MockStructGroup
|
||||||
from .mocking import MockStructPasswd
|
from .mocking import MockStructPasswd
|
||||||
from .utils import add_user
|
from .utils import add_user
|
||||||
|
from .utils import async_requests
|
||||||
|
from .utils import public_url
|
||||||
from jupyterhub import auth
|
from jupyterhub import auth
|
||||||
from jupyterhub import crypto
|
from jupyterhub import crypto
|
||||||
from jupyterhub import orm
|
from jupyterhub import orm
|
||||||
@@ -515,3 +518,12 @@ def test_deprecated_methods_subclass():
|
|||||||
assert authenticator.check_whitelist("subclass-allowed")
|
assert authenticator.check_whitelist("subclass-allowed")
|
||||||
assert not authenticator.check_allowed("otheruser")
|
assert not authenticator.check_allowed("otheruser")
|
||||||
assert not authenticator.check_whitelist("otheruser")
|
assert not authenticator.check_whitelist("otheruser")
|
||||||
|
|
||||||
|
|
||||||
|
async def test_nullauthenticator(app):
|
||||||
|
with mock.patch.dict(
|
||||||
|
app.tornado_settings, {"authenticator": auth.NullAuthenticator(parent=app)}
|
||||||
|
):
|
||||||
|
r = await async_requests.get(public_url(app))
|
||||||
|
assert urlparse(r.url).path.endswith("/hub/login")
|
||||||
|
assert r.status_code == 403
|
||||||
|
1
setup.py
1
setup.py
@@ -100,6 +100,7 @@ setup_args = dict(
|
|||||||
'default = jupyterhub.auth:PAMAuthenticator',
|
'default = jupyterhub.auth:PAMAuthenticator',
|
||||||
'pam = jupyterhub.auth:PAMAuthenticator',
|
'pam = jupyterhub.auth:PAMAuthenticator',
|
||||||
'dummy = jupyterhub.auth:DummyAuthenticator',
|
'dummy = jupyterhub.auth:DummyAuthenticator',
|
||||||
|
'null = jupyterhub.auth:NullAuthenticator',
|
||||||
],
|
],
|
||||||
'jupyterhub.proxies': [
|
'jupyterhub.proxies': [
|
||||||
'default = jupyterhub.proxy:ConfigurableHTTPProxy',
|
'default = jupyterhub.proxy:ConfigurableHTTPProxy',
|
||||||
|
Reference in New Issue
Block a user