AuthZ | C# SDK
AuthZ
AuthZClientAuthZ client.
var config = new Config("pangea_token", "pangea_domain");
var builder = new AuthZClient.Builder(config);
var client = builder.Build();
Create tuples.
AuthZClient.TupleCreate(TupleCreateRequest, CancellationToken)Create tuples in the AuthZ Service. The request will fail if there is no schema or the tuples do not validate against the schema.
var request = new TupleCreateRequest(
new Net.AuthZ.Models.Tuple[] {
new(
new Resource("folder") { ID = "folder1" },
"owner",
new Subject("user") { ID = "user_1" }
)
}
);
await client.TupleCreate(request);
List tuples.
AuthZClient.TupleList(TupleListRequest, CancellationToken)Return a paginated list of filtered tuples. The filter is given in terms of a tuple. Fill out the fields that you want to filter. If the filter is empty it will return all the tuples.
var filter = new FilterTupleList();
filter.SubjectType.Set("user);
filter.SubjectID.Set("user_id");
var request = new TupleListRequest
{
Filter = filter,
Size = 10, // Optional: Set the size of the result set
Last = "token123", // Optional: Set the last token from a previous response
Order = ItemOrder.Desc, // Optional: Set the order (asc or desc)
OrderBy = TupleOrderBy.ResourceType // Optional: Set the field to order results by
};
var response = await client.TupleList(request);
Delete tuples.
AuthZClient.TupleDelete(TupleDeleteRequest, CancellationToken)Delete tuples in the AuthZ Service.
var request = new TupleDeleteRequest(
new Net.AuthZ.Models.Tuple[] {
new(
new Resource("folder") { ID = "folder1" },
"owner",
new Subject("user") { ID = "user_1" }
)
}
);
await client.TupleDelete(request);
Perform a check request.
AuthZClient.Check(CheckRequest, CancellationToken)Check if a subject has permission to perform an action on the resource.
var response = await client.Check(new CheckRequest(
new Resource("folder") { ID = "folder1" },
"editor",
new Subject("user") { ID = "user_1" }
));
List resources.
AuthZClient.ListResources(ListResourcesRequest, CancellationToken)Given a type, action, and subject, list all the resources of the type that the subject has access to the action with.
var response = await client.ListResources(new ListResourcesRequest(
"folder",
"update",
new Subject("user") { ID = "user_1" }
));
List subjects.
AuthZClient.ListSubjects(ListSubjectsRequest, CancellationToken)Given a resource and an action, return the list of subjects who have access to the action for the given resource.
var response = await client.ListSubjects(new ListSubjectsRequest(
new Resource("folder") { ID = "folder_1" },
"update"
));