ezidam + jwt: get key, import private key, create jwt claims and sign them
This commit is contained in:
parent
ef8d75ecee
commit
e99115e174
14 changed files with 217 additions and 5 deletions
|
|
@ -1,6 +1,7 @@
|
|||
use crate::Error;
|
||||
use crate::{Error, JwtClaims};
|
||||
use id::KeyID;
|
||||
use jwt_compact::alg::{RsaPrivateKey, StrongKey};
|
||||
use jwt_compact::alg::{Rsa, RsaPrivateKey, StrongKey};
|
||||
use jwt_compact::{AlgorithmExt, Claims, Header};
|
||||
use rsa::pkcs8::der::zeroize::Zeroizing;
|
||||
use rsa::pkcs8::{DecodePrivateKey, EncodePrivateKey};
|
||||
|
||||
|
|
@ -27,6 +28,18 @@ impl PrivateKey {
|
|||
key: RsaPrivateKey::from_pkcs8_der(der)?,
|
||||
})
|
||||
}
|
||||
|
||||
pub fn id(&self) -> &str {
|
||||
self.id.as_ref()
|
||||
}
|
||||
|
||||
pub fn sign_serialize_jwt(
|
||||
&self,
|
||||
header: Header,
|
||||
claims: Claims<JwtClaims>,
|
||||
) -> Result<String, Error> {
|
||||
Ok(Rsa::ps256().token(header, &claims, &self.key)?)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue