Start extending to support GitLab authentication.

Add necessary dependency.
Add baseURL parameter for self-hosted GitLab
Add necessary require.
Add block for GitLab auth.
Fix typo
Update font-awesome dependency for GitLab icon.
Use a color closer to GitLab orange.
More direct TODO
This commit is contained in:
Jason Croft 2016-05-09 16:27:35 -04:00
parent 8e8a5e1ecb
commit 079822dfec
8 changed files with 43 additions and 1 deletions

17
app.js
View file

@ -292,6 +292,23 @@ if (config.github) {
//github callback actions //github callback actions
app.get('/auth/github/callback/:noteId/:action', response.githubActions); app.get('/auth/github/callback/:noteId/:action', response.githubActions);
} }
//gitlab auth
if (config.gitlab) {
app.get('/auth/gitlab',
passport.authenticate('gitlab'),
function (req, res) {});
//gitlab auth callback
app.get('/auth/gitlab/callback',
passport.authenticate('gitlab', {
failureRedirect: config.serverurl
}),
function (req, res) {
res.redirect(config.serverurl);
});
//gitlab callback actions
// TODO: Maybe in the future
//app.get('/auth/gitlab/callback/:noteId/:action', response.gitlabActions);
}
//dropbox auth //dropbox auth
if (config.dropbox) { if (config.dropbox) {
app.get('/auth/dropbox', app.get('/auth/dropbox',

View file

@ -20,7 +20,7 @@
"dependencies": { "dependencies": {
"bootstrap": "~3.3.6", "bootstrap": "~3.3.6",
"jquery": "~1.11.3", "jquery": "~1.11.3",
"font-awesome": "~4.5.0", "font-awesome": "~4.6.0",
"Ionicons": "ionicons#~2.0.1", "Ionicons": "ionicons#~2.0.1",
"reveal.js": "~3.2.0", "reveal.js": "~3.2.0",
"gsap": "greensock#~1.18.0", "gsap": "greensock#~1.18.0",

View file

@ -32,6 +32,11 @@
"clientID": "change this", "clientID": "change this",
"clientSecret": "change this" "clientSecret": "change this"
}, },
"gitlab": {
"baseURL": "change this",
"clientID": "change this",
"clientSecret": "change this"
},
"dropbox": { "dropbox": {
"clientID": "change this", "clientID": "change this",
"clientSecret": "change this" "clientSecret": "change this"

View file

@ -4,6 +4,7 @@ var passport = require('passport');
var FacebookStrategy = require('passport-facebook').Strategy; var FacebookStrategy = require('passport-facebook').Strategy;
var TwitterStrategy = require('passport-twitter').Strategy; var TwitterStrategy = require('passport-twitter').Strategy;
var GithubStrategy = require('passport-github').Strategy; var GithubStrategy = require('passport-github').Strategy;
var GitlabStrategy = require('passport-gitlab2').Strategy;
var DropboxStrategy = require('passport-dropbox-oauth2').Strategy; var DropboxStrategy = require('passport-dropbox-oauth2').Strategy;
//core //core
@ -56,6 +57,15 @@ if (config.github) {
callbackURL: config.serverurl + '/auth/github/callback' callbackURL: config.serverurl + '/auth/github/callback'
}, callback)); }, callback));
} }
//gitlab
if (config.gitlab) {
passport.use(new GitlabStrategy({
baseURL: config.gitlab.baseURL,
clientID: config.gitlab.clientID,
clientSecret: config.gitlab.clientSecret,
callbackURL: config.serverurl + '/auth/gitlab/callback'
}, callback));
}
//dropbox //dropbox
if (config.dropbox) { if (config.dropbox) {
passport.use(new DropboxStrategy({ passport.use(new DropboxStrategy({

View file

@ -59,6 +59,7 @@ var documentmaxlength = config.documentmaxlength || 100000;
var facebook = config.facebook || false; var facebook = config.facebook || false;
var twitter = config.twitter || false; var twitter = config.twitter || false;
var github = config.github || false; var github = config.github || false;
var gitlab = config.gitlab || false;
var dropbox = config.dropbox || false; var dropbox = config.dropbox || false;
var imgur = config.imgur || false; var imgur = config.imgur || false;
@ -110,6 +111,7 @@ module.exports = {
facebook: facebook, facebook: facebook,
twitter: twitter, twitter: twitter,
github: github, github: github,
gitlab: gitlab,
dropbox: dropbox, dropbox: dropbox,
imgur: imgur imgur: imgur
}; };

View file

@ -94,6 +94,7 @@ function showIndex(req, res, next) {
facebook: config.facebook, facebook: config.facebook,
twitter: config.twitter, twitter: config.twitter,
github: config.github, github: config.github,
gitlab: config.gitlab,
dropbox: config.dropbox, dropbox: config.dropbox,
}); });
res.write(content); res.write(content);
@ -124,6 +125,7 @@ function responseHackMD(res, note) {
facebook: config.facebook, facebook: config.facebook,
twitter: config.twitter, twitter: config.twitter,
github: config.github, github: config.github,
gitlab: config.gitlab,
dropbox: config.dropbox, dropbox: config.dropbox,
}); });
var buf = html; var buf = html;

View file

@ -39,6 +39,7 @@
"passport-dropbox-oauth2": "^1.0.0", "passport-dropbox-oauth2": "^1.0.0",
"passport-facebook": "^2.1.0", "passport-facebook": "^2.1.0",
"passport-github": "^1.1.0", "passport-github": "^1.1.0",
"passport-gitlab2": "^2.2.0",
"passport-twitter": "^1.0.4", "passport-twitter": "^1.0.4",
"passport.socketio": "^3.6.1", "passport.socketio": "^3.6.1",
"pg": "^4.5.3", "pg": "^4.5.3",

View file

@ -28,6 +28,11 @@
<i class="fa fa-dropbox"></i> Sign in via Dropbox <i class="fa fa-dropbox"></i> Sign in via Dropbox
</a> </a>
<% } %> <% } %>
<% if(gitlab) { %>
<a href="<%- url %>/auth/gitlab" class="btn btn-lg btn-block btn-social btn-soundcloud">
<i class="fa fa-gitlab"></i> Sign in via GitLab
</a>
<% } %>
</div> </div>
</div> </div>
</div> </div>