Skip to content

Commit

Permalink
dont error if permission error for role grants
Browse files Browse the repository at this point in the history
  • Loading branch information
laurenleach committed Nov 26, 2024
1 parent 8d30e4c commit 9f78e35
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
1 change: 1 addition & 0 deletions pkg/connector/connector.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (

const awsApp = "amazon_aws"
const ResourceNotFoundExceptionErrorCode = "E0000007"
const AccessDeniedErrorCode = "E0000006"
const ExpectedIdentityProviderArnRegexCaptureGroups = 2
const ExpectedGroupNameCaptureGroupsWithGroupFilterForMultipleAWSInstances = 3

Expand Down
2 changes: 1 addition & 1 deletion pkg/connector/custom_role.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func listGroupAssignedRoles(ctx context.Context, client *okta.Client, groupId st
var role []*Roles
resp, err := doRequest(ctx, reqUrl.String(), http.MethodGet, &role, client)
if err != nil {
return nil, nil, err
return nil, resp, err
}

return role, resp, nil
Expand Down
19 changes: 18 additions & 1 deletion pkg/connector/group.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,24 @@ func (o *groupResourceType) Grants(
case resourceTypeRole.Id:
roles, resp, err := listGroupAssignedRoles(ctx, o.connector.client, groupID, nil)
if err != nil {
return nil, "", nil, err
if resp != nil {
defer resp.Body.Close()
errOkta, err := getError(resp)
if err != nil {
return nil, "", nil, err
}
if errOkta.ErrorCode == AccessDeniedErrorCode {
err = bag.Next("")

Check failure on line 185 in pkg/connector/group.go

View workflow job for this annotation

GitHub Actions / go-lint

ineffectual assignment to err (ineffassign)
pageToken, err := bag.Marshal()
if err != nil {
return nil, "", nil, err
}
return nil, pageToken, nil, nil
} else {
return nil, "", nil, fmt.Errorf("okta-connectorv2: failed to list group roles: %v", errOkta)
}
}
return nil, "", nil, fmt.Errorf("okta-connectorv2: failed to list group roles: %w", err)
}

for _, role := range roles {
Expand Down

0 comments on commit 9f78e35

Please sign in to comment.