permission

package
v0.0.0-...-cda7898 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2021 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ParamFileID is the name of the file id param in URL.
	ParamFileID = "id"

	// QueryDeleteUserPermission is the id of the user to delete its permission to a file.
	QueryDeleteUserPermission = "userId"

	// GetFilePermissionsRole is the role that is required of the authenticated requester to have to be
	// permitted to make the GetFilePermissions action.
	GetFilePermissionsRole = ppb.Role_READ

	// CreateFilePermissionRole is the role that is required of the authenticated requester to have to be
	// permitted to make the CreateFilePermission action.
	CreateFilePermissionRole = ppb.Role_WRITE

	// DeleteFilePermissionRole is the role that is required of the authenticated requester to have to be
	// permitted to make the DeleteFilePermission action.
	DeleteFilePermissionRole = ppb.Role_WRITE
)

Variables

This section is empty.

Functions

func CreatePermission

func CreatePermission(ctx context.Context,
	permissionClient ppb.PermissionClient,
	permission Permission, appID string, override bool) (*ppb.PermissionObject, error)

CreatePermission creates permission in the permission-service.

func IsDomainUserID

func IsDomainUserID(userID string) bool

IsDomainUserID checks if the userID is domainuser

func IsPermitted

func IsPermitted(ctx context.Context,
	permissionClient ppb.PermissionClient,
	fileID string,
	userID string,
	role ppb.Role) (*ppb.IsPermittedResponse, error)

IsPermitted checks if the userID has a permission with role for fileID.

Types

type Permission

type Permission struct {
	UserID  string `json:"userID,omitempty"`
	FileID  string `json:"fileID,omitempty"`
	Role    string `json:"role,omitempty"`
	Creator string `json:"creator,omitempty"`
}

Permission is a struct that describes a user's permission to a file.

func GetFilePermissions

func GetFilePermissions(ctx context.Context,
	fileID string,
	permissionClient ppb.PermissionClient,
	fileClient fpb.FileServiceClient) ([]Permission, error)

GetFilePermissions returns all derived user permissions of a file.

type Router

type Router struct {
	// contains filtered or unexported fields
}

Router is a structure that handles permission requests.

func NewRouter

func NewRouter(
	permissionConn *grpcPoolTypes.ConnPool,
	fileConn *grpcPoolTypes.ConnPool,
	userConnection *grpcPoolTypes.ConnPool,
	oAuthMiddleware *oauth.Middleware,
	logger *logrus.Logger,
) *Router

NewRouter creates a new Router, and initializes clients of the quota Service with the given connection. If logger is non-nil then it will be set as-is, otherwise logger would default to logrus.New().

func (*Router) CreateFilePermission

func (r *Router) CreateFilePermission(c *gin.Context)

CreateFilePermission creates a permission for a given file File id is extracted from url params, role is extracted from request body.

func (*Router) DeleteFilePermission

func (r *Router) DeleteFilePermission(c *gin.Context)

DeleteFilePermission deletes a file permission, File id and permission id are extracted from url params

func (*Router) GetFilePermissions

func (r *Router) GetFilePermissions(c *gin.Context)

GetFilePermissions is a route function for retrieving permissions of a file File id is extracted from url params

func (*Router) HandleUserFilePermission

func (r *Router) HandleUserFilePermission(
	c *gin.Context,
	fileID string,
	role ppb.Role) (string, *ppb.PermissionObject)

HandleUserFilePermission checks if the requesting user has a given role for the given file File id is extracted from url params

func (*Router) Setup

func (r *Router) Setup(rg *gin.RouterGroup)

Setup sets up r and intializes its routes under rg.

Jump to

Keyboard shortcuts

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