Skip to content

Commit

Permalink
Updated & refactored
Browse files Browse the repository at this point in the history
  • Loading branch information
wesuuu committed Jun 4, 2021
1 parent 1165831 commit aa73ff8
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 6 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Jupyterhub SAML Auth

[![image](https://badge.fury.io/py/jupyterhub-saml-auth.svg)](https://pypi.org/project/jupyterhub-saml-auth/)

Authenticate your Jupyterhub users using SAML. This authenticator uses OneLogin's [python3-saml](https://github.com/onelogin/python3-saml) package as a backend API for handling SAML authentication.

## Installation
Expand Down Expand Up @@ -33,7 +35,7 @@ c.SAMLAuthenticator.session_cookie_names = {'PHPSESSIDIDP', 'SimpleSAMLAuthToken
c.SAMLAuthenticator.extract_username = extract_username

# register the SAML authenticator with jupyterhub
c.JupyterHub.authenticator_class = 'jupyterhub_saml_auth.authenticator.SAMLAuthenticator'
c.JupyterHub.authenticator_class = 'jupyterhub_saml_auth.SAMLAuthenticator'
```

## Development
Expand Down
4 changes: 3 additions & 1 deletion jupyterhub_saml_auth/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
__version__ = '0.1.0'
__version__ = '0.1.1'

from .authenticator import SAMLAuthenticator
2 changes: 1 addition & 1 deletion jupyterhub_saml_auth/authenticator.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ def configure_handlers(self):
self.metadata_handler.saml_settings_path = self.saml_settings_path
self.acs_handler.saml_settings_path = self.saml_settings_path
self.logout_handler.saml_settings = self.saml_settings_path
self.logout_handler.session_cookie_names = self.session_cookie_names

self.logout_handler.session_cookie_names = self.session_cookie_names
self.acs_handler.extract_username = self.extract_username

def get_handlers(self, app):
Expand Down
27 changes: 25 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,24 @@
import os.path


# https://packaging.python.org/guides/single-sourcing-package-version/
def read(rel_path):
here = os.path.abspath(os.path.dirname(__file__))
with codecs.open(os.path.join(here, rel_path), 'r') as fp:
return fp.read()


def get_version(rel_path):
"""https://packaging.python.org/guides/single-sourcing-package-version/
Args:
rel_path (str): relative path of init file with __version__
Raises:
RuntimeError: wrong path
Returns:
str: version
"""
for line in read(rel_path).splitlines():
if line.startswith('__version__'):
delim = '"' if '"' in line else "'"
Expand All @@ -20,10 +30,23 @@ def get_version(rel_path):
raise RuntimeError("Unable to find version string.")


def get_description():
"""https://packaging.python.org/guides/making-a-pypi-friendly-readme/
Returns:
str: README file
"""
this_dir = os.path.abspath(os.path.dirname(__file__))
with open(os.path.join(this_dir, 'README.md'), encoding='utf-8') as f:
long_description = f.read()
return long_description


setup(name='jupyterhub_saml_auth',
version=get_version('jupyterhub_saml_auth/__init__.py'),
python_requires='>=3.7.0',
description='Authenticate your Jupyterhub users using SAML.',
long_description=get_description(),
long_description_content_type='text/markdown',
author='Wesley Uykimpang',
url='https://github.com/ucsd-ets/jupyterhub-saml-auth',
packages=find_packages(),
Expand Down
2 changes: 1 addition & 1 deletion test/jupyterhub_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def extract_username(acs_handler, attributes):
c.SAMLAuthenticator.session_cookie_names = {'PHPSESSIDIDP', 'SimpleSAMLAuthTokenIdp'}
c.SAMLAuthenticator.extract_username = extract_username

c.JupyterHub.authenticator_class = 'jupyterhub_saml_auth.authenticator.SAMLAuthenticator'
c.JupyterHub.authenticator_class = 'jupyterhub_saml_auth.SAMLAuthenticator'


def pre_spawn_hook(spawner):
Expand Down

0 comments on commit aa73ff8

Please sign in to comment.