mirror of
https://github.com/wekan/wekan.git
synced 2026-11-24 09:59:47 -05:00
New passwords: PASSWORD_MIN_LENGTH (default 8) and PASSWORD_CHECK_PWNED (off by default), in Admin Panel / People / Login and on every platform. The browser sends a password to Meteor hashed, so the server checks every password that reaches it as text - Admin Panel Set password and Add user, POST /users/register - and the sign-up, Change Password, reset and enrolment forms check in the browser. Signing in is never checked, so an existing shorter password keeps working until it is changed. A breached password is found with Have I Been Pwned's k-anonymity range API: only 5 hex digits of the SHA-1 leave WeKan, and an unreachable service never refuses a password. REQUIRE_2FA: off (default), admins or all. It covers accounts that sign in with a WeKan password; LDAP, OAuth2, SAML, CAS and Sandstorm accounts sign in through an identity provider and are not asked. Such an account can still sign in, sees only the 2FA set-up until it has 2FA, and until then the server refuses every method and publication but signing in and enrolling, HTTP routes do not accept its login and the REST API gives it no token. Once required, 2FA cannot be switched off. The new interface strings are pending translation. Thanks to xet7 !
56 lines
1.7 KiB
JavaScript
56 lines
1.7 KiB
JavaScript
import { Blaze } from 'meteor/blaze';
|
|
import { Template } from 'meteor/templating';
|
|
import { Tracker } from 'meteor/tracker';
|
|
|
|
// REQUIRE_2FA: after signing in, ask whether this account must still set up
|
|
// two-factor authentication, and if so show nothing but the set-up
|
|
// (twoFactorRequired.jade). accounts-2fa publishes the account's own
|
|
// services.twoFactorAuthentication.type, so finishing the set-up is seen at
|
|
// once; the page then reloads, because every subscription the server left
|
|
// empty meanwhile has to be made again.
|
|
let overlay = null;
|
|
|
|
function closeOverlay() {
|
|
if (!overlay) return;
|
|
Blaze.remove(overlay.view);
|
|
overlay.node.remove();
|
|
overlay = null;
|
|
}
|
|
|
|
function openOverlay() {
|
|
if (overlay) return;
|
|
const node = document.createElement('div');
|
|
document.body.appendChild(node);
|
|
overlay = { node, view: Blaze.render(Template.twoFactorRequired, node) };
|
|
}
|
|
|
|
Template.twoFactorRequired.events({
|
|
'click .js-two-factor-required-logout'() {
|
|
Meteor.logout(() => closeOverlay());
|
|
},
|
|
});
|
|
|
|
Meteor.startup(() => {
|
|
let askedFor = null;
|
|
Tracker.autorun(() => {
|
|
const userId = Meteor.userId();
|
|
const user = Meteor.user({ fields: { 'services.twoFactorAuthentication.type': 1 } });
|
|
if (!userId) {
|
|
askedFor = null;
|
|
closeOverlay();
|
|
return;
|
|
}
|
|
const enabled = user?.services?.twoFactorAuthentication?.type === 'otp';
|
|
if (overlay && enabled) {
|
|
window.location.reload();
|
|
return;
|
|
}
|
|
if (askedFor === userId) return;
|
|
askedFor = userId;
|
|
Meteor.call('getTwoFactorRequirement', (error, result) => {
|
|
if (error || !result || Meteor.userId() !== userId) return;
|
|
if (result.required && !result.enabled) openOverlay();
|
|
});
|
|
});
|
|
});
|