Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
158a14ec
Commit
158a14ec
authored
May 22, 2019
by
Amit Rathi
Committed by
Dmitriy Zaporozhets
May 22, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
JupyterHub Repo Integration
parent
728ddeb6
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
0 deletions
+34
-0
app/models/clusters/applications/jupyter.rb
app/models/clusters/applications/jupyter.rb
+9
-0
changelogs/unreleased/jupyter_pre_spawn_hook_v2.yml
changelogs/unreleased/jupyter_pre_spawn_hook_v2.yml
+5
-0
vendor/jupyter/values.yaml
vendor/jupyter/values.yaml
+20
-0
No files found.
app/models/clusters/applications/jupyter.rb
View file @
158a14ec
# frozen_string_literal: true
require
'securerandom'
module
Clusters
module
Applications
class
Jupyter
<
ApplicationRecord
...
...
@@ -80,6 +82,9 @@ module Clusters
"secretToken"
=>
secret_token
},
"auth"
=>
{
"state"
=>
{
"cryptoKey"
=>
crypto_key
},
"gitlab"
=>
{
"clientId"
=>
oauth_application
.
uid
,
"clientSecret"
=>
oauth_application
.
secret
,
...
...
@@ -95,6 +100,10 @@ module Clusters
}
end
def
crypto_key
@crypto_key
||=
SecureRandom
.
hex
(
32
)
end
def
project_id
cluster
&
.
project
&
.
id
end
...
...
changelogs/unreleased/jupyter_pre_spawn_hook_v2.yml
0 → 100644
View file @
158a14ec
---
title
:
Pass user's identity and token from JupyterHub to user's Jupyter environment
merge_request
:
27314
author
:
Amit Rathi
type
:
added
vendor/jupyter/values.yaml
View file @
158a14ec
...
...
@@ -8,8 +8,28 @@ hub:
extraConfig
:
|
c.KubeSpawner.cmd = ['jupyter-labhub']
async def add_auth_env(spawner):
'''
We set user's id, login and access token on single user image to
enable repository integration for JupyterHub.
See: https://gitlab.com/gitlab-org/gitlab-ce/issues/47138#note_154294790
'''
auth_state = await spawner.user.get_auth_state()
if not auth_state:
spawner.log.warning("No auth state for %s", spawner.user)
return
spawner.environment['GITLAB_ACCESS_TOKEN'] = auth_state['access_token']
spawner.environment['GITLAB_USER_LOGIN'] = auth_state['gitlab_user']['username']
spawner.environment['GITLAB_USER_ID'] = str(auth_state['gitlab_user']['id'])
c.KubeSpawner.pre_spawn_hook = add_auth_env
auth
:
type
:
gitlab
state
:
enabled
:
true
singleuser
:
defaultUrl
:
"
/lab"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment