Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for OAuthentication via JupyterHub triggering account creation in FreeIPA #385

Open
cmd-ntrf opened this issue Sep 28, 2024 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@cmd-ntrf
Copy link
Member

cmd-ntrf commented Sep 28, 2024

It can be easier to ask people to log in Magic Castle with an OAuth authenticator and automatically create the account in FreeIPA instead of using Mokey.

I was able to put together a proof of concept that works with GitHub authenticator.

Here are the steps so far:

  1. Create a FreeIPA keytab for JupyterHub:
ipa role-add 'JupyterHub' --desc='JupyterHub User management'
ipa role-add-privilege 'JupyterHub' --privilege='Group Administrators'
ipa role-add-privilege 'JupyterHub' --privilege='User Administrators'
ipa user-add jupyterhub --first Jupyter --last Hub
ipa role-add-member 'JupyterHub' --users=jupyterhub
ipa-getkeytab -p jupyterhub -k /etc/jupyterhub/jupyterhub.keytab
  1. Define the function add_system_user of the jupyterhub authenticator:
class LocalGitHubOAuthenticator(LocalAuthenticator, GitHubOAuthenticator):
    """A version that mixes in local system user creation"""
    def add_system_user(self, user):
        subprocess.run(["kinit", "-kt", "/etc/jupyterhub/jupyterhub.keytab", "-p", "jupyterhub"])
        subprocess.run(["ipa_create_user.py", user.name, "--posix_group", "def-sponsor00"])
        subprocess.run(["kdestroy"])
        time.sleep(5)
  1. Create a GitHub app and export the following variables before launching JupyterHub:
 export GITHUB_CLIENT_ID=[redacted]
 export GITHUB_CLIENT_SECRET=[redacted]
 export OAUTH_CALLBACK_URL=[redacted]

If internally jupyterhub is not running SSL, the OAUTH callback URL prefix must be http.
4. Configure JupyterHub authenticator in /etc/jupyterhub/jupyterhub_config.json:

  "JupyterHub": {
    "authenticator_class": "oauthenticator.LocalGitHubOAuthenticator",
  },
  "LocalAuthenticator": {
    "create_system_users": true
  },
  "GitHubOAuthenticator": {
     "allow_all": true
  }
  1. Launch JupyterHub
@cmd-ntrf cmd-ntrf added the enhancement New feature or request label Sep 28, 2024
@cmd-ntrf cmd-ntrf self-assigned this Sep 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant