Skip to content

Commit

Permalink
fix: update api docs
Browse files Browse the repository at this point in the history
Signed-off-by: WashingtonKK <washingtonkigan@gmail.com>

feat: update checkdomain and checkpolicy

Signed-off-by: WashingtonKK <washingtonkigan@gmail.com>

fix: errors on service layer

Signed-off-by: WashingtonKK <washingtonkigan@gmail.com>

fix: tests

Signed-off-by: WashingtonKK <washingtonkigan@gmail.com>
  • Loading branch information
WashingtonKK committed Apr 5, 2024
1 parent ec2506d commit 5ca3fe8
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 10 deletions.
2 changes: 2 additions & 0 deletions api/openapi/users.yml
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,8 @@ paths:
description: Failed due to malformed JSON.
"401":
description: Missing or invalid access token provided.
"404":
description: Entity not found.
"415":
description: Missing or invalid content type.
"422":
Expand Down
9 changes: 1 addition & 8 deletions auth/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,14 +186,7 @@ func (svc service) Authorize(ctx context.Context, pr PolicyReq) error {
func (svc service) checkPolicy(ctx context.Context, pr PolicyReq) error {
// Domain status is required for if user sent authorization request on things, channels, groups and domains
if pr.SubjectType == UserType && (pr.ObjectType == GroupType || pr.ObjectType == ThingType || pr.ObjectType == DomainType) {
domainID := pr.Domain
if domainID == "" {
if pr.ObjectType != DomainType {
return svcerr.ErrDomainAuthorization
}
domainID = pr.Object
}
if err := svc.checkDomain(ctx, pr.SubjectType, pr.Subject, domainID); err != nil {
if err := svc.checkDomain(ctx, pr.SubjectType, pr.Subject, pr.Domain); err != nil {
return err
}
}
Expand Down
1 change: 0 additions & 1 deletion pkg/errors/service/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ var (
// ErrFailedPolicyUpdate indicates a failure to update user policy.
ErrFailedPolicyUpdate = errors.New("failed to update user policy")


// ErrPasswordFormat indicates weak password.
ErrPasswordFormat = errors.New("password does not meet the requirements")

Expand Down
2 changes: 1 addition & 1 deletion users/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ func (svc service) UpdateClientSecret(ctx context.Context, token, oldSecret, new
return mgclients.Client{}, errors.Wrap(svcerr.ErrViewEntity, err)
}
if _, err := svc.IssueToken(ctx, dbClient.Credentials.Identity, oldSecret, ""); err != nil {
return mgclients.Client{}, errors.Wrap(svcerr.ErrIssueToken, err)
return mgclients.Client{}, errors.Wrap(ErrIssueToken, err)
}
newSecret, err = svc.hasher.Hash(newSecret)
if err != nil {
Expand Down

0 comments on commit 5ca3fe8

Please sign in to comment.