From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 4030892359 for ; Thu, 1 Feb 2024 15:25:08 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 1D0A31164B for ; Thu, 1 Feb 2024 15:24:38 +0100 (CET) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS for ; Thu, 1 Feb 2024 15:24:36 +0100 (CET) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 6905F40C0D for ; Thu, 1 Feb 2024 15:24:36 +0100 (CET) From: Gabriel Goller To: pbs-devel@lists.proxmox.com Date: Thu, 1 Feb 2024 15:24:28 +0100 Message-ID: <20240201142431.195108-1-g.goller@proxmox.com> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL -0.123 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record T_SCC_BODY_TEXT_LINE -0.01 - URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [openid.rs, lib.rs, rfc-editor.org, openid.net] Subject: [pbs-devel] [PATCH proxmox-backup] fix #5190: api-types: openid acr format regex X-BeenThere: pbs-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Backup Server development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 01 Feb 2024 14:25:08 -0000 Allow more complex strings for the acr-value when using openid. The openid documentation only specifies the acr-value *should* be an URI [0]. Implemented a regex that loosely disallows some of the reserved URI characters specified in the RFC [1]. A value like "urn:mace:incommon:iap:silver" should work. [0]: https://openid.net/specs/openid-connect-core-1_0.html [1]: https://www.rfc-editor.org/rfc/rfc2396.txt Signed-off-by: Gabriel Goller --- pbs-api-types/src/lib.rs | 3 +++ pbs-api-types/src/openid.rs | 5 +++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/pbs-api-types/src/lib.rs b/pbs-api-types/src/lib.rs index 795ff2a6..2668db3e 100644 --- a/pbs-api-types/src/lib.rs +++ b/pbs-api-types/src/lib.rs @@ -178,6 +178,9 @@ const_regex! { /// any identifier command line tools work with. pub PROXMOX_SAFE_ID_REGEX = concat!(r"^", PROXMOX_SAFE_ID_REGEX_STR!(), r"$"); + /// Regex that (loosely) matches URIs according to [RFC 2396](https://www.rfc-editor.org/rfc/rfc2396.txt) + pub URI_REGEX = r#"^[^\x00-\x1F\x7F <>#"]*$"#; + pub SINGLE_LINE_COMMENT_REGEX = r"^[[:^cntrl:]]*$"; pub MULTI_LINE_COMMENT_REGEX = r"(?m)^([[:^cntrl:]]*)$"; diff --git a/pbs-api-types/src/openid.rs b/pbs-api-types/src/openid.rs index 2c7646a3..049137e6 100644 --- a/pbs-api-types/src/openid.rs +++ b/pbs-api-types/src/openid.rs @@ -4,6 +4,7 @@ use proxmox_schema::{api, ApiStringFormat, ArraySchema, Schema, StringSchema, Up use super::{ PROXMOX_SAFE_ID_FORMAT, PROXMOX_SAFE_ID_REGEX, REALM_ID_SCHEMA, SINGLE_LINE_COMMENT_SCHEMA, + URI_REGEX, }; pub const OPENID_SCOPE_FORMAT: ApiStringFormat = ApiStringFormat::Pattern(&PROXMOX_SAFE_ID_REGEX); @@ -24,11 +25,11 @@ pub const OPENID_SCOPE_LIST_SCHEMA: Schema = StringSchema::new("OpenID Scope Lis .default(OPENID_DEFAILT_SCOPE_LIST) .schema(); -pub const OPENID_ACR_FORMAT: ApiStringFormat = ApiStringFormat::Pattern(&PROXMOX_SAFE_ID_REGEX); +pub const OPENID_ACR_FORMAT: ApiStringFormat = ApiStringFormat::Pattern(&URI_REGEX); pub const OPENID_ACR_SCHEMA: Schema = StringSchema::new("OpenID Authentication Context Class Reference.") - .format(&OPENID_SCOPE_FORMAT) + .format(&OPENID_ACR_FORMAT) .schema(); pub const OPENID_ACR_ARRAY_SCHEMA: Schema = -- 2.43.0