Add config option for gitlab api scope and auto adapt gitlab snippet feature on it
This commit is contained in:
parent
baf13072c1
commit
506a381eca
7 changed files with 19 additions and 9 deletions
|
@ -128,6 +128,7 @@ Environment variables (will overwrite other server configs)
|
|||
| HMD_TWITTER_CONSUMERSECRET | no example | Twitter API consumer secret |
|
||||
| HMD_GITHUB_CLIENTID | no example | GitHub API client id |
|
||||
| HMD_GITHUB_CLIENTSECRET | no example | GitHub API client secret |
|
||||
| HMD_GITLAB_SCOPE | `read_user` or `api` | GitLab API requested scope (default is `api`) (gitlab snippet import/export need `api` scope) |
|
||||
| HMD_GITLAB_BASEURL | no example | GitLab authentication endpoint, set to use other endpoint than GitLab.com (optional) |
|
||||
| HMD_GITLAB_CLIENTID | no example | GitLab API client id |
|
||||
| HMD_GITLAB_CLIENTSECRET | no example | GitLab API client secret |
|
||||
|
|
6
app.js
6
app.js
|
@ -335,8 +335,10 @@ if (config.github) {
|
|||
successReturnToOrRedirect: config.serverurl + '/',
|
||||
failureRedirect: config.serverurl + '/'
|
||||
}))
|
||||
// github callback actions
|
||||
app.get('/auth/github/callback/:noteId/:action', response.githubActions)
|
||||
if (!config.gitlab.scope || config.gitlab.scope === 'api') {
|
||||
// gitlab callback actions
|
||||
app.get('/auth/gitlab/callback/:noteId/:action', response.gitlabActions)
|
||||
}
|
||||
}
|
||||
// gitlab auth
|
||||
if (config.gitlab) {
|
||||
|
|
4
app.json
4
app.json
|
@ -89,6 +89,10 @@
|
|||
"description": "GitLab API client secret",
|
||||
"required": false
|
||||
},
|
||||
"HMD_GITLAB_SCOPE": {
|
||||
"description": "GitLab API client scope (optional)",
|
||||
"required": false
|
||||
},
|
||||
"HMD_DROPBOX_CLIENTID": {
|
||||
"description": "Dropbox API client id",
|
||||
"required": false
|
||||
|
|
|
@ -36,7 +36,8 @@
|
|||
"gitlab": {
|
||||
"baseURL": "change this",
|
||||
"clientID": "change this",
|
||||
"clientSecret": "change this"
|
||||
"clientSecret": "change this",
|
||||
"scope": "use 'read_user' scope for auth user only or remove this property if you need gitlab snippet import/export support (will result to be default scope 'api')"
|
||||
},
|
||||
"dropbox": {
|
||||
"clientID": "change this",
|
||||
|
|
|
@ -91,6 +91,7 @@ function registerAuthMethod () {
|
|||
baseURL: config.gitlab.baseURL,
|
||||
clientID: config.gitlab.clientID,
|
||||
clientSecret: config.gitlab.clientSecret,
|
||||
scope: config.gitlab.scope,
|
||||
callbackURL: config.serverurl + '/auth/gitlab/callback'
|
||||
}, callback))
|
||||
}
|
||||
|
|
|
@ -102,8 +102,9 @@ var github = ((process.env.HMD_GITHUB_CLIENTID && process.env.HMD_GITHUB_CLIENTS
|
|||
var gitlab = ((process.env.HMD_GITLAB_CLIENTID && process.env.HMD_GITLAB_CLIENTSECRET) || (fs.existsSync('/run/secrets/gitlab_clientID') && fs.existsSync('/run/secrets/gitlab_clientSecret'))) ? {
|
||||
baseURL: process.env.HMD_GITLAB_BASEURL,
|
||||
clientID: handleDockerSecret('gitlab_clientID') || process.env.HMD_GITLAB_CLIENTID,
|
||||
clientSecret: handleDockerSecret('gitlab_clientSecret') || process.env.HMD_GITLAB_CLIENTSECRET
|
||||
} : config.gitlab || false
|
||||
clientSecret: handleDockerSecret('gitlab_clientSecret') || process.env.HMD_GITLAB_CLIENTSECRET,
|
||||
scope: process.env.HMD_GITLAB_SCOPE
|
||||
} : (config.gitlab && config.gitlab.clientID && config.gitlab.clientSecret && config.gitlab) || false
|
||||
var dropbox = ((process.env.HMD_DROPBOX_CLIENTID && process.env.HMD_DROPBOX_CLIENTSECRET) || (fs.existsSync('/run/secrets/dropbox_clientID') && fs.existsSync('/run/secrets/dropbox_clientSecret'))) ? {
|
||||
clientID: handleDockerSecret('dropbox_clientID') || process.env.HMD_DROPBOX_CLIENTID,
|
||||
clientSecret: handleDockerSecret('dropbox_clientSecret') || process.env.HMD_DROPBOX_CLIENTSECRET
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
<li role="presentation"><a role="menuitem" class="ui-save-gist" tabindex="-1" href="#" target="_blank"><i class="fa fa-github fa-fw"></i> Gist</a>
|
||||
</li>
|
||||
<% } %>
|
||||
<% if(typeof gitlab !== 'undefined' && gitlab) { %>
|
||||
<% if(typeof gitlab !== 'undefined' && gitlab && (!gitlab.scope || gitlab.scope === 'api')) { %>
|
||||
<li role="presentation"><a role="menuitem" class="ui-save-snippet" href="#"><i class="fa fa-gitlab fa-fw"></i> Snippet</a>
|
||||
</li>
|
||||
<% } %>
|
||||
|
@ -54,7 +54,7 @@
|
|||
</li>
|
||||
<li role="presentation"><a role="menuitem" class="ui-import-gist" href="#" data-toggle="modal" data-target="#gistImportModal"><i class="fa fa-github fa-fw"></i> Gist</a>
|
||||
</li>
|
||||
<% if(typeof gitlab !== 'undefined' && gitlab) { %>
|
||||
<% if(typeof gitlab !== 'undefined' && gitlab && (!gitlab.scope || gitlab.scope === 'api')) { %>
|
||||
<li role="presentation"><a role="menuitem" class="ui-import-snippet" href="#"><i class="fa fa-gitlab fa-fw"></i> Snippet</a>
|
||||
</li>
|
||||
<% } %>
|
||||
|
@ -139,7 +139,7 @@
|
|||
<li role="presentation"><a role="menuitem" class="ui-save-gist" tabindex="-1" href="#" target="_blank"><i class="fa fa-github fa-fw"></i> Gist</a>
|
||||
</li>
|
||||
<% } %>
|
||||
<% if(typeof gitlab !== 'undefined' && gitlab) { %>
|
||||
<% if(typeof gitlab !== 'undefined' && gitlab && (!gitlab.scope || gitlab.scope === 'api')) { %>
|
||||
<li role="presentation"><a role="menuitem" class="ui-save-snippet" href="#"><i class="fa fa-gitlab fa-fw"></i> Snippet</a>
|
||||
</li>
|
||||
<% } %>
|
||||
|
@ -151,7 +151,7 @@
|
|||
</li>
|
||||
<li role="presentation"><a role="menuitem" class="ui-import-gist" href="#" data-toggle="modal" data-target="#gistImportModal"><i class="fa fa-github fa-fw"></i> Gist</a>
|
||||
</li>
|
||||
<% if(typeof gitlab !== 'undefined' && gitlab) { %>
|
||||
<% if(typeof gitlab !== 'undefined' && gitlab && (!gitlab.scope || gitlab.scope === 'api')) { %>
|
||||
<li role="presentation"><a role="menuitem" class="ui-import-snippet" href="#"><i class="fa fa-gitlab fa-fw"></i> Snippet</a>
|
||||
</li>
|
||||
<% } %>
|
||||
|
|
Loading…
Reference in a new issue