Skip to main content

AuthZ | C# SDK

AuthZ

AuthZClient

AuthZ 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.

required parameters

TupleCreateRequest

The request to the '/tuple/create' endpoint.

CancellationToken

Cancellation token.

Response Object

Task<Response<TupleCreateResult>>

Empty result.

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.

required parameters

TupleListRequest

The request to the '/tuple/list' endpoint.

CancellationToken

Cancellation token.

Response Object

Task<Response<TupleListResult>>

List of 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.

required parameters

TupleDeleteRequest

The request to the '/tuple/delete' endpoint.

CancellationToken

Cancellation token.

Response Object

Task<Response<TupleDeleteResult>>

Empty result.

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.

required parameters

CheckRequest

The request to the '/check' endpoint.

CancellationToken

Cancellation token.

Response Object

Task<Response<CheckResult>>

Result of the authorization check.

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.

required parameters

ListResourcesRequest

The request to the '/list-resources' endpoint.

CancellationToken

Cancellation token.

Response Object

Task<Response<ListResourcesResult>>

List of resources.

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.

required parameters

ListSubjectsRequest

The request to the '/list-subjects' endpoint.

CancellationToken

Cancellation token.

Response Object

Task<Response<ListSubjectsResult>>

List of subjects.

var response = await client.ListSubjects(new ListSubjectsRequest(
    new Resource("folder") { ID = "folder_1" },
    "update"
));