From 1fb281d0ee38b07fa03327f6a7e5a8329e2bade2 Mon Sep 17 00:00:00 2001 From: Eric Chiang Date: Mon, 4 May 2020 22:06:59 -0700 Subject: [PATCH 1/2] *: add a go.mod file and migrate to v3 package Adds a go.mod file and moves the package to the "oidc" directory. Everything in this PR is just a move except: * Changes to the test script for go.mods. * Moves oidc/jose.go comments to above the const block to satify golint. --- example/idtoken/app.go | 3 +-- example/nonce/app.go | 3 +-- example/userinfo/app.go | 3 +-- go.mod | 12 +++++++++ go.sum | 37 +++++++++++++++++++++++++++ jose.go => oidc/jose.go | 10 +++----- jwks.go => oidc/jwks.go | 0 jwks_test.go => oidc/jwks_test.go | 0 oidc.go => oidc/oidc.go | 0 oidc_test.go => oidc/oidc_test.go | 0 verify.go => oidc/verify.go | 0 verify_test.go => oidc/verify_test.go | 0 test | 14 +++------- 13 files changed, 58 insertions(+), 24 deletions(-) create mode 100644 go.mod create mode 100644 go.sum rename jose.go => oidc/jose.go (68%) rename jwks.go => oidc/jwks.go (100%) rename jwks_test.go => oidc/jwks_test.go (100%) rename oidc.go => oidc/oidc.go (100%) rename oidc_test.go => oidc/oidc_test.go (100%) rename verify.go => oidc/verify.go (100%) rename verify_test.go => oidc/verify_test.go (100%) diff --git a/example/idtoken/app.go b/example/idtoken/app.go index 9e52ac22..b13879ea 100644 --- a/example/idtoken/app.go +++ b/example/idtoken/app.go @@ -9,8 +9,7 @@ import ( "net/http" "os" - oidc "github.com/coreos/go-oidc" - + "github.com/coreos/go-oidc/v3/oidc" "golang.org/x/net/context" "golang.org/x/oauth2" ) diff --git a/example/nonce/app.go b/example/nonce/app.go index 2dcbd7d8..b25feb09 100644 --- a/example/nonce/app.go +++ b/example/nonce/app.go @@ -9,8 +9,7 @@ import ( "net/http" "os" - oidc "github.com/coreos/go-oidc" - + "github.com/coreos/go-oidc/v3/oidc" "golang.org/x/net/context" "golang.org/x/oauth2" ) diff --git a/example/userinfo/app.go b/example/userinfo/app.go index 0039088e..457c2999 100644 --- a/example/userinfo/app.go +++ b/example/userinfo/app.go @@ -9,8 +9,7 @@ import ( "net/http" "os" - oidc "github.com/coreos/go-oidc" - + "github.com/coreos/go-oidc/v3/oidc" "golang.org/x/net/context" "golang.org/x/oauth2" ) diff --git a/go.mod b/go.mod new file mode 100644 index 00000000..50be11fb --- /dev/null +++ b/go.mod @@ -0,0 +1,12 @@ +module github.com/coreos/go-oidc/v3 + +go 1.14 + +require ( + github.com/google/go-cmp v0.4.0 // indirect + github.com/pquerna/cachecontrol v0.0.0-20180517163645-1555304b9b35 + github.com/stretchr/testify v1.5.1 // indirect + golang.org/x/net v0.0.0-20200505041828-1ed23360d12c + golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d + gopkg.in/square/go-jose.v2 v2.5.1 +) diff --git a/go.sum b/go.sum new file mode 100644 index 00000000..660d6659 --- /dev/null +++ b/go.sum @@ -0,0 +1,37 @@ +cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/golang/protobuf v1.2.0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM= +github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/google/go-cmp v0.4.0 h1:xsAVV57WRhGj6kEIi8ReJzQlHHqcBYCElAvkovg3B/4= +github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/pquerna/cachecontrol v0.0.0-20180517163645-1555304b9b35 h1:J9b7z+QKAmPf4YLrFg6oQUotqHQeUNWwkvo7jZp1GLU= +github.com/pquerna/cachecontrol v0.0.0-20180517163645-1555304b9b35/go.mod h1:prYjPmNq4d1NPVmpShWobRqXY3q7Vp+80DqgxxUrUIA= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H4= +github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2 h1:VklqNMn3ovrHsnt90PveolxSbWFaJdECFbxSq0Mqo2M= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20200505041828-1ed23360d12c h1:zJ0mtu4jCalhKg6Oaukv6iIkb+cOvDrajDH9DH46Q4M= +golang.org/x/net v0.0.0-20200505041828-1ed23360d12c/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d h1:TzXSXBo42m9gQenoE3b9BGiEpg5IG2JkU5FkPIawgtw= +golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= +golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4 h1:YUO/7uOKsKeq9UokNS62b8FYywz3ker1l1vDZRCRefw= +golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +google.golang.org/appengine v1.4.0 h1:/wp5JvzpHIxhs/dumFmF7BXTf3Z+dd4uXta4kVyO508= +google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/square/go-jose.v2 v2.5.1 h1:7odma5RETjNHWJnR32wx8t+Io4djHE1PqxCFx3iiZ2w= +gopkg.in/square/go-jose.v2 v2.5.1/go.mod h1:M9dMgbHiYLoDGQrXy7OpJDJWiKiU//h+vD76mk0e1AI= +gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/jose.go b/oidc/jose.go similarity index 68% rename from jose.go rename to oidc/jose.go index f2e6bf43..8afa895c 100644 --- a/jose.go +++ b/oidc/jose.go @@ -1,13 +1,9 @@ -// +build !golint - -// Don't lint this file. We don't want to have to add a comment to each constant. - package oidc +// JOSE asymmetric signing algorithm values as defined by RFC 7518 +// +// see: https://tools.ietf.org/html/rfc7518#section-3.1 const ( - // JOSE asymmetric signing algorithm values as defined by RFC 7518 - // - // see: https://tools.ietf.org/html/rfc7518#section-3.1 RS256 = "RS256" // RSASSA-PKCS-v1.5 using SHA-256 RS384 = "RS384" // RSASSA-PKCS-v1.5 using SHA-384 RS512 = "RS512" // RSASSA-PKCS-v1.5 using SHA-512 diff --git a/jwks.go b/oidc/jwks.go similarity index 100% rename from jwks.go rename to oidc/jwks.go diff --git a/jwks_test.go b/oidc/jwks_test.go similarity index 100% rename from jwks_test.go rename to oidc/jwks_test.go diff --git a/oidc.go b/oidc/oidc.go similarity index 100% rename from oidc.go rename to oidc/oidc.go diff --git a/oidc_test.go b/oidc/oidc_test.go similarity index 100% rename from oidc_test.go rename to oidc/oidc_test.go diff --git a/verify.go b/oidc/verify.go similarity index 100% rename from verify.go rename to oidc/verify.go diff --git a/verify_test.go b/oidc/verify_test.go similarity index 100% rename from verify_test.go rename to oidc/verify_test.go diff --git a/test b/test index b262d0e7..7f89531c 100755 --- a/test +++ b/test @@ -2,15 +2,7 @@ set -e -# Filter out any files with a !golint build tag. -LINTABLE=$( go list -tags=golint -f ' - {{- range $i, $file := .GoFiles -}} - {{ $file }} {{ end }} - {{ range $i, $file := .TestGoFiles -}} - {{ $file }} {{ end }}' github.com/coreos/go-oidc ) - -go test -v -i -race github.com/coreos/go-oidc/... -go test -v -race github.com/coreos/go-oidc/... -golint -set_exit_status $LINTABLE +go test -v -race ./... +golint -set_exit_status ./... go vet github.com/coreos/go-oidc/... -go build -v ./example/... +go build -v ./... From 526e05fd6b9d20a317aca386fe924ba6f9fd5341 Mon Sep 17 00:00:00 2001 From: Eric Chiang Date: Tue, 5 May 2020 18:48:19 -0700 Subject: [PATCH 2/2] *: switch from Travis CI to GitHub Actions --- .github/workflows/test.yaml | 25 +++++++++++++++++++++++++ .travis.yml | 16 ---------------- 2 files changed, 25 insertions(+), 16 deletions(-) create mode 100644 .github/workflows/test.yaml delete mode 100644 .travis.yml diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml new file mode 100644 index 00000000..c62811c4 --- /dev/null +++ b/.github/workflows/test.yaml @@ -0,0 +1,25 @@ +name: test +on: + push: + branches: + - v3 + pull_request: + branches: + - v3 + +jobs: + build: + name: Linux + runs-on: ubuntu-latest + steps: + - name: Set up Go 1.14 + uses: actions/setup-go@v2 + with: + go-version: '1.14.2' + id: go + - name: Check out code into the Go module directory + uses: actions/checkout@v2 + - name: Install golint + run: go get -u golang.org/x/lint/golint + - name: Test + run: "./test" diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 3fddaaac..00000000 --- a/.travis.yml +++ /dev/null @@ -1,16 +0,0 @@ -language: go - -go: - - "1.12" - - "1.13" - -install: - - go get -v -t github.com/coreos/go-oidc/... - - go get golang.org/x/tools/cmd/cover - - go get golang.org/x/lint/golint - -script: - - ./test - -notifications: - email: false