Skip to content

Commit

Permalink
refactor: Fixes bulk permission handling and version bump
Browse files Browse the repository at this point in the history
Refactored the way permissions are handled in SpiceDbPermissions.cs, specifically how they're created and their context is set. Also updated the version of SpiceDb from 1.4.7 to 1.4.8 in SpiceDb.csproj file. Simplified object creation in SpiceDbClient.cs by removing optional relation from subject reference.
  • Loading branch information
tanczosm committed Apr 11, 2024
1 parent 4d67fe5 commit f6837b1
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
6 changes: 4 additions & 2 deletions SpiceDb/Api/SpiceDbPermissions.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Authzed.Api.V1;
using Google.Protobuf;
using Google.Protobuf.Collections;
using Grpc.Core;
using SpiceDb.Enum;
Expand Down Expand Up @@ -174,8 +175,9 @@ public async Task<PermissionResponse> CheckPermissionAsync(string resourceType,
CheckPermissionResponse.Types.Permissionship.ConditionalPermission => Permissionship.ConditionalPermission,
_ => Permissionship.Unspecified
},
Permission = new Models.Permission(x.Request.Permission),
Context = x.Request.Context.FromStruct()
Permission = new Models.Permission(new ResourceReference (x.Request.Resource.ObjectType, x.Request.Resource.ObjectId),
x.Request.Permission, new ResourceReference(x.Request.Subject.Object.ObjectType, x.Request.Subject.Object.ObjectId, x.Request.Subject.OptionalRelation ?? string.Empty)),
Context = x.Request.Context?.FromStruct() ?? new()
}).ToList()
};

Expand Down
2 changes: 1 addition & 1 deletion SpiceDb/SpiceDb.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<PackageIcon>logo.png</PackageIcon>
<PackageLicenseFile>LICENSE.txt</PackageLicenseFile>
<PackageReadmeFile>README.md</PackageReadmeFile>
<Version>1.4.7</Version>
<Version>1.4.8</Version>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
Expand Down
3 changes: 1 addition & 2 deletions SpiceDb/SpiceDbClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -561,8 +561,7 @@ public async Task ImportSchemaFromStringAsync(string schema)
Subject = new Authzed.Api.V1.SubjectReference()
{
Object = new Authzed.Api.V1.ObjectReference()
{ ObjectId = x.Permission?.Subject.Id, ObjectType = EnsurePrefix(x.Permission?.Subject.Type) },
OptionalRelation = x.Permission?.Relation
{ ObjectId = x.Permission?.Subject.Id, ObjectType = EnsurePrefix(x.Permission?.Subject.Type) }
}
});

Expand Down

0 comments on commit f6837b1

Please sign in to comment.