permissions

package
v0.0.0-...-84a60d7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 9, 2026 License: AGPL-3.0 Imports: 19 Imported by: 1

Documentation

Overview

Package permissions is the HTTP handlers for managing the permissions on a Cozy (creating a share by link for example).

Index

Constants

View Source
const ContextClaims = "token_claims"

ContextClaims is the key used in echo context to store claims

View Source
const ContextPermissionSet = "permissions_set"

ContextPermissionSet is the key used in echo context to store permissions set

Variables

View Source
var ErrPatchCodeOrSet = echo.NewHTTPError(http.StatusBadRequest,
	"The patch doc should have property 'codes' or 'permissions', not both")

ErrPatchCodeOrSet is returned when an attempt is made to patch both code & set in one request

Functions

func HandleCreateShareByLink(c echo.Context, inst *instance.Instance, opts CreateShareByLinkOptions) error

HandleCreateShareByLink is the common handler for creating share-by-link permissions. It handles parsing, optional additional validation, creation via CreateShareSet, and response formatting.

func Routes

func Routes(router *echo.Group)

Routes sets the routing for the permissions service

Types

type APIPermission

type APIPermission struct {
	*permission.Permission
	// contains filtered or unexported fields
}

APIPermission is the struct that will be used to serialized a permission to JSON-API

func (*APIPermission) Included

func (p *APIPermission) Included() []jsonapi.Object

Included implements jsonapi.Doc

func (p *APIPermission) Links() *jsonapi.LinksList

Links implements jsonapi.Doc

func (*APIPermission) MarshalJSON

func (p *APIPermission) MarshalJSON() ([]byte, error)

MarshalJSON implements jsonapi.Doc

func (*APIPermission) Relationships

func (p *APIPermission) Relationships() jsonapi.RelationshipMap

Relationships implements jsonapi.Doc

type CreateShareByLinkOptions

type CreateShareByLinkOptions struct {
	// runs additional validations after request binding and
	ValidatePermissions ValidatePermissionsFn
	// controls whether CreateShareSet's standard permission validation is skipped.
	SkipValidation bool
	// overrides the app slug stored in metadata.
	CreatorSlug *string
	// overrides the creator domain stored in metadata.
	CreatorDomain *string
}

CreateShareByLinkOptions configures HandleCreateShareByLink behavior.

type ValidatePermissionsFn

type ValidatePermissionsFn func(perms permission.Set) error

ValidatePermissionsFn is a function that validates permission rules. Used by HandleCreateShareByLink to allow additional validation on top of the standard permission checks (e.g., verifying files are within a shared drive).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL