Skip to content

jwt_authn refactory: move threadlocal from JwksCache into JwksDataImpl#16109

Merged
lizan merged 3 commits intoenvoyproxy:mainfrom
qiwzhang:move-jwks-cache
Apr 23, 2021
Merged

jwt_authn refactory: move threadlocal from JwksCache into JwksDataImpl#16109
lizan merged 3 commits intoenvoyproxy:mainfrom
qiwzhang:move-jwks-cache

Conversation

@qiwzhang
Copy link
Copy Markdown
Contributor

This change will not change the functionality, it just changes the internal implementation detail.

JwKsCache holds both config and cache. Currently, the whole JwksCache object is in the thread local slot, but actually, only the cache data needs to be in in the thread local.

This change will move the thread local data inside JwksDataImpl, only stores its {jwks, and expire} into thread local. Move JwksCache object out of thread local.

This change is in preparation to support async fetch of remote_jwks proposed in #14556 (comment).

Detail changes:

  • Created tls for {jwks, expire} inside JwksDataImpl
  • Removed tls for JwksCache in FilterConfigImpl
  • Removed enable_shared_from_this from FilterConfigImpl

Risk Level: Low
Testing: Unit-tested.
Docs Changes: None
Release Notes: None

Signed-off-by: Wayne Zhang <qiwzhang@google.com>
Signed-off-by: Wayne Zhang <qiwzhang@google.com>
Signed-off-by: Wayne Zhang <qiwzhang@google.com>
@qiwzhang qiwzhang requested a review from lizan as a code owner April 22, 2021 00:24
@qiwzhang
Copy link
Copy Markdown
Contributor Author

@yangminzhu @nareddyt @TAOXUY could you help to review this PR?

@lizan lizan merged commit 8e1e022 into envoyproxy:main Apr 23, 2021
@qiwzhang qiwzhang mentioned this pull request Apr 23, 2021
// Set jwks shared_ptr to all threads.
void setJwksToAllThreads(::google::jwt_verify::JwksPtr&& jwks,
std::chrono::steady_clock::time_point expire) {
JwksSharedPtr shared_jwks(jwks.release());
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@qiwzhang how come this isn't a const shared pointer?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be. I will update it in the next pr. Thanks.

gokulnair pushed a commit to gokulnair/envoy that referenced this pull request May 6, 2021
envoyproxy#16109)

This change will not change the functionality,  it just changes the internal implementation detail.

JwKsCache holds both config and cache.  Currently,  the whole JwksCache object is in the thread local slot, but actually, only the  cache data needs to be in in the thread local.

This change will move the thread local data inside JwksDataImpl,  only stores its {jwks, and expire} into thread local. Move JwksCache object out of thread local.

This change is in preparation to support async fetch of remote_jwks proposed in envoyproxy#14556 (comment).

Detail changes:
* Created `tls` for {jwks, expire} inside JwksDataImpl
* Removed `tls` for JwksCache in FilterConfigImpl
* Removed `enable_shared_from_this` from FilterConfigImpl

Risk Level:  Low
Testing:  Unit-tested.
Docs Changes: None
Release Notes: None

Signed-off-by: Wayne Zhang <qiwzhang@google.com>
Signed-off-by: Gokul Nair <gnair@twitter.com>
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

Successfully merging this pull request may close these issues.

5 participants