From 550f004fe3e427c6f61f06ab4b091d14179a0684 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Nieto?= Date: Tue, 11 Apr 2023 16:13:54 +0200 Subject: [PATCH 1/2] added serde to grant types --- oxide-auth/src/primitives/grant.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/oxide-auth/src/primitives/grant.rs b/oxide-auth/src/primitives/grant.rs index 18a7e2aa..efe07b17 100644 --- a/oxide-auth/src/primitives/grant.rs +++ b/oxide-auth/src/primitives/grant.rs @@ -7,6 +7,7 @@ use std::collections::HashMap; use std::collections::hash_map::Iter; use std::rc::Rc; use std::sync::Arc; +use serde_derive::{Deserialize, Serialize}; /// Provides a name registry for extensions. pub trait GrantExtension { @@ -24,7 +25,8 @@ pub trait GrantExtension { /// /// Some extensions have semantics where the presence alone is the stored data, so storing data /// is optional and storing no data is distinct from not attaching any extension instance at all. -#[derive(Clone, Debug, PartialEq, Eq)] +#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] +#[serde(tag = "type")] pub enum Value { /// An extension that the token owner is allowed to read and interpret. Public(Option), @@ -39,7 +41,7 @@ pub enum Value { /// /// This also serves as a clean interface for both frontend and backend to reliably and /// conveniently manipulate or query the stored data sets. -#[derive(Clone, Default, Debug, PartialEq, Eq)] +#[derive(Clone, Default, Debug, PartialEq, Eq, Serialize, Deserialize)] pub struct Extensions { extensions: HashMap, } @@ -48,7 +50,7 @@ pub struct Extensions { /// /// This can be stored in a database without worrying about lifetimes or shared across thread /// boundaries. A reference to this can be converted to a purely referential `GrantRef`. -#[derive(Clone, Debug, PartialEq, Eq)] +#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] pub struct Grant { /// Identifies the owner of the resource. pub owner_id: String, From ccc912adde43b6259754174a49243d676e0a5e86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Nieto?= Date: Tue, 11 Apr 2023 16:52:18 +0200 Subject: [PATCH 2/2] added serde to chrono dependency --- oxide-auth/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/oxide-auth/Cargo.toml b/oxide-auth/Cargo.toml index 2281a6da..1974c671 100644 --- a/oxide-auth/Cargo.toml +++ b/oxide-auth/Cargo.toml @@ -16,7 +16,7 @@ autoexamples = false [dependencies] base64 = "0.13" -chrono = { version = "0.4", default-features = false, features = ["clock"] } +chrono = { version = "0.4", default-features = false, features = ["clock", "serde"] } hmac = "0.12.0" once_cell = "1.3.1" serde = { version = "1.0", features = ["derive"] }