Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync authenticator #12

Closed
wants to merge 34 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
89916a2
misc: Release candidate v0.19.0 (#190)
vikramdevtron Oct 3, 2024
ad8cac9
fix: sync with common-lib changes (#132)
systemsdt Oct 3, 2024
d1816bc
fix: sync with common-lib changes (#43)
vikramdevtron Oct 3, 2024
44c4465
misc: Release candidate v0.19.0 (#79)
vikramdevtron Oct 3, 2024
bf3835b
fix: sync with common-lib changes (#42)
vikramdevtron Oct 3, 2024
1859c74
chore: Release candidate v0.19.0 (#194)
vikramdevtron Oct 3, 2024
7a9aea9
chore: Release candidate v0.19.0 (#33)
vikramdevtron Oct 3, 2024
c63dd67
Merge remote-tracking branch 'chart-sync/main'
nishant-d Oct 5, 2024
d137165
Move chart-sync files into subdir
nishant-d Oct 5, 2024
214b517
Merge remote-tracking branch 'ci-runner/main'
nishant-d Oct 5, 2024
f24c7c3
Move ci-runner files into subdir
nishant-d Oct 5, 2024
5d1cbc6
Merge remote-tracking branch 'kubelink/main'
nishant-d Oct 5, 2024
77c84dd
Move kubelink files into subdir
nishant-d Oct 5, 2024
c1db5b3
Merge remote-tracking branch 'git-sensor/main'
nishant-d Oct 5, 2024
f83cf04
Move git-sensor files into subdir
nishant-d Oct 5, 2024
89a3765
Merge remote-tracking branch 'kubewatch/main'
nishant-d Oct 5, 2024
48142dc
Move kubewatch files into subdir
nishant-d Oct 5, 2024
12cd6fb
Merge remote-tracking branch 'lens/main'
nishant-d Oct 5, 2024
aa78050
Move lens files into subdir
nishant-d Oct 5, 2024
edce168
Merge remote-tracking branch 'authenticator/main'
nishant-d Oct 5, 2024
909d03c
Move authenticator files into subdir
nishant-d Oct 5, 2024
029148c
added binaries
nishant-d Oct 5, 2024
c5f393f
removed unused file
nishant-d Oct 5, 2024
6e7e640
error handling in verifyAppState
prkhrkat Oct 10, 2024
c184e8c
error handling in verifyAppState
prkhrkat Oct 10, 2024
803fd9d
Merge branch 'release-candidate-v0.20.0'
nishant-d Oct 10, 2024
3ca5891
update build files
ayu-devtron Oct 10, 2024
ef03c06
Merge pull request #6 from devtron-labs/release-prep
ayu-devtron Oct 10, 2024
90495d6
rc vendor fix
nishant-d Oct 10, 2024
85abb52
Merge pull request #7 from devtron-labs/rc-vendor-fix
ayu-devtron Oct 10, 2024
e2c23f9
Merge pull request #8 from devtron-labs/release-candidate-v0.20.0
nishant-d Oct 10, 2024
1b44810
dep imported
nishant-d Oct 10, 2024
04f5251
Merge pull request #9 from devtron-labs/dep-import
nishant-d Oct 10, 2024
3c1a0d3
Merge remote-tracking branch 'authenticator/main-auth-fix' into sync-…
prkhrkat Oct 14, 2024
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
2 changes: 1 addition & 1 deletion .github/semantic.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ititleOnly: true
titleOnly: true

types:
- fix
Expand Down
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,13 @@
.vscode
.env
/cmd/external-app/devtron-ea

#binaries
authenticator/authenticator
chart-sync/chart-sync
ci-runner/cirunner
git-sensor/git-sensor
kubelink/kubelink
kubewatch/kubewatch
lens/lens

14 changes: 0 additions & 14 deletions .travis.yml

This file was deleted.

5 changes: 3 additions & 2 deletions authenticator/client/oidcClient.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"net/http"
"net/url"
"path"
"sync"
"time"
)

Expand Down Expand Up @@ -65,8 +66,8 @@ func getOidcClient(dexServerAddress string, settings *oidc.Settings, userVerifie
},
}
dexProxy := oidc.NewDexHTTPReverseProxy(dexServerAddress, dexClient.Transport)
cahecStore := &oidc.Cache{OidcState: map[string]*oidc.OIDCState{}}
oidcClient, err := oidc.NewClientApp(settings, cahecStore, "/", userVerifier, RedirectUrlSanitiser)
cacheStore := &oidc.Cache{OidcState: sync.Map{}}
oidcClient, err := oidc.NewClientApp(settings, cacheStore, "/", userVerifier, RedirectUrlSanitiser)
if err != nil {
return nil, nil, err
}
Expand Down
19 changes: 15 additions & 4 deletions authenticator/oidc/oidc.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import (
"path"
"regexp"
"strings"
"sync"
"time"

gooidc "github.com/coreos/go-oidc/v3/oidc"
Expand Down Expand Up @@ -69,16 +70,23 @@ type OIDCStateStorage interface {
}

type Cache struct {
OidcState map[string]*OIDCState
OidcState sync.Map
}

func (c *Cache) GetOIDCState(key string) (*OIDCState, error) {
state := c.OidcState[key]
value, exists := c.OidcState.Load(key)
if !exists {
return nil, ErrCacheMiss
}
state, ok := value.(*OIDCState)
if !ok || state == nil {
return nil, ErrInvalidState
}
return state, nil
}

func (c *Cache) SetOIDCState(key string, state *OIDCState) error {
c.OidcState[key] = state
c.OidcState.Store(key, state)
return nil
}

Expand Down Expand Up @@ -287,12 +295,15 @@ func (a *ClientApp) generateAppState(returnURL string) string {
}

var ErrCacheMiss = errors.New("cache: key is missing")
var ErrInvalidState = errors.New("invalid app state")

func (a *ClientApp) verifyAppState(state string) (*OIDCState, error) {
res, err := a.cache.GetOIDCState(state)
if err != nil {
if err == ErrCacheMiss {
if errors.Is(err, ErrCacheMiss) {
return nil, fmt.Errorf("unknown app state %s", state)
} else if errors.Is(err, ErrInvalidState) {
return nil, fmt.Errorf("invalid app state %s", state)
} else {
return nil, fmt.Errorf("failed to verify app state %s: %v", state, err)
}
Expand Down
15 changes: 9 additions & 6 deletions chart-sync/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@ go 1.22.4

toolchain go1.22.6

replace helm.sh/helm/v3 v3.14.3 => github.com/devtron-labs/helm/v3 v3.14.1-0.20240401080259-90238cf69e42
replace (
github.com/devtron-labs/common-lib => github.com/devtron-labs/devtron-services/common-lib v0.0.0-20241010131105-e2c23f9c80da
helm.sh/helm/v3 v3.14.3 => github.com/devtron-labs/helm/v3 v3.14.1-0.20240401080259-90238cf69e42
)

require (
github.com/caarlos0/env v3.5.0+incompatible
github.com/devtron-labs/common-lib v0.18.0
github.com/devtron-labs/common-lib v0.0.0
github.com/ghodss/yaml v1.0.0
github.com/go-pg/pg v6.15.1+incompatible
github.com/google/wire v0.6.0
Expand Down Expand Up @@ -90,7 +93,7 @@ require (
go.starlark.net v0.0.0-20230525235612-a134d8f9ddca // indirect
go.uber.org/atomic v1.10.0 // indirect
go.uber.org/goleak v1.2.1 // indirect
go.uber.org/multierr v1.6.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/crypto v0.25.0 // indirect
golang.org/x/net v0.27.0 // indirect
golang.org/x/oauth2 v0.21.0 // indirect
Expand All @@ -105,10 +108,10 @@ require (
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/api v0.29.0 // indirect
k8s.io/apimachinery v0.29.0 // indirect
k8s.io/api v0.29.7 // indirect
k8s.io/apimachinery v0.29.7 // indirect
k8s.io/cli-runtime v0.29.0 // indirect
k8s.io/client-go v0.29.0 // indirect
k8s.io/client-go v0.29.7 // indirect
k8s.io/klog/v2 v2.110.1 // indirect
k8s.io/kube-openapi v0.0.0-20231010175941-2dd684a91f00 // indirect
k8s.io/utils v0.0.0-20230726121419-3b25d923346b // indirect
Expand Down
19 changes: 10 additions & 9 deletions chart-sync/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ github.com/creack/pty v1.1.18/go.mod h1:MOBLtS5ELjhRRrroQr9kyvTxUAFNvYEK993ew/Vr
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/devtron-labs/common-lib v0.18.0 h1:3sjGGxzugZEtFJ1yevG+KBFlnOFmVqjYaIJdgWYG+zc=
github.com/devtron-labs/common-lib v0.18.0/go.mod h1:rAY9Xd6iz+OqNQ3nO3reVHapAVr1N6Osf4Irdc0A08Q=
github.com/devtron-labs/devtron-services/common-lib v0.0.0-20241010131105-e2c23f9c80da h1:vC6SMz6BM1doN+ZBGiDGyERJ/LphFQi5+Ab/YQkNJVo=
github.com/devtron-labs/devtron-services/common-lib v0.0.0-20241010131105-e2c23f9c80da/go.mod h1:KpKnF4OSpQNDJmb4wVZq3Za88ePBw4xec2GOAGRm5UQ=
github.com/devtron-labs/helm/v3 v3.14.1-0.20240401080259-90238cf69e42 h1:pJmK44QaSztOiZe0iQHNf0sdy5KwkAeceydyhOG4RaY=
github.com/devtron-labs/helm/v3 v3.14.1-0.20240401080259-90238cf69e42/go.mod h1:v6myVbyseSBJTzhmeE39UcPLNv6cQK6qss3dvgAySaE=
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78=
Expand Down Expand Up @@ -360,8 +360,9 @@ go.uber.org/atomic v1.10.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0
go.uber.org/goleak v1.1.11/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ=
go.uber.org/goleak v1.2.1 h1:NBol2c7O1ZokfZ0LEU9K6Whx/KnwvepVetCUhtKja4A=
go.uber.org/goleak v1.2.1/go.mod h1:qlT2yGI9QafXHhZZLxlSuNsMw3FFLxBr+tBRlmO1xH4=
go.uber.org/multierr v1.6.0 h1:y6IPFStTAIT5Ytl7/XYmHvzXQ7S3g/IeZW9hyZ5thw4=
go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU=
go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
go.uber.org/zap v1.21.0 h1:WefMeulhovoZ2sYXz7st6K0sLj7bBhpiFaud4r4zST8=
go.uber.org/zap v1.21.0/go.mod h1:wjWOCqI0f2ZZrJF/UufIOkiC8ii6tm1iqIsLo76RfJw=
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
Expand Down Expand Up @@ -547,14 +548,14 @@ gotest.tools/v3 v3.4.0 h1:ZazjZUfuVeZGLAmlKKuyv3IKP5orXcwtOwDQH6YVr6o=
gotest.tools/v3 v3.4.0/go.mod h1:CtbdzLSsqVhDgMtKsx03ird5YTGB3ar27v0u/yKBW5g=
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
k8s.io/api v0.29.0 h1:NiCdQMY1QOp1H8lfRyeEf8eOwV6+0xA6XEE44ohDX2A=
k8s.io/api v0.29.0/go.mod h1:sdVmXoz2Bo/cb77Pxi71IPTSErEW32xa4aXwKH7gfBA=
k8s.io/apimachinery v0.29.0 h1:+ACVktwyicPz0oc6MTMLwa2Pw3ouLAfAon1wPLtG48o=
k8s.io/apimachinery v0.29.0/go.mod h1:eVBxQ/cwiJxH58eK/jd/vAk4mrxmVlnpBH5J2GbMeis=
k8s.io/api v0.29.7 h1:Q2/thp7YYESgy0MGzxT9RvA/6doLJHBXSFH8GGLxSbc=
k8s.io/api v0.29.7/go.mod h1:mPimdbyuIjwoLtBEVIGVUYb4BKOE+44XHt/n4IqKsLA=
k8s.io/apimachinery v0.29.7 h1:ICXzya58Q7hyEEfnTrbmdfX1n1schSepX2KUfC2/ykc=
k8s.io/apimachinery v0.29.7/go.mod h1:i3FJVwhvSp/6n8Fl4K97PJEP8C+MM+aoDq4+ZJBf70Y=
k8s.io/cli-runtime v0.29.0 h1:q2kC3cex4rOBLfPOnMSzV2BIrrQlx97gxHJs21KxKS4=
k8s.io/cli-runtime v0.29.0/go.mod h1:VKudXp3X7wR45L+nER85YUzOQIru28HQpXr0mTdeCrk=
k8s.io/client-go v0.29.0 h1:KmlDtFcrdUzOYrBhXHgKw5ycWzc3ryPX5mQe0SkG3y8=
k8s.io/client-go v0.29.0/go.mod h1:yLkXH4HKMAywcrD82KMSmfYg2DlE8mepPR4JGSo5n38=
k8s.io/client-go v0.29.7 h1:vTtiFrGBKlcBhxaeZC4eDrqui1e108nsTyue/KU63IY=
k8s.io/client-go v0.29.7/go.mod h1:69BvVqdRozgR/9TP45u/oO0tfrdbP+I8RqrcCJQshzg=
k8s.io/klog/v2 v2.110.1 h1:U/Af64HJf7FcwMcXyKm2RPM22WZzyR7OSpYj5tg3cL0=
k8s.io/klog/v2 v2.110.1/go.mod h1:YGtd1984u+GgbuZ7e08/yBuAfKLSO0+uR1Fhi6ExXjo=
k8s.io/kube-openapi v0.0.0-20231010175941-2dd684a91f00 h1:aVUu9fTY98ivBPKR9Y5w/AuzbMm96cd3YHRTU83I780=
Expand Down

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

23 changes: 0 additions & 23 deletions chart-sync/vendor/go.uber.org/multierr/.travis.yml

This file was deleted.

35 changes: 35 additions & 0 deletions chart-sync/vendor/go.uber.org/multierr/CHANGELOG.md

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

2 changes: 1 addition & 1 deletion chart-sync/vendor/go.uber.org/multierr/LICENSE.txt

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

6 changes: 1 addition & 5 deletions chart-sync/vendor/go.uber.org/multierr/Makefile

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

30 changes: 25 additions & 5 deletions chart-sync/vendor/go.uber.org/multierr/README.md

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

Loading
Loading