Open supchuck opened 1 year ago
Im gone take a look at it when I get home in about 10 hours.
Have you added one of the Features
respective to their implementation?
Using exonum-crypto, I tried:
jwt-compact = {version = "0.7.0", features=["exonum-crypto"]}
as well as the beta version, just to see if there was any difference,
jwt-compact = {version = "0.8.0-beta.1", features=["exonum-crypto"]}
both of which led to the error.
Since, I've switched to ed25519-compact and received the error on 0.8.0-beta.1 of JWT-compact but when I used the current version (0.7.0), I do appear to have any issue.
jwt-compact = {version = "0.7.0", features=["ed25519-compact"]}
I plan to test it further tonight as well but am not able to access my computer at the moment (away from the house).
It would be great if you could share a minimal example to reproduce the error.
Here is the version that works; I commented out the exonum-crypto that always fails so you can uncomment it and switch between the two.. When Cargo.toml (below) is switched to 0.8.0-beta.1 for jwt-compact using ed25519-compact, it will fail. It fails each time when using exonum-crypto for jwt-compact in versions 0.7.0 or 0.8.0-beta.1. I do have a working program using jwt-compact 0.7.0 with ed25519-compact. I also just found out that exonum-crypto is no longer available for linux so I'm not that concerned about continuing its use but thought I would still pass this along.
src/main.rs
:
use actix_jwt_auth_middleware::{AuthenticationService, Authority, FromRequest, TokenSigner};
use actix_web::{
cookie::time::Duration,
web::{self, Data},
App, HttpServer,
};
use jwt_compact::alg::Ed25519;
//Exonum-crypto example
//use exonum_crypto::KeyPair;
//ed25519-compact example
use ed25519_compact::{KeyPair, Seed};
use serde::Serialize;
#[derive(Serialize)]
pub struct UserJWT {
pub id: i32,
}
#[actix_rt::main]
async fn main() -> std::io::Result<()> {
/*
//exonum-cryptro minimal test
//Create the key pair to be used with the token signer.
let key_pair = KeyPair::random();
//Used for the JWT
let token_signer = TokenSigner::<UserJWT, _>::new()
.signing_key(key_pair.secret_key().clone())
.access_token_name("user_access_token")
//Token's lifespan is 2 hours, then requires reauthentication
.refresh_token_lifetime(chrono::Duration::minutes(120))
.algorithm(Ed25519)
.build()
.unwrap();
*/
//######################################################
//ed25519-compact minimal test (works for jwt-compact 0.7.0 but not 0.8.0-beta.1)
//Create the key pair to be used with the token signer.
let key_pair = KeyPair::from_seed(Seed::default());
//Used for the JWT
let token_signer = TokenSigner::<UserJWT, _>::new()
.signing_key(key_pair.sk.clone())
.access_token_name("user_access_token")
//Token's lifespan is 2 hours, then requires reauthentication
.refresh_token_lifetime(chrono::Duration::minutes(120))
.algorithm(Ed25519)
.build()
.unwrap();
HttpServer::new(move || {
//Create the web app
App::new()
})
//Bind to the local address on port 8888
.bind("127.0.0.1:8888")?
.run()
.await
}
Cargo.toml
:
[package]
name = "min_reproducable"
version = "0.1.0"
edition = "2021"
[dependencies]
actix-rt = "2.8.0"
actix-web = {version = "4.3.1", features=["openssl"]}
actix-jwt-auth-middleware = "0.3.0"
#Exonum fails for both 0.7.0 & 0.8.0 Beta
#exonum-crypto = "1.0.0"
#jwt-compact = {version = "0.7.0", features=["exonum-crypto"]}
#jwt-compact = {version = "0.8.0-beta.1", features=["exonum-crypto"]}
#This works when jwt-compact version = 0.7.0, but not 0.8.0 Beta
ed25519-compact = "2.0.4"
jwt-compact = {version = "0.7.0", features=["ed25519-compact"]}
#jwt-compact = {version = "0.8.0-beta.1", features=["ed25519-compact"]}
chrono = {version = "0.4.26", features = ["serde"]}
serde = "1.0.166"
Sorry Mate, your minimal example compiles on my system just fine.
Here is the head of my os-release
(x64):
PRETTY_NAME="Debian GNU/Linux 11 (bullseye)"
NAME="Debian GNU/Linux"
VERSION_ID="11"
VERSION="11 (bullseye)"
VERSION_CODENAME=bullseye
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"
Could you share some info about your system?
I would also try to delete the cargo build cache:
cargo clean
@supchuck does this issue still a cure?
Everything seems to be working.On Aug 10, 2023 11:57, Michael @.***> wrote: @supchuck does this issue still a cure?
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you were mentioned.Message ID: @.***>
I've been having this same issue, resolved it by reverting back to jwt_compact to 0.7.0. I've been stuck on this for a few days now and I can't make any sense of what must be going wrong. I can only assume that jwt_compact 0.8 introduced some module layout changes.
I will take a look.
I am currently receiving the error mentioned above when I try to compile code utilizing a TokenSigner, however did not receive any such error when using a CookieSigner. This only began after recently updating to version 0.3.0. My code is as follows:
The full error output is as follows (this output is also produced if I copy and paste the example code on docs.rs for a TokenSigner):