Skip to content

Commit

Permalink
cleanup of unused and verbose code
Browse files Browse the repository at this point in the history
  • Loading branch information
jlarfors committed Nov 14, 2024
1 parent a690465 commit 1758d15
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 19 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
20 changes: 4 additions & 16 deletions pkg/auth/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -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...)
Expand All @@ -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,
Expand Down Expand Up @@ -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())
}
Expand Down Expand Up @@ -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).
Expand Down
2 changes: 0 additions & 2 deletions pkg/gateway/oidc.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 1758d15

Please sign in to comment.