Skip to main content

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.

required parameters

context.Context
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.

required parameters

context.Context
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.

required parameters

context.Context
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.

required parameters

context.Context
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.

required parameters

context.Context
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(),
})

required parameters

context.Context

Type CheckRequest

type CheckRequest struct

required parameters

Resource `json:"resource"`
string `json:"action"`
*bool `json:"debug,omitempty"`
map[string]any `json:"attributes,omitempty"`
type 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 struct

required parameters

string `json:"schema_id"`
int `json:"schema_version"`
bool `json:"allowed"`
int `json:"depth"`
type 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 interface

required parameters

func(ctx context.Context, input *TupleCreateRequest) (*pangea.PangeaResponse[TupleCreateResult], error)
context.Context
func(ctx context.Context, input *TupleListRequest) (*pangea.PangeaResponse[TupleListResult], error)
context.Context
func(ctx context.Context, input *TupleDeleteRequest) (*pangea.PangeaResponse[TupleDeleteResult], error)
context.Context
func(ctx context.Context, input *CheckRequest) (*pangea.PangeaResponse[CheckResult], error)
context.Context
func(ctx context.Context, input *ListResourcesRequest) (*pangea.PangeaResponse[ListResourcesResult], error)
context.Context
func(ctx context.Context, input *ListSubjectsRequest) (*pangea.PangeaResponse[ListSubjectsResult], error)
context.Context
pangea.BaseServicer

Base service methods

type 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 struct

required parameters

[]DebugPath `json:"path"`
type Debug struct {
	Path []DebugPath `json:"path"`
}

Type DebugPath

type DebugPath struct

required parameters

string `json:"type"`
string `json:"id"`
string `json:"action"`
type DebugPath struct {
	Type	string	`json:"type"`
	ID	string	`json:"id"`
	Action	string	`json:"action"`
}

Type ItemOrder

type ItemOrder string
type ItemOrder string

Type ListResourcesRequest

type ListResourcesRequest struct

required parameters

string `json:"type"`
string `json:"action"`
map[string]any `json:"attributes,omitempty"`
type 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 struct

required parameters

[]string `json:"ids"`
type ListResourcesResult struct {
	IDs []string `json:"ids"`
}

Type ListSubjectsRequest

type ListSubjectsRequest struct

required parameters

Resource `json:"resource"`
string `json:"action"`
map[string]any `json:"attributes,omitempty"`
type 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 struct

required parameters

[]Subject `json:"subjects"`
type ListSubjectsResult struct {
	Subjects []Subject `json:"subjects"`
}

Type Resource

type Resource struct

required parameters

string `json:"type"`
string `json:"id,omitempty"`
type Resource struct {
	Type	string	`json:"type"`
	ID	string	`json:"id,omitempty"`
}

Type Subject

type Subject struct

required parameters

string `json:"type"`
string `json:"id,omitempty"`
string `json:"action,omitempty"`
type Subject struct {
	Type	string	`json:"type"`
	ID	string	`json:"id,omitempty"`
	Action	string	`json:"action,omitempty"`
}

Type Tuple

type Tuple struct

required parameters

Resource `json:"resource"`
string `json:"relation"`
type Tuple struct {
	Resource	Resource	`json:"resource"`
	Relation	string		`json:"relation"`
	Subject		Subject		`json:"subject"`
}

Type TupleCreateRequest

type TupleCreateRequest struct

required parameters

[]Tuple `json:"tuples"`
type TupleCreateRequest struct {
	pangea.BaseRequest

	Tuples	[]Tuple	`json:"tuples"`
}

Type TupleCreateResult

type TupleCreateResult struct
type TupleCreateResult struct {
}

Type TupleDeleteRequest

type TupleDeleteRequest struct

required parameters

[]Tuple `json:"tuples"`
type TupleDeleteRequest struct {
	pangea.BaseRequest

	Tuples	[]Tuple	`json:"tuples"`
}

Type TupleDeleteResult

type TupleDeleteResult struct
type TupleDeleteResult struct {
}

Type TupleListFilter

type TupleListFilter struct

required parameters

*pangea.FilterMatch[string]
*pangea.FilterMatch[string]
*pangea.FilterMatch[string]
*pangea.FilterMatch[string]
*pangea.FilterMatch[string]
*pangea.FilterMatch[string]
type 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 struct

required parameters

pangea.Filter `json:"filter"`
int `json:"size,omitempty"`
string `json:"last,omitempty"`
type 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 struct

required parameters

[]Tuple `json:"tuples"`
string `json:"last,omitempty"`
int `json:"count"`
type TupleListResult struct {
	Tuples	[]Tuple	`json:"tuples"`
	Last	string	`json:"last,omitempty"`
	Count	int	`json:"count"`
}

Type TupleOrderBy

type TupleOrderBy string
type TupleOrderBy string

Type authz

type authz struct
type authz struct {
	pangea.BaseService
}