From 1758d154a3df24162b15476105a1b515b16ed271 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20L=C3=A4rfors?= <1135394+jlarfors@users.noreply.github.com> Date: Thu, 14 Nov 2024 21:00:56 +0200 Subject: [PATCH] cleanup of unused and verbose code --- go.mod | 2 +- pkg/auth/auth.go | 20 ++++---------------- pkg/gateway/oidc.go | 2 -- 3 files changed, 5 insertions(+), 19 deletions(-) diff --git a/go.mod b/go.mod index 437fa52..93d05d0 100644 --- a/go.mod +++ b/go.mod @@ -10,7 +10,6 @@ require ( github.com/charmbracelet/huh v0.3.0 github.com/charmbracelet/lipgloss v0.9.1 github.com/coreos/go-oidc/v3 v3.9.0 - github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc github.com/go-chi/chi v1.5.5 github.com/go-chi/chi/v5 v5.0.12 github.com/go-chi/httplog/v2 v2.0.9 @@ -85,6 +84,7 @@ require ( github.com/containerd/console v1.0.4-0.20230313162750-1ae8d489ac81 // indirect github.com/curioswitch/go-reassign v0.2.0 // indirect github.com/daixiang0/gci v0.12.1 // indirect + github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect github.com/denis-tingaikin/go-header v0.4.3 // indirect github.com/esimonov/ifshort v1.0.4 // indirect github.com/ettle/strcase v0.2.0 // indirect diff --git a/pkg/auth/auth.go b/pkg/auth/auth.go index cea4aae..b46907d 100644 --- a/pkg/auth/auth.go +++ b/pkg/auth/auth.go @@ -7,18 +7,11 @@ import ( "errors" "fmt" "log/slog" - "time" "github.com/nats-io/nats.go" "github.com/verifa/horizon/pkg/hz" ) -func WithInitTimeout(timeout time.Duration) Option { - return func(o *authorizerOptions) { - o.timeout = timeout - } -} - func WithAdminGroups(groups ...string) Option { return func(o *authorizerOptions) { o.adminGroups = append(o.adminGroups, groups...) @@ -28,13 +21,10 @@ func WithAdminGroups(groups ...string) Option { type Option func(*authorizerOptions) type authorizerOptions struct { - timeout time.Duration adminGroups []string } -var defaultAuthorizerOptions = authorizerOptions{ - timeout: 5 * time.Second, -} +var defaultAuthorizerOptions = authorizerOptions{} func Start( ctx context.Context, @@ -119,9 +109,6 @@ func (a *Auth) Start( func (a *Auth) Close() error { var errs error - // if a.Sessions != nil { - // errs = errors.Join(errs, a.Sessions.Close()) - // } if a.RBAC != nil { errs = errors.Join(errs, a.RBAC.Close()) } @@ -150,8 +137,9 @@ func (a *Auth) Check( Verb: req.Verb, Object: req.Object, } - slog.Info("checking", "checkRequest", checkRequest) - return a.RBAC.Check(ctx, checkRequest), nil + ok := a.RBAC.Check(ctx, checkRequest) + slog.Info("checking", "checkRequest", checkRequest, "ok", ok) + return ok, nil } // Verb is implied (read). diff --git a/pkg/gateway/oidc.go b/pkg/gateway/oidc.go index f878fe4..4740b87 100644 --- a/pkg/gateway/oidc.go +++ b/pkg/gateway/oidc.go @@ -15,7 +15,6 @@ import ( "time" "github.com/coreos/go-oidc/v3/oidc" - "github.com/davecgh/go-spew/spew" "github.com/google/uuid" "github.com/nats-io/nats.go" "github.com/verifa/horizon/pkg/auth" @@ -237,7 +236,6 @@ func (or *oidcHandler) authCallback(w http.ResponseWriter, req *http.Request) { ) return } - spew.Dump(i) var claims auth.UserInfo if err := idToken.Claims(&claims); err != nil {