data

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2023 License: Apache-2.0 Imports: 0 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ModuleName       = "auth-svc"
	OrchestratorName = "orchestrator"
	TokenRegExpStr   = `^[A-Za-z0-9-_=]+\.[A-Za-z0-9-_=]+\.?[A-Za-z0-9-_.+/=]*$`
	RefreshCookie    = "refresh_token"
	AccessCookie     = "access_token"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type GenerateTokens

type GenerateTokens struct {
	User              User
	AccessLife        int64
	RefreshLife       int64
	Secret            string
	PermissionsString string
}

type JwtClaims

type JwtClaims struct {
	ExpiresAt        int64  `json:"exp"`
	CreatedAtNano    int64  `json:"iat_nano"`
	OwnerId          int64  `json:"owner_id"`
	Email            string `json:"email"`
	ModulePermission string `json:"module.permission"`
}

type Module

type Module struct {
	Id   int64  `db:"id" structs:"-"`
	Name string `db:"name" structs:"name"`
}

type ModulePayload

type ModulePayload struct {
	RequestId string `json:"request_id"`
	Action    string `json:"action"`

	//other fields that are required for module
	ModulePermissions ModulePermissions `json:"module_permissions,omitempty"`
	ModuleName        string            `json:"module_name"`
}

type ModulePermission

type ModulePermission struct {
	Id             int64  `db:"id" structs:"-"`
	ModuleId       int64  `db:"module_id" structs:"module_id"`
	ModuleName     string `db:"module_name" structs:"name"`
	PermissionName string `db:"permission_name" structs:"name"`
}

type ModulePermissions

type ModulePermissions map[string]StatusPermission

type Modules

type Modules interface {
	New() Modules

	Insert(module Module) error
	Select() ([]Module, error)
	Get() (*Module, error)
	Delete() error

	FilterByNames(names ...string) Modules
}

type Permission

type Permission struct {
	Id       int64      `db:"id" structs:"-"`
	ModuleId int64      `db:"module_id" structs:"module_id"`
	Name     string     `db:"name" structs:"name"`
	Status   UserStatus `db:"status" structs:"status"`
	*Module  `db:"-" structs:",omitempty"`
}

type Permissions

type Permissions interface {
	New() Permissions

	Insert(permission Permission) error
	Select() ([]ModulePermission, error)
	Get() (*ModulePermission, error)
	Delete() error

	IncludeModules() Permissions

	FilterByStatus(status UserStatus) Permissions
}

type RefreshToken

type RefreshToken struct {
	Token     string `db:"token" structs:"token"`
	OwnerId   int64  `db:"owner_id" structs:"owner_id"`
	ValidTill int64  `db:"valid_till" structs:"valid_till"`
}

type RefreshTokens

type RefreshTokens interface {
	New() RefreshTokens

	Create(token RefreshToken) error
	Get() (*RefreshToken, error)
	Select() ([]RefreshToken, error)
	Delete() error

	FilterByTokens(tokens ...string) RefreshTokens
	FilterByLowerValidTill(expiresAtUnix int64) RefreshTokens
}

type StatusPermission

type StatusPermission map[string]string

type User

type User struct {
	Id       int64      `db:"id" structs:"-"`
	Email    string     `db:"email" structs:"email"`
	Password string     `db:"password" structs:"password"`
	Status   UserStatus `db:"status" structs:"status"`
}

type UserStatus

type UserStatus string
const (
	SUPER_ADMIN UserStatus = "super_admin"
	ADMIN       UserStatus = "admin"
	USER        UserStatus = "user"
)

type Users

type Users interface {
	New() Users

	Get() (*User, error)

	FilterByEmails(emails ...string) Users
	FilterByIds(id ...int64) Users
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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