AuthZ | Node.js SDK
AuthZ
constructor(token: PangeaToken, config: PangeaConfig): AuthZServiceCreates a new AuthZService
with the given Pangea API token and
configuration.
const config = new PangeaConfig({ domain: "pangea_domain" });
const audit = new AuthZService("pangea_token", config);
Check Authorization
check(request: CheckRequest): Promise<PangeaResponse<CheckResult>>Check if a subject is authorized to perform an action on a resource in the AuthZ Service.
const response = await authz.check({
resource: { type: 'folder', id: 'resource1' },
action: 'read',
subject: { type: 'user', id: 'user1' },
debug: true,
});
List Resources
listResources(request: ListResourcesRequest): Promise<PangeaResponse<ListResourcesResult>>List resources that a subject is authorized to perform a specified action on in the AuthZ Service.
const response = await authz.listResources({
type: 'folder',
action: 'read',
subject: { type: 'user', id: 'user1' },
});
List Subjects
listSubjects(request: ListSubjectsRequest): Promise<PangeaResponse<ListSubjectsResult>>List subjects that are authorized to perform a specified action on a resource in the AuthZ Service.
const response = await authz.listSubjects({
resource: { type: 'folder', id: 'resource1' },
action: 'read',
});
Tuple Create
tupleCreate(request: TupleCreateRequest): Promise<PangeaResponse<TupleCreateResult>>Create tuples in the AuthZ Service. The request will fail if there is no schema or the tuples do not validate against the schema.
const response = await authz.tupleCreate({
tuples: [
{
resource: { type: 'folder', id: 'resource1' },
relation: 'editor',
subject: { type: 'user', id: 'user1' },
},
// Add more tuples as needed
],
});
Tuple Delete
tupleDelete(request: TupleDeleteRequest): Promise<PangeaResponse<TupleDeleteResult>>Delete tuples in the AuthZ Service based on the provided criteria.
const response = await authz.tupleDelete({
tuples: [
{
resource: { type: 'folder', id: 'resource1' },
relation: 'owner',
subject: { type: 'user', id: 'user1' },
},
// Add more tuples to be deleted as needed
],
});
Tuple List
tupleList(request: TupleListRequest): Promise<PangeaResponse<TupleListResult>>List tuples in the AuthZ Service based on provided filters.
const response = await authz.tupleList({
filter: {
resource_type: 'folder',
resource_id: 'resource1',
},
size: 10,
});
Enum ItemOrder
ItemOrderASC
= "asc"
DESC
= "desc"
Enum TupleOrderBy
TupleOrderByRELATION
= "relation"
RESOURCE_ID
= "resource_id"
RESOURCE_NAMESPACE
= "resource_namespace"
SUBJECT_ACTION
= "subject_action"
SUBJECT_ID
= "subject_id"
SUBJECT_NAMESPACE
= "subject_namespace"