Skip to content
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: update OpenID4VP to WG Draft 20 #62

Merged
merged 21 commits into from
Mar 28, 2024
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
5419af3
fix: remove `iota_method`
nanderstabel Jan 2, 2024
7a03a8a
test: add test-utils feature, bump ed25519-dalek dep
nanderstabel Jan 2, 2024
0901175
feat: add `JsonObject`
nanderstabel Jan 2, 2024
1de6a7d
refactor: remove `serialize_unit_struct`, use `#[serde(tag = ...)]` i…
nanderstabel Jan 7, 2024
eee00e2
style: use `JsonObject`
nanderstabel Jan 12, 2024
6627c3d
feat: add `Extension` trait
nanderstabel Feb 21, 2024
6af267c
feat: implement `Extension` trait for `siopv2`
nanderstabel Feb 21, 2024
5368f0b
feat: implement `Extension` trait for `oid4vp`
nanderstabel Feb 21, 2024
a43dae7
fix: update manager
nanderstabel Feb 21, 2024
1f31e54
fix: use `MustBe` macro to enforce `response_type` values
nanderstabel Feb 22, 2024
fda2512
style: sort dependencies
nanderstabel Feb 22, 2024
b952165
fix: remove `siopv2_oid4vp`
nanderstabel Feb 22, 2024
436ba85
chore: change `ClaimFormatProperty`'s vector to a `Vec<String>`
nanderstabel Feb 29, 2024
7a12f58
refactor: change `ClientMetadata` to an enum that can represent `clie…
nanderstabel Feb 29, 2024
4372e21
feat: add `vp_formats` client metadata field
nanderstabel Feb 29, 2024
d30505c
chore: update siopv2's with `ClientMetadataEnum`, update `oid4vc-mana…
nanderstabel Feb 29, 2024
7dce695
feat: use an enum for the `client_id_scheme` field
nanderstabel Feb 29, 2024
ec4bbcc
chore: update the oid4vp version links in README files
nanderstabel Feb 29, 2024
0bf01c0
Merge branch 'dev' into feat/oid4vp-wg-draft-20
nanderstabel Mar 12, 2024
dfda52b
style: remove trailing dots from links in comments
nanderstabel Mar 15, 2024
d7e23d5
style: rename `ClientMetadataEnum` to `ClientMetadataResource`
nanderstabel Mar 15, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ This workspace includes Rust implementations for the following DCP specification
| Specification | Description | Version
| -------------------| ------------------------------------------ | -------
| [OID4VCI](oid4vci) | OpenID for Verifiable Credential Issuance | [Editor's Draft published: 30 August 2023](https://github.com/openid/OpenID4VCI/blob/111db260b1ad1915ca1462cc4904781beb179972/openid-4-verifiable-credential-issuance-1_0.md)
| [OID4VP](oid4vp) | OpenID for Verifiable Presentations | [Editor's Draft published: 30 August 2023](https://github.com/openid/OpenID4VP/blob/965597ae01fc6e6a2bddc0d6b16f3f6122f3c1ab/openid-4-verifiable-presentations-1_0.md)
| [OID4VP](oid4vp) | OpenID for Verifiable Presentations | [Working Group Draft 20 published: 29 November 2023](https://openid.net/specs/openid-4-verifiable-presentations-1_0-20.html)
| [SIOPv2](siopv2) | Self-Issued OpenID Provider v2 | [Editor's Draft published: 24 August 2023](https://github.com/openid/SIOPv2/blob/fb00ab840daa0cec614691b712e28c1f77ed43ea/openid-connect-self-issued-v2-1_0.md)

### DIF Presentation Exchange
Expand Down
18 changes: 9 additions & 9 deletions dif-presentation-exchange/src/presentation_definition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ pub enum ClaimFormatDesignation {
#[derive(Deserialize, Debug, PartialEq, Clone, Serialize)]
#[serde(rename_all = "snake_case")]
pub enum ClaimFormatProperty {
Alg(Vec<serde_json::Value>),
ProofType(Vec<serde_json::Value>),
Alg(Vec<String>),
ProofType(Vec<String>),
}

#[allow(dead_code)]
Expand Down Expand Up @@ -129,7 +129,7 @@ mod tests {
purpose: None,
format: Some(HashMap::from_iter(vec![(
ClaimFormatDesignation::AcVc,
ClaimFormatProperty::ProofType(vec![serde_json::json!("CLSignature2019")])
ClaimFormatProperty::ProofType(vec!["CLSignature2019".to_string()])
)])),
constraints: Constraints {
limit_disclosure: Some(LimitDisclosure::Required),
Expand Down Expand Up @@ -170,7 +170,7 @@ mod tests {
purpose: None,
format: Some(HashMap::from_iter(vec![(
ClaimFormatDesignation::AcVc,
ClaimFormatProperty::ProofType(vec![serde_json::json!("CLSignature2019")])
ClaimFormatProperty::ProofType(vec!["CLSignature2019".to_string()])
)])),
constraints: Constraints {
fields: Some(vec![Field {
Expand Down Expand Up @@ -201,7 +201,7 @@ mod tests {
purpose: None,
format: Some(HashMap::from_iter(vec![(
ClaimFormatDesignation::JwtVcJson,
ClaimFormatProperty::ProofType(vec![serde_json::json!("JsonWebSignature2020")])
ClaimFormatProperty::ProofType(vec!["JsonWebSignature2020".to_string()])
)])),
constraints: Constraints {
fields: Some(vec![Field {
Expand Down Expand Up @@ -234,7 +234,7 @@ mod tests {
purpose: None,
format: Some(HashMap::from_iter(vec![(
ClaimFormatDesignation::LdpVc,
ClaimFormatProperty::ProofType(vec![serde_json::json!("Ed25519Signature2018")])
ClaimFormatProperty::ProofType(vec!["Ed25519Signature2018".to_string()])
)])),
constraints: Constraints {
fields: Some(vec![Field {
Expand Down Expand Up @@ -268,7 +268,7 @@ mod tests {
purpose: None,
format: Some(HashMap::from_iter(vec![(
ClaimFormatDesignation::MsoMdoc,
ClaimFormatProperty::Alg(vec![serde_json::json!("EdDSA"), serde_json::json!("ES256")])
ClaimFormatProperty::Alg(vec!["EdDSA".to_string(), "ES256".to_string()])
)])),
constraints: Constraints {
limit_disclosure: Some(LimitDisclosure::Required),
Expand Down Expand Up @@ -321,7 +321,7 @@ mod tests {
purpose: None,
format: Some(HashMap::from_iter(vec![(
ClaimFormatDesignation::LdpVc,
ClaimFormatProperty::ProofType(vec![serde_json::json!("Ed25519Signature2018")])
ClaimFormatProperty::ProofType(vec!["Ed25519Signature2018".to_string()])
)])),
constraints: Constraints {
fields: Some(vec![
Expand Down Expand Up @@ -366,7 +366,7 @@ mod tests {
purpose: None,
format: Some(HashMap::from_iter(vec![(
ClaimFormatDesignation::LdpVc,
ClaimFormatProperty::ProofType(vec![serde_json::json!("Ed25519Signature2018")])
ClaimFormatProperty::ProofType(vec!["Ed25519Signature2018".to_string()])
)])),
constraints: Constraints {
fields: Some(vec![Field {
Expand Down
79 changes: 15 additions & 64 deletions oid4vc-core/src/client_metadata.rs
Original file line number Diff line number Diff line change
@@ -1,70 +1,21 @@
use crate::SubjectSyntaxType;
use getset::Getters;
use serde::{Deserialize, Serialize};
use serde_with::skip_serializing_none;
use url::Url;

/// [`ClientMetadata`] is a request parameter used by a [`crate::RelyingParty`] to communicate its capabilities to a [`crate::Provider`].
/// [`ClientMetadata`] is a request parameter used by a [`crate::RelyingParty`] to communicate its capabilities to a
/// [`crate::Provider`].
#[skip_serializing_none]
#[derive(Getters, Debug, PartialEq, Clone, Default, Deserialize, Serialize)]
pub struct ClientMetadata {
// TODO: Move to siopv2 crate.
#[getset(get = "pub")]
pub subject_syntax_types_supported: Option<Vec<SubjectSyntaxType>>,
// TODO: Move to siopv2 crate.
#[getset(get = "pub")]
pub id_token_signing_alg_values_supported: Option<Vec<String>>,
#[getset(get = "pub")]
pub client_name: Option<String>,
#[getset(get = "pub")]
pub logo_uri: Option<Url>,
}

impl ClientMetadata {
pub fn new() -> Self {
Self::default()
}

pub fn with_subject_syntax_types_supported(
mut self,
subject_syntax_types_supported: Vec<SubjectSyntaxType>,
) -> Self {
self.subject_syntax_types_supported = Some(subject_syntax_types_supported);
self
}

pub fn with_id_token_signing_alg_values_supported(
mut self,
id_token_signing_alg_values_supported: Vec<String>,
) -> Self {
self.id_token_signing_alg_values_supported = Some(id_token_signing_alg_values_supported);
self
}
}

#[cfg(test)]
mod tests {
use super::*;
use crate::DidMethod;
use std::str::FromStr;

#[test]
fn test_client_metadata() {
let client_metadata: ClientMetadata = serde_json::from_value(serde_json::json!(
{
"subject_syntax_types_supported": [
"did:example",
"urn:ietf:params:oauth:jwk-thumbprint"
]
}
))
.unwrap();
assert_eq!(
client_metadata,
ClientMetadata::default().with_subject_syntax_types_supported(vec![
SubjectSyntaxType::Did(DidMethod::from_str("did:example").unwrap()),
SubjectSyntaxType::JwkThumbprint,
])
);
}
#[derive(Debug, PartialEq, Clone, Deserialize, Serialize)]
#[serde(rename_all = "snake_case")]
pub enum ClientMetadataEnum<T = ()> {
daniel-mader marked this conversation as resolved.
Show resolved Hide resolved
// TODO: Add all fields described in https://www.rfc-editor.org/rfc/rfc7591.html#section-2.
ClientMetadata {
client_name: Option<String>,
logo_uri: Option<Url>,
/// As described in [RFC7591](https://www.rfc-editor.org/rfc/rfc7591.html#section-2), the client metadata can be
/// expanded with Extensions and profiles.
#[serde(flatten)]
extension: T,
},
ClientMetadataUri(String),
}
17 changes: 9 additions & 8 deletions oid4vc-manager/tests/siopv2/implicit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ use lazy_static::lazy_static;
use oid4vc_core::{
authorization_request::{AuthorizationRequest, ByReference, Object},
authorization_response::AuthorizationResponse,
client_metadata::ClientMetadata,
client_metadata::ClientMetadataEnum,
scope::{Scope, ScopeValue},
DidMethod, SubjectSyntaxType,
};
use oid4vc_manager::{ProviderManager, RelyingPartyManager};
use siopv2::{
authorization_request::ClientMetadataParameters,
claims::{Address, IndividualClaimRequest},
siopv2::SIOPv2,
StandardClaimsRequests, StandardClaimsValues,
Expand Down Expand Up @@ -69,13 +70,13 @@ async fn test_implicit_flow() {
.scope(Scope::from(vec![ScopeValue::OpenId, ScopeValue::Phone]))
.redirect_uri(format!("{server_url}/redirect_uri").parse::<url::Url>().unwrap())
.response_mode("direct_post".to_string())
.client_metadata(
ClientMetadata::default()
.with_subject_syntax_types_supported(vec![SubjectSyntaxType::Did(
DidMethod::from_str("did:test").unwrap(),
)])
.with_id_token_signing_alg_values_supported(vec!["EdDSA".to_string()]),
)
.client_metadata(ClientMetadataEnum::<ClientMetadataParameters>::ClientMetadata {
client_name: None,
logo_uri: None,
extension: ClientMetadataParameters {
subject_syntax_types_supported: vec![SubjectSyntaxType::Did(DidMethod::from_str("did:test").unwrap())],
},
})
.claims(
r#"{
"id_token": {
Expand Down
2 changes: 1 addition & 1 deletion oid4vp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Working Group](https://openid.net/wg/digital-credentials-protocols/).

| Specification | Description | Version
| -------------------| ------------------------------------------ | -------
| [OID4VP](oid4vp) | OpenID for Verifiable Presentations | [Editor's Draft published: 30 August 2023](https://github.com/openid/OpenID4VP/blob/965597ae01fc6e6a2bddc0d6b16f3f6122f3c1ab/openid-4-verifiable-presentations-1_0.md)
| [OID4VP](oid4vp) | OpenID for Verifiable Presentations | [Working Group Draft 20 published: 29 November 2023](https://openid.net/specs/openid-4-verifiable-presentations-1_0-20.html)


An overview of all the OpenID Digital Credentials Protocols implementation in Rust can be found [here](../README.md).
Expand Down
Loading