mirror of
https://github.com/wekan/wekan.git
synced 2026-11-25 04:49:41 -05:00
#6545 - a Keycloak login opened the popup and closed it immediately. The snap's default for OAUTH2_REQUEST_PERMISSIONS was "'openid profile email'" - the single quotes are part of the VALUE - so the scope sent to the provider was `'openid` … `email'`, which no provider knows and a strict one refuses outright. The default has no quotes now, and WeKan normalises the value anyway (models/lib/oauth2Scopes.js: strips surrounding quotes, accepts commas or spaces, drops duplicates), so an install still carrying the old value keeps working without anyone noticing the difference. #6546 / #6555 - there was a mongodb-bind-ip but no way to say where WeKan itself should listen, so it was always Meteor's default of 0.0.0.0 and IPv6 was unreachable. `snap set wekan bind-ip='::'` listens on IPv6 (and on IPv4 through it on a dual-stack host); empty keeps today's behaviour exactly. #6550 - an IPv6 database could not be reached at all: the snap built `mongodb://$MONGODB_BIND_IP:$PORT/wekan`, and an IPv6 LITERAL has to be bracketed - `mongodb://::1:27019/` is not a URL and the driver refuses it. The address is bracketed when it contains a colon, which no hostname and no IPv4 address does; the readiness probe builds its URI the same way, so it can no longer wait forever on a URL that cannot be parsed. #6551 - a mail server whose certificate does not match the name it is reached by ("Hostname/IP doesn't match certificate's altnames" - a wildcard one level too short, an internal CA) could not be used at all, because Meteor builds its transport from MAIL_URL with no say in it. MAIL_TLS_REJECT_UNAUTHORIZED=false installs a transport that connects anyway. #6553 - the same for an outgoing webhook to a server with a self-signed certificate: WEBHOOK_TLS_REJECT_UNAUTHORIZED=false. Both are OFF by default, both are per-purpose, and neither is NODE_TLS_REJECT_UNAUTHORIZED, which would drop certificate checking for everything the server connects to. The webhook switch changes nothing else: the connection is still pinned to the resolved address and private ranges are still refused, so the SSRF protection is untouched - what is given up is only the proof of who is on the other end, for the one endpoint the operator chose. tests/mailTransportTls.test.cjs covers the SMTP option building (ports, smtps, credentials with encoded characters), that only the exact string "false" turns verification off, that nothing is installed unless it is asked for, and that neither file reaches for the global switch. Thanks to lukasjelonek, sysblade, scoopex, 1977er, GuiGuiSoft, marioschulz93 and xet7 ! Fixes #6545, Fixes #6546, Fixes #6550, Fixes #6551, Fixes #6553, Fixes #6555.
74 lines
2.5 KiB
JavaScript
74 lines
2.5 KiB
JavaScript
'use strict';
|
|
|
|
// The OAuth2 / OIDC scope string, cleaned up before it is sent to the provider.
|
|
//
|
|
// #6545: a Keycloak login opened the popup and closed it again immediately,
|
|
// because the snap's default for OAUTH2_REQUEST_PERMISSIONS was
|
|
//
|
|
// "'openid profile email'"
|
|
//
|
|
// - the single quotes are part of the VALUE. The scope reaching the provider was
|
|
// therefore `'openid` … `email'`, which is not a scope any provider knows, and a
|
|
// strict one (Keycloak) refuses the whole authorization request.
|
|
//
|
|
// The snap default no longer has them, but every install configured from the old
|
|
// default or from a wiki example still carries them, and nothing on the WeKan
|
|
// side should depend on an operator noticing. So the value is normalised here:
|
|
// surrounding quotes are removed, commas count as separators (a list written the
|
|
// JSON way), whitespace is collapsed, and duplicates are dropped. The result is
|
|
// the space-separated string OAuth2 defines.
|
|
//
|
|
// An empty or missing value gives the documented default, `openid profile email`,
|
|
// which is what the OIDC client fell back to anyway.
|
|
|
|
const DEFAULT_SCOPES = 'openid profile email';
|
|
|
|
// Strip ONE layer of matching surrounding quotes, whatever kind.
|
|
function unquote(value) {
|
|
const text = String(value).trim();
|
|
|
|
if (text.length >= 2) {
|
|
const first = text[0];
|
|
const last = text[text.length - 1];
|
|
|
|
if ((first === "'" || first === '"' || first === '`') && first === last) {
|
|
return text.slice(1, -1).trim();
|
|
}
|
|
}
|
|
|
|
return text;
|
|
}
|
|
|
|
// The scopes as an array, in the order given, without empties or duplicates.
|
|
function parseScopes(value) {
|
|
if (value === undefined || value === null) return DEFAULT_SCOPES.split(' ');
|
|
|
|
// An array is already a list; a string may be space- or comma-separated.
|
|
const parts = Array.isArray(value)
|
|
? value.map(part => unquote(part))
|
|
: unquote(value).split(/[\s,]+/);
|
|
|
|
const seen = new Set();
|
|
const scopes = [];
|
|
|
|
for (const part of parts) {
|
|
// A single quote left inside is not part of a scope name: it is what a
|
|
// half-quoted value ("'openid profile email") leaves behind.
|
|
const scope = String(part).replace(/^['"`]+|['"`]+$/g, '').trim();
|
|
|
|
if (scope === '' || seen.has(scope)) continue;
|
|
|
|
seen.add(scope);
|
|
scopes.push(scope);
|
|
}
|
|
|
|
return scopes.length ? scopes : DEFAULT_SCOPES.split(' ');
|
|
}
|
|
|
|
// The value to hand to the OIDC client: the space-separated scope string.
|
|
function requestPermissions(value) {
|
|
return parseScopes(value).join(' ');
|
|
}
|
|
|
|
module.exports = { parseScopes, requestPermissions, DEFAULT_SCOPES, unquote };
|