Skip to content

Commit f63520e

Browse files
authored
move auth module into a new project (#522)
* move auth module into a new project * upgrade go 1.22.2. to 1.22.4 --------- Co-authored-by: rick <[email protected]>
1 parent ad1521b commit f63520e

File tree

14 files changed

+21
-424
lines changed

14 files changed

+21
-424
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ COPY console/atest-ui .
55
RUN npm install --ignore-scripts --registry=https://registry.npmmirror.com
66
RUN npm run build-only
77

8-
FROM docker.io/golang:1.22.2 AS builder
8+
FROM docker.io/golang:1.22.4 AS builder
99

1010
ARG VERSION
1111
ARG GOPROXY

cmd/server.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ import (
4242
"github.com/linuxsuren/api-testing/pkg/downloader"
4343
"github.com/linuxsuren/api-testing/pkg/logging"
4444
"github.com/linuxsuren/api-testing/pkg/mock"
45-
"github.com/linuxsuren/api-testing/pkg/oauth"
4645
template "github.com/linuxsuren/api-testing/pkg/render"
4746
"github.com/linuxsuren/api-testing/pkg/server"
4847
"github.com/linuxsuren/api-testing/pkg/service"
@@ -51,6 +50,8 @@ import (
5150
"github.com/linuxsuren/api-testing/pkg/testing/remote"
5251
"github.com/linuxsuren/api-testing/pkg/util"
5352
fakeruntime "github.com/linuxsuren/go-fake-runtime"
53+
atestoauth "github.com/linuxsuren/api-testing/pkg/oauth"
54+
"github.com/linuxsuren/oauth-hub"
5455

5556
"github.com/prometheus/client_golang/prometheus"
5657
"github.com/prometheus/client_golang/prometheus/collectors"
@@ -182,7 +183,7 @@ func (o *serverOption) preRunE(cmd *cobra.Command, args []string) (err error) {
182183
return
183184
}
184185

185-
grpcOpts = append(grpcOpts, oauth.NewAuthInterceptor(o.oauthGroup))
186+
grpcOpts = append(grpcOpts, atestoauth.NewAuthInterceptor(o.oauthGroup))
186187
}
187188
if o.tls {
188189
if o.tlsCert != "" && o.tlsKey != "" {

go.mod

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/linuxsuren/api-testing
22

3-
go 1.22.2
3+
go 1.22.4
44

55
require (
66
github.com/Masterminds/sprig/v3 v3.2.3
@@ -33,7 +33,7 @@ require (
3333
github.com/tidwall/gjson v1.14.4
3434
github.com/xeipuuv/gojsonschema v1.2.0
3535
go.uber.org/zap v1.27.0
36-
golang.org/x/oauth2 v0.18.0
36+
golang.org/x/oauth2 v0.22.0
3737
golang.org/x/sync v0.6.0
3838
google.golang.org/genproto/googleapis/api v0.0.0-20240123012728-ef4313101c80
3939
google.golang.org/grpc v1.62.1
@@ -64,6 +64,7 @@ require (
6464
github.com/imdario/mergo v0.3.16 // indirect
6565
github.com/inconshreveable/mousetrap v1.1.0 // indirect
6666
github.com/josharian/intern v1.0.0 // indirect
67+
github.com/linuxsuren/oauth-hub v0.0.0-20240809060240-e78c21b5d8d4 // indirect
6768
github.com/mailru/easyjson v0.7.7 // indirect
6869
github.com/mitchellh/copystructure v1.2.0 // indirect
6970
github.com/mitchellh/reflectwalk v1.0.2 // indirect

go.sum

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,10 @@ github.com/linuxsuren/go-fake-runtime v0.0.4 h1:y+tvBuw6MKTCav8Bo5HWwaXhBx1Z//VA
119119
github.com/linuxsuren/go-fake-runtime v0.0.4/go.mod h1:zmh6J78hSnWZo68faMA2eKOdaEp8eFbERHi3ZB9xHCQ=
120120
github.com/linuxsuren/go-service v0.0.0-20231225060426-efabcd3a5161 h1:dSL/ah6zaRGqH3FW0ogtMjP6xCFXX5NsgWJTaNIofI4=
121121
github.com/linuxsuren/go-service v0.0.0-20231225060426-efabcd3a5161/go.mod h1:QX22v61PxpOfJa4Xug8qzGTbPjclDZFx2j1PlGLknJw=
122+
github.com/linuxsuren/oauth-hub v0.0.0-20240809035103-220d1f431cc3 h1:Nmh7TETH85skH7Wfw6M5J8DhdAyAGodGOwshNfzpM88=
123+
github.com/linuxsuren/oauth-hub v0.0.0-20240809035103-220d1f431cc3/go.mod h1:NrsEbf2IUUmNUoNbTkeWMcswb+4nEMniZ/8xTUhk2zw=
124+
github.com/linuxsuren/oauth-hub v0.0.0-20240809060240-e78c21b5d8d4 h1:muVmKxx+JneaVgUKHqLc+As5vpgKXZAfVu6h+iyb5LQ=
125+
github.com/linuxsuren/oauth-hub v0.0.0-20240809060240-e78c21b5d8d4/go.mod h1:6K1L5ajpFTNO8iJSsNrxMWAigAqczI0UPfEV9NSE0nc=
122126
github.com/linuxsuren/unstructured v0.0.1 h1:ilUA8MUYbR6l9ebo/YPV2bKqlf62bzQursDSE+j00iU=
123127
github.com/linuxsuren/unstructured v0.0.1/go.mod h1:KH6aTj+FegzGBzc1vS6mzZx3/duhTUTEVyW5sO7p4as=
124128
github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0=
@@ -234,6 +238,8 @@ golang.org/x/net v0.23.0 h1:7EYJ93RZ9vYSZAIb2x3lnuvqO5zneoD6IvWjuhfxjTs=
234238
golang.org/x/net v0.23.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg=
235239
golang.org/x/oauth2 v0.18.0 h1:09qnuIAgzdx1XplqJvW6CQqMCtGZykZWcXzPMPUusvI=
236240
golang.org/x/oauth2 v0.18.0/go.mod h1:Wf7knwG0MPoWIMMBgFlEaSUDaKskp0dCfrlJRJXbBi8=
241+
golang.org/x/oauth2 v0.22.0 h1:BzDx2FehcG7jJwgWLELCdmLuxk2i+x9UDpSiss2u0ZA=
242+
golang.org/x/oauth2 v0.22.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI=
237243
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
238244
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
239245
golang.org/x/sync v0.6.0 h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ=

go.work

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
go 1.22.2
1+
go 1.22.4
22

33
use (
44
.

go.work.sum

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ cloud.google.com/go/compute v1.23.3/go.mod h1:VCgBUoMnIVIR0CscqQiPJLAG25E3ZRZMzc
144144
cloud.google.com/go/compute v1.24.0/go.mod h1:kw1/T+h/+tK2LJK0wiPPx1intgdAM3j/g3hFDlscY40=
145145
cloud.google.com/go/compute/metadata v0.2.3 h1:mg4jlk7mCAj6xXp9UJ4fjI9VUI5rubuGBW5aJ7UnBMY=
146146
cloud.google.com/go/compute/metadata v0.2.3/go.mod h1:VAV5nSsACxMJvgaAuX6Pk2AawlZn8kiOGuCv6gTkwuA=
147+
cloud.google.com/go/compute/metadata v0.3.0/go.mod h1:zFmK7XCadkQkj6TtorcaGlCW1hT1fIilQDwofLpJ20k=
147148
cloud.google.com/go/contactcenterinsights v1.10.0 h1:YR2aPedGVQPpFBZXJnPkqRj8M//8veIZZH5ZvICoXnI=
148149
cloud.google.com/go/contactcenterinsights v1.10.0/go.mod h1:bsg/R7zGLYMVxFFzfh9ooLTruLRCG9fnzhH9KznHhbM=
149150
cloud.google.com/go/contactcenterinsights v1.12.1 h1:EiGBeejtDDtr3JXt9W7xlhXyZ+REB5k2tBgVPVtmNb0=
@@ -753,8 +754,6 @@ github.com/bits-and-blooms/bitset v1.2.0/go.mod h1:gIdJ4wp64HaoK2YrL1Q5/N7Y16edY
753754
github.com/bketelsen/crypt v0.0.3-0.20200106085610-5cbc8cc4026c/go.mod h1:MKsuJmJgSg28kpZDP6UIiPt0e0Oz0kqKNGyRaWEPv84=
754755
github.com/blang/semver v3.1.0+incompatible/go.mod h1:kRBLl5iJ+tD4TcOOxsy/0fnwebNt5EWlYSAyrTnjyyk=
755756
github.com/blang/semver v3.5.1+incompatible/go.mod h1:kRBLl5iJ+tD4TcOOxsy/0fnwebNt5EWlYSAyrTnjyyk=
756-
github.com/blang/semver/v4 v4.0.0 h1:1PFHFE6yCCTv8C1TeyNNarDzntLi7wMI5i/pzqYIsAM=
757-
github.com/blang/semver/v4 v4.0.0/go.mod h1:IbckMUScFkM3pff0VJDNKRiT6TG/YpiHIM2yvyW5YoQ=
758757
github.com/bool64/httpmock v0.1.13 h1:3QpRXQ5kwHLW8xnVT8+Ug7VS6RerhdEFV+RWYC61aVo=
759758
github.com/bool64/httpmock v0.1.13/go.mod h1:YMTLaypQ3o5DAx78eA/kDRSLec0f+42sLMDmHdmeY+E=
760759
github.com/boombuler/barcode v1.0.1 h1:NDBbPmhS+EqABEs5Kg3n/5ZNjy73Pz7SIV+KCeqyXcs=

pkg/oauth/dex.go

Lines changed: 0 additions & 50 deletions
This file was deleted.

pkg/oauth/github.go

Lines changed: 0 additions & 56 deletions
This file was deleted.

pkg/oauth/gitlab.go

Lines changed: 0 additions & 66 deletions
This file was deleted.

pkg/oauth/interceptor.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020

2121
"errors"
2222

23+
"github.com/linuxsuren/oauth-hub"
2324
"google.golang.org/grpc"
2425
"google.golang.org/grpc/codes"
2526
"google.golang.org/grpc/metadata"
@@ -77,11 +78,11 @@ func (a *authInter) authInterceptor(ctx context.Context, req interface{}, info *
7778
return
7879
}
7980

80-
func GetUserFromContext(ctx context.Context) (user *UserInfo) {
81+
func GetUserFromContext(ctx context.Context) (user *oauth.UserInfo) {
8182
if md, ok := metadata.FromIncomingContext(ctx); ok {
8283
data := md.Get("auth")
8384
if len(data) > 0 {
84-
user = GetUser(data[0])
85+
user = oauth.GetUser(data[0])
8586
}
8687
}
8788
return

0 commit comments

Comments
 (0)