mirror of
https://github.com/wekan/wekan.git
synced 2025-09-22 01:50:48 +02:00
wip redirect on landing page and logout to oidc provider
This commit is contained in:
parent
b97c51abde
commit
2e354f9b1e
7 changed files with 92 additions and 15 deletions
|
@ -8,7 +8,7 @@ const i18nTagToT9n = i18nTag => {
|
||||||
|
|
||||||
let alreadyCheck = 1;
|
let alreadyCheck = 1;
|
||||||
let isCheckDone = false;
|
let isCheckDone = false;
|
||||||
|
let counter = 0;
|
||||||
const validator = {
|
const validator = {
|
||||||
set(obj, prop, value) {
|
set(obj, prop, value) {
|
||||||
if (prop === 'state' && value !== 'signIn') {
|
if (prop === 'state' && value !== 'signIn') {
|
||||||
|
@ -54,6 +54,46 @@ Template.userFormsLayout.onCreated(function() {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Meteor.call('isOidcRedirectionEnabled', (_, result) => {
|
||||||
|
serviceName = 'oidc';
|
||||||
|
if (result) {
|
||||||
|
if(Session.get("tmp") && ((Math.floor(Date.now() / 1000) - Session.get("tmp") < 5) ))
|
||||||
|
{
|
||||||
|
window.location.reload(true);
|
||||||
|
console.log(Meteor.user().profile);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Session.set("tmp", Math.floor(Date.now() / 1000));
|
||||||
|
console.log("Säschön", Session.get("tmp"));
|
||||||
|
methodName = "loginWithOidc";
|
||||||
|
var loginWithService = Meteor[methodName];
|
||||||
|
AccountsTemplates.options.socialLoginStyle = 'redirect';
|
||||||
|
options = {
|
||||||
|
loginStyle: AccountsTemplates.options.socialLoginStyle,
|
||||||
|
};
|
||||||
|
console.log("keys", options);
|
||||||
|
loginWithService(options, function(err) {
|
||||||
|
AccountsTemplates.setDisabled(false);
|
||||||
|
if (err && err instanceof Accounts.LoginCancelledError)
|
||||||
|
{
|
||||||
|
console.log("login cancelled");
|
||||||
|
}
|
||||||
|
else if (err && err instanceof ServiceConfiguration.ConfigError)
|
||||||
|
{
|
||||||
|
console.log("service config");
|
||||||
|
if (Accounts._loginButtonsSession) return Accounts._loginButtonsSession.configureService('oidc');
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
console.log("else_block");
|
||||||
|
AccountsTemplates.submitCallback(err, state);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else console.log("kein result");
|
||||||
|
});
|
||||||
Meteor.call('isDisableRegistration', (_, result) => {
|
Meteor.call('isDisableRegistration', (_, result) => {
|
||||||
if (result) {
|
if (result) {
|
||||||
$('.at-signup-link').hide();
|
$('.at-signup-link').hide();
|
||||||
|
@ -286,6 +326,7 @@ Template.userFormsLayout.events({
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
},
|
},
|
||||||
'click #at-btn'(event, templateInstance) {
|
'click #at-btn'(event, templateInstance) {
|
||||||
|
console.log("hello");
|
||||||
if (FlowRouter.getRouteName() === 'atSignIn') {
|
if (FlowRouter.getRouteName() === 'atSignIn') {
|
||||||
templateInstance.isLoading.set(true);
|
templateInstance.isLoading.set(true);
|
||||||
authentication(event, templateInstance).then(() => {
|
authentication(event, templateInstance).then(() => {
|
||||||
|
|
|
@ -3,6 +3,7 @@ const emailField = AccountsTemplates.removeField('email');
|
||||||
let disableRegistration = false;
|
let disableRegistration = false;
|
||||||
let disableForgotPassword = false;
|
let disableForgotPassword = false;
|
||||||
let passwordLoginDisabled = false;
|
let passwordLoginDisabled = false;
|
||||||
|
let oidcEnabled = false;
|
||||||
|
|
||||||
Meteor.call('isPasswordLoginDisabled', (_, result) => {
|
Meteor.call('isPasswordLoginDisabled', (_, result) => {
|
||||||
if (result) {
|
if (result) {
|
||||||
|
@ -11,6 +12,16 @@ Meteor.call('isPasswordLoginDisabled', (_, result) => {
|
||||||
//console.log(result);
|
//console.log(result);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Meteor.call('getOauthServerUrl', (_, result) => {
|
||||||
|
if (result) {
|
||||||
|
oauthServerUrl = result;
|
||||||
|
const a = document.createElement("a");
|
||||||
|
a.href = oauthServerUrl;
|
||||||
|
const baseUrl = `${a.protocol}//${a.hostname}`;
|
||||||
|
console.log(baseUrl);
|
||||||
|
}
|
||||||
|
else oauthServerUrl = "home";
|
||||||
|
});
|
||||||
|
|
||||||
Meteor.call('isDisableRegistration', (_, result) => {
|
Meteor.call('isDisableRegistration', (_, result) => {
|
||||||
if (result) {
|
if (result) {
|
||||||
|
@ -19,7 +30,9 @@ Meteor.call('isDisableRegistration', (_, result) => {
|
||||||
//console.log(result);
|
//console.log(result);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Meteor.call('isOidcRedirectionEnabled', (_, result) => {
|
||||||
|
oidcEnabled = result ? true : false;
|
||||||
|
});
|
||||||
Meteor.call('isDisableForgotPassword', (_, result) => {
|
Meteor.call('isDisableForgotPassword', (_, result) => {
|
||||||
if (result) {
|
if (result) {
|
||||||
disableForgotPassword = true;
|
disableForgotPassword = true;
|
||||||
|
@ -57,6 +70,12 @@ AccountsTemplates.configure({
|
||||||
showForgotPasswordLink: !disableForgotPassword,
|
showForgotPasswordLink: !disableForgotPassword,
|
||||||
forbidClientAccountCreation: disableRegistration,
|
forbidClientAccountCreation: disableRegistration,
|
||||||
onLogoutHook() {
|
onLogoutHook() {
|
||||||
|
if(oidcEnabled && oauthServerUrl!=="home")
|
||||||
|
{
|
||||||
|
|
||||||
|
oidcEnabled = !oidcEnabled;
|
||||||
|
window.location.href = oauthServerUrl + "/if/user/#/library";
|
||||||
|
}
|
||||||
const homePage = 'home';
|
const homePage = 'home';
|
||||||
if (FlowRouter.getRouteName() === homePage) {
|
if (FlowRouter.getRouteName() === homePage) {
|
||||||
FlowRouter.reload();
|
FlowRouter.reload();
|
||||||
|
|
|
@ -494,6 +494,12 @@ if (Meteor.isServer) {
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
|
getOauthServerUrl(){
|
||||||
|
return process.env.OAUTH2_SERVER_URL;
|
||||||
|
},
|
||||||
|
getOauthDashboardUrl(){
|
||||||
|
return process.env.DASHBOARD_URL;
|
||||||
|
},
|
||||||
getDefaultAuthenticationMethod() {
|
getDefaultAuthenticationMethod() {
|
||||||
return process.env.DEFAULT_AUTHENTICATION_METHOD;
|
return process.env.DEFAULT_AUTHENTICATION_METHOD;
|
||||||
},
|
},
|
||||||
|
@ -501,6 +507,10 @@ if (Meteor.isServer) {
|
||||||
isPasswordLoginDisabled() {
|
isPasswordLoginDisabled() {
|
||||||
return process.env.PASSWORD_LOGIN_ENABLED === 'false';
|
return process.env.PASSWORD_LOGIN_ENABLED === 'false';
|
||||||
},
|
},
|
||||||
|
isOidcRedirectionEnabled(){
|
||||||
|
console.log(process.env.REDIRECT_LOGIN_LOGOUT_TO_OIDC === 'true');
|
||||||
|
return process.env.REDIRECT_LOGIN_LOGOUT_TO_OIDC === 'true';
|
||||||
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,11 +7,14 @@ if (Meteor.isClient) {
|
||||||
callback = options;
|
callback = options;
|
||||||
options = null;
|
options = null;
|
||||||
}
|
}
|
||||||
|
console.log(options.loginStyle);
|
||||||
|
console.log(callback);
|
||||||
var credentialRequestCompleteCallback = Accounts.oauth.credentialRequestCompleteHandler(callback);
|
var credentialRequestCompleteCallback = Accounts.oauth.credentialRequestCompleteHandler(callback);
|
||||||
|
console.log("credentialCallback",credentialRequestCompleteCallback);
|
||||||
Oidc.requestCredential(options, credentialRequestCompleteCallback);
|
Oidc.requestCredential(options, credentialRequestCompleteCallback);
|
||||||
};
|
};
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
Accounts.addAutopublishFields({
|
Accounts.addAutopublishFields({
|
||||||
// not sure whether the OIDC api can be used from the browser,
|
// not sure whether the OIDC api can be used from the browser,
|
||||||
// thus not sure if we should be sending access tokens; but we do it
|
// thus not sure if we should be sending access tokens; but we do it
|
||||||
|
|
|
@ -7,6 +7,8 @@ Oidc = {};
|
||||||
// error.
|
// error.
|
||||||
Oidc.requestCredential = function (options, credentialRequestCompleteCallback) {
|
Oidc.requestCredential = function (options, credentialRequestCompleteCallback) {
|
||||||
// support both (options, callback) and (callback).
|
// support both (options, callback) and (callback).
|
||||||
|
console.log("from client");
|
||||||
|
console.log(options);
|
||||||
if (!credentialRequestCompleteCallback && typeof options === 'function') {
|
if (!credentialRequestCompleteCallback && typeof options === 'function') {
|
||||||
credentialRequestCompleteCallback = options;
|
credentialRequestCompleteCallback = options;
|
||||||
options = {};
|
options = {};
|
||||||
|
@ -55,13 +57,14 @@ Oidc.requestCredential = function (options, credentialRequestCompleteCallback) {
|
||||||
width: options.popupOptions.width || 320,
|
width: options.popupOptions.width || 320,
|
||||||
height: options.popupOptions.height || 450
|
height: options.popupOptions.height || 450
|
||||||
};
|
};
|
||||||
|
OAuth.saveDataForRedirect(options.loginService, options.credentialToken);
|
||||||
OAuth.launchLogin({
|
Accounts.oauth.tryLoginAfterPopupClosed(credentialToken, credentialRequestCompleteCallback);
|
||||||
loginService: 'oidc',
|
// OAuth.launchLogin({
|
||||||
loginStyle: loginStyle,
|
// loginService: 'oidc',
|
||||||
loginUrl: loginUrl,
|
// loginStyle: loginStyle,
|
||||||
credentialRequestCompleteCallback: credentialRequestCompleteCallback,
|
// loginUrl: loginUrl,
|
||||||
credentialToken: credentialToken,
|
// credentialRequestCompleteCallback: credentialRequestCompleteCallback,
|
||||||
popupOptions: popupOptions,
|
// credentialToken: credentialToken,
|
||||||
});
|
// popupOptions: popupOptions,
|
||||||
|
// });
|
||||||
};
|
};
|
||||||
|
|
|
@ -19,7 +19,8 @@ var serviceData = {};
|
||||||
var userinfo = {};
|
var userinfo = {};
|
||||||
|
|
||||||
OAuth.registerService('oidc', 2, null, function (query) {
|
OAuth.registerService('oidc', 2, null, function (query) {
|
||||||
|
console.log(Date.now());
|
||||||
|
console.log("query: ", query);
|
||||||
var debug = process.env.DEBUG || false;
|
var debug = process.env.DEBUG || false;
|
||||||
|
|
||||||
var token = getToken(query);
|
var token = getToken(query);
|
||||||
|
|
|
@ -108,7 +108,7 @@ Meteor.startup(() => {
|
||||||
// OAUTH2_ID_TOKEN_WHITELIST_FIELDS || [],
|
// OAUTH2_ID_TOKEN_WHITELIST_FIELDS || [],
|
||||||
// OAUTH2_REQUEST_PERMISSIONS || 'openid profile email',
|
// OAUTH2_REQUEST_PERMISSIONS || 'openid profile email',
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
} else if (
|
} else if (
|
||||||
process.env.CAS_ENABLED === 'true' ||
|
process.env.CAS_ENABLED === 'true' ||
|
||||||
process.env.CAS_ENABLED === true
|
process.env.CAS_ENABLED === true
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue