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

blob/fileblob: make errors returned by URLSignerHMAC.KeyFromURL recognizable #3504

Open
a-gierczak opened this issue Oct 24, 2024 · 1 comment

Comments

@a-gierczak
Copy link

a-gierczak commented Oct 24, 2024

Is your feature request related to a problem? Please describe.

Pretty small change request, to make errors returned by URLSignerHMAC.KeyFromURL identifiable by errors.Is

Describe the solution you'd like

https://github.com/google/go-cloud/blob/master/blob/fileblob/fileblob.go#L1021

I'd change the returned errors in the linked function to:

var (
    ErrSignatureExpired = errors.New("signature expired")
    ErrInvalidSignature = errors.New("invalid signature")
)

...

if err != nil || time.Now().Unix() > exp {
	return "", ErrSignatureExpired
}

if !h.checkMAC(q) {
	return "", ErrInvalidSignature
}

Describe alternatives you've considered

Custom URLSigner implementation - but it's such a minor thing, that it'd be an overkill not to use the built-in one :)

@vangent
Copy link
Contributor

vangent commented Oct 24, 2024

This doesn't seem portable; other providers just return an error. How would you use this?

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

No branches or pull requests

2 participants