Skip to main content

AuthZ | C# SDK

AuthZ (Beta)

AuthZClient

AuthZ client.

var config = new Config("pangea_token", "pangea_domain");
var builder = new AuthZClient.Builder(config);
var client = builder.Build();

Create tuples. (Beta)

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. How to install a Beta release.

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. (Beta)

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. How to install a Beta release.

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.SubjectNamespace.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.ResourceNamespace // Optional: Set the field to order results by
};
var response = await client.TupleList(request);

Delete tuples. (Beta)

AuthZClient.TupleDelete(TupleDeleteRequest, CancellationToken)

Delete tuples in the AuthZ Service. How to install a Beta release.

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. (Beta)

AuthZClient.Check(CheckRequest, CancellationToken)

Check if a subject has permission to perform an action on the resource. How to install a Beta release.

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. (Beta)

AuthZClient.ListResources(ListResourcesRequest, CancellationToken)

Given a namespace, action, and subject, list all the resources in the namespace that the subject has access to the action with. How to install a Beta release.

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. (Beta)

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. How to install a Beta release.

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"
));