Upgrade basic-jwt to version 0.2.0
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing

This commit is contained in:
2024-04-20 13:56:05 +02:00
parent 23e0b33b43
commit 865494572f
6 changed files with 19 additions and 19 deletions

View File

@ -4,7 +4,7 @@ use crate::app_config::AppConfig;
use crate::constants;
use crate::utils::time_utils::time;
use actix_http::Method;
use basic_jwt::{TokenPrivKey, TokenPubKey};
use basic_jwt::{JWTPrivateKey, JWTPublicKey};
use std::path::Path;
use std::str::FromStr;
@ -76,7 +76,7 @@ pub struct Token {
created: u64,
updated: u64,
#[serde(skip_serializing_if = "Option::is_none")]
pub pub_key: Option<TokenPubKey>,
pub pub_key: Option<JWTPublicKey>,
pub rights: TokenRights,
pub last_used: u64,
pub ip_restriction: Option<ipnetwork::IpNetwork>,
@ -195,8 +195,9 @@ impl NewToken {
}
/// Create a new Token
pub async fn create(t: &NewToken) -> anyhow::Result<(Token, TokenPrivKey)> {
let (pub_key, priv_key) = basic_jwt::generate_ec384_keypair()?;
pub async fn create(t: &NewToken) -> anyhow::Result<(Token, JWTPrivateKey)> {
let priv_key = JWTPrivateKey::generate_ec384_signing_key()?;
let pub_key = priv_key.to_public_key()?;
let token = Token {
name: t.name.to_string(),

View File

@ -5,7 +5,7 @@ use crate::api_tokens::{NewToken, TokenID, TokenRights};
use crate::controllers::api_tokens_controller::rest_token::RestToken;
use crate::controllers::HttpResult;
use actix_web::{web, HttpResponse};
use basic_jwt::TokenPrivKey;
use basic_jwt::JWTPrivateKey;
/// Create a special module for REST token to enforce usage of constructor function
mod rest_token {
@ -28,7 +28,7 @@ mod rest_token {
#[derive(serde::Serialize)]
struct CreateTokenResult {
token: RestToken,
priv_key: TokenPrivKey,
priv_key: JWTPrivateKey,
}
/// Create a new API token

View File

@ -71,13 +71,12 @@ impl FromRequest for ApiAuthExtractor {
return Err(ErrorBadRequest("Unable to validate token!"));
}
let claims = match basic_jwt::validate_jwt::<TokenClaims>(
&token
.pub_key
.clone()
.expect("All tokens shall have public key!"),
&token_jwt,
) {
let claims = match token
.pub_key
.as_ref()
.expect("All tokens shall have public key!")
.validate_jwt::<TokenClaims>(&token_jwt)
{
Ok(c) => c,
Err(e) => {
log::error!("Failed to validate JWT: {e}");