-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: builder pattern for id_token and response (#26)
* Add support for Request by reference Add tests for RequestUrl Add missing request parameters Add sphereon demo website test Update documentation with new RequestUrl Remove sphereon demo example Add validate_request method to Provider struct Add preoper Ser and De for SiopRequest and RequestBuilder Add skeptic for Markdown code testing Add support for Request by reference fix: fix rebase conflicts Add comments and fix some tests fix: Move `derivative` to dev-dependencies Refactor Provider and Subject improve tests and example using wiremock Improve struct field serde fix: remove claims from lib.rs style: fix arguments order Add did:key DID method Add support for Request by reference fix: Remove lifetime annotations Add preoper Ser and De for SiopRequest and RequestBuilder Add Scope and Claim fix: fix rebase conflicts * Improve struct field serde * fix: remove custom serde * Add claims and scope parameters * Add Storage and RelyingParty test improvement * Update README example * fix: Add standard_claims to test IdToken * Move Storage trait to test_utils * Remove storage.rs * fix: fix dev-dependencies * fix: fex rebase to dev * fix: fix rebase to dev * feat: add Claim trait with associated types * fix: build * fix: remove build.rs and change crate name in doc tests * feat: refactor claims.rs * feat: Add builder for Response and IdToken * fix: silence clippy warning * feat: add missing ID Token claim parameters * fix: remove skeptic crate * feat: allow json arguments for claims() method * fix: replace unwraps * style: add specific request folder * fix: undo unnecassary cloning * style: explicit serde_json usage * test: improve RequestBuilder tests * fix: fix rebase * style: Rename SiopRequest and add comments * style: rename Request and Response * style: remove whitespace
- Loading branch information
1 parent
198e111
commit bcd4a00
Showing
14 changed files
with
621 additions
and
240 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,60 @@ | ||
pub mod claims; | ||
pub mod id_token; | ||
pub mod jwt; | ||
pub mod key_method; | ||
pub mod provider; | ||
pub mod registration; | ||
pub mod relying_party; | ||
pub mod request; | ||
pub mod request_builder; | ||
pub mod response; | ||
pub mod scope; | ||
pub mod subject; | ||
pub mod token; | ||
pub mod validator; | ||
|
||
pub use claims::{StandardClaimsRequests, StandardClaimsValues}; | ||
pub use id_token::IdToken; | ||
pub use claims::{ClaimRequests, StandardClaimsRequests, StandardClaimsValues}; | ||
pub use jwt::JsonWebToken; | ||
pub use provider::Provider; | ||
pub use registration::Registration; | ||
pub use relying_party::RelyingParty; | ||
pub use request::{RequestUrl, SiopRequest}; | ||
pub use request_builder::RequestUrlBuilder; | ||
pub use response::SiopResponse; | ||
pub use request::{request_builder::RequestUrlBuilder, AuthorizationRequest, RequestUrl}; | ||
pub use response::AuthorizationResponse; | ||
pub use scope::Scope; | ||
pub use subject::Subject; | ||
pub use token::{id_token::IdToken, id_token_builder::IdTokenBuilder}; | ||
pub use validator::Validator; | ||
|
||
use serde::{Deserialize, Deserializer}; | ||
|
||
#[cfg(test)] | ||
pub mod test_utils; | ||
|
||
#[macro_export] | ||
macro_rules! builder_fn { | ||
($name:ident, $ty:ty) => { | ||
#[allow(clippy::should_implement_trait)] | ||
pub fn $name(mut self, value: impl Into<$ty>) -> Self { | ||
self.$name.replace(value.into()); | ||
self | ||
} | ||
}; | ||
($field:ident, $name:ident, $ty:ty) => { | ||
#[allow(clippy::should_implement_trait)] | ||
pub fn $name(mut self, value: impl Into<$ty>) -> Self { | ||
self.$field.$name.replace(value.into()); | ||
self | ||
} | ||
}; | ||
} | ||
|
||
// When a struct has fields of type `Option<serde_json::Map<String, serde_json::Value>>`, by default these fields are deserialized as | ||
// `Some(Object {})` instead of None when the corresponding values are missing. | ||
// The `parse_other()` helper function ensures that these fields are deserialized as `None` when no value is present. | ||
pub fn parse_other<'de, D>(deserializer: D) -> Result<Option<serde_json::Map<String, serde_json::Value>>, D::Error> | ||
where | ||
D: Deserializer<'de>, | ||
{ | ||
serde_json::Value::deserialize(deserializer).map(|value| match value { | ||
serde_json::Value::Object(object) if !object.is_empty() => Some(object), | ||
_ => None, | ||
}) | ||
} |
Oops, something went wrong.