Skip to content
Closed
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
4 changes: 4 additions & 0 deletions lib/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ module.exports = (function () {
clientSecret: "replace me with the real value",
redirectURL: ""
},
cloudron: {
enabled: false
},
// @deprecated, use local with just an user
alone: {
enabled: false,
Expand Down Expand Up @@ -155,6 +158,7 @@ module.exports = (function () {

if (!config.authentication.google.enabled &&
!config.authentication.github.enabled &&
!config.authentication.cloudron.enabled &&
!config.authentication.alone.enabled &&
!config.authentication.local.enabled
) {
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
"morgan": "^1.5.0",
"node-syntaxhighlighter": "*",
"passport": "^0.2.0",
"passport-cloudron": "^0.3.2",
"passport-github": "^0.1.5",
"passport-google-oauth": "^0.1.5",
"passport-local": "^1.0.0",
Expand Down
20 changes: 20 additions & 0 deletions routes/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ var router = require("express").Router(),
passportLocal = require("passport-local"),
passportGoogle = require("passport-google-oauth"),
passportGithub = require("passport-github").Strategy,
passportCloudron = require("passport-cloudron"),
tools = require("../lib/tools");

var auth = app.locals.config.get("authentication");
Expand Down Expand Up @@ -33,6 +34,12 @@ router.get("/auth/github/callback", passport.authenticate("github", {
failureRedirect: proxyPath + "/login"
}));

router.get("/auth/cloudron", passport.authenticate("cloudron"));
router.get("/auth/cloudron/callback", passport.authenticate("cloudron", {
successRedirect: proxyPath + "/auth/done",
failureRedirect: proxyPath + "/login"
}));

if (auth.google.enabled) {
var redirectURL = auth.google.redirectURL || app.locals.baseUrl + "/oauth2callback";
passport.use(new passportGoogle.OAuth2Strategy({
Expand Down Expand Up @@ -67,6 +74,19 @@ if (auth.github.enabled) {
));
}

if (auth.cloudron.enabled) {
var redirectURL = process.env.APP_ORIGIN + "/auth/cloudron/callback";

passport.use(new passportCloudron({
callbackURL: redirectURL
},
function (accessToken, refreshToken, profile, done) {
usedAuthentication("cloudron");
done(null, profile);
}
));
}

if (auth.alone.enabled) {

passport.use(new passportLocal.Strategy(
Expand Down
19 changes: 12 additions & 7 deletions views/layout.jade
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,22 @@ include mixins/links
if hasSidebar()
.col-md-2.with-sidebar
.content !{_sidebar}
else
.col-md-2

#main.hide-tools.col-md-8
block content
#main.hide-tools.col-md-10
block content
else
#main.hide-tools.col-md-12
block content

if hasFooter()
.row
.col-md-2
.col-md-8.with-footer
.content !{_footer}
if hasSidebar()
.col-md-2
.col-md-10.with-footer
.content !{_footer}
else
.col-md-12.with-footer
.content !{_footer}

script(src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js")
script.
Expand Down
4 changes: 4 additions & 0 deletions views/login.jade
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ block content
p
+anchor('/auth/github', 'Github login').btn-auth.btn-auth-github

if (auth.cloudron.enabled)
p
a.btn.btn-primary(href="/auth/cloudron") Cloudron Login

if (auth.google.enabled || auth.github.enabled)
p
+anchor("/", 'Cancel')
Expand Down