Documentation
¶
Index ¶
- func AuthVars(ctx context.Context) map[string]any
- func CtxWithPerm(ctx context.Context, perm *RolePermissions) context.Context
- type Permission
- type PermissionFieldRule
- func (r *PermissionFieldRule) EnterArgument(_ *validator.WalkContext, _ *ast.ArgumentDefinition, _ *ast.Argument) gqlerror.List
- func (r *PermissionFieldRule) EnterDirective(_ *validator.WalkContext, _ *ast.Definition, _ *ast.Directive) gqlerror.List
- func (r *PermissionFieldRule) EnterField(ctx *validator.WalkContext, parentDef *ast.Definition, field *ast.Field) gqlerror.List
- func (r *PermissionFieldRule) EnterFragment(_ *validator.WalkContext, _ *ast.Definition, _ ast.Selection) gqlerror.List
- type RolePermissions
- func (r *RolePermissions) CheckMutationInput(ctx context.Context, defs base.DefinitionsSource, inputName string, ...) error
- func (r *RolePermissions) CheckQuery(query *ast.Field) error
- func (r *RolePermissions) DataArgument(ctx context.Context, object, field string) map[string]any
- func (r *RolePermissions) Enabled(object, field string) (*Permission, bool)
- func (r *RolePermissions) FilterArgument(ctx context.Context, object, field string) map[string]any
- func (r *RolePermissions) Visible(object, field string) (*Permission, bool)
- type Service
- type Store
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CtxWithPerm ¶
func CtxWithPerm(ctx context.Context, perm *RolePermissions) context.Context
Types ¶
type Permission ¶
type PermissionFieldRule ¶ added in v0.3.0
type PermissionFieldRule struct{}
PermissionFieldRule is an InlineRule that checks field access permissions using RolePermissions from the context.
func (*PermissionFieldRule) EnterArgument ¶ added in v0.3.0
func (r *PermissionFieldRule) EnterArgument(_ *validator.WalkContext, _ *ast.ArgumentDefinition, _ *ast.Argument) gqlerror.List
func (*PermissionFieldRule) EnterDirective ¶ added in v0.3.0
func (r *PermissionFieldRule) EnterDirective(_ *validator.WalkContext, _ *ast.Definition, _ *ast.Directive) gqlerror.List
func (*PermissionFieldRule) EnterField ¶ added in v0.3.0
func (r *PermissionFieldRule) EnterField(ctx *validator.WalkContext, parentDef *ast.Definition, field *ast.Field) gqlerror.List
func (*PermissionFieldRule) EnterFragment ¶ added in v0.3.0
func (r *PermissionFieldRule) EnterFragment(_ *validator.WalkContext, _ *ast.Definition, _ ast.Selection) gqlerror.List
type RolePermissions ¶
type RolePermissions struct {
Name string `json:"name"`
Disabled bool `json:"disabled"`
Permissions []Permission `json:"permissions"`
}
func PermissionsFromCtx ¶
func PermissionsFromCtx(ctx context.Context) *RolePermissions
func (*RolePermissions) CheckMutationInput ¶
func (r *RolePermissions) CheckMutationInput(ctx context.Context, defs base.DefinitionsSource, inputName string, data map[string]any) error
func (*RolePermissions) CheckQuery ¶
func (r *RolePermissions) CheckQuery(query *ast.Field) error
func (*RolePermissions) DataArgument ¶
func (*RolePermissions) Enabled ¶
func (r *RolePermissions) Enabled(object, field string) (*Permission, bool)
func (*RolePermissions) FilterArgument ¶
func (*RolePermissions) Visible ¶
func (r *RolePermissions) Visible(object, field string) (*Permission, bool)
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
func (*Service) ContextWithPermissions ¶
func (*Service) RolePermissions ¶
func (s *Service) RolePermissions(ctx context.Context) (RolePermissions, error)
type Store ¶
type Store interface {
// ContextWithPermissions returns a new context with the permissions of the user.
ContextWithPermissions(ctx context.Context) (context.Context, error)
RolePermissions(ctx context.Context) (RolePermissions, error)
}
Store manager that provides methods to to retrieve Role permissions info from context.
Click to show internal directories.
Click to hide internal directories.