Skip to content

Commit

Permalink
MG-2530 - Fix domain assign and unassign for users (absmach#2531)
Browse files Browse the repository at this point in the history
Signed-off-by: Felix Gateru <felix.gateru@gmail.com>
  • Loading branch information
felixgateru authored Nov 20, 2024
1 parent d9f3bca commit eb49015
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 57 deletions.
8 changes: 5 additions & 3 deletions auth/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -618,8 +618,9 @@ func (svc service) AssignUsers(ctx context.Context, token, id string, userIds []
return errors.Wrap(svcerr.ErrAuthentication, err)
}

domainUserID := EncodeDomainUserID(id, res.User)
if err := svc.Authorize(ctx, policies.Policy{
Subject: res.User,
Subject: domainUserID,
SubjectType: policies.UserType,
SubjectKind: policies.UsersKind,
Object: id,
Expand All @@ -630,7 +631,7 @@ func (svc service) AssignUsers(ctx context.Context, token, id string, userIds []
}

if err := svc.Authorize(ctx, policies.Policy{
Subject: res.User,
Subject: domainUserID,
SubjectType: policies.UserType,
SubjectKind: policies.UsersKind,
Object: id,
Expand Down Expand Up @@ -661,8 +662,9 @@ func (svc service) UnassignUser(ctx context.Context, token, id, userID string) e
return errors.Wrap(svcerr.ErrAuthentication, err)
}

domainUserID := EncodeDomainUserID(id, res.User)
pr := policies.Policy{
Subject: res.User,
Subject: domainUserID,
SubjectType: policies.UserType,
SubjectKind: policies.UsersKind,
Object: id,
Expand Down
Loading

0 comments on commit eb49015

Please sign in to comment.