public inbox for pmg-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pmg-devel] [PATCH proxmox-acme-rs/pmg-rs] fix #3688: allow missing 'meta' property for acme directories
@ 2021-10-21  9:10 Dominik Csapak
  2021-10-21  9:10 ` [pmg-devel] [PATCH proxmox-acme-rs 1/1] directory: make meta object optional Dominik Csapak
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Dominik Csapak @ 2021-10-21  9:10 UTC (permalink / raw)
  To: pmg-devel

like we already do in pve, also make the 'meta' property optional

NOTE: the code compiles, but the actual code path is untested, sending it with the
intention to test on a patched pebble instance later (or maybe someone
else can do that (@stoiko) ?)

proxmox-acme-rs:

Dominik Csapak (1):
  directory: make meta object optional

 src/directory.rs | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

pmg-rs:

Dominik Csapak (1):
  fix #3688: handle optional meta property of the directory

 src/acme.rs | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

-- 
2.30.2





^ permalink raw reply	[flat|nested] 4+ messages in thread

* [pmg-devel] [PATCH proxmox-acme-rs 1/1] directory: make meta object optional
  2021-10-21  9:10 [pmg-devel] [PATCH proxmox-acme-rs/pmg-rs] fix #3688: allow missing 'meta' property for acme directories Dominik Csapak
@ 2021-10-21  9:10 ` Dominik Csapak
  2021-10-21  9:10 ` [pmg-devel] [PATCH pmg-rs 1/1] fix #3688: handle optional meta property of the directory Dominik Csapak
  2021-10-21 11:24 ` [pmg-devel] applied: [PATCH proxmox-acme-rs/pmg-rs] fix #3688: allow missing 'meta' property for acme directories Wolfgang Bumiller
  2 siblings, 0 replies; 4+ messages in thread
From: Dominik Csapak @ 2021-10-21  9:10 UTC (permalink / raw)
  To: pmg-devel

some custom ACME endpoints do not have a TOS, and thus do not return
a meta property at all

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
 src/directory.rs | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/src/directory.rs b/src/directory.rs
index 474b615..755ea8c 100644
--- a/src/directory.rs
+++ b/src/directory.rs
@@ -36,7 +36,8 @@ pub struct DirectoryData {
 
     /// Metadata object, for additional information which aren't directly part of the API
     /// itself, such as the terms of service.
-    pub meta: Meta,
+    #[serde(skip_serializing_if = "Option::is_none")]
+    pub meta: Option<Meta>,
 }
 
 /// The directory's "meta" object.
@@ -57,7 +58,10 @@ impl Directory {
 
     /// Get the ToS URL.
     pub fn terms_of_service_url(&self) -> Option<&str> {
-        self.data.meta.terms_of_service.as_deref()
+        match &self.data.meta {
+            Some(meta) => meta.terms_of_service.as_deref(),
+            None => None,
+        }
     }
 
     /// Get the "newNonce" URL. Use `HEAD` requests on this to get a new nonce.
@@ -76,7 +80,7 @@ impl Directory {
     /// Access to the in the Acme spec defined metadata structure.
     /// Currently only contains the ToS URL already exposed via the `terms_of_service_url()`
     /// method.
-    pub fn meta(&self) -> &Meta {
-        &self.data.meta
+    pub fn meta(&self) -> Option<&Meta> {
+        self.data.meta.as_ref()
     }
 }
-- 
2.30.2





^ permalink raw reply	[flat|nested] 4+ messages in thread

* [pmg-devel] [PATCH pmg-rs 1/1] fix #3688: handle optional meta property of the directory
  2021-10-21  9:10 [pmg-devel] [PATCH proxmox-acme-rs/pmg-rs] fix #3688: allow missing 'meta' property for acme directories Dominik Csapak
  2021-10-21  9:10 ` [pmg-devel] [PATCH proxmox-acme-rs 1/1] directory: make meta object optional Dominik Csapak
@ 2021-10-21  9:10 ` Dominik Csapak
  2021-10-21 11:24 ` [pmg-devel] applied: [PATCH proxmox-acme-rs/pmg-rs] fix #3688: allow missing 'meta' property for acme directories Wolfgang Bumiller
  2 siblings, 0 replies; 4+ messages in thread
From: Dominik Csapak @ 2021-10-21  9:10 UTC (permalink / raw)
  To: pmg-devel

meta is optional so handle that, fixes the issue where one could not
create an account on custom ACME endpoints without a meta property since
it could not be parsed

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
needs proxmox-acme-rs to be bumped and the depency adapted in Cargo.toml

 src/acme.rs | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/src/acme.rs b/src/acme.rs
index 9a57624..a1b5278 100644
--- a/src/acme.rs
+++ b/src/acme.rs
@@ -265,10 +265,11 @@ pub mod export {
 
     /// Get the directory's meta information.
     #[export]
-    pub fn get_meta(#[try_from_ref] this: &Acme) -> Result<Meta, Error> {
-        Ok(Meta::clone(
-            this.inner.lock().unwrap().client.directory()?.meta(),
-        ))
+    pub fn get_meta(#[try_from_ref] this: &Acme) -> Result<Option<Meta>, Error> {
+        match this.inner.lock().unwrap().client.directory()?.meta() {
+            Some(meta) => Ok(Some(meta.clone())),
+            None => Ok(None),
+        }
     }
 
     /// Get the account's directory URL.
-- 
2.30.2





^ permalink raw reply	[flat|nested] 4+ messages in thread

* [pmg-devel] applied: [PATCH proxmox-acme-rs/pmg-rs] fix #3688: allow missing 'meta' property for acme directories
  2021-10-21  9:10 [pmg-devel] [PATCH proxmox-acme-rs/pmg-rs] fix #3688: allow missing 'meta' property for acme directories Dominik Csapak
  2021-10-21  9:10 ` [pmg-devel] [PATCH proxmox-acme-rs 1/1] directory: make meta object optional Dominik Csapak
  2021-10-21  9:10 ` [pmg-devel] [PATCH pmg-rs 1/1] fix #3688: handle optional meta property of the directory Dominik Csapak
@ 2021-10-21 11:24 ` Wolfgang Bumiller
  2 siblings, 0 replies; 4+ messages in thread
From: Wolfgang Bumiller @ 2021-10-21 11:24 UTC (permalink / raw)
  To: Dominik Csapak; +Cc: pmg-devel

applied both

On Thu, Oct 21, 2021 at 11:10:42AM +0200, Dominik Csapak wrote:
> like we already do in pve, also make the 'meta' property optional
> 
> NOTE: the code compiles, but the actual code path is untested, sending it with the
> intention to test on a patched pebble instance later (or maybe someone
> else can do that (@stoiko) ?)
> 
> proxmox-acme-rs:
> 
> Dominik Csapak (1):
>   directory: make meta object optional
> 
>  src/directory.rs | 12 ++++++++----
>  1 file changed, 8 insertions(+), 4 deletions(-)
> 
> pmg-rs:
> 
> Dominik Csapak (1):
>   fix #3688: handle optional meta property of the directory
> 
>  src/acme.rs | 9 +++++----
>  1 file changed, 5 insertions(+), 4 deletions(-)
> 
> -- 
> 2.30.2




^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-10-21 11:32 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-21  9:10 [pmg-devel] [PATCH proxmox-acme-rs/pmg-rs] fix #3688: allow missing 'meta' property for acme directories Dominik Csapak
2021-10-21  9:10 ` [pmg-devel] [PATCH proxmox-acme-rs 1/1] directory: make meta object optional Dominik Csapak
2021-10-21  9:10 ` [pmg-devel] [PATCH pmg-rs 1/1] fix #3688: handle optional meta property of the directory Dominik Csapak
2021-10-21 11:24 ` [pmg-devel] applied: [PATCH proxmox-acme-rs/pmg-rs] fix #3688: allow missing 'meta' property for acme directories Wolfgang Bumiller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal