AuthZ | Golang SDK
Relation
func (fu *TupleListFilter) Relation() *pangea.FilterMatch[string]ResourceID
func (fu *TupleListFilter) ResourceID() *pangea.FilterMatch[string]ResourceType
func (fu *TupleListFilter) ResourceType() *pangea.FilterMatch[string]SubjectAction
func (fu *TupleListFilter) SubjectAction() *pangea.FilterMatch[string]SubjectID
func (fu *TupleListFilter) SubjectID() *pangea.FilterMatch[string]SubjectType
func (fu *TupleListFilter) SubjectType() *pangea.FilterMatch[string]Perform a check request.
func (e *authz) Check(ctx context.Context, input *CheckRequest) (*pangea.PangeaResponse[CheckResult], error)Check if a subject has permission to do action on the resource.
rCheck, err = cli.Check(ctx, &authz.CheckRequest{
Resource: authz.Resource{
Type: "folder",
ID: "folder_id",
},
Action: "editor",
Subject: authz.Subject{
Type: "user",
ID: "user_id",
},
Debug: pangea.Bool(true),
})
List resources.
func (e *authz) ListResources(ctx context.Context, input *ListResourcesRequest) (*pangea.PangeaResponse[ListResourcesResult], error)Given a type, action, and subject, list all the resources in the type that the subject has permission to the action with.
rListResources, err := cli.ListResources(ctx, &authz.ListResourcesRequest{
Type: "folder",
Action: "editor",
Subject: authz.Subject{
Type: "user",
ID: "user_id",
},
})
List subjects.
func (e *authz) ListSubjects(ctx context.Context, input *ListSubjectsRequest) (*pangea.PangeaResponse[ListSubjectsResult], error)Given a resource and an action, return the list of subjects who have the given action to the given resource.
rListSubjects, err := cli.ListSubjects(ctx, &authz.ListSubjectsRequest{
Resource: authz.Resource{
Type: "folder",
ID: "folder_id",
},
Action: "editor",
})
Write tuples.
func (e *authz) TupleCreate(ctx context.Context, input *TupleCreateRequest) (*pangea.PangeaResponse[TupleCreateResult], error)Write tuples. The request will fail if tuples do not validate against the schema defined resource types.
rCreate, err := cli.TupleCreate(ctx, &authz.TupleCreateRequest{
Tuples: []authz.Tuple{
authz.Tuple{
Resource: authz.Resource{
Type: "folder",
ID: "folder_id",
},
Relation: "reader",
Subject: authz.Subject{
Type: "user",
ID: "user_id",
},
},
},
})
Delete tuples.
func (e *authz) TupleDelete(ctx context.Context, input *TupleDeleteRequest) (*pangea.PangeaResponse[TupleDeleteResult], error)Delete tuples.
rDelete, err := cli.TupleDelete(ctx, &authz.TupleDeleteRequest{
Tuples: []authz.Tuple{
authz.Tuple{
Resource: authz.Resource{
Type: "folder",
ID: "folder_id",
},
Relation: "editor",
Subject: authz.Subject{
Type: "user",
ID: "user_id",
},
},
},
})
TupleList
func (e *authz) TupleList(ctx context.Context, input *TupleListRequest) (*pangea.PangeaResponse[TupleListResult], error)rListWithResource, err := cli.TupleList(ctx, &authz.TupleListRequest{
Filter: filter.Filter(),
})
Type CheckRequest
type CheckRequest structtype CheckRequest struct {
pangea.BaseRequest
Resource Resource `json:"resource"`
Action string `json:"action"`
Subject Subject `json:"subject"`
Debug *bool `json:"debug,omitempty"`
Attributes map[string]any `json:"attributes,omitempty"`
}
Type CheckResult
type CheckResult structtype CheckResult struct {
SchemaID string `json:"schema_id"`
SchemaVersion int `json:"schema_version"`
Allowed bool `json:"allowed"`
Depth int `json:"depth"`
Debug *Debug `json:"debug,omitempty"`
}
Type Client
type Client interfacetype Client interface {
TupleCreate(ctx context.Context, input *TupleCreateRequest) (*pangea.PangeaResponse[TupleCreateResult], error)
TupleList(ctx context.Context, input *TupleListRequest) (*pangea.PangeaResponse[TupleListResult], error)
TupleDelete(ctx context.Context, input *TupleDeleteRequest) (*pangea.PangeaResponse[TupleDeleteResult], error)
Check(ctx context.Context, input *CheckRequest) (*pangea.PangeaResponse[CheckResult], error)
ListResources(ctx context.Context, input *ListResourcesRequest) (*pangea.PangeaResponse[ListResourcesResult], error)
ListSubjects(ctx context.Context, input *ListSubjectsRequest) (*pangea.PangeaResponse[ListSubjectsResult], error)
// Base service methods
pangea.BaseServicer
}
Type Debug
type Debug structtype Debug struct {
Path []DebugPath `json:"path"`
}
Type DebugPath
type DebugPath structtype DebugPath struct {
Type string `json:"type"`
ID string `json:"id"`
Action string `json:"action"`
}
Type ItemOrder
type ItemOrder stringtype ItemOrder string
Type ListResourcesRequest
type ListResourcesRequest structtype ListResourcesRequest struct {
pangea.BaseRequest
Type string `json:"type"`
Action string `json:"action"`
Subject Subject `json:"subject"`
Attributes map[string]any `json:"attributes,omitempty"` // A JSON object of attribute data.
}
Type ListResourcesResult
type ListResourcesResult structtype ListResourcesResult struct {
IDs []string `json:"ids"`
}
Type ListSubjectsRequest
type ListSubjectsRequest structtype ListSubjectsRequest struct {
pangea.BaseRequest
Resource Resource `json:"resource"`
Action string `json:"action"`
Attributes map[string]any `json:"attributes,omitempty"` // A JSON object of attribute data.
}
Type ListSubjectsResult
type ListSubjectsResult structtype ListSubjectsResult struct {
Subjects []Subject `json:"subjects"`
}
Type Resource
type Resource structtype Resource struct {
Type string `json:"type"`
ID string `json:"id,omitempty"`
}
Type Subject
type Subject structtype Subject struct {
Type string `json:"type"`
ID string `json:"id,omitempty"`
Action string `json:"action,omitempty"`
}
Type Tuple
type Tuple structtype Tuple struct {
Resource Resource `json:"resource"`
Relation string `json:"relation"`
Subject Subject `json:"subject"`
}
Type TupleCreateRequest
type TupleCreateRequest structtype TupleCreateRequest struct {
pangea.BaseRequest
Tuples []Tuple `json:"tuples"`
}
Type TupleCreateResult
type TupleCreateResult structtype TupleCreateResult struct {
}
Type TupleDeleteRequest
type TupleDeleteRequest structtype TupleDeleteRequest struct {
pangea.BaseRequest
Tuples []Tuple `json:"tuples"`
}
Type TupleDeleteResult
type TupleDeleteResult structtype TupleDeleteResult struct {
}
Type TupleListFilter
type TupleListFilter structtype TupleListFilter struct {
pangea.FilterBase
resourceType *pangea.FilterMatch[string]
resourceID *pangea.FilterMatch[string]
relation *pangea.FilterMatch[string]
subjectType *pangea.FilterMatch[string]
subjectID *pangea.FilterMatch[string]
subjectAction *pangea.FilterMatch[string]
}
Type TupleListRequest
type TupleListRequest structtype TupleListRequest struct {
pangea.BaseRequest
Filter pangea.Filter `json:"filter"`
Size int `json:"size,omitempty"`
Last string `json:"last,omitempty"`
Order ItemOrder `json:"order,omitempty"`
OrderBy TupleOrderBy `json:"order_by,omitempty"`
}
Type TupleListResult
type TupleListResult structtype TupleListResult struct {
Tuples []Tuple `json:"tuples"`
Last string `json:"last,omitempty"`
Count int `json:"count"`
}
Type TupleOrderBy
type TupleOrderBy stringtype TupleOrderBy string
Type authz
type authz structtype authz struct {
pangea.BaseService
}