Skip to content
This repository has been archived by the owner on Dec 7, 2020. It is now read-only.

Commit

Permalink
Merge pull request #236 from gambol99/skip_client_id
Browse files Browse the repository at this point in the history
Skip client
  • Loading branch information
gambol99 committed Jun 12, 2017
2 parents 50484f4 + ae2570e commit cd973d7
Show file tree
Hide file tree
Showing 61 changed files with 4,174 additions and 250 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ FEATURES
* added spelling code coverage to the ci build [#PR208](https://github.com/gambol99/keycloak-proxy/pull/208)
* update the encryption to use aes gcm [#PR220](https://github.com/gambol99/keycloak-proxy/pull/220)
* added the --enable-encrypted-token option to enable encrypting the access token:wq

* added the --skip-client-id option to permit skipping the verification of the auduence against client in token [#PR236](https://github.com/gambol99/keycloak-proxy/pull/236)
* updated the base image to apline 3.6 in commit [0fdebaf821](https://github.com/gambol99/keycloak-proxy/pull/236/commits/0fdebaf8215e9480896f01ec7ab2ef7caa242da1)

BREAKING CHANGES:
* the proxy no longer uses prefixes for resources, if you wish to use wildcard urls you need
Expand All @@ -33,6 +34,9 @@ BREAKING CHANGES:
* changed option from log-requests -> enable-logging [#PR199](https://github.com/gambol99/keycloak-proxy/pull/199)
* changed option from json-format -> enable-json-logging [#PR199](https://github.com/gambol99/keycloak-proxy/pull/199)

MISC:
* Switch to using a go-oidc [fork](https://github.com/gambol99/go-oidc/commit/2111f98a1397a35f1800f4c3c354a7abebbef75c) for now, until i get the various bit merged upstream

#### **2.0.7**

FIXES:
Expand Down
5 changes: 2 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
FROM alpine:3.5
FROM alpine:3.6
MAINTAINER Rohith <gambol99@gmail.com>

RUN apk update && \
apk add ca-certificates
RUN apk add ca-certificates --update

ADD templates/ /opt/templates
ADD bin/keycloak-proxy /opt/keycloak-proxy
Expand Down
49 changes: 35 additions & 14 deletions Godeps/Godeps.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ NAME=keycloak-proxy
AUTHOR=gambol99
AUTHOR_EMAIL=gambol99@gmail.com
REGISTRY=quay.io
GOVERSION ?= 1.8.1
GOVERSION ?= 1.8.3
ROOT_DIR=${PWD}
HARDWARE=$(shell uname -m)
GIT_SHA=$(shell git --no-pager describe --always --dirty)
Expand Down
4 changes: 3 additions & 1 deletion doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"strconv"
"time"

"github.com/coreos/go-oidc/jose"
"github.com/gambol99/go-oidc/jose"
)

var (
Expand Down Expand Up @@ -184,6 +184,8 @@ type Config struct {
TLSClientCertificate string `json:"tls-client-certificate" yaml:"tls-client-certificate" usage:"path to the client certificate for outbound connections in reverse and forwarding proxy modes"`
// SkipUpstreamTLSVerify skips the verification of any upstream tls
SkipUpstreamTLSVerify bool `json:"skip-upstream-tls-verify" yaml:"skip-upstream-tls-verify" usage:"skip the verification of any upstream TLS"`
// SkipClientID indicates we don't need to check the client id of the token
SkipClientID bool `json:"skip-client-id" yaml:"skip-client-id" usage:"skip the check on the client token"`

// CorsOrigins is a list of origins permitted
CorsOrigins []string `json:"cors-origins" yaml:"cors-origins" usage:"origins to add to the CORE origins control (Access-Control-Allow-Origin)"`
Expand Down
4 changes: 2 additions & 2 deletions forwarding.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ import (
"time"

log "github.com/Sirupsen/logrus"
"github.com/coreos/go-oidc/jose"
"github.com/coreos/go-oidc/oidc"
"github.com/gambol99/go-oidc/jose"
"github.com/gambol99/go-oidc/oidc"
"github.com/labstack/echo"
)

Expand Down
2 changes: 1 addition & 1 deletion handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import (
"time"

log "github.com/Sirupsen/logrus"
"github.com/coreos/go-oidc/oauth2"
"github.com/gambol99/go-oidc/oauth2"
"github.com/labstack/echo"
)

Expand Down
5 changes: 3 additions & 2 deletions middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (

"github.com/PuerkitoBio/purell"
log "github.com/Sirupsen/logrus"
"github.com/coreos/go-oidc/jose"
"github.com/gambol99/go-oidc/jose"
"github.com/labstack/echo"
"github.com/prometheus/client_golang/prometheus"
"github.com/unrolled/secure"
Expand Down Expand Up @@ -101,7 +101,7 @@ func (r *oauthProxy) metricsMiddleware() echo.MiddlewareFunc {
},
[]string{"code", "method"},
)
prometheus.MustRegisterOrGet(statusMetrics)
prometheus.MustRegister(statusMetrics)

return func(next echo.HandlerFunc) echo.HandlerFunc {
return func(cx echo.Context) error {
Expand Down Expand Up @@ -303,6 +303,7 @@ func (r *oauthProxy) admissionMiddleware(resource *Resource) echo.MiddlewareFunc

log.WithFields(log.Fields{
"access": "permitted",
"client": user.audience,
"email": user.email,
"expires": time.Until(user.expiresAt).String(),
"resource": resource.URL,
Expand Down
3 changes: 2 additions & 1 deletion middleware_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
"time"

log "github.com/Sirupsen/logrus"
"github.com/coreos/go-oidc/jose"
"github.com/gambol99/go-oidc/jose"
"github.com/go-resty/resty"
"github.com/labstack/echo/middleware"
"github.com/stretchr/testify/assert"
Expand Down Expand Up @@ -78,6 +78,7 @@ func newFakeProxy(c *Config) *fakeProxy {
auth := newFakeAuthServer()
c.DiscoveryURL = auth.getLocation()
c.RevocationEndpoint = auth.getRevocationURL()
c.Verbose = false
proxy, err := newProxy(c)
if err != nil {
panic("failed to create fake proxy service, error: " + err.Error())
Expand Down
2 changes: 1 addition & 1 deletion misc.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
"time"

log "github.com/Sirupsen/logrus"
"github.com/coreos/go-oidc/jose"
"github.com/gambol99/go-oidc/jose"
"github.com/labstack/echo"
)

Expand Down
6 changes: 3 additions & 3 deletions oauth.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ import (
"strings"
"time"

"github.com/coreos/go-oidc/jose"
"github.com/coreos/go-oidc/oauth2"
"github.com/coreos/go-oidc/oidc"
"github.com/gambol99/go-oidc/jose"
"github.com/gambol99/go-oidc/oauth2"
"github.com/gambol99/go-oidc/oidc"
)

// getOAuthClient returns a oauth2 client from the openid client
Expand Down
4 changes: 2 additions & 2 deletions oauth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ import (
"testing"
"time"

"github.com/coreos/go-oidc/jose"
"github.com/coreos/go-oidc/oauth2"
"github.com/gambol99/go-oidc/jose"
"github.com/gambol99/go-oidc/oauth2"
"github.com/labstack/echo"
"github.com/stretchr/testify/assert"
)
Expand Down
2 changes: 1 addition & 1 deletion server.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import (

log "github.com/Sirupsen/logrus"
"github.com/armon/go-proxyproto"
"github.com/coreos/go-oidc/oidc"
"github.com/gambol99/go-oidc/oidc"
"github.com/gambol99/goproxy"
"github.com/labstack/echo"
"github.com/labstack/echo/middleware"
Expand Down
66 changes: 65 additions & 1 deletion server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (
"time"

log "github.com/Sirupsen/logrus"
"github.com/coreos/go-oidc/jose"
"github.com/gambol99/go-oidc/jose"
"github.com/stretchr/testify/assert"
)

Expand Down Expand Up @@ -226,6 +226,70 @@ func TestTokenEncryption(t *testing.T) {
newFakeProxy(c).RunTests(t, requests)
}

func TestSkipClientIDDisabled(t *testing.T) {
c := newFakeKeycloakConfig()
p := newFakeProxy(c)
// create two token, one with a bad client id
bad := newTestToken(p.idp.getLocation())
bad.merge(jose.Claims{"aud": "bad_client_id"})
badSigned, _ := p.idp.signToken(bad.claims)
// and the good
good := newTestToken(p.idp.getLocation())
goodSigned, _ := p.idp.signToken(good.claims)
requests := []fakeRequest{
{
URI: "/auth_all/test",
RawToken: goodSigned.Encode(),
ExpectedProxy: true,
ExpectedCode: http.StatusOK,
},
{
URI: "/auth_all/test",
RawToken: badSigned.Encode(),
ExpectedCode: http.StatusForbidden,
},
}
p.RunTests(t, requests)
}

func TestSkipClientIDEnabled(t *testing.T) {
c := newFakeKeycloakConfig()
c.SkipClientID = true
p := newFakeProxy(c)
// create two token, one with a bad client id
bad := newTestToken(p.idp.getLocation())
bad.merge(jose.Claims{"aud": "bad_client_id"})
badSigned, _ := p.idp.signToken(bad.claims)
// and the good
good := newTestToken(p.idp.getLocation())
goodSigned, _ := p.idp.signToken(good.claims)
// bad issuer
badIssurer := newTestToken("http://someone_else")
badIssurer.merge(jose.Claims{"aud": "bad_client_id"})
badIssuerSigned, _ := p.idp.signToken(badIssurer.claims)

requests := []fakeRequest{
{
URI: "/auth_all/test",
RawToken: goodSigned.Encode(),
ExpectedProxy: true,
ExpectedCode: http.StatusOK,
},
{
URI: "/auth_all/test",
RawToken: badSigned.Encode(),
ExpectedProxy: true,
ExpectedCode: http.StatusOK,
},
{
URI: "/auth_all/test",
RawToken: badIssuerSigned.Encode(),
ExpectedCode: http.StatusForbidden,
},
}
p.RunTests(t, requests)
}

func newTestService() string {
_, _, u := newTestProxyService(nil)
return u
Expand Down
2 changes: 1 addition & 1 deletion session.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
"strings"

log "github.com/Sirupsen/logrus"
"github.com/coreos/go-oidc/jose"
"github.com/gambol99/go-oidc/jose"
)

// getIdentity retrieves the user identity from a request, either from a session cookie or a bearer token
Expand Down
2 changes: 1 addition & 1 deletion stores.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
"net/url"

log "github.com/Sirupsen/logrus"
"github.com/coreos/go-oidc/jose"
"github.com/gambol99/go-oidc/jose"
)

// createStorage creates the store client for use
Expand Down
4 changes: 2 additions & 2 deletions user_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ import (
"strings"
"time"

"github.com/coreos/go-oidc/jose"
"github.com/coreos/go-oidc/oidc"
"github.com/gambol99/go-oidc/jose"
"github.com/gambol99/go-oidc/oidc"
)

// extractIdentity parse the jwt token and extracts the various elements is order to construct
Expand Down
Loading

0 comments on commit cd973d7

Please sign in to comment.