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

idtoken: provide option to validate token despite being expired #1315

Open
agusterodin opened this issue Nov 26, 2021 · 6 comments
Open

idtoken: provide option to validate token despite being expired #1315

agusterodin opened this issue Nov 26, 2021 · 6 comments
Assignees
Labels
priority: p3 Desirable enhancement or fix. May not be included in next release. status: investigating The issue is under investigation, which is determined to be non-trivial. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.

Comments

@agusterodin
Copy link

agusterodin commented Nov 26, 2021

Is your feature request related to a problem? Please describe.
I am implementing a refresh token endpoint. In order to decide what refresh token I should give out I first want to check the attached bearer token. I want to determine whether the bearer token is valid (properly signed but doesn't matter if expired or not) and want to be able to access the token's claims (particularly sub so I know which user it is). Right now an expired but validly signed token will completely fail and return an error.

Describe the solution you'd like
An boolean parameter for the idtoken.Validate function for allowExpired. Either that or a parameter that allows you to define an object where you describe the validation steps you want to "opt-out" of / ignore.

I think the allowExpired solution would be a lot simpler.

Describe alternatives you've considered
Implementing token validation and parsing entirely by myself which seems very difficult and leaves a lot of room for potential security holes / missed validation checks.

Additional context
N/A

@agusterodin agusterodin added priority: p3 Desirable enhancement or fix. May not be included in next release. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design. labels Nov 26, 2021
@agusterodin agusterodin changed the title idtoken: provide option to allow validation of token despite being expired idtoken: provide option to validate token despite being expired Nov 26, 2021
@codyoss
Copy link
Member

codyoss commented Nov 29, 2021

Hey @agusterodin thanks for the feature request. I don't believe any of our language libraries allow this kind of flexibility around omit to validate the expiry of a token as it is critical to make sure the token is active to prevent misuse of old tokens. I will do some double checking but I think it is likely we will not move forward with this proposal at this time. In the meantime I would just vendor the library and refactor out expire check. The parsed token returned by the method will allow additional validations.

@codyoss codyoss added the status: investigating The issue is under investigation, which is determined to be non-trivial. label Nov 29, 2021
@agusterodin
Copy link
Author

Understandable. Much appreciated!

@agusterodin
Copy link
Author

Out of curiosity, what is your official suggestion on how to handle refresh token endpoint logic (checking whether or not previous token was valid)?

Also I agree with you that maximum security should always be there by default. Definitely if the user didn't supply a boolean to skip expiry check I would default to enforcing expiry.

Will vendor for now. Hope that this sort of thing makes its way to this library (or a viable alternative) in the future!

@agusterodin
Copy link
Author

Hey, I tried vendoring the library (https://github.com/agusterodin/google-api-go-client) by commenting out the offending lines.

Unfortunately when I run go get github.com/agusterodin/google-api-go-client the terminal just hangs indefinitely. I have a suspicion it is related to this library being so big or having so much history.

My second attempt involved stripping the repository down to just the idtoken folder contents (https://github.com/agusterodin/google-idtoken). Unfortunately it gave me this error, not to mention that updating my fork will be a lot more difficult since the repositories have a completely different structure:

go: downloading github.com/agusterodin/google-idtoken v0.0.0-20211206003719-8bc73e1e950e
package github.com/agusterodin/google-idtoken
        ../../../go/pkg/mod/github.com/agusterodin/google-idtoken@v0.0.0-20211206003719-8bc73e1e950e/compute.go:15:2: use of internal package google.golang.org/api/internal not allowed

Any suggestions?

@codyoss
Copy link
Member

codyoss commented Dec 6, 2021

The internal folders are where a lot of auth layer stuff happens. You are getting the error because you can't call code from another projects internal folder. You would need to have that copied over as well.

@Mansalol

This comment was marked as off-topic.

@Mansalol Mansalol mentioned this issue Feb 4, 2022
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: p3 Desirable enhancement or fix. May not be included in next release. status: investigating The issue is under investigation, which is determined to be non-trivial. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.
Projects
None yet
Development

No branches or pull requests

4 participants
@codyoss @agusterodin @Mansalol and others