mirror of
https://codeberg.org/icewind/rss-webhook-trigger.git
synced 2026-11-30 04:00:49 +01:00
log info about generated jwt key
This commit is contained in:
parent
cbb14a6ae3
commit
905c240037
1 changed files with 10 additions and 4 deletions
|
|
@ -1,8 +1,9 @@
|
||||||
use crate::error::{ConfigError, JwtError};
|
use crate::error::{ConfigError, JwtError};
|
||||||
use jsonwebtoken::EncodingKey;
|
use jsonwebtoken::jwk::{Jwk, ThumbprintHash};
|
||||||
use rsa::pkcs8::EncodePrivateKey;
|
use jsonwebtoken::{Algorithm, EncodingKey};
|
||||||
use rsa::RsaPrivateKey;
|
use rsa::RsaPrivateKey;
|
||||||
use secretfile::{load, SecretError};
|
use rsa::pkcs8::EncodePrivateKey;
|
||||||
|
use secretfile::{SecretError, load};
|
||||||
use serde::de::Error;
|
use serde::de::Error;
|
||||||
use serde::{Deserialize, Deserializer};
|
use serde::{Deserialize, Deserializer};
|
||||||
use serde_json::Value;
|
use serde_json::Value;
|
||||||
|
|
@ -12,6 +13,7 @@ use std::fs::read_to_string;
|
||||||
use std::net::IpAddr;
|
use std::net::IpAddr;
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
use tracing::info;
|
||||||
|
|
||||||
#[derive(Debug, Deserialize)]
|
#[derive(Debug, Deserialize)]
|
||||||
pub struct Config {
|
pub struct Config {
|
||||||
|
|
@ -70,7 +72,11 @@ impl TryFrom<JwtConfigRaw> for JwtConfig {
|
||||||
None => {
|
None => {
|
||||||
let mut rng = rand::rng();
|
let mut rng = rand::rng();
|
||||||
let key = RsaPrivateKey::new(&mut rng, 4096)?.to_pkcs8_der()?;
|
let key = RsaPrivateKey::new(&mut rng, 4096)?.to_pkcs8_der()?;
|
||||||
EncodingKey::from_rsa_der(key.as_bytes())
|
let key = EncodingKey::from_rsa_der(key.as_bytes());
|
||||||
|
let jwk = Jwk::from_encoding_key(&key, Algorithm::RS256)?;
|
||||||
|
let key_id = jwk.thumbprint(ThumbprintHash::SHA256)?;
|
||||||
|
info!(kid = key_id, "generated new RS256 key");
|
||||||
|
key
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue