Skip to content

Commit

Permalink
Merge pull request #7 from minrk/formgrader-api-token
Browse files Browse the repository at this point in the history
Use formgrader_hubapi_token to pre-load tokens
  • Loading branch information
willingc committed Apr 26, 2016
2 parents bf1adcb + cc160a2 commit 78cc48f
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 10 deletions.
7 changes: 6 additions & 1 deletion host_vars/hostname.example
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jupyterhub_users:
- student2

# The secret token to use for accessing the proxy
# Creat using something like `openssl rand -hex 32`
# Create using something like `openssl rand -hex 32`
proxy_auth_token: ''

# nbgrader formgrade setup
Expand All @@ -34,6 +34,11 @@ nbgrader_graders:
- grader
nbgrader_port: 5005

# The API token formgrader will use to make requests of the Hub
# Create using something like `openssl rand -hex 32`
formgrader_hubapi_token: ''


# ---------------------------------------------------
# Optional
# ---------------------------------------------------
Expand Down
4 changes: 0 additions & 4 deletions roles/formgrade/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@
- autograded
- submitted

- name: generate a config proxy auth token for the formgrade instance
command: jupyterhub token --db={{ jupyterhub_srv_dir }}/jupyterhub.sqlite {{nbgrader_owner}}
register: hubapi_token

- name: install nbgrader config file
template: "src=nbgrader_config.py.j2 dest={{nbgrader_base_dir}}/nbgrader_config.py owner={{nbgrader_owner}} mode=700"
become: true
Expand Down
2 changes: 1 addition & 1 deletion roles/formgrade/templates/nbgrader_config.py.j2
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ c.FormgradeApp.authenticator_class = u'nbgrader.auth.hubauth.HubAuth'
c.FormgradeApp.port = {{nbgrader_port}}

c.HubAuth.proxy_token = u'{{proxy_auth_token}}'
c.HubAuth.hubapi_token = u'{{hubapi_token.stdout}}'
c.HubAuth.hubapi_token = u'{{formgrader_hubapi_token}}'
c.HubAuth.hub_base_url = u'https://{{ansible_fqdn}}'
c.HubAuth.notebook_url_prefix = u'{{nbgrader_base_dir}}'
c.HubAuth.graders = [
Expand Down
4 changes: 2 additions & 2 deletions roles/jupyterhub/tasks/packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@
pip: name={{item}} state=present executable=pip3 editable=false
become: true
with_items:
- git+https://github.com/jupyter/jupyterhub#egg=jupyterhub
- git+https://github.com/jupyter/oauthenticator#egg=oauthenticator
- jupyterhub==0.6
- oauthenticator==0.3
7 changes: 5 additions & 2 deletions roles/jupyterhub/templates/jupyterhub_config.py.j2
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,8 @@ c.Authenticator.whitelist = {
c.Authenticator.whitelist = set()
{% endif %}



{% if formgrader_hubapi_token %}
c.JupyterHub.api_tokens = {
'{{formgrader_hubapi_token}}': '{{nbgrader_owner}}',
}
{% endif %}

0 comments on commit 78cc48f

Please sign in to comment.