Skip to content

Commit

Permalink
Fixing validations and updating resource names
Browse files Browse the repository at this point in the history
  • Loading branch information
mchavez committed Oct 30, 2024
1 parent 46dda62 commit 9ecb1c6
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 17 deletions.
16 changes: 8 additions & 8 deletions pkg/connector/connector.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,10 @@ var (
Annotations: v1AnnotationsForResourceType("role", false),
}
resourceTypeCustomRole = &v2.ResourceType{
Id: "custom_role",
Id: "custom-role",
DisplayName: "Custom Role",
Traits: []v2.ResourceType_Trait{v2.ResourceType_TRAIT_ROLE},
Annotations: v1AnnotationsForResourceType("custom_role", false),
Annotations: v1AnnotationsForResourceType("custom-role", false),
}
resourceTypeUser = &v2.ResourceType{
Id: "user",
Expand All @@ -143,14 +143,14 @@ var (
Annotations: v1AnnotationsForResourceType("account", false),
}
resourceTypeResourceSets = &v2.ResourceType{
Id: "resourcesets",
DisplayName: "Resource Sets",
Annotations: v1AnnotationsForResourceType("resourcesets", false),
Id: "resource-set",
DisplayName: "Resource Set",
Annotations: v1AnnotationsForResourceType("resource-set", false),
}
resourceTypeResourceSetsBindings = &v2.ResourceType{
Id: "resourcesets_bindings",
DisplayName: "Resource Sets Bindings",
Annotations: v1AnnotationsForResourceType("resourcesets_bindings", false),
Id: "resourceset-binding",
DisplayName: "Resource Set Binding",
Annotations: v1AnnotationsForResourceType("resourceset-binding", false),
}
defaultScopes = []string{
"okta.users.read",
Expand Down
11 changes: 6 additions & 5 deletions pkg/connector/resource_sets.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"
"net/http"
"net/url"
"strings"

v2 "github.com/conductorone/baton-sdk/pb/c1/connector/v2"
"github.com/conductorone/baton-sdk/pkg/annotations"
Expand Down Expand Up @@ -133,13 +134,13 @@ func (rs *resourceSetsResourceType) Entitlements(_ context.Context, resource *v2
return []*v2.Entitlement{
sdkEntitlement.NewAssignmentEntitlement(
resource,
"member",
"bindings",
sdkEntitlement.WithAnnotation(&v2.V1Identifier{
Id: V1MembershipEntitlementID(resource.Id.GetResource()),
}),
sdkEntitlement.WithGrantableTo(resourceTypeResourceSets),
sdkEntitlement.WithDisplayName(fmt.Sprintf("%s Resource Sets Member", resource.DisplayName)),
sdkEntitlement.WithDescription(fmt.Sprintf("Member of %s resource-sets in Okta", resource.DisplayName)),
sdkEntitlement.WithDisplayName(fmt.Sprintf("%s Resource Set Member", resource.DisplayName)),
sdkEntitlement.WithDescription(fmt.Sprintf("Member of %s resource-set in Okta", resource.DisplayName)),
),
}, "", nil, nil
}
Expand Down Expand Up @@ -302,12 +303,12 @@ func (rs *resourceSetsResourceType) Grants(ctx context.Context, resource *v2.Res
}

for _, role := range roles {
if role.Status == roleStatusInactive || role.Type != roleTypeCustom || role.ResourceSet != resource.Id.Resource {
if role.Status == roleStatusInactive || role.Type != roleTypeCustom || !strings.Contains(resource.Id.Resource, role.ResourceSet) {
continue
}

rl := &v2.Resource{Id: &v2.ResourceId{ResourceType: resourceTypeCustomRole.Id, Resource: role.Role}}
gr := sdkGrant.NewGrant(resource, "member", rl,
gr := sdkGrant.NewGrant(resource, "bindings", rl,
sdkGrant.WithAnnotation(&v2.V1Identifier{
Id: fmtGrantIdV1(V1MembershipEntitlementID(resource.Id.Resource), resource.Id.Resource),
}),
Expand Down
8 changes: 4 additions & 4 deletions pkg/connector/resource_sets_bindings.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,13 @@ func (rsb *resourceSetsBindingsResourceType) Entitlements(_ context.Context, res
return []*v2.Entitlement{
sdkEntitlement.NewAssignmentEntitlement(
resource,
"member",
"members",
sdkEntitlement.WithAnnotation(&v2.V1Identifier{
Id: V1MembershipEntitlementID(resource.Id.GetResource()),
}),
sdkEntitlement.WithGrantableTo(resourceTypeResourceSets),
sdkEntitlement.WithDisplayName(fmt.Sprintf("%s Resource Sets Bindings Member", resource.DisplayName)),
sdkEntitlement.WithDescription(fmt.Sprintf("Member of %s resource-sets-bindings in Okta", resource.DisplayName)),
sdkEntitlement.WithDisplayName(fmt.Sprintf("%s Resource Set Binding Member", resource.DisplayName)),
sdkEntitlement.WithDescription(fmt.Sprintf("Member of %s resource-set-binding in Okta", resource.DisplayName)),
),
}, "", nil, nil
}
Expand Down Expand Up @@ -276,7 +276,7 @@ func (rsb *resourceSetsBindingsResourceType) Grants(ctx context.Context, resourc
}

rl := &v2.Resource{Id: &v2.ResourceId{ResourceType: resourceTypeCustomRole.Id, Resource: role.Role}}
gr := sdkGrant.NewGrant(resource, "member", rl,
gr := sdkGrant.NewGrant(resource, "members", rl,
sdkGrant.WithAnnotation(&v2.V1Identifier{
Id: fmtGrantIdV1(V1MembershipEntitlementID(resource.Id.Resource), resource.Id.Resource),
}),
Expand Down

0 comments on commit 9ecb1c6

Please sign in to comment.