Skip to content

Commit 7a6abc5

Browse files
committed
ING-1499: Map cbmgmt access denied err to appropriate status
1 parent 946d29e commit 7a6abc5

2 files changed

Lines changed: 9 additions & 0 deletions

File tree

gateway/dataimpl/server_v1/errorhandler.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1000,6 +1000,12 @@ func (e ErrorHandler) NewNoAuthStatus(ctx context.Context) *status.Status {
10001000
return st
10011001
}
10021002

1003+
func (e ErrorHandler) NewUnauthenticatedStatus(ctx context.Context, baseErr error) *status.Status {
1004+
st := e.newStatus(ctx, codes.Unauthenticated, "An authentication error occured.")
1005+
st = e.tryAttachExtraContext(st, baseErr)
1006+
return st
1007+
}
1008+
10031009
func (e ErrorHandler) NewInvalidCredentialsStatus(ctx context.Context) *status.Status {
10041010
st := e.newStatus(ctx, codes.PermissionDenied, "Your username or password is invalid.")
10051011
st = e.tryAttachStatusDetails(st, &epb.ResourceInfo{

gateway/dataimpl/server_v1/xdcrserver.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@ func (s *XdcrServer) GetClusterInfo(ctx context.Context, in *internal_xdcr_v1.Ge
6666
OnBehalfOf: oboUser,
6767
})
6868
if err != nil {
69+
if errors.Is(err, cbmgmtx.ErrAccessDenied) {
70+
return nil, s.errorHandler.NewUnauthenticatedStatus(ctx, err).Err()
71+
}
6972
return nil, s.errorHandler.NewGenericStatus(ctx, err).Err()
7073
}
7174

0 commit comments

Comments
 (0)