example/local-using-builder panics #3
Comments
Thanks for the bug report! This looks to be an issue with newer versions of rust. As on 1.31.1 (current stable), running:
Works. However after running
I get the same error as you on the latest nightly (1.33). I wonder if this is because of our use of error-chain instead of using the newer failure APIs. (or something even more nebulous). Needless to say I'll look into it, so we don't start failing to compile on stable. |
Thanks for the quick reply. I would like to add, that I was also having weird Here's the code. use paseto;
use rocket::Outcome;
use rocket::Request;
use rocket::request;
use rocket::request::FromRequest;
use serde_json::Value;
use crate::modules::auth::enums::token::AuthTokenError;
#[derive(Debug)]
pub struct AuthToken(Result<Value, AuthTokenError>);
impl<'a, 'r> FromRequest<'a, 'r> for AuthToken {
type Error = ();
fn from_request(request: &'a Request<'r>) -> request::Outcome<AuthToken, ()> {
let keys: Vec<_> = request.headers().get("x-api-key").collect();
if keys.len() != 1 {
return Outcome::Success(AuthToken(Err(AuthTokenError::MissingHeader)));
}
let token = keys[0];
println!("{:?}", token);
match paseto::tokens::validate_local_token(
token.to_string(),
None,
Vec::from("YELLOW SUBMARINE, BLACK WIZARDRY".as_bytes()),
) {
Ok(t) => match t {
Value::String(_) => Outcome::Success(AuthToken(Ok(t))),
_ => Outcome::Success(AuthToken(Err(AuthTokenError::UnexpectedContent)))
},
x => {
println!("{:?}", x);
Outcome::Success(AuthToken(Err(AuthTokenError::InvalidSignature)))
}
}
}
} Earlier I was getting Utf8Error, now I am getting
|
Hmmm not sure why you were getting a Utf8 error, but something is definitely going on. Upgrading dependencies, and porting over to rust-2018 still leaves with this error. After doing some more digging it seems on nightly we end up writing an invalid payload. Specifically I got a payload that looks like:
Which is part of the json, just not all of it (thus leading to the json parse error). This should all be handled through serde, so perhaps serde is having problems in nightly? That seems suspect though, anyway I'll keep digging just wanted to update. |
Turns out this bug was caused by our custom libsodium_ffi code, on newer versions of rust. Which we originally had in because sodiumoxide didn't have the functions we needed. Luckily sodiumoxide does contain the functions we need! So I've pushed a commit that fixes it locally for me to master. I'll be testing with some of our internal applications before cutting a release, but would you mind testing it out yourself? See if you still run into the issue? |
Will do that. But my use case is rather simple. |
Any idea, how to fix this? Do I still have to export vars?
Got it! unset SODIUM_STATIC
unset SODIUM_BUILD_STATIC |
Hm, you have moved |
Doh, didn't realize you couldn't set those env vars at all anymore. I'll be sure to include that in the changelog. As for the internal error type, yes it has been moved to: |
Well, I've got my app running. Thanks for help with errors. And verification seems to work! Great 🥇 |
Good to hear it! I still have some testing to do, but we should cut an official version by end of day Monday. |
Thanks again for fix and help :) You are awesome maintainer 🎉 |
Description
Steps to reproduce
cp examples/local-using-builders.rs src/main.rs
cargo run
This should verify the token, but it fails with this error mesage.
Error
Additional Information
The text was updated successfully, but these errors were encountered: