Skip to content

Conversation

@HaoK
Copy link
Member

@HaoK HaoK commented Aug 5, 2022

Perf followup to #39840

This adds a metadata cache so we cache the computed policies per endpoint

Fixes #43227

@HaoK HaoK requested review from a team, DamianEdwards, Tratcher and davidfowl August 5, 2022 23:25
@ghost ghost added the area-auth Includes: Authn, Authz, OAuth, OIDC, Bearer label Aug 5, 2022
@HaoK HaoK added the api-suggestion Early API idea and discussion, it is NOT ready for implementation label Aug 8, 2022
@HaoK HaoK requested a review from captainsafia August 11, 2022 18:18
@HaoK
Copy link
Member Author

HaoK commented Aug 11, 2022

I'll send out an email API review for this now

@HaoK HaoK added api-ready-for-review API is ready for formal API review - https://github.com/dotnet/apireviews and removed api-suggestion Early API idea and discussion, it is NOT ready for implementation labels Aug 11, 2022
@ghost
Copy link

ghost commented Aug 11, 2022

Thank you for your API proposal. I'm removing the api-ready-for-review label. API Proposals should be submitted for review through Issues based on this template.

@ghost ghost removed the api-ready-for-review API is ready for formal API review - https://github.com/dotnet/apireviews label Aug 11, 2022
@HaoK HaoK added the api-suggestion Early API idea and discussion, it is NOT ready for implementation label Aug 11, 2022
@HaoK
Copy link
Member Author

HaoK commented Aug 12, 2022

Updated to WithAuthorizationPolicyCache and IVT for the metadata per #43227

Copy link
Member

Choose a reason for hiding this comment

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

How about to only add AuthorizationPolicyCache if there are IAuthorizeData or AuthorizationPolicy is available in the metadata. Also the new Finally method could be used instead of Add.

// Cache the computed policy
if (policy != null && canCachePolicy)
{
_policyCache!.Value![endpoint!] = policy;
Copy link
Member

Choose a reason for hiding this comment

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

the symbols here are funny 😄

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah the cache code is very excited!!!


public void Store(Endpoint endpoint, AuthorizationPolicy policy)
{
_policyCache!.Value![endpoint!] = policy;
Copy link
Member

@davidfowl davidfowl Aug 15, 2022

Choose a reason for hiding this comment

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

No more null checks!

Suggested change
_policyCache!.Value![endpoint!] = policy;
_policyCache.Value[endpoint] = policy;

Copy link
Member Author

Choose a reason for hiding this comment

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

Value can still be null I think or at least vs says so

@HaoK HaoK enabled auto-merge (squash) August 15, 2022 08:48
@HaoK HaoK merged commit 525705f into main Aug 15, 2022
@HaoK HaoK deleted the haok/authzPerf branch August 15, 2022 10:29
@ghost ghost added this to the 7.0-rc1 milestone Aug 15, 2022
@davidfowl davidfowl added the Perf label Aug 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api-suggestion Early API idea and discussion, it is NOT ready for implementation area-auth Includes: Authn, Authz, OAuth, OIDC, Bearer Perf

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add AuthorizationPolicyCache

6 participants