diff --git a/internal/cmd/server/rbac.go b/internal/cmd/server/rbac.go index eac71cc..259c732 100644 --- a/internal/cmd/server/rbac.go +++ b/internal/cmd/server/rbac.go @@ -2,14 +2,14 @@ package server import ( discoveryv1connect "github.com/postfinance/discovery/pkg/discoverypb/postfinance/discovery/v1/discoveryv1connect" - goauth "gitlab.pnet.ch/linux/go/auth" + "gitlab.pnet.ch/linux/go/auth" ) -func rbacConfig() []goauth.Config { - return []goauth.Config{ +func rbacConfig() []auth.Config { + return []auth.Config{ { Role: "cop_appl_linux", - Rules: []goauth.Rule{ + Rules: []auth.Rule{ { Service: discoveryv1connect.NamespaceAPIName, Methods: []string{ @@ -46,7 +46,7 @@ func rbacConfig() []goauth.Config { }, { Role: "machine", - Rules: []goauth.Rule{ + Rules: []auth.Rule{ { Service: discoveryv1connect.NamespaceAPIName, Methods: []string{ diff --git a/internal/server/api.go b/internal/server/api.go index 2e320c4..c659490 100644 --- a/internal/server/api.go +++ b/internal/server/api.go @@ -17,7 +17,6 @@ import ( discoveryv1 "github.com/postfinance/discovery/pkg/discoverypb/postfinance/discovery/v1" discoveryv1connect "github.com/postfinance/discovery/pkg/discoverypb/postfinance/discovery/v1/discoveryv1connect" "gitlab.pnet.ch/linux/go/auth" - goauth "gitlab.pnet.ch/linux/go/auth" "gitlab.pnet.ch/linux/go/auth/self" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" @@ -167,7 +166,7 @@ func (a *API) Create(_ context.Context, req *connect.Request[discoveryv1.CreateR expiry = d } - u := goauth.User{ + u := auth.User{ Name: req.Msg.GetId(), Roles: req.Msg.GetRoles(), Data: req.Msg.GetNamespaces(), @@ -194,7 +193,7 @@ func (a *API) Info(ctx context.Context, in *connect.Request[discoveryv1.InfoRequ ns := []string{} - userNS := goauth.MustGetData[[]string](*u) + userNS := auth.MustGetData[[]string](*u) if userNS != nil { ns = *userNS } @@ -314,7 +313,7 @@ func (a *API) UnregisterNamespace(_ context.Context, req *connect.Request[discov } func verifyNamespace(ctx context.Context, namespace string) error { - u, ok := goauth.UserFromContext(ctx) + u, ok := auth.UserFromContext(ctx) if !ok { return status.Errorf(codes.Unauthenticated, "unauthententicated user") } diff --git a/internal/server/log.go b/internal/server/log.go deleted file mode 100644 index 52ecf1e..0000000 --- a/internal/server/log.go +++ /dev/null @@ -1,51 +0,0 @@ -package server - -import ( - "go.uber.org/zap" - "go.uber.org/zap/zapcore" - "google.golang.org/grpc/codes" -) - -// configure gprc logger -// -//nolint:gocyclo // this is the only way to confgure the logger middleware -func customCodeToLevel(code codes.Code) zapcore.Level { - switch code { - case codes.OK: - return zap.DebugLevel - case codes.Canceled: - return zap.DebugLevel - case codes.Unknown: - return zap.ErrorLevel - case codes.InvalidArgument: - return zap.DebugLevel - case codes.DeadlineExceeded: - return zap.ErrorLevel - case codes.NotFound: - return zap.DebugLevel - case codes.AlreadyExists: - return zap.DebugLevel - case codes.PermissionDenied: - return zap.ErrorLevel - case codes.Unauthenticated: - return zap.DebugLevel - case codes.ResourceExhausted: - return zap.ErrorLevel - case codes.FailedPrecondition: - return zap.ErrorLevel - case codes.Aborted: - return zap.ErrorLevel - case codes.OutOfRange: - return zap.ErrorLevel - case codes.Unimplemented: - return zap.ErrorLevel - case codes.Internal: - return zap.ErrorLevel - case codes.Unavailable: - return zap.ErrorLevel - case codes.DataLoss: - return zap.ErrorLevel - default: - return zap.ErrorLevel - } -}