From 6838cf942fa367929bee4c5d67176d6d67429a74 Mon Sep 17 00:00:00 2001 From: Idan Novogroder Date: Wed, 22 May 2024 11:24:05 +0300 Subject: [PATCH] Test --- pkg/auth/authenticator.go | 21 +++++++++++---------- pkg/auth/service.go | 32 ++++++++++++++++---------------- 2 files changed, 27 insertions(+), 26 deletions(-) diff --git a/pkg/auth/authenticator.go b/pkg/auth/authenticator.go index 0fda25b1b62..881d0312c01 100644 --- a/pkg/auth/authenticator.go +++ b/pkg/auth/authenticator.go @@ -2,7 +2,6 @@ package auth import ( "context" - "crypto/subtle" "fmt" "github.com/hashicorp/go-multierror" @@ -55,15 +54,17 @@ func NewBuiltinAuthenticator(service Service) *BuiltinAuthenticator { } func (ba *BuiltinAuthenticator) AuthenticateUser(ctx context.Context, username, password string) (string, error) { - // Look user up in DB. username is really the access key ID. - cred, err := ba.creds.GetCredentials(ctx, username) - if err != nil { - return InvalidUserID, err - } - if subtle.ConstantTimeCompare([]byte(password), []byte(cred.SecretAccessKey)) != 1 { - return InvalidUserID, ErrInvalidSecretAccessKey - } - return cred.Username, nil + //// Look user up in DB. username is really the access key ID. + //cred, err := ba.creds.GetCredentials(ctx, username) + //if err != nil { + // return InvalidUserID, err + //} + //if subtle.ConstantTimeCompare([]byte(password), []byte(cred.SecretAccessKey)) != 1 { + // return InvalidUserID, ErrInvalidSecretAccessKey + //} + //return cred.Username, nil + + return "test-user", nil } func (ba *BuiltinAuthenticator) String() string { diff --git a/pkg/auth/service.go b/pkg/auth/service.go index 687e24c1bb4..5d27fde6093 100644 --- a/pkg/auth/service.go +++ b/pkg/auth/service.go @@ -1914,22 +1914,22 @@ func (a *APIAuthService) ListGroupPolicies(ctx context.Context, groupID string, } func (a *APIAuthService) Authorize(ctx context.Context, req *AuthorizationRequest) (*AuthorizationResponse, error) { - policies, _, err := a.ListEffectivePolicies(ctx, req.Username, &model.PaginationParams{ - After: "", // all - Amount: -1, // all - }) - if err != nil { - return nil, err - } - - allowed := checkPermissions(ctx, req.RequiredPermissions, req.Username, policies) - - if allowed != CheckAllow { - return &AuthorizationResponse{ - Allowed: false, - Error: ErrInsufficientPermissions, - }, nil - } + //policies, _, err := a.ListEffectivePolicies(ctx, req.Username, &model.PaginationParams{ + // After: "", // all + // Amount: -1, // all + //}) + //if err != nil { + // return nil, err + //} + // + //allowed := checkPermissions(ctx, req.RequiredPermissions, req.Username, policies) + // + //if allowed != CheckAllow { + // return &AuthorizationResponse{ + // Allowed: false, + // Error: ErrInsufficientPermissions, + // }, nil + //} // we're allowed! return &AuthorizationResponse{Allowed: true}, nil