Skip to content

Commit

Permalink
Have NewTypes for end user claims wrap String instead of Url
Browse files Browse the repository at this point in the history
For the non-essential end user claims, it matters less that this crate be
strict about parsing them as URLs. This helps ensure interoperability with
some less conformant providers, such as those that implement SMART-on-FHIR
alongside OpenID Connect. SMART-on-FHIR and OIDC have conflicting
specifications for the `profile` claim, for example.
  • Loading branch information
David Ramos committed Dec 1, 2019
1 parent 078e869 commit 3b092a1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 17 deletions.
17 changes: 6 additions & 11 deletions src/id_token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -698,15 +698,13 @@ mod tests {
None,
EndUserProfileUrl::new(
"https://example.com/profile?id=12345".to_string(),
)
.unwrap(),
),
),
(
Some(LanguageTag::new("es".to_string())),
EndUserProfileUrl::new(
"https://example.com/profile?id=12345&lang=es".to_string(),
)
.unwrap(),
),
),
]
.into_iter()
Expand All @@ -718,15 +716,13 @@ mod tests {
None,
EndUserPictureUrl::new(
"https://example.com/avatar?id=12345".to_string(),
)
.unwrap(),
),
),
(
Some(LanguageTag::new("es".to_string())),
EndUserPictureUrl::new(
"https://example.com/avatar?id=12345&lang=es".to_string(),
)
.unwrap(),
),
),
]
.into_iter()
Expand All @@ -736,12 +732,11 @@ mod tests {
vec![
(
None,
EndUserWebsiteUrl::new("https://homersimpson.me".to_string()).unwrap(),
EndUserWebsiteUrl::new("https://homersimpson.me".to_string()),
),
(
Some(LanguageTag::new("es".to_string())),
EndUserWebsiteUrl::new("https://homersimpson.me/?lang=es".to_string())
.unwrap(),
EndUserWebsiteUrl::new("https://homersimpson.me/?lang=es".to_string()),
),
]
.into_iter()
Expand Down
15 changes: 9 additions & 6 deletions src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -611,18 +611,20 @@ new_type![
EndUserPhoneNumber(String)
];

new_url_type![
new_type![
///
/// URL of end user's profile picture.
///
EndUserPictureUrl
#[derive(Deserialize, Eq, Hash, Ord, PartialOrd, Serialize)]
EndUserPictureUrl(String)
];

new_url_type![
new_type![
///
/// URL of end user's profile page.
///
EndUserProfileUrl
#[derive(Deserialize, Eq, Hash, Ord, PartialOrd, Serialize)]
EndUserProfileUrl(String)
];

new_type![
Expand All @@ -634,11 +636,12 @@ new_type![
EndUserTimezone(String)
];

new_url_type![
new_type![
///
/// URL of end user's website.
///
EndUserWebsiteUrl
#[derive(Deserialize, Eq, Hash, Ord, PartialOrd, Serialize)]
EndUserWebsiteUrl(String)
];

new_type![
Expand Down

0 comments on commit 3b092a1

Please sign in to comment.