Skip to content
This repository has been archived by the owner on Aug 28, 2024. It is now read-only.

Added support for providing a JWKSCache implementation #804

Closed
wants to merge 1 commit into from

Conversation

sandboxbohemian
Copy link

Summary

Added support for consumers to provide a JWKSetCache implementation to the UserPrincipalManager

Issue Type

  • Bug fixing

Starter Names

  • active directory spring boot starter

Additional Information

Fix for #802

@msftclas
Copy link

msftclas commented Jan 8, 2020

CLA assistant check
Thank you for your submission, we really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.

❌ sandboxbohemian sign now
You have signed the CLA already but the status is still pending? Let us recheck it.

@Incarnation-p-lee
Copy link
Contributor

Codacy Here is an overview of what got changed by this pull request:

Issues
======
+ Solved 1
           

See the complete overview on Codacy

superrdean
superrdean previously approved these changes Jan 9, 2020
Copy link
Contributor

@superrdean superrdean left a comment

Choose a reason for hiding this comment

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

It is ok

@superrdean superrdean self-assigned this Jan 9, 2020
@superrdean superrdean dismissed their stale review January 9, 2020 11:25

re review

@bcannariato
Copy link
Contributor

Is there any update on when this will potentially be implemented?

Thanks

@Bean
@ConditionalOnMissingBean(JWKSetCache.class)
public JWKSetCache getJWKSetCache() {
return null;
Copy link
Contributor

Choose a reason for hiding this comment

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

This method will always return null. It makes no sense.

Copy link
Contributor

@bcannariato bcannariato Feb 4, 2020

Choose a reason for hiding this comment

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

Well with my understanding that @ConditionalOnMissingBean annotation makes it so this method will only get called when JWKSetCache is missing? So in that case just return null. So the check above will create the AADAuthenticationFilter without the cache object.

That's what the library currently does, it doesn't include that last argument, it has 2 constructers the old one without jwkSetCache and a new one with it.

But I do not understand where the cache is configured if that bean is present...

@superrdean
Copy link
Contributor

Hi @briancarneiro, I leave a comment for the method getJWKCache(). Could you or your team respond to the comment? Once it is resolved, the PR can be merged into the master.

@@ -60,7 +64,12 @@ public AADAuthenticationFilterAutoConfiguration(AADAuthenticationProperties aadA
@ConditionalOnExpression("${azure.activedirectory.session-stateless:false} == false")
public AADAuthenticationFilter azureADJwtTokenFilter() {
LOG.info("AzureADJwtTokenFilter Constructor.");
return new AADAuthenticationFilter(aadAuthProps, serviceEndpointsProps, getJWTResourceRetriever());
if (getJWKSetCache() != null) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This method will always return null. How can you get the specific JWKSetCache customized by yourself?

Copy link
Contributor

Choose a reason for hiding this comment

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

I am also wondering about this. Trying to figure this part out

Copy link
Contributor

Choose a reason for hiding this comment

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

I think with the below changes I suggested we might not need the null check. We would always add it as the 4th parameter. And we could default the lifespan to 5 minutes. That's what it gets defaulted to if you don't pass it in as per the documentation so that would be the same behavior unless you specify in the properties file

Copy link
Contributor

Choose a reason for hiding this comment

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

Sounds good.

@@ -80,6 +89,12 @@ public ResourceRetriever getJWTResourceRetriever() {
aadAuthProps.getJwtSizeLimit());
}

@Bean
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
@Bean
@Bean
@ConditionalOnMissingBean(JWKSetCache.class)
public JWKSetCache getJWKSetCache() {
return new DefaultJWKSetCache(properties.lifespan, TimeUnit.MILLISECONDS)
}

Copy link
Contributor

Choose a reason for hiding this comment

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

Would this be something like what we would want to do? We would then define the lifespan within a properties file

Copy link
Contributor

Choose a reason for hiding this comment

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

Sound good! It is a cool way to customize the cache by properties. If users don't set related configuration, it will use 5 min by default.

@bcannariato
Copy link
Contributor

Is there a way for me to edit/add to his pull request or do I need to create my own?

@bcannariato
Copy link
Contributor

Please see above new pull request with the comments we discussed @neuqlz #827

@superrdean
Copy link
Contributor

Please see above new pull request with the comments we discussed @neuqlz #827

ok, now I close this PR.

@superrdean superrdean closed this Feb 6, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants