mirror of
https://github.com/wekan/wekan.git
synced 2026-11-24 09:59:47 -05:00
Member Settings gets Passkeys: add a passkey on this device under a name, see the account's passkeys and remove one. The sign-in page gets "Sign in with a passkey": the browser offers this WeKan's passkeys, no user name needed. Verification is @simplewebauthn/server 14.0.3 (MIT, pinned) against ROOT_URL's host and origin, so a passkey cannot sign in to another site or through another address; each sign-in signs a fresh challenge that is used once and expires in five minutes, and the signature counter must move forward, so a copied passkey is refused. A disabled account cannot sign in with one (the existing validateLoginAttempt hooks apply). Passkeys are a top-level user field, never published and not writable from the client; up to 20 per account. Not offered on Sandstorm. Member Settings also gets Log out everywhere: after a confirmation every login token of the account goes, so Meteor ends every session - other browsers, phones, the desktop app - and this one. Nothing else changes. models/lib/passkeys.js holds the relying party, base64url and the browser conversions; client/lib/passkeys.js uses navigator.credentials directly. tests/passkeys.test.cjs signs assertions with a software ES256 authenticator: a real signature verifies, and another key, another origin, another challenge or a counter that went back are refused; it also checks single-use challenges, the unpublished field and the pin. server/lib/tests/passkeys.tests.js runs in Meteor (2 passing): the module bundles, login options name no account, and registration needs a user. Documented in docs/Features/Login/Passkeys.md. The new strings are English placeholders until the next translation pass. Thanks to xet7 ! Fixes #5847.
27 lines
1.3 KiB
JavaScript
27 lines
1.3 KiB
JavaScript
/* eslint-env mocha */
|
|
// #5847: the passkey server loads in Meteor - @simplewebauthn/server bundled
|
|
// and the methods registered - and anonymous login options name no account.
|
|
import { Meteor } from 'meteor/meteor';
|
|
import { expect } from 'chai';
|
|
|
|
describe('passkeys (runtime)', function () {
|
|
it('offers login options with a stored single-use challenge', async function () {
|
|
const handler = Meteor.server.method_handlers.passkeyLoginOptions;
|
|
expect(handler, 'passkeyLoginOptions is registered').to.be.a('function');
|
|
const { challengeId, options } = await handler.call({ userId: null });
|
|
expect(challengeId).to.be.a('string');
|
|
expect(options.challenge).to.be.a('string');
|
|
expect(options.allowCredentials || []).to.have.length(0, 'no account is named');
|
|
const { PasskeyChallenges } = require('/server/passkeys');
|
|
const saved = await PasskeyChallenges.findOneAsync(challengeId);
|
|
expect(saved.kind).to.equal('login');
|
|
expect(saved.expiresAt.getTime()).to.be.greaterThan(Date.now());
|
|
});
|
|
|
|
it('refuses registration without a signed-in user', async function () {
|
|
let error;
|
|
try { await Meteor.server.method_handlers.passkeyRegistrationOptions.call({ userId: null }); } catch (e) { error = e; }
|
|
expect(error && error.error).to.equal('not-logged-in');
|
|
});
|
|
});
|