mirror of
https://github.com/jupyterhub/jupyterhub.git
synced 2025-10-18 07:23:00 +00:00
support oauth in services
fix bugs caught by tests
This commit is contained in:
@@ -57,7 +57,7 @@ from traitlets.config import LoggingConfigurable
|
||||
from .. import orm
|
||||
from ..traitlets import Command
|
||||
from ..spawner import LocalProcessSpawner, set_user_setuid
|
||||
from ..utils import url_path_join
|
||||
from ..utils import url_path_join, new_token
|
||||
|
||||
class _MockUser(HasTraits):
|
||||
name = Unicode()
|
||||
@@ -198,6 +198,30 @@ class Service(LoggingConfigurable):
|
||||
db = Any()
|
||||
orm = Any()
|
||||
|
||||
oauth_provider = Any()
|
||||
|
||||
oauth_client_id = Unicode(
|
||||
help="""OAuth client ID for this service.
|
||||
|
||||
You shouldn't generally need to change this.
|
||||
Default: `service-<name>`
|
||||
"""
|
||||
).tag(input=True)
|
||||
@default('oauth_client_id')
|
||||
def _default_client_id(self):
|
||||
return 'service-%s' % self.name
|
||||
|
||||
oauth_client_secret = Unicode(
|
||||
help="""OAuth client secret for this service.
|
||||
|
||||
Default: Generated on each launch.
|
||||
"""
|
||||
).tag(input=True)
|
||||
@default('oauth_client_secret')
|
||||
def _default_client_secret(self):
|
||||
self.log.debug("Generating new OAuth secret for service %s", self.name)
|
||||
return new_token()
|
||||
|
||||
@property
|
||||
def server(self):
|
||||
return self.orm.server
|
||||
@@ -242,6 +266,8 @@ class Service(LoggingConfigurable):
|
||||
cmd=self.command,
|
||||
environment=env,
|
||||
api_token=self.api_token,
|
||||
oauth_client_id=self.oauth_client_id,
|
||||
oauth_client_secret=self.oauth_client_secret,
|
||||
cwd=self.cwd,
|
||||
user=_MockUser(
|
||||
name=self.user,
|
||||
|
Reference in New Issue
Block a user