Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support use of external signing service #325

Open
fiadliel opened this issue Aug 30, 2023 · 1 comment
Open

Support use of external signing service #325

fiadliel opened this issue Aug 30, 2023 · 1 comment

Comments

@fiadliel
Copy link
Contributor

I'd like to use this library to create JWTs, but use an external key management service for signing (so the private key material is never made public).

I don't know what kind of API you might prefer, but a minimal option might be to expose something like:

pub fn encode_unsigned<T: Serialize>(header: &Header, claims: &T) -> Result<String> {
    let encoded_header = b64_encode_part(header)?;
    let encoded_claims = b64_encode_part(claims)?;
    let message = [encoded_header, encoded_claims].join(".");

    Ok(message)
}

and then leave it up to the user to generate everything else with their preferred signing system.

A more extensive change would include an API for calling the external service.

Do you have a preference for a particular approach here?

@Keats
Copy link
Owner

Keats commented Sep 1, 2023

I don't think we would add something like that. There's no JWT involved there, just some base64 serializing. You can put that snippet in your codebase, add base64 to the deps + b64_encode_part and it's going to work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants