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

Use Hub OAuth provider #11

Merged
merged 6 commits into from
Jan 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 3 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ Here's the config if you set it up as an external service, say, in another Docke
]

You have to specify the API token for the hub and the announcement service to share here.
Starting with JupyterHub 2.0, you will need to set user access through appropriate definition of `c.JupyterHub.load_roles`.

The service also has its own configuration file, by default `announcement_config.py` is what it is called.
The configuration text can be generated with a `--generate-config` option.
Expand All @@ -55,16 +56,11 @@ If you're running a hub with internal SSL turned on, you'll want to take advanta

What does it actually look like when it runs?
Start up the hub.
If you're running this locally on port 8000 (or in a Docker container with that port exposed), go to
Log in as an admin user, then go to

http://localhost:8000/services/announcement/

If all goes well you'll see a mostly blank JupyterHub-style page with "None" for the "Latest Announcement."

![Unauthenticated view](docs/resources/01-unauthenticated-view.png "Unauthenticated view")

Now go ahead and click the convenient login button.
Log in as an admin user, then go back to the above URL.
You should see:

![Admin view uninitialized](docs/resources/02-admin-view-uninitialized.png "Admin view uninitialized")

Expand Down
110 changes: 77 additions & 33 deletions announcement_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,67 +3,109 @@
#------------------------------------------------------------------------------
# Application(SingletonConfigurable) configuration
#------------------------------------------------------------------------------

## This is an application.

## The date format used by logging formatters for %(asctime)s
#c.Application.log_datefmt = '%Y-%m-%d %H:%M:%S'
# Default: '%Y-%m-%d %H:%M:%S'
# c.Application.log_datefmt = '%Y-%m-%d %H:%M:%S'

## The Logging format template
#c.Application.log_format = '[%(name)s]%(highlevel)s %(message)s'
# Default: '[%(name)s]%(highlevel)s %(message)s'
# c.Application.log_format = '[%(name)s]%(highlevel)s %(message)s'

## Set the log level by value or name.
#c.Application.log_level = 30
# Choices: any of [0, 10, 20, 30, 40, 50, 'DEBUG', 'INFO', 'WARN', 'ERROR', 'CRITICAL']
# Default: 30
# c.Application.log_level = 30

## Instead of starting the Application, dump configuration to stdout
# Default: False
# c.Application.show_config = False

## Instead of starting the Application, dump configuration to stdout (as JSON)
# Default: False
# c.Application.show_config_json = False

#------------------------------------------------------------------------------
# AnnouncementService(Application) configuration
#------------------------------------------------------------------------------

## This is an application.

## Allow access from subdomains
# Default: False
# c.AnnouncementService.allow_origin = False

## Config file to load
#c.AnnouncementService.config_file = 'announcement_config.py'
# Default: 'announcement_config.py'
# c.AnnouncementService.config_file = 'announcement_config.py'

## File in which to store the cookie secret.
# Default: 'jupyterhub-announcement-cookie-secret'
# c.AnnouncementService.cookie_secret_file = 'jupyterhub-announcement-cookie-secret'

## Fixed message to show at the top of the page.
#
# A good use for this parameter would be a link to a more general live system
# status page or MOTD.
#c.AnnouncementService.fixed_message = ''
# A good use for this parameter would be a link to a more general
# live system status page or MOTD.
# Default: ''
# c.AnnouncementService.fixed_message = ''

## Generate default config file
#c.AnnouncementService.generate_config = False
# Default: False
# c.AnnouncementService.generate_config = False

## The date format used by logging formatters for %(asctime)s
# See also: Application.log_datefmt
# c.AnnouncementService.log_datefmt = '%Y-%m-%d %H:%M:%S'

## The Logging format template
# See also: Application.log_format
# c.AnnouncementService.log_format = '[%(name)s]%(highlevel)s %(message)s'

## Set the log level by value or name.
# See also: Application.log_level
# c.AnnouncementService.log_level = 30

## Logo path, can be used to override JupyterHub one
#c.AnnouncementService.logo_file = ''
# Default: ''
# c.AnnouncementService.logo_file = ''

## Port this service will listen on
#c.AnnouncementService.port = 8888
# Default: 8888
# c.AnnouncementService.port = 8888

## Announcement service prefix
#c.AnnouncementService.service_prefix = '/services/announcement/'
# Default: '/services/announcement/'
# c.AnnouncementService.service_prefix = '/services/announcement/'

## Allow access from subdomains
#c.AnnouncementService.allow_origin = False
## Instead of starting the Application, dump configuration to stdout
# See also: Application.show_config
# c.AnnouncementService.show_config = False

## Instead of starting the Application, dump configuration to stdout (as JSON)
# See also: Application.show_config_json
# c.AnnouncementService.show_config_json = False

## Search paths for jinja templates, coming before default ones
#c.AnnouncementService.template_paths = []
# Default: []
# c.AnnouncementService.template_paths = []

#------------------------------------------------------------------------------
# AnnouncementQueue(LoggingConfigurable) configuration
#------------------------------------------------------------------------------

## Number of days to retain announcements.
#
# Announcements that have been in the queue for this many days are purged from
# the queue.
#c.AnnouncementQueue.lifetime_days = 7.0
# Announcements that have been in the queue for this many days are
# purged from the queue.
# Default: 7.0
# c.AnnouncementQueue.lifetime_days = 7.0

## File path where announcements persist as JSON.
#
# For a persistent announcement queue, this parameter must be set to a non-empty
# value and correspond to a read+write-accessible path. The announcement queue
# is stored as a list of JSON objects. If this parameter is set to a non-empty
# value:
# For a persistent announcement queue, this parameter must be set to
# a non-empty value and correspond to a read+write-accessible path.
# The announcement queue is stored as a list of JSON objects. If this
# parameter is set to a non-empty value:
#
# * The persistence file is used to initialize the announcement queue
# at start-up. This is the only time the persistence file is read.
Expand All @@ -72,21 +114,23 @@
# * The persistence file is over-written with the contents of the
# announcement queue each time a new announcement is added.
#
# If this parameter is set to an empty value (the default) then the queue is
# just empty at initialization and the queue is ephemeral; announcements will
# not be persisted on updates to the queue.
#c.AnnouncementQueue.persist_path = ''
# If this parameter is set to an empty value (the default) then the
# queue is just empty at initialization and the queue is ephemeral;
# announcements will not be persisted on updates to the queue.
# Default: ''
# c.AnnouncementQueue.persist_path = ''

#------------------------------------------------------------------------------
# SSLContext(Configurable) configuration
#------------------------------------------------------------------------------

## SSL CA, use with keyfile and certfile
#c.SSLContext.cafile = ''
# Default: ''
# c.SSLContext.cafile = ''

## SSL cert, use with keyfile
#c.SSLContext.certfile = ''
# Default: ''
# c.SSLContext.certfile = ''

## SSL key, use with certfile
#c.SSLContext.keyfile = ''

# Default: ''
# c.SSLContext.keyfile = ''
Loading