Skip to content

Commit

Permalink
Clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
cobward committed Oct 9, 2023
1 parent 7b29a6b commit 7bef537
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 26 deletions.
2 changes: 1 addition & 1 deletion src/core/authorization_request/parameters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ impl fmt::Display for ClientIdScheme {
ClientIdScheme::RedirectUri => REDIRECT_URI,
ClientIdScheme::X509SanDns => X509_SAN_DNS,
ClientIdScheme::X509SanUri => X509_SAN_URI,
ClientIdScheme::Other(o) => &o,
ClientIdScheme::Other(o) => o,
}
.fmt(f)
}
Expand Down
14 changes: 1 addition & 13 deletions src/core/authorization_request/verification/did.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ pub async fn verify_with_resolver(
"expected a DID verification method in 'kid' header, received '{kid}'"
))?;

if &client_id.0 != did {
if client_id.0 != did {
bail!(
"DIDs from 'kid' ({did}) and 'client_id' ({}) do not match",
client_id.0
Expand All @@ -83,18 +83,6 @@ pub async fn verify_with_resolver(
}
}

println!(
"{}",
serde_json::to_string_pretty(
&didkit::dereference(resolver, did, &Default::default())
.await
.1
)
.unwrap()
);

println!("{kid:?}");

let jwk = resolve_key(&kid, resolver)
.await
.context("unable to resolve verification method from 'kid' header")?;
Expand Down
2 changes: 1 addition & 1 deletion src/core/authorization_request/verification/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ pub(crate) async fn verify_request<WP: WalletProfile + ?Sized>(
ClientIdScheme::RedirectUri => profile.redirect_uri(&request, jwt).await?,
ClientIdScheme::X509SanDns => profile.x509_san_dns(&request, jwt).await?,
ClientIdScheme::X509SanUri => profile.x509_san_uri(&request, jwt).await?,
ClientIdScheme::Other(scheme) => profile.other(&scheme, &request, jwt).await?,
ClientIdScheme::Other(scheme) => profile.other(scheme, &request, jwt).await?,
};

Ok(request)
Expand Down
4 changes: 2 additions & 2 deletions src/core/authorization_request/verification/x509_san_dns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,15 +119,15 @@ pub trait Verifier: Sized {
/// ## Params
/// * `spki` - the public key information necessary to construct a [Verifier].
/// * `algorithm` - the value taken from the `alg` header of the request, to hint at what curve should be used by the [Verifier].
fn from_spki<'a>(spki: SubjectPublicKeyInfoRef<'a>, algorithm: String) -> Result<Self>;
fn from_spki(spki: SubjectPublicKeyInfoRef<'_>, algorithm: String) -> Result<Self>;
fn verify(&self, payload: &[u8], signature: &[u8]) -> Result<()>;
}

#[derive(Debug, Clone)]
pub struct P256Verifier(p256::ecdsa::VerifyingKey);

impl Verifier for P256Verifier {
fn from_spki<'a>(spki: SubjectPublicKeyInfoRef<'a>, algorithm: String) -> Result<Self> {
fn from_spki(spki: SubjectPublicKeyInfoRef<'_>, algorithm: String) -> Result<Self> {
if algorithm != "ES256" {
bail!("P256Verifier cannot verify requests signed with '{algorithm}'")
}
Expand Down
4 changes: 2 additions & 2 deletions src/core/authorization_request/verification/x509_san_uri.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,15 +133,15 @@ pub trait Verifier: Sized {
/// ## Params
/// * `spki` - the public key information necessary to construct a [Verifier].
/// * `algorithm` - the value taken from the `alg` header of the request, to hint at what curve should be used by the [Verifier].
fn from_spki<'a>(spki: SubjectPublicKeyInfoRef<'a>, algorithm: String) -> Result<Self>;
fn from_spki(spki: SubjectPublicKeyInfoRef<'_>, algorithm: String) -> Result<Self>;
fn verify(&self, payload: &[u8], signature: &[u8]) -> Result<()>;
}

#[derive(Debug, Clone)]
pub struct P256Verifier(p256::ecdsa::VerifyingKey);

impl Verifier for P256Verifier {
fn from_spki<'a>(spki: SubjectPublicKeyInfoRef<'a>, algorithm: String) -> Result<Self> {
fn from_spki(spki: SubjectPublicKeyInfoRef<'_>, algorithm: String) -> Result<Self> {
if algorithm != "ES256" {
bail!("P256Verifier cannot verify requests signed with '{algorithm}'")
}
Expand Down
2 changes: 1 addition & 1 deletion src/core/verifier/builder/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ impl<S: RequestSigner> SessionBuilder<S> {
if !wallet_metadata
.client_id_schemes_supported()
.0
.contains(&client_id_scheme)
.contains(client_id_scheme)
{
bail!("wallet does not support client_id_scheme '{client_id_scheme}'")
}
Expand Down
10 changes: 4 additions & 6 deletions src/presentation_exchange.rs
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ pub(crate) mod tests {
let path = path.unwrap().path();
if let Some(ext) = path.extension() {
if ext != OsStr::new("json")
|| vec!["VC_expiration_example.json", "VC_revocation_example.json"] // TODO bad format
|| ["VC_expiration_example.json", "VC_revocation_example.json"] // TODO bad format
.contains(&path.file_name().unwrap().to_str().unwrap())
{
continue;
Expand Down Expand Up @@ -267,10 +267,8 @@ pub(crate) mod tests {
let path = path.unwrap().path();
if let Some(ext) = path.extension() {
if ext != OsStr::new("json")
|| vec![
"appendix_DIDComm_example.json",
"appendix_CHAPI_example.json",
]
|| ["appendix_DIDComm_example.json",
"appendix_CHAPI_example.json"]
.contains(&path.file_name().unwrap().to_str().unwrap())
{
continue;
Expand Down Expand Up @@ -299,7 +297,7 @@ pub(crate) mod tests {
let path = path.unwrap().path();
if let Some(ext) = path.extension() {
if ext != OsStr::new("json")
|| vec!["schema.json"].contains(&path.file_name().unwrap().to_str().unwrap())
|| ["schema.json"].contains(&path.file_name().unwrap().to_str().unwrap())
{
continue;
}
Expand Down

0 comments on commit 7bef537

Please sign in to comment.