Documentation
¶
Index ¶
- type CheckPermissionType
- type Database
- func (db *Database) CheckPermission(permission Permission, zookie string) (CheckPermissionType, string, error)
- func (db *Database) CreateRelations(relations ...Relation) (string, error)
- func (db *Database) DeleteRelation(relation Relation) (string, error)
- func (db *Database) GetPermissions(resourceType ObjectType, subjectType ObjectType, subjectId string, ...) ([]string, error)
- func (db *Database) GetResourceRelations(resourceType ObjectType, resourceId string, relation RelationType, ...) ([]Relation, error)
- type ObjectType
- type Permission
- type PermissionType
- type Relation
- type RelationType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CheckPermissionType ¶
type CheckPermissionType string
const ( HasPermission CheckPermissionType = "HasPermission" UnspecifiedPermission CheckPermissionType = "UnspecifiedPermission" NoPermission CheckPermissionType = "NoPermission" )
type Database ¶
type Database struct { DB *authzed.Client Token string // contains filtered or unexported fields }
func CreateDatabase ¶
func CreateDatabase(host string, port string, token string, tls bool, cert string, tiDB *ti.Database) (*Database, error)
CreateDatabase Create a new database instance for SpiceDB Args
host - string, host address for the SpiceDB instance port - string, port that the SpiceDB instance is available at token - string, bearer token for authentication with the SpiceDB instance tls - bool, whether to use TLS encryption to secure connection with SpiceDB cert - string, path to certificate file for use in TLS connection
Returns
out - *Database, new instance of the SpiceDB database connection
func (*Database) CheckPermission ¶
func (db *Database) CheckPermission(permission Permission, zookie string) (CheckPermissionType, string, error)
CheckPermission Wrapper function to simplify interface for the checking of permissions in SpiceDB Args
permission - Permission, permission that will be checked for in SpiceDB zookie - string, optional Zookie (ZedToken) to track cache consistency (pass full for full consistency)
Returns
permissionCheck - CheckPermission, the result of the permission check represented in the native type zookie - string, Zookie (ZedToken) returned by the permission check for tracking consistency
func (*Database) CreateRelations ¶
CreateRelations Wrapper function to simplify interface for the creation of relations in SpiceDB Args
relations - ...Relation, variable list of relations that will be created
Returns
zookie - string, Zookie (ZedToken) to track cache consistency
func (*Database) DeleteRelation ¶
DeleteRelation Wrapper function to simplify interface for the deleting of relations in SpiceDB Args
relation - Relation, relation that will be deleted from SpiceDB
Returns
zookie - string, Zookie (ZedToken) returned by the relation deletion for tracking consistency
func (*Database) GetPermissions ¶
func (db *Database) GetPermissions(resourceType ObjectType, subjectType ObjectType, subjectId string, permission PermissionType, zookie string) ([]string, error)
GetPermissions Wrapper function to simplify interface for the retrieval of resources a user has access to Args
resourceType - ObjectType, type of the object that we will be bound the permissions to subjectType - ObjectType, type of the subject that we are checking permission for subjectId - string, id of the subject that we are checking for permission - PermissionType, type of permission that we are checking for zookie - string, optional Zookie (ZedToken) to track cache consistency (pass full for full consistency)
Returns
resources - []string, slice containing the ids of each resource that the subject has the specified permission for
func (*Database) GetResourceRelations ¶
func (db *Database) GetResourceRelations(resourceType ObjectType, resourceId string, relation RelationType, zookie string) ([]Relation, error)
GetResourceRelations Wrapper function to simplify interface for the retrieval of relations for a given resource Args
resourceType - ObjectType, type of the object that we will be bound the relations to resourceId - string, id of the resource that we are checking for relation - RelationType, type of relation that we are checking for zookie - string, optional Zookie (ZedToken) to track cache consistency (pass full for full consistency)
Returns
relations - []Relation, slice containing the relations of the resource was specified
type ObjectType ¶
type ObjectType string
type Permission ¶
type Permission struct { ResourceType ObjectType ResourceID string SubjectType ObjectType SubjectID string Permission PermissionType }
type PermissionType ¶
type PermissionType string
type Relation ¶
type Relation struct { ResourceType ObjectType ResourceID string SubjectType ObjectType SubjectID string Relation RelationType }
type RelationType ¶
type RelationType string