Skip to content
Snippets Groups Projects
Unverified Commit 57736a41 authored by Rohith Jayawardene's avatar Rohith Jayawardene Committed by GitHub
Browse files

Client Audience Header (#319)

- adding the X-Auth-Audience header the to the upstream endpoint
- adding a the unit test to ensure it
parent 000e5cd9
Branches
No related tags found
No related merge requests found
...@@ -5,6 +5,7 @@ FEATURES: ...@@ -5,6 +5,7 @@ FEATURES:
* Updated the docker base image alpine 3.7 [#PR313](https://github.com/gambol99/keycloak-proxy/pull/313) * Updated the docker base image alpine 3.7 [#PR313](https://github.com/gambol99/keycloak-proxy/pull/313)
* Added the ability to control the timeout on the initial openid configuration from .well-known/openid-configuration [#PR315](https://github.com/gambol99/keycloak-proxy/pull/315) * Added the ability to control the timeout on the initial openid configuration from .well-known/openid-configuration [#PR315](https://github.com/gambol99/keycloak-proxy/pull/315)
* Updated to Golang version 1.10 [#PR316](https://github.com/gambol99/keycloak-proxy/pull/316) * Updated to Golang version 1.10 [#PR316](https://github.com/gambol99/keycloak-proxy/pull/316)
* Added the X-Auth-Audience to the upstream headers [#PR319](https://github.com/gambol99/keycloak-proxy/pull/319)
#### **2.1.1** #### **2.1.1**
......
...@@ -334,6 +334,7 @@ func (r *oauthProxy) headersMiddleware(custom []string) func(http.Handler) http. ...@@ -334,6 +334,7 @@ func (r *oauthProxy) headersMiddleware(custom []string) func(http.Handler) http.
scope := req.Context().Value(contextScopeName).(*RequestScope) scope := req.Context().Value(contextScopeName).(*RequestScope)
if scope.Identity != nil { if scope.Identity != nil {
user := scope.Identity user := scope.Identity
req.Header.Set("X-Auth-Audience", user.audience)
req.Header.Set("X-Auth-Email", user.email) req.Header.Set("X-Auth-Email", user.email)
req.Header.Set("X-Auth-ExpiresIn", user.expiresAt.String()) req.Header.Set("X-Auth-ExpiresIn", user.expiresAt.String())
req.Header.Set("X-Auth-Groups", strings.Join(user.groups, ",")) req.Header.Set("X-Auth-Groups", strings.Join(user.groups, ","))
......
...@@ -147,6 +147,24 @@ func TestForbiddenTemplate(t *testing.T) { ...@@ -147,6 +147,24 @@ func TestForbiddenTemplate(t *testing.T) {
newFakeProxy(cfg).RunTests(t, requests) newFakeProxy(cfg).RunTests(t, requests)
} }
func TestAudienceHeader(t *testing.T) {
c := newFakeKeycloakConfig()
c.NoRedirects = false
requests := []fakeRequest{
{
URI: "/auth_all/test",
HasLogin: true,
ExpectedProxy: true,
Redirects: true,
ExpectedProxyHeaders: map[string]string{
"X-Auth-Audience": "test",
},
ExpectedCode: http.StatusOK,
},
}
newFakeProxy(c).RunTests(t, requests)
}
func TestAuthorizationTemplate(t *testing.T) { func TestAuthorizationTemplate(t *testing.T) {
cfg := newFakeKeycloakConfig() cfg := newFakeKeycloakConfig()
cfg.SignInPage = "templates/sign_in.html.tmpl" cfg.SignInPage = "templates/sign_in.html.tmpl"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment