Skip to content

Commit

Permalink
feat: add claims and scope support (#18)
Browse files Browse the repository at this point in the history
* 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

* docs: adjust comments for fn generate_response

* fix: loosen serde version

* fix: loosen serde dependency versions

* fix: fix dev-dependencies

* fix: fex rebase to dev

* fix: fix rebase to dev

* feat: add rust-tls feature flag

fix: disable default features for reqwest

fix: add dependency feature

fix: add dependency feature

* fix: remove skeptic crate

* docs: add  todo comment

* fix: adjust TODO comment

* feat: add Claim trait with associated types

* fix: Remove Deref derive for Scope

* fix: fix mutable id_token

* style: consistent use of to_string over to_owned

* fix: use derive_more::Display for ScopeValue

* fix: fix rust-analyzer complaint

* fix: build

* fix: remove build.rs and change crate name in doc tests

* feat: refactor claims.rs

* style: restyle StandardClaims serde bounds
  • Loading branch information
nanderstabel authored Jun 2, 2023
1 parent 159658c commit 198e111
Show file tree
Hide file tree
Showing 16 changed files with 889 additions and 146 deletions.
12 changes: 4 additions & 8 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@ homepage = "https://www.impierce.com/"
keywords = ["openid4vc", "siopv2", "openid4vp", "openid4vci", "OpenID Connect"]
license = "Apache-2.0"
repository = "https://github.com/impierce/openid4vc"
build = "build.rs"

[dependencies]
tokio = { version = "1.26.0", features = ["rt", "macros", "rt-multi-thread"] }
serde = { version = "1.0.154", features = ["derive"]}
serde_json = "1.0.94"
serde = { version = "1.0", features = ["derive"]}
serde_json = "1.0"
serde_with = "2.3"
anyhow = "1.0.70"
chrono = "0.4.24"
getset = "0.1.2"
jsonwebtoken = "8.2.0"
reqwest = { version = "0.11.14", features = ["json"] }
reqwest = { version = "0.11.14", default-features = false, features = ["json", "rustls-tls"] }
base64-url = "2.0.0"
async-trait = "0.1.68"
did_url = "0.1.0"
Expand All @@ -31,8 +31,4 @@ ed25519-dalek = "1.0.1"
rand = "0.7"
lazy_static = "1.4.0"
derivative = "2.2.0"
skeptic = "0.13"
wiremock = "0.5.18"

[build-dependencies]
skeptic = "0.13"
29 changes: 20 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@ use ed25519_dalek::{Keypair, Signature, Signer};
use lazy_static::lazy_static;
use rand::rngs::OsRng;
use siopv2::{
request::ResponseType, IdToken, Provider, Registration, RelyingParty, RequestUrl, SiopRequest, SiopResponse,
Subject, Validator,
claims::{Claim, ClaimRequests},
request::ResponseType, StandardClaim,
IdToken, Provider, Registration, RelyingParty, RequestUrl, Scope, SiopRequest, SiopResponse, Subject, Validator,
};
use wiremock::{
http::Method,
Expand Down Expand Up @@ -103,17 +104,24 @@ async fn main() {
// Create a new RequestUrl with response mode `post` for cross-device communication.
let request: SiopRequest = RequestUrl::builder()
.response_type(ResponseType::IdToken)
.client_id("did:mymethod:relyingparty".to_owned())
.scope("openid".to_owned())
.client_id("did:mymethod:relyingparty".to_string())
.scope(Scope::openid())
.redirect_uri(format!("{server_url}/redirect_uri"))
.response_mode("post".to_owned())
.response_mode("post".to_string())
.registration(
Registration::default()
.with_subject_syntax_types_supported(vec!["did:mymethod".to_owned()])
.with_id_token_signing_alg_values_supported(vec!["EdDSA".to_owned()]),
.with_subject_syntax_types_supported(vec!["did:mymethod".to_string()])
.with_id_token_signing_alg_values_supported(vec!["EdDSA".to_string()]),
)
.claims(ClaimRequests {
id_token: Some(StandardClaim {
name: Some(Claim::default()),
..Default::default()
}),
..Default::default()
})
.exp((Utc::now() + Duration::minutes(10)).timestamp())
.nonce("n-0S6_WzA2Mj".to_owned())
.nonce("n-0S6_WzA2Mj".to_string())
.build()
.and_then(TryInto::try_into)
.unwrap();
Expand Down Expand Up @@ -156,7 +164,10 @@ async fn main() {

// Let the provider generate a response based on the validated request. The response is an `IdToken` which is
// encoded as a JWT.
let response = provider.generate_response(request).await.unwrap();
let response = provider
.generate_response(request, StandardClaim::default())
.await
.unwrap();

// The provider sends it's response to the mock server's `redirect_uri` endpoint.
provider.send_response(response).await.unwrap();
Expand Down
4 changes: 0 additions & 4 deletions build.rs

This file was deleted.

Loading

0 comments on commit 198e111

Please sign in to comment.