From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9]) by lore.proxmox.com (Postfix) with ESMTPS id ABF1A1FF390 for ; Fri, 24 May 2024 09:08:26 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 2E4993C97; Fri, 24 May 2024 09:08:46 +0200 (CEST) Date: Fri, 24 May 2024 09:08:42 +0200 From: Wolfgang Bumiller To: Markus Frank Message-ID: References: <20240507084745.8025-1-m.frank@proxmox.com> <20240507084745.8025-3-m.frank@proxmox.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20240507084745.8025-3-m.frank@proxmox.com> X-SPAM-LEVEL: Spam detection results: 0 AWL 0.085 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 Subject: Re: [pmg-devel] [PATCH proxmox-perl-rs v2 2/7] move openid code from pve-rs to common X-BeenThere: pmg-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Mail Gateway development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: pmg-devel@lists.proxmox.com Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pmg-devel-bounces@lists.proxmox.com Sender: "pmg-devel" On Tue, May 07, 2024 at 10:47:40AM +0200, Markus Frank wrote: > Change pve-rs functions to be wrapper functions for common > and add similar wrapper functions for pmg-rs. > > Signed-off-by: Markus Frank > --- > common/src/mod.rs | 1 + > common/src/openid/mod.rs | 63 ++++++++++++++++++++++++++++++++++++++++ > pmg-rs/Cargo.toml | 1 + > pmg-rs/src/lib.rs | 1 + > pmg-rs/src/openid/mod.rs | 47 ++++++++++++++++++++++++++++++ > pve-rs/src/openid/mod.rs | 32 +++++--------------- > 6 files changed, 121 insertions(+), 24 deletions(-) > create mode 100644 common/src/openid/mod.rs > create mode 100644 pmg-rs/src/openid/mod.rs > > diff --git a/common/src/mod.rs b/common/src/mod.rs > index c3574f4..8460439 100644 > --- a/common/src/mod.rs > +++ b/common/src/mod.rs > @@ -3,3 +3,4 @@ mod calendar_event; > pub mod logger; > pub mod notify; > mod subscription; > +pub mod openid; (...) > diff --git a/pmg-rs/src/openid/mod.rs b/pmg-rs/src/openid/mod.rs > new file mode 100644 > index 0000000..c0988d6 > --- /dev/null > +++ b/pmg-rs/src/openid/mod.rs > @@ -0,0 +1,47 @@ > +#[perlmod::package(name = "PMG::RS::OpenId", lib = "pmg_rs")] Do we have any reason to suspect we might need different functions between pve and pmg here in the future? I think it should be enough to just have the `Proxmox::RS::OpenId` package and directly use that from the perl code. The PVE::RS::* side wrapper should stick around for a while for easier up/downgrading without dependency issues, but I don't think we need the PMG::RS::* one? > +mod export { > + use anyhow::Error; > + > + use perlmod::Value; > + > + use proxmox_openid::{OpenIdConfig, PrivateAuthState}; > + > + use crate::common::openid::export as common; > + use crate::common::openid::export::OpenId as OpenId; > + > + /// Create a new OpenId client instance > + #[export(raw_return)] > + pub fn discover( > + #[raw] class: Value, > + config: OpenIdConfig, > + redirect_url: &str, > + ) -> Result { > + common::discover(class, config, redirect_url) > + } > + > + #[export] > + pub fn authorize_url( > + #[try_from_ref] this: &OpenId, > + state_dir: &str, > + realm: &str, > + ) -> Result { > + common::authorize_url(this, state_dir, realm) > + } > + > + #[export] > + pub fn verify_public_auth_state( > + state_dir: &str, > + state: &str, > + ) -> Result<(String, PrivateAuthState), Error> { > + common::verify_public_auth_state(state_dir, state) > + } > + > + #[export(raw_return)] > + pub fn verify_authorization_code( > + #[try_from_ref] this: &OpenId, > + code: &str, > + private_auth_state: PrivateAuthState, > + ) -> Result { > + common::verify_authorization_code(this, code, private_auth_state) > + } > +} _______________________________________________ pmg-devel mailing list pmg-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pmg-devel