Unbreak oauth2-proxy for keycloak provider after 2c668a (#1502)
* Unbreak oauth2-proxy for keycloak provider after 2c668a
With 2c668a, oauth2-proxy fails a request if the token validation fails.
Token validation always fails with the keycloak provider, due to the
valudation request passing the token via the URL, and keycloak not
parsing the url for tokens.
This is fixed by forcing the validation request to pass the token via a
header.
This code taken from the DigitalOcean provider, which presumably forcing
the token to be passed via header for the same reason.
Test plan: I was unable to build a docker image to test the fix, but I
believe it is relatively simple, and it passes the "looks good to me"
test plan.
* Add changelog entry for unbreak keycloak
Co-authored-by: Joel Speed <Joel.speed@hotmail.co.uk>
commitc900c51a1bb596051d2b8e2cd04a04be5d1a0b07
authorckwalsh <ckwalsh@cullenwalsh.com>
dateSun 29 May 2022, 03:08 (4 years ago)
parent01da2ac
CHANGELOG.md+1
@@ -43,6 +43,7 @@ If you are using an architecture specific tag (ex: v7.2.1-arm64) you should move
4343- [#1638](https://github.com/oauth2-proxy/oauth2-proxy/pull/1638) Implement configurable upstream timeout (@jacksgt)
4444- [#1650](https://github.com/oauth2-proxy/oauth2-proxy/pull/1650) Fixed 500 when checking if user has repo (@adamsong)
4545- [#1635](https://github.com/oauth2-proxy/oauth2-proxy/pull/1635) Added description and unit tests for ipv6 address (@t-katsumura)
46+- [#1502](https://github.com/oauth2-proxy/oauth2-proxy/pull/1502) Unbreak oauth2-proxy for keycloak provider after 2c668a (@ckwalsh)
4647
4748# V7.2.1
4849
providers/keycloak.go+5
@@ -100,3 +100,8 @@ func (p *KeycloakProvider) EnrichSession(ctx context.Context, s *sessions.Sessio
100100
101101 return nil
102102}
103+
104+// ValidateSession validates the AccessToken
105+func (p *KeycloakProvider) ValidateSession(ctx context.Context, s *sessions.SessionState) bool {
106+ return validateToken(ctx, p, s.AccessToken, makeOIDCHeader(s.AccessToken))
107+}