-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: builder pattern for id_token and response #26
Merged
Merged
Changes from 29 commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
586c6da
Add support for Request by reference
nanderstabel 0bd23b7
Improve struct field serde
nanderstabel 6c67a90
fix: remove custom serde
nanderstabel eb5990d
Add claims and scope parameters
nanderstabel c4e78b6
Add Storage and RelyingParty test improvement
nanderstabel cbf35ac
Update README example
nanderstabel db8e0b6
fix: Add standard_claims to test IdToken
nanderstabel ba19bf9
Move Storage trait to test_utils
nanderstabel 7c424d9
Remove storage.rs
nanderstabel 4f28f97
fix: fix dev-dependencies
nanderstabel 47f728c
fix: fex rebase to dev
nanderstabel 41a2339
fix: fix rebase to dev
nanderstabel ce6a463
feat: add Claim trait with associated types
nanderstabel 5cabc48
fix: build
nanderstabel 40d0d06
fix: remove build.rs and change crate name in doc tests
nanderstabel bbcf6e7
feat: refactor claims.rs
nanderstabel 1db5af7
feat: Add builder for Response and IdToken
nanderstabel 970cf9b
fix: silence clippy warning
nanderstabel 23f9e48
feat: add missing ID Token claim parameters
nanderstabel 6fe43e8
fix: remove skeptic crate
nanderstabel d5a2542
feat: allow json arguments for claims() method
nanderstabel 7a96a0f
fix: replace unwraps
nanderstabel 3a7be43
style: add specific request folder
nanderstabel 3187c47
fix: undo unnecassary cloning
nanderstabel 015c970
style: explicit serde_json usage
nanderstabel 7534575
test: improve RequestBuilder tests
nanderstabel 79053a2
fix: fix rebase
nanderstabel 7907fac
style: Rename SiopRequest and add comments
nanderstabel c0d8b8c
style: rename Request and Response
nanderstabel 50d4842
style: remove whitespace
nanderstabel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this whitespace before
$name
intended? If no, why didfmt
not find it?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh no not intended, nice catch. Apparently cargo fmt has more difficulties with formatting macros so good to take that into consideration 👍 : rust-lang/rustfmt#8