mirror of
https://gitlab.com/commento/commento.git
synced 2025-06-28 22:55:39 -04:00
frontend, api, db: add single sign-on
Closes https://gitlab.com/commento/commento/issues/90
This commit is contained in:
@ -292,6 +292,29 @@
|
||||
<label for="gitlab-provider">GitLab login</label>
|
||||
</div>
|
||||
|
||||
<div class="row no-border commento-round-check">
|
||||
<input type="checkbox" v-model="domains[cd].ssoProvider" id="sso-provider" @change="window.commento.ssoProviderChangeHandler()">
|
||||
<label for="sso-provider">Single sign-on</label>
|
||||
</div>
|
||||
|
||||
<div class="indent" v-if="domains[cd].ssoProvider">
|
||||
<div class="row">
|
||||
<div class="label">HMAC shared secret key</div>
|
||||
<input class="input gray-input monospace" id="sso-secret" readonly="true" type="text" placeholder="Loading..." v-model="domains[cd].ssoSecret">
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="label">Redirect URL</div>
|
||||
<input class="input gray-input" id="sso-url" type="text" :placeholder="domains[cd].ssoUrl" v-model="domains[cd].ssoUrl">
|
||||
</div>
|
||||
<div class="normal-text">
|
||||
<div class="subtext-container">
|
||||
<div class="subtext">
|
||||
Read the Commento documentation <a href="https://docs.commento.io/configuration/frontend/sso.html">on single sign-on</a>.
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="warning" v-if="!domains[cd].allowAnonymous && !domains[cd].commentoProvider && !domains[cd].googleProvider && !domains[cd].twitterProvider && !domains[cd].githubProvider && !domains[cd].gitlabProvider">
|
||||
You have disabled all authentication options. Your readers will not be able to login, create comments, or vote.
|
||||
</div>
|
||||
|
@ -1214,10 +1214,14 @@
|
||||
global.popupRender = function(id) {
|
||||
var loginBoxContainer = $(ID_LOGIN_BOX_CONTAINER);
|
||||
var loginBox = create("div");
|
||||
var ssoSubtitle = create("div");
|
||||
var ssoButtonContainer = create("div");
|
||||
var ssoButton = create("div");
|
||||
var hr1 = create("hr");
|
||||
var oauthSubtitle = create("div");
|
||||
var oauthButtonsContainer = create("div");
|
||||
var oauthButtons = create("div");
|
||||
var hr = create("hr");
|
||||
var hr2 = create("hr");
|
||||
var emailSubtitle = create("div");
|
||||
var emailContainer = create("div");
|
||||
var email = create("div");
|
||||
@ -1233,7 +1237,7 @@
|
||||
emailButton.id = ID_LOGIN_BOX_EMAIL_BUTTON;
|
||||
loginLink.id = ID_LOGIN_BOX_LOGIN_LINK;
|
||||
loginLinkContainer.id = ID_LOGIN_BOX_LOGIN_LINK_CONTAINER;
|
||||
hr.id = ID_LOGIN_BOX_HR;
|
||||
hr2.id = ID_LOGIN_BOX_HR;
|
||||
oauthSubtitle.id = ID_LOGIN_BOX_OAUTH_PRETEXT;
|
||||
oauthButtonsContainer.id = ID_LOGIN_BOX_OAUTH_BUTTONS_CONTAINER;
|
||||
|
||||
@ -1246,6 +1250,9 @@
|
||||
classAdd(emailButton, "email-button");
|
||||
classAdd(loginLinkContainer, "login-link-container");
|
||||
classAdd(loginLink, "login-link");
|
||||
classAdd(ssoSubtitle, "login-box-subtitle");
|
||||
classAdd(ssoButtonContainer, "oauth-buttons-container");
|
||||
classAdd(ssoButton, "oauth-buttons");
|
||||
classAdd(oauthSubtitle, "login-box-subtitle");
|
||||
classAdd(oauthButtonsContainer, "oauth-buttons-container");
|
||||
classAdd(oauthButtons, "oauth-buttons");
|
||||
@ -1256,6 +1263,7 @@
|
||||
emailSubtitle.innerText = "Login with your email address";
|
||||
emailButton.innerText = "Continue";
|
||||
oauthSubtitle.innerText = "Proceed with social login";
|
||||
ssoSubtitle.innerText = "Proceed with " + parent.location.host + " authentication";
|
||||
|
||||
onclick(emailButton, global.passwordAsk, id);
|
||||
onclick(loginLink, global.popupSwitch);
|
||||
@ -1274,7 +1282,7 @@
|
||||
var button = create("button");
|
||||
|
||||
classAdd(button, "button");
|
||||
classAdd(button, provider+ "-button");
|
||||
classAdd(button, provider + "-button");
|
||||
|
||||
button.innerText = provider;
|
||||
|
||||
@ -1285,6 +1293,26 @@
|
||||
}
|
||||
});
|
||||
|
||||
if (configuredOauths["sso"]) {
|
||||
var button = create("button");
|
||||
|
||||
classAdd(button, "button");
|
||||
classAdd(button, "sso-button");
|
||||
|
||||
button.innerText = "Login with Single Sign-On";
|
||||
|
||||
onclick(button, global.commentoAuth, {"provider": "sso", "id": id});
|
||||
|
||||
append(ssoButton, button);
|
||||
append(ssoButtonContainer, ssoButton);
|
||||
append(loginBox, ssoSubtitle);
|
||||
append(loginBox, ssoButtonContainer);
|
||||
|
||||
if (numOauthConfigured > 0 || configuredOauths["commento"]) {
|
||||
append(loginBox, hr1);
|
||||
}
|
||||
}
|
||||
|
||||
if (numOauthConfigured > 0) {
|
||||
append(loginBox, oauthSubtitle);
|
||||
append(oauthButtonsContainer, oauthButtons);
|
||||
@ -1301,7 +1329,7 @@
|
||||
append(loginLinkContainer, loginLink);
|
||||
|
||||
if (numOauthConfigured > 0 && configuredOauths["commento"]) {
|
||||
append(loginBox, hr);
|
||||
append(loginBox, hr2);
|
||||
}
|
||||
|
||||
if (configuredOauths["commento"]) {
|
||||
|
@ -19,4 +19,27 @@
|
||||
});
|
||||
};
|
||||
|
||||
global.ssoProviderChangeHandler = function() {
|
||||
var data = global.dashboard.$data;
|
||||
|
||||
if (data.domains[data.cd].ssoSecret === "") {
|
||||
var json = {
|
||||
"ownerToken": global.cookieGet("commentoOwnerToken"),
|
||||
"domain": data.domains[data.cd].domain,
|
||||
};
|
||||
|
||||
global.post(global.origin + "/api/domain/sso/new", json, function(resp) {
|
||||
if (!resp.success) {
|
||||
global.globalErrorShow(resp.message);
|
||||
return;
|
||||
}
|
||||
|
||||
data.domains[data.cd].ssoSecret = resp.ssoSecret;
|
||||
$("#sso-secret").val(data.domains[data.cd].ssoSecret);
|
||||
});
|
||||
} else {
|
||||
$("#sso-secret").val(data.domains[data.cd].ssoSecret);
|
||||
}
|
||||
};
|
||||
|
||||
} (window.commento, document));
|
||||
|
@ -37,5 +37,12 @@
|
||||
font-size: 13px;
|
||||
width: 70px;
|
||||
}
|
||||
|
||||
.commento-sso-button {
|
||||
background: #000000;
|
||||
text-transform: uppercase;
|
||||
font-size: 13px;
|
||||
width: 200px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -367,6 +367,10 @@ body {
|
||||
font-size: 13px;
|
||||
line-height: 17px;
|
||||
text-align: center;
|
||||
|
||||
a {
|
||||
border: none;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -540,6 +544,11 @@ body {
|
||||
.input::placeholder {
|
||||
color: $gray-4;
|
||||
}
|
||||
|
||||
.monospace {
|
||||
font-family: "Source Code Pro", monospace;
|
||||
font-size: 11px;
|
||||
}
|
||||
}
|
||||
|
||||
.theme {
|
||||
@ -598,7 +607,7 @@ body {
|
||||
|
||||
.indent {
|
||||
margin-top: 0px;
|
||||
padding-left: 32px;
|
||||
padding-left: 35px;
|
||||
}
|
||||
|
||||
.stat {
|
||||
|
Reference in New Issue
Block a user