sso_proxy: fix session revalidation/refresh when group validation isn't being used #286
+132
−47
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
When certain TTL's expire we revalidate or refresh the session (e.g. https://github.com/buzzfeed/sso/blob/master/internal/proxy/oauthproxy.go#L759-L764), which then ends up directly calling the
ValidateGroup
provider method (https://github.com/buzzfeed/sso/blob/master/internal/proxy/providers/sso.go#L381).Because here we're not using the validator abstractions, if group validation isn't being utilised, then this causes a
403
withuser is no longer in valid groups
to be returned, requiring the user to refresh the page to progress further.Solution
The logic within
ValidateGroup
to return a success when an empty slice of groups is passed in was removed during some refactoring as, when using 'validator' abstractions this was deemed bad behaviour**, but until we stop callingValidateGroup
directly and use those abstractions everywhere we need to maintain this behaviour.#275 fixes this in a more permanent, stable fashion by replacing any remaining direct calls to
ValidateGroup
with calls to the validator abstractions, however until that is merged this is one possible temporary fix.Notes
**This was deemed bad behaviour because if the group validator is the only validator in use (and not email domains or addresses), then allowing
ValidateGroup
to return successful if an empty list of groups is passed becomes a loophole to allow the defining of no validators, something which we explicitly prevent (https://github.com/buzzfeed/sso/blob/master/internal/proxy/options.go#L205-L213)