Skip to content

Add JWT cache #12644

Closed
Closed

Description

@AmaliMatharaarachchi

Title:
Add token cache for the jwt authentication.

Description
JWT verification adds a significant latency. So it's better to have token cache: to cache the tokens with their verification results. Currently, jwt_authn filter only has jwks cache [1].

[1]

* Now it only has jwks_cache, but in the future, it will have token cache: to cache the tokens

Activity

  1. qiwzhang commented on Aug 14, 2020

    @qiwzhang
    Contributor

    It is a reasonable request. Thanks

  2. mk46 commented on Oct 6, 2020

    @mk46
    Contributor

    Hi @AmaliMatharaarachchi, Are you working on this issue? If not then I would like to take up this.

  3. AmaliMatharaarachchi commented on Oct 7, 2020

    @AmaliMatharaarachchi
    Author

    @mk46 No, I'm not working on it. Thanks, please take it.

  4. mk46 commented on Dec 3, 2020

    @mk46
    Contributor

    @qiwzhang Could you please suggest where to start? Similar to jwks_cache.h/cc

  5. qiwzhang commented on Dec 3, 2020

    @qiwzhang
    Contributor

    The easier way is to add token cache feature into JwksCache class.
    The the class name may be confusing, we could rename it to "Cache".

    Add two functions:

     void addTokenResult(const string& token, const TokenResult& token_result);
     bool findTokenResult(const string& token,  TokenResult& result);
    

    class TokenResult, may need to store
    token payload, payStruct, etc. for successful token, or failure status

  6. mk46 commented on Dec 7, 2020

    @mk46
    Contributor

    @qiwzhang Thanks!. I've some quick questions.

    The easier way is to add token cache feature into JwksCache class.
    The the class name may be confusing, we could rename it to "Cache".

    Add two functions:

     void addTokenResult(const string& token, const TokenResult& token_result);
     bool findTokenResult(const string& token,  TokenResult& result);
    

    Needs to add in JwksData or in JwksCache class?

    class TokenResult, may need to store
    token payload, payStruct, etc. for successful token, or failure status

    Could we use ::google::jwt_verify::Jwt instead of TokenResult?

  7. qiwzhang commented on Dec 7, 2020

    @qiwzhang
    Contributor
    1. in JwksData, so it is a per-provider cache. it is fine to separate token cache by provider
    2. We could save Jwt struct ( the parsed jwt ) into cache for a good token. For a bad token, we also need to store Status

    Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions