Skip to content

EncodingKey to JWK #357

@andrewbaxter

Description

@andrewbaxter

The same way that there's a way to go from JWK to DecodingKey, when creating a JWT you generate a key and need to embed information about that key in the payload.

I think the expected usage (? I couldn't find an example here) is to generate the private key and at the same point generate the JWK, then pass them around together. This risks mixing up the JWK and key leading to invalid tokens, vs generating the JWK from the key at the time of generating the JWT.

Right now EncodingKey contains an opaque u8 blob which is decoded into the correct key type at the time of signing. Following this approach, it would have to be decoded twice, once for signing and once for JWK generation. I think it may be better to decode the key into the parsed structure immediately when creating the EncodingKey -- this has the added benefit of validating the key early.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions