Options
All
  • Public
  • Public/Protected
  • All
Menu

Resource class, permissions are stored on these Nodes, and Subject nodes check for access to these nodes.

Hierarchy

Index

Constructors

constructor

Properties

doc

Static displayName

displayName: string = ""

Static id

id: string = "id"

The id property within the document contained by this node type, defaults to 'id'

Static parentId

parentId: string

String indicating the property on this nodes document that contains the id(s) of its parent.

Static permissionPropertyKey

permissionPropertyKey: string = "permissions"

Static repository

repository: Repository

The repository for this node type, provides async getter function. Must follow the Repository interface spec.

Methods

allow

deny

determineAccess

  • Determine access to a given permission, provide a reason for access result.

    Steps for checking access for a given permission:

    1. If an assertion function is provided, make sure it returns true
    2. return false if not
    3. Check if there is a permission on this resource specifically referencing the given subject
    4. return true || false if the permission is not undefined
    5. Recurse up resource hierarchy, checking if parent resource has access to this resource.
    6. if a parent subject specifically has true / false access -- return that boolean
    7. Recurse up subject hierarchy

    Parameters

    • subject: Subject
    • permissionType: string | string[]
    • Optional options: PermOpts

    Returns Promise<Hash<AccessResult>>

explainPermission

  • explainPermission(subject: Subject, permissionType: string, options?: PermOpts): Promise<string>
  • Get a string explaining why a subject has a permission set to a particular value for a given resource.

    Parameters

    Returns Promise<string>

getClass

getHierarchyClassNames

  • getHierarchyClassNames(): string[]

getHierarchyIds

  • getHierarchyIds(): Promise<string[]>

getId

  • getId(): string

getName

  • getName(): string

getNodeDepth

  • getNodeDepth(): number

getNodeSubclass

  • getNodeSubclass(): Node

getParentClass

  • getParentClass(): Node

getParentNode

getParents

  • getParents(): Promise<Node[]>
  • Get the parent objects of an instance of this node. Must be overriden by subclass unless the static parentId is defined.

    Returns Promise<Node[]>

getPermission

  • Retrieve a permission for a given subject via binary search. Returns an empty permission object if none is found.

    Parameters

    Returns Promise<Permission>

getPermissionList

getPermissionsHierarchy

getRepository

hierarchyRoot

  • hierarchyRoot(): boolean
  • Check if this class direcly inherits from HierarchyNode by checking if the class two levels up is Node

    Returns boolean

isAllowed

  • isAllowed(subject: Subject, permissionType: string, options?: PermOpts): Promise<boolean>

isNodeType

  • isNodeType(nc: Node): boolean

setDoc

setPermissionAccess

  • setPermissionAccess(subject: Subject, permissionType: string, access: boolean): Promise<Resource>
  • Set access for a particular permission type to true or false for a given Subject.

    Parameters

    • subject: Subject
    • permissionType: string
    • access: boolean

    Returns Promise<Resource>

sortPermissions

  • sortPermissions(): this
  • Sort the permissions on this document by subjectId to allow for fast searching.

    Returns this

toString

  • toString(): string

updatePermission

Static assertNodeClass

  • assertNodeClass(nodeClass: Node): void

Static getHierarchyClassNames

  • getHierarchyClassNames(): string[]

Static getNodeDepth

  • getNodeDepth(): number

Generated using TypeDoc