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

Migration to go-oidc from upstream v1 #407

Merged
merged 1 commit into from
Aug 24, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 19 additions & 19 deletions Gopkg.lock

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

6 changes: 3 additions & 3 deletions Gopkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@
version = "1.4.7"

[[constraint]]
branch = "master"
name = "github.com/gambol99/go-oidc"
branch = "v1"
name = "github.com/coreos/go-oidc"

[[constraint]]
branch = "master"
name = "github.com/gambol99/goproxy"
name = "github.com/elazarl/goproxy"

[[constraint]]
name = "github.com/rs/cors"
Expand Down
4 changes: 1 addition & 3 deletions doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"strconv"
"time"

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

Expand Down Expand Up @@ -265,8 +265,6 @@ 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 @@ -20,8 +20,8 @@ import (
"net/http"
"time"

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

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 (
"strings"
"time"

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

"github.com/pressly/chi"
"go.uber.org/zap"
Expand Down
2 changes: 1 addition & 1 deletion middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
"time"

"github.com/PuerkitoBio/purell"
"github.com/gambol99/go-oidc/jose"
"github.com/coreos/go-oidc/jose"
"github.com/go-chi/chi/middleware"
uuid "github.com/satori/go.uuid"
"github.com/unrolled/secure"
Expand Down
2 changes: 1 addition & 1 deletion middleware_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
"testing"
"time"

"github.com/gambol99/go-oidc/jose"
"github.com/coreos/go-oidc/jose"
"github.com/go-resty/resty"
"github.com/rs/cors"
"github.com/stretchr/testify/assert"
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 (
"path"
"time"

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

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/gambol99/go-oidc/jose"
"github.com/gambol99/go-oidc/oauth2"
"github.com/gambol99/go-oidc/oidc"
"github.com/coreos/go-oidc/jose"
"github.com/coreos/go-oidc/oauth2"
"github.com/coreos/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 @@ -28,8 +28,8 @@ import (
"testing"
"time"

"github.com/gambol99/go-oidc/jose"
"github.com/gambol99/go-oidc/oauth2"
"github.com/coreos/go-oidc/jose"
"github.com/coreos/go-oidc/oauth2"
"github.com/pressly/chi"
"github.com/pressly/chi/middleware"
"github.com/stretchr/testify/assert"
Expand Down
13 changes: 6 additions & 7 deletions server.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ import (
httplog "log"

proxyproto "github.com/armon/go-proxyproto"
"github.com/gambol99/go-oidc/oidc"
"github.com/gambol99/goproxy"
"github.com/coreos/go-oidc/oidc"
"github.com/elazarl/goproxy"
"github.com/pressly/chi"
"github.com/pressly/chi/middleware"
"github.com/prometheus/client_golang/prometheus"
Expand Down Expand Up @@ -703,11 +703,10 @@ func (r *oauthProxy) newOpenIDClient() (*oidc.Client, oidc.ProviderConfig, *http
ID: r.config.ClientID,
Secret: r.config.ClientSecret,
},
HTTPClient: hc,
RedirectURL: fmt.Sprintf("%s/oauth/callback", r.config.RedirectionURL),
ProviderConfig: config,
Scope: append(r.config.Scopes, oidc.DefaultScope...),
SkipClientIDCheck: r.config.SkipClientID,
HTTPClient: hc,
RedirectURL: fmt.Sprintf("%s/oauth/callback", r.config.RedirectionURL),
ProviderConfig: config,
Scope: append(r.config.Scopes, oidc.DefaultScope...),
})
if err != nil {
return nil, config, hc, err
Expand Down
40 changes: 1 addition & 39 deletions server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
"testing"
"time"

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

Expand Down Expand Up @@ -351,44 +351,6 @@ func TestSkipClientIDDisabled(t *testing.T) {
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 TestAuthTokenHeaderEnabled(t *testing.T) {
p := newFakeProxy(nil)
token := newTestToken(p.idp.getLocation())
Expand Down
2 changes: 1 addition & 1 deletion session.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"strconv"
"strings"

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

Expand Down
2 changes: 1 addition & 1 deletion stores.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
"fmt"
"net/url"

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

Expand Down
6 changes: 3 additions & 3 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/gambol99/go-oidc/jose"
"github.com/gambol99/go-oidc/oidc"
"github.com/coreos/go-oidc/jose"
"github.com/coreos/go-oidc/oidc"
)

// extractIdentity parse the jwt token and extracts the various elements is order to construct
Expand Down Expand Up @@ -95,7 +95,7 @@ func extractIdentity(token jose.JWT) (*userContext, error) {
}, nil
}

// backported from https://github.com/gambol99/go-oidc/blob/master/oidc/verification.go#L28-L37
// backported from https://github.com/coreos/go-oidc/blob/master/oidc/verification.go#L28-L37
// I'll raise another PR to make it public in the go-oidc package so we can just use `oidc.ContainsString()`
func containsString(needle string, haystack []string) bool {
for _, v := range haystack {
Expand Down
2 changes: 1 addition & 1 deletion utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ import (
"unicode"
"unicode/utf8"

"github.com/gambol99/go-oidc/jose"
"github.com/coreos/go-oidc/jose"
"github.com/urfave/cli"
"gopkg.in/yaml.v2"
)
Expand Down