mirror of
https://github.com/BitskiCo/jwk-rs
synced 2024-11-22 03:49:22 +00:00
Bump version to include x5c fix
This commit is contained in:
parent
2cddce0696
commit
952a80199e
@ -1,10 +1,11 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "jsonwebkey"
|
name = "jsonwebkey"
|
||||||
version = "0.3.1"
|
version = "0.3.2"
|
||||||
authors = ["Nick Hynes <nhynes@nhynes.com>"]
|
authors = ["Nick Hynes <nhynes@nhynes.com>"]
|
||||||
description = "JSON Web Key (JWK) (de)serialization, generation, and conversion."
|
description = "JSON Web Key (JWK) (de)serialization, generation, and conversion."
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
repository = "https://github.com/nhynes/jwk-rs"
|
repository = "https://github.com/nhynes/jwk-rs"
|
||||||
|
documentation = "http://docs.rs/jsonwebkey/"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
|
||||||
|
36
src/lib.rs
36
src/lib.rs
@ -65,8 +65,7 @@ mod key_ops;
|
|||||||
mod tests;
|
mod tests;
|
||||||
mod utils;
|
mod utils;
|
||||||
|
|
||||||
use std::borrow::Cow;
|
use std::{borrow::Cow, fmt};
|
||||||
use std::fmt;
|
|
||||||
|
|
||||||
use generic_array::typenum::U32;
|
use generic_array::typenum::U32;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
@ -193,6 +192,7 @@ impl std::fmt::Display for JsonWebKey {
|
|||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||||
#[serde(tag = "kty")]
|
#[serde(tag = "kty")]
|
||||||
|
#[allow(clippy::upper_case_acronyms)]
|
||||||
pub enum Key {
|
pub enum Key {
|
||||||
/// An elliptic curve, as per [RFC 7518 §6.2](https://tools.ietf.org/html/rfc7518#section-6.2).
|
/// An elliptic curve, as per [RFC 7518 §6.2](https://tools.ietf.org/html/rfc7518#section-6.2).
|
||||||
EC {
|
EC {
|
||||||
@ -219,14 +219,17 @@ impl Key {
|
|||||||
/// Returns true iff this key only contains private components (i.e. a private asymmetric
|
/// Returns true iff this key only contains private components (i.e. a private asymmetric
|
||||||
/// key or a symmetric key).
|
/// key or a symmetric key).
|
||||||
pub fn is_private(&self) -> bool {
|
pub fn is_private(&self) -> bool {
|
||||||
matches!(self, Self::Symmetric { .. }
|
matches!(
|
||||||
| Self::EC {
|
self,
|
||||||
curve: Curve::P256 { d: Some(_), .. },
|
Self::Symmetric { .. }
|
||||||
..
|
| Self::EC {
|
||||||
}
|
curve: Curve::P256 { d: Some(_), .. },
|
||||||
| Self::RSA {
|
..
|
||||||
private: Some(_), ..
|
}
|
||||||
}
|
| Self::RSA {
|
||||||
|
private: Some(_),
|
||||||
|
..
|
||||||
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -533,6 +536,7 @@ pub enum KeyUse {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||||
|
#[allow(clippy::upper_case_acronyms)]
|
||||||
pub enum Algorithm {
|
pub enum Algorithm {
|
||||||
HS256,
|
HS256,
|
||||||
RS256,
|
RS256,
|
||||||
@ -543,12 +547,12 @@ pub enum Algorithm {
|
|||||||
const _IMPL_JWT_CONVERSIONS: () = {
|
const _IMPL_JWT_CONVERSIONS: () = {
|
||||||
use jsonwebtoken as jwt;
|
use jsonwebtoken as jwt;
|
||||||
|
|
||||||
impl Into<jwt::Algorithm> for Algorithm {
|
impl From<Algorithm> for jwt::Algorithm {
|
||||||
fn into(self) -> jsonwebtoken::Algorithm {
|
fn from(alg: Algorithm) -> Self {
|
||||||
match self {
|
match alg {
|
||||||
Self::HS256 => jwt::Algorithm::HS256,
|
Algorithm::HS256 => Self::HS256,
|
||||||
Self::ES256 => jwt::Algorithm::ES256,
|
Algorithm::ES256 => Self::ES256,
|
||||||
Self::RS256 => jwt::Algorithm::RS256,
|
Algorithm::RS256 => Self::RS256,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -437,7 +437,10 @@ fn x509_params() {
|
|||||||
|
|
||||||
let jwk = JsonWebKey::from_str(X509_JWK_FIXTURE).unwrap();
|
let jwk = JsonWebKey::from_str(X509_JWK_FIXTURE).unwrap();
|
||||||
assert_eq!(jwk.x5.url.unwrap(), "https://example.com/testing.crt");
|
assert_eq!(jwk.x5.url.unwrap(), "https://example.com/testing.crt");
|
||||||
assert_eq!(jwk.x5.cert_chain.unwrap(), "---BEGIN CERTIFICATE---...");
|
assert_eq!(
|
||||||
|
jwk.x5.cert_chain.unwrap(),
|
||||||
|
vec!["---BEGIN CERTIFICATE---..."]
|
||||||
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
jwk.x5.thumbprint.unwrap(),
|
jwk.x5.thumbprint.unwrap(),
|
||||||
"aaf4c61ddcc5e8a2dabede0f3b482cd9aea9434d"
|
"aaf4c61ddcc5e8a2dabede0f3b482cd9aea9434d"
|
||||||
|
Loading…
Reference in New Issue
Block a user