authz

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2023 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const ResourceTypePermission = "permission"

Variables

This section is empty.

Functions

This section is empty.

Types

type MySQLRepository

type MySQLRepository struct {
	database.SQLRepository
}

func NewMySQLRepository

func NewMySQLRepository(db *database.MySQL) MySQLRepository

func (MySQLRepository) Create

func (repo MySQLRepository) Create(ctx context.Context, permission Permission) (int64, error)

func (MySQLRepository) DeleteByPermissionId

func (repo MySQLRepository) DeleteByPermissionId(ctx context.Context, permissionId string) error

func (MySQLRepository) GetById

func (repo MySQLRepository) GetById(ctx context.Context, id int64) (*Permission, error)

func (MySQLRepository) GetByPermissionId

func (repo MySQLRepository) GetByPermissionId(ctx context.Context, permissionId string) (*Permission, error)

func (MySQLRepository) List

func (repo MySQLRepository) List(ctx context.Context, listParams middleware.ListParams) ([]Permission, error)

func (MySQLRepository) UpdateByPermissionId

func (repo MySQLRepository) UpdateByPermissionId(ctx context.Context, permissionId string, permission Permission) error

type Permission

type Permission struct {
	ID           int64               `mysql:"id" postgres:"id"`
	ObjectId     int64               `mysql:"objectId" postgres:"object_id"`
	PermissionId string              `mysql:"permissionId" postgres:"permission_id"`
	Name         database.NullString `mysql:"name" postgres:"name"`
	Description  database.NullString `mysql:"description" postgres:"description"`
	CreatedAt    time.Time           `mysql:"createdAt" postgres:"created_at"`
	UpdatedAt    time.Time           `mysql:"updatedAt" postgres:"updated_at"`
	DeletedAt    database.NullTime   `mysql:"deletedAt" postgres:"deleted_at"`
}

func (Permission) ToPermissionSpec

func (permission Permission) ToPermissionSpec() *PermissionSpec

type PermissionListParamParser

type PermissionListParamParser struct{}

func (PermissionListParamParser) GetDefaultSortBy

func (parser PermissionListParamParser) GetDefaultSortBy() string

func (PermissionListParamParser) GetSupportedSortBys

func (parser PermissionListParamParser) GetSupportedSortBys() []string

func (PermissionListParamParser) ParseValue

func (parser PermissionListParamParser) ParseValue(val string, sortBy string) (interface{}, error)

type PermissionRepository

type PermissionRepository interface {
	Create(ctx context.Context, permission Permission) (int64, error)
	GetById(ctx context.Context, id int64) (*Permission, error)
	GetByPermissionId(ctx context.Context, permissionId string) (*Permission, error)
	List(ctx context.Context, listParams middleware.ListParams) ([]Permission, error)
	UpdateByPermissionId(ctx context.Context, permissionId string, permission Permission) error
	DeleteByPermissionId(ctx context.Context, permissionId string) error
}

func NewRepository

func NewRepository(db database.Database) (PermissionRepository, error)

type PermissionService

type PermissionService struct {
	service.BaseService
}

func NewService

func NewService(env service.Env) PermissionService

func (PermissionService) Create

func (svc PermissionService) Create(ctx context.Context, permissionSpec PermissionSpec) (*PermissionSpec, error)

func (PermissionService) DeleteByPermissionId

func (svc PermissionService) DeleteByPermissionId(ctx context.Context, permissionId string) error

func (PermissionService) GetByPermissionId

func (svc PermissionService) GetByPermissionId(ctx context.Context, permissionId string) (*PermissionSpec, error)

func (PermissionService) GetRoutes

func (svc PermissionService) GetRoutes() []service.Route

GetRoutes registers all route handlers for this module

func (PermissionService) List

func (PermissionService) UpdateByPermissionId

func (svc PermissionService) UpdateByPermissionId(ctx context.Context, permissionId string, permissionSpec UpdatePermissionSpec) (*PermissionSpec, error)

type PermissionSpec

type PermissionSpec struct {
	PermissionId string                 `json:"permissionId" validate:"required"`
	Name         database.NullString    `json:"name"`
	Description  database.NullString    `json:"description"`
	Context      context.ContextSetSpec `json:"context,omitempty"`
	CreatedAt    time.Time              `json:"createdAt"`
}

func (PermissionSpec) ToObjectSpec

func (spec PermissionSpec) ToObjectSpec() *object.ObjectSpec

func (PermissionSpec) ToPermission

func (spec PermissionSpec) ToPermission(objectId int64) *Permission

type PostgresRepository added in v0.4.0

type PostgresRepository struct {
	database.SQLRepository
}

func NewPostgresRepository added in v0.4.0

func NewPostgresRepository(db *database.Postgres) PostgresRepository

func (PostgresRepository) Create added in v0.4.0

func (repo PostgresRepository) Create(ctx context.Context, permission Permission) (int64, error)

func (PostgresRepository) DeleteByPermissionId added in v0.4.0

func (repo PostgresRepository) DeleteByPermissionId(ctx context.Context, permissionId string) error

func (PostgresRepository) GetById added in v0.4.0

func (repo PostgresRepository) GetById(ctx context.Context, id int64) (*Permission, error)

func (PostgresRepository) GetByPermissionId added in v0.4.0

func (repo PostgresRepository) GetByPermissionId(ctx context.Context, permissionId string) (*Permission, error)

func (PostgresRepository) List added in v0.4.0

func (repo PostgresRepository) List(ctx context.Context, listParams middleware.ListParams) ([]Permission, error)

func (PostgresRepository) UpdateByPermissionId added in v0.4.0

func (repo PostgresRepository) UpdateByPermissionId(ctx context.Context, permissionId string, permission Permission) error

type UpdatePermissionSpec

type UpdatePermissionSpec struct {
	Name        database.NullString `json:"name"`
	Description database.NullString `json:"description"`
}

Jump to

Keyboard shortcuts

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