Skip to content

Commit 72bf1cc

Browse files
authored
Update dependencies (#52)
* Update module to go 1.21, go-jose to v3 * Always need a valid code now, so default to internal service error * Remove old proto storage, massage generation, promote proto to v1 Remove the old protobuf based storage, it's not been used for a while so it can go to clean stuff up. Now only the versioned JSON is supported. Update the proto build to use tools.go/shimmed local script, to make sure we generate code with the expected version. This updates us to the latest old-style proto package. Promote the persisted types to v1. We don't use Any anywhere, so the package name isn't a problem. * Update to new protobuf package * Update all modules, use built-in homedir func * Correct lint/deprecation issues * Switch to revive * use built-in cache dir for default rather than cluttering up HOME * Update CI to always use latest stable go * Use lint action
1 parent d3cbcb7 commit 72bf1cc

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+437
-1278
lines changed

.github/workflows/go.yml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@ jobs:
77
runs-on: ubuntu-latest
88
steps:
99

10-
- name: Set up Go 1.13
11-
uses: actions/setup-go@v1
10+
- name: Set up Go stable
11+
uses: actions/setup-go@v4
1212
with:
13-
go-version: 1.13
13+
go-version: stable
1414
id: go
1515

1616
- name: Check out code into the Go module directory
17-
uses: actions/checkout@v1
17+
uses: actions/checkout@v4
1818

1919
- name: Get dependencies
2020
run: go mod download
@@ -26,4 +26,6 @@ jobs:
2626
run: make test
2727

2828
- name: Lint
29-
run: make lint
29+
uses: golangci/golangci-lint-action@v3
30+
with:
31+
version: latest

.golangci.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,13 @@ issues:
99
exclude:
1010
- "exported \\w+ (\\S*['.]*)([a-zA-Z'.*]*) should have comment( \\(or a comment on this block\\))? or be unexported"
1111
- "Error return value of .((os\\.)?std(out|err)\\..*|.*Close|.*Flush|os\\.Remove(All)?|.*printf?|os\\.(Un)?Setenv). is not checked"
12+
- "package-comments: should have a package comment"
13+
- "unused-parameter: parameter '\\w+' seems to be unused, consider removing or renaming it as _"
1214

1315
linters:
1416
enable:
1517
- errcheck
16-
- golint
18+
- revive
1719
- goimports
1820
- govet
1921
- misspell

Makefile

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
.PHONY: all build test lint proto
22

3-
gopath=$(shell go env GOPATH)
3+
export PATH := $(shell pwd)/bin:$(PATH)
44

55
all: proto build test lint
66

@@ -10,13 +10,7 @@ build:
1010
test:
1111
go test -v ./...
1212

13-
lint: bin/golangci-lint-1.23.8
14-
./bin/golangci-lint-1.23.8 run ./...
13+
proto: proto/core/v1/storage.pb.go
1514

16-
bin/golangci-lint-1.23.8:
17-
./hack/fetch-golangci-lint.sh
18-
19-
proto: proto/core/v1beta1/storage.pb.go
20-
21-
proto/core/v1beta1/storage.pb.go: proto/core/v1beta1/storage.proto
22-
protoc -I proto/core/v1beta1 --go_out=proto/core/v1beta1 storage.proto
15+
proto/core/v1/storage.pb.go: proto/core/v1/storage.proto
16+
protoc -I proto/core/v1 --go_out=proto/core/v1 storage.proto

bin/protoc-gen-go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/usr/bin/env bash
2+
3+
exec go run google.golang.org/protobuf/cmd/protoc-gen-go "$@"

client.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ import (
88
"strings"
99
"time"
1010

11+
"github.com/go-jose/go-jose/v3"
1112
"github.com/pardot/oidc/discovery"
1213
"golang.org/x/oauth2"
13-
"gopkg.in/square/go-jose.v2"
1414
)
1515

1616
const (

clitoken/local_token_source.go

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -63,24 +63,25 @@ var _ oidc.TokenSource = (*LocalOIDCTokenSource)(nil)
6363
// cached.
6464
//
6565
// Example:
66-
// ctx := context.TODO()
6766
//
68-
// client, err := oidc.DiscoverClient(ctx, StagingURL, ClientID, ClientSecret, "")
69-
// if err != nil {
70-
// // handle err
71-
// }
67+
// ctx := context.TODO()
7268
//
73-
// ts, err := NewLocalOIDCTokenSource(client, clientID, clientSecret)
74-
// if err != nil {
75-
// // handle err
76-
// }
69+
// client, err := oidc.DiscoverClient(ctx, StagingURL, ClientID, ClientSecret, "")
70+
// if err != nil {
71+
// // handle err
72+
// }
7773
//
78-
// token, err := ts.Token(ctx)
79-
// if err != nil {
80-
// // handle error
81-
// }
74+
// ts, err := NewLocalOIDCTokenSource(client, clientID, clientSecret)
75+
// if err != nil {
76+
// // handle err
77+
// }
8278
//
83-
// // use token
79+
// token, err := ts.Token(ctx)
80+
// if err != nil {
81+
// // handle error
82+
// }
83+
//
84+
// // use token
8485
func NewSource(client *oidc.Client, opts ...LocalOIDCTokenSourceOpt) (*LocalOIDCTokenSource, error) {
8586
s := &LocalOIDCTokenSource{
8687
client: client,

cmd/oidc-example-op/signer.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import (
44
"crypto/rand"
55
"crypto/rsa"
66

7+
"github.com/go-jose/go-jose/v3"
78
"github.com/pardot/oidc/signer"
8-
"gopkg.in/square/go-jose.v2"
99
)
1010

1111
func mustInitSigner() *signer.StaticSigner {

core/oauth2_errors.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,11 @@ func writeError(w http.ResponseWriter, req *http.Request, err error) error {
4444
if err.WWWAuthenticate != "" {
4545
w.Header().Add("WWW-Authenticate", err.WWWAuthenticate)
4646
}
47-
http.Error(w, m, err.Code)
47+
code := err.Code
48+
if code == 0 {
49+
code = http.StatusInternalServerError
50+
}
51+
http.Error(w, m, code)
4852

4953
case *oauth2.TokenError:
5054
w.Header().Add("Content-Type", "application/json;charset=UTF-8")

core/oidc.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ import (
1111
"strings"
1212
"time"
1313

14+
"github.com/go-jose/go-jose/v3"
1415
"github.com/pardot/oidc"
1516
"github.com/pardot/oidc/oauth2"
16-
"gopkg.in/square/go-jose.v2"
1717
)
1818

1919
// Signer is used for signing identity tokens

core/oidc_test.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import (
1515
"github.com/google/go-cmp/cmp/cmpopts"
1616
"github.com/pardot/oidc"
1717
"github.com/pardot/oidc/oauth2"
18-
corev1beta1 "github.com/pardot/oidc/proto/core/v1beta1"
18+
corev1 "github.com/pardot/oidc/proto/core/v1"
1919
)
2020

2121
func TestStartAuthorization(t *testing.T) {
@@ -79,8 +79,7 @@ func TestStartAuthorization(t *testing.T) {
7979
}
8080
if sess == nil {
8181
t.Error("session should not be nil")
82-
}
83-
if sess.Request == nil {
82+
} else if sess.Request == nil {
8483
t.Error("request in session should not be nil")
8584
}
8685
},
@@ -1013,7 +1012,7 @@ func TestUserinfo(t *testing.T) {
10131012
}
10141013
}
10151014

1016-
func mustMarshal(u *corev1beta1.UserToken) string {
1015+
func mustMarshal(u *corev1.UserToken) string {
10171016
t, err := marshalToken(u)
10181017
if err != nil {
10191018
panic(err)

0 commit comments

Comments
 (0)