authz

package
v1.15.1 Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ObjectTypeFeature     = "feature"
	ObjectTypePermission  = "permission"
	ObjectTypePricingTier = "pricing-tier"
	ObjectTypeRole        = "role"
	ObjectTypeTenant      = "tenant"
	ObjectTypeUser        = "user"

	InheritIfAllOf  = "allOf"
	InheritIfAnyOf  = "anyOf"
	InheritIfNoneOf = "noneOf"
)
View Source
const PrimarySortKey = "typeId"

Variables

This section is empty.

Functions

This section is empty.

Types

type CreateObjectTypeSpec added in v0.57.0

type CreateObjectTypeSpec struct {
	Type      string                  `json:"type"             validate:"required,valid_object_type"`
	Source    *Source                 `json:"source,omitempty"`
	Relations map[string]RelationRule `json:"relations"        validate:"required,dive"` // NOTE: map key = name of relation
}

func (CreateObjectTypeSpec) ToObjectType added in v0.57.0

func (spec CreateObjectTypeSpec) ToObjectType() (*ObjectType, error)

type ForeignKeySpec

type ForeignKeySpec struct {
	Column   string `json:"column"   validate:"required"`
	Relation string `json:"relation" validate:"required,valid_relation"`
	Type     string `json:"type"     validate:"required,valid_object_type"`
	Subject  string `json:"subject"  validate:"required"`
}

type ListObjectTypesSpecV1 added in v0.57.0

type ListObjectTypesSpecV1 []ObjectTypeSpec

type ListObjectTypesSpecV2 added in v0.57.0

type ListObjectTypesSpecV2 struct {
	Results    []ObjectTypeSpec `json:"results"`
	PrevCursor *service.Cursor  `json:"prevCursor,omitempty"`
	NextCursor *service.Cursor  `json:"nextCursor,omitempty"`
}

type Model added in v0.8.0

type Model interface {
	GetID() int64
	GetTypeId() string
	GetDefinition() string
	SetDefinition(string)
	GetCreatedAt() time.Time
	GetUpdatedAt() time.Time
	GetDeletedAt() *time.Time
	ToObjectTypeSpec() (*ObjectTypeSpec, error)
}

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, model Model) (int64, error)

func (MySQLRepository) DeleteByTypeId

func (repo MySQLRepository) DeleteByTypeId(ctx context.Context, typeId string) error

func (MySQLRepository) GetById

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

func (MySQLRepository) GetByTypeId

func (repo MySQLRepository) GetByTypeId(ctx context.Context, typeId string) (Model, error)

func (MySQLRepository) List

func (repo MySQLRepository) List(ctx context.Context, listParams service.ListParams) ([]Model, *service.Cursor, *service.Cursor, error)

func (MySQLRepository) UpdateByTypeId

func (repo MySQLRepository) UpdateByTypeId(ctx context.Context, typeId string, model Model) error

type ObjectType

type ObjectType struct {
	ID         int64      `mysql:"id"         postgres:"id"         sqlite:"id"`
	TypeId     string     `mysql:"typeId"     postgres:"type_id"    sqlite:"typeId"`
	Definition string     `mysql:"definition" postgres:"definition" sqlite:"definition"`
	CreatedAt  time.Time  `mysql:"createdAt"  postgres:"created_at" sqlite:"createdAt"`
	UpdatedAt  time.Time  `mysql:"updatedAt"  postgres:"updated_at" sqlite:"updatedAt"`
	DeletedAt  *time.Time `mysql:"deletedAt"  postgres:"deleted_at" sqlite:"deletedAt"`
}

func (ObjectType) GetCreatedAt added in v0.8.0

func (objectType ObjectType) GetCreatedAt() time.Time

func (ObjectType) GetDefinition added in v0.8.0

func (objectType ObjectType) GetDefinition() string

func (ObjectType) GetDeletedAt added in v0.8.0

func (objectType ObjectType) GetDeletedAt() *time.Time

func (ObjectType) GetID added in v0.8.0

func (objectType ObjectType) GetID() int64

func (ObjectType) GetTypeId added in v0.8.0

func (objectType ObjectType) GetTypeId() string

func (ObjectType) GetUpdatedAt added in v0.8.0

func (objectType ObjectType) GetUpdatedAt() time.Time

func (*ObjectType) SetDefinition added in v0.8.0

func (objectType *ObjectType) SetDefinition(newDefinition string)

func (ObjectType) ToObjectTypeSpec

func (objectType ObjectType) ToObjectTypeSpec() (*ObjectTypeSpec, error)

type ObjectTypeListParamParser

type ObjectTypeListParamParser struct{}

func (ObjectTypeListParamParser) GetDefaultSortBy

func (parser ObjectTypeListParamParser) GetDefaultSortBy() string

func (ObjectTypeListParamParser) GetSupportedSortBys

func (parser ObjectTypeListParamParser) GetSupportedSortBys() []string

func (ObjectTypeListParamParser) ParseValue

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

type ObjectTypeRepository

type ObjectTypeRepository interface {
	Create(ctx context.Context, objectType Model) (int64, error)
	GetById(ctx context.Context, id int64) (Model, error)
	GetByTypeId(ctx context.Context, typeId string) (Model, error)
	List(ctx context.Context, listParams service.ListParams) ([]Model, *service.Cursor, *service.Cursor, error)
	UpdateByTypeId(ctx context.Context, typeId string, objectType Model) error
	DeleteByTypeId(ctx context.Context, typeId string) error
}

func NewRepository

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

type ObjectTypeService

type ObjectTypeService struct {
	service.BaseService
	// contains filtered or unexported fields
}

func NewService

func NewService(env service.Env, repository ObjectTypeRepository) *ObjectTypeService

func (ObjectTypeService) Create

func (ObjectTypeService) DeleteByTypeId

func (svc ObjectTypeService) DeleteByTypeId(ctx context.Context, typeId string) (*wookie.Token, error)

func (ObjectTypeService) GetByTypeId

func (svc ObjectTypeService) GetByTypeId(ctx context.Context, typeId string) (*ObjectTypeSpec, error)

func (ObjectTypeService) List

func (ObjectTypeService) Routes added in v0.8.0

func (svc ObjectTypeService) Routes() ([]service.Route, error)

func (ObjectTypeService) UpdateByTypeId

func (svc ObjectTypeService) UpdateByTypeId(ctx context.Context, typeId string, spec UpdateObjectTypeSpec) (*ObjectTypeSpec, *wookie.Token, error)

type ObjectTypeSpec

type ObjectTypeSpec struct {
	Type      string                  `json:"type"`
	Source    *Source                 `json:"source,omitempty"`
	Relations map[string]RelationRule `json:"relations"`
	CreatedAt time.Time               `json:"createdAt,omitempty"`
}

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, model Model) (int64, error)

func (PostgresRepository) DeleteByTypeId added in v0.4.0

func (repo PostgresRepository) DeleteByTypeId(ctx context.Context, typeId string) error

func (PostgresRepository) GetById added in v0.4.0

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

func (PostgresRepository) GetByTypeId added in v0.4.0

func (repo PostgresRepository) GetByTypeId(ctx context.Context, typeId string) (Model, error)

func (PostgresRepository) List added in v0.4.0

func (PostgresRepository) UpdateByTypeId added in v0.4.0

func (repo PostgresRepository) UpdateByTypeId(ctx context.Context, typeId string, model Model) error

type RelationRule

type RelationRule struct {
	InheritIf    string         `json:"inheritIf,omitempty"    validate:"required_with=Rules OfType WithRelation,valid_inheritif"`
	Rules        []RelationRule `json:"rules,omitempty"        validate:"required_if_oneof=InheritIf anyOf allOf noneOf,omitempty,min=1,dive"` // Required if InheritIf is "anyOf", "allOf", or "noneOf", empty otherwise
	OfType       string         `json:"ofType,omitempty"       validate:"required_with=WithRelation,valid_relation"`
	WithRelation string         `json:"withRelation,omitempty" validate:"required_with=OfType,valid_relation"`
}

RelationRule type represents the rule or set of rules that imply a particular relation if met

type SQLiteRepository added in v0.11.0

type SQLiteRepository struct {
	database.SQLRepository
}

func NewSQLiteRepository added in v0.11.0

func NewSQLiteRepository(db *database.SQLite) *SQLiteRepository

func (SQLiteRepository) Create added in v0.11.0

func (repo SQLiteRepository) Create(ctx context.Context, model Model) (int64, error)

func (SQLiteRepository) DeleteByTypeId added in v0.11.0

func (repo SQLiteRepository) DeleteByTypeId(ctx context.Context, typeId string) error

func (SQLiteRepository) GetById added in v0.11.0

func (repo SQLiteRepository) GetById(ctx context.Context, id int64) (Model, error)

func (SQLiteRepository) GetByTypeId added in v0.11.0

func (repo SQLiteRepository) GetByTypeId(ctx context.Context, typeId string) (Model, error)

func (SQLiteRepository) List added in v0.11.0

func (SQLiteRepository) UpdateByTypeId added in v0.11.0

func (repo SQLiteRepository) UpdateByTypeId(ctx context.Context, typeId string, model Model) error

type Service added in v0.39.0

type Service interface {
	Create(ctx context.Context, spec CreateObjectTypeSpec) (*ObjectTypeSpec, *wookie.Token, error)
	GetByTypeId(ctx context.Context, typeId string) (*ObjectTypeSpec, error)
	List(ctx context.Context, listParams service.ListParams) ([]ObjectTypeSpec, *service.Cursor, *service.Cursor, error)
	UpdateByTypeId(ctx context.Context, typeId string, spec UpdateObjectTypeSpec) (*ObjectTypeSpec, *wookie.Token, error)
	DeleteByTypeId(ctx context.Context, typeId string) (*wookie.Token, error)
}

type Source

type Source struct {
	DatabaseType string           `json:"dbType"                validate:"required"`
	DatabaseName string           `json:"dbName"                validate:"required"`
	Table        string           `json:"table"                 validate:"required"`
	PrimaryKey   []string         `json:"primaryKey"            validate:"min=1"`
	ForeignKeys  []ForeignKeySpec `json:"foreignKeys,omitempty"`
}

type UpdateObjectTypeSpec added in v0.57.0

type UpdateObjectTypeSpec struct {
	Type      string                  `json:"type"` // NOTE: used internally for updates, but value from request is ignored
	Source    *Source                 `json:"source,omitempty"`
	Relations map[string]RelationRule `json:"relations"        validate:"required,dive"` // NOTE: map key = name of relation
}

func (*UpdateObjectTypeSpec) ToObjectType added in v0.57.0

func (spec *UpdateObjectTypeSpec) ToObjectType(typeId string) (*ObjectType, error)

Jump to

Keyboard shortcuts

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