Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(auth): fail gracefully when no cache headers are available #623

Merged
merged 2 commits into from
May 23, 2024

Conversation

lahirumaramba
Copy link
Member

@lahirumaramba lahirumaramba commented May 22, 2024

Resolves: #621

Avoid throwing errors when parsing cache control headers for public keys and set the cache duration to 0 (equivalent to no cache) when the cache headers cannot be parsed.

@lahirumaramba lahirumaramba added release-note release:stage Stage a release candidate labels May 22, 2024
@lahirumaramba lahirumaramba changed the title fix: fail gracefully when no cache headers fix: fail gracefully when no cache headers are available May 22, 2024
@@ -476,19 +473,20 @@ func parsePublicKey(kid string, key []byte) (*publicKey, error) {
return &publicKey{kid, pk}, nil
}

func findMaxAge(resp *http.Response) (*time.Duration, error) {
func findMaxAge(resp *http.Response) *time.Duration {
duration := time.Duration(0) * time.Second

Choose a reason for hiding this comment

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

Can this line go with the default return value at the bottom of the function?

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks! Moved the default value to the bottom

Copy link
Contributor

@jonathanedey jonathanedey left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link

@Xiaoshouzi-gh Xiaoshouzi-gh left a comment

Choose a reason for hiding this comment

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

LGTM. Thank you so much for the quick response Lahiru!

qq - r we able to test this against a real response?

@lahirumaramba
Copy link
Member Author

LGTM. Thank you so much for the quick response Lahiru!

qq - r we able to test this against a real response?

Yeah, the integrations tests are all green!

@lahirumaramba lahirumaramba merged commit be294e6 into dev May 23, 2024
8 checks passed
@lahirumaramba lahirumaramba deleted the lm-fix-cache branch May 23, 2024 16:47
@lahirumaramba lahirumaramba changed the title fix: fail gracefully when no cache headers are available fix(auth): fail gracefully when no cache headers are available May 29, 2024
lahirumaramba added a commit that referenced this pull request May 29, 2024
lahirumaramba added a commit that referenced this pull request May 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release:stage Stage a release candidate release-note
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants