schema

package
v1.5.17 Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2025 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SchemaName        = "auth"
	RootUserName      = "root"
	UserListLimit     = 50
	AuthHashAlgorithm = "sha256"
	APIPrefix         = "/auth/v1"
)
View Source
const (
	ScopeRoot      = "root"
	ScopeUserRead  = "mutablelogic/go-server/pkg/auth/user_read"
	ScopeUserWrite = "mutablelogic/go-server/pkg/auth/user_write"
)
View Source
const (
	TokenStatusLive     = TokenStatus("live")
	TokenStatusArchived = TokenStatus("archived")
)
View Source
const (
	UserStatusLive     = UserStatus("live")
	UserStatusArchived = UserStatus("archived")
)

Variables

This section is empty.

Functions

func Bootstrap

func Bootstrap(ctx context.Context, conn pg.Conn) error

Bootstrap creates the schema and tables for the auth manager and returns an error if it fails. It is expected that this function will be called within a transaction

Types

type Token

type Token struct {
	TokenId
	Ts     time.Time `json:"timestamp"`
	Status string    `json:"status"`
	TokenMeta
	Value *string `json:"token,omitempty"`
}

func (*Token) Scan

func (t *Token) Scan(row pg.Row) error

func (Token) String

func (t Token) String() string

type TokenId

type TokenId struct {
	User string `json:"user" arg:"" help:"User name"`
	Id   uint64 `json:"id" arg:"" help:"Token ID"`
}

func (TokenId) Select

func (t TokenId) Select(bind *pg.Bind, op pg.Op) (string, error)

type TokenList

type TokenList struct {
	TokenListRequest
	Count uint64  `json:"count"`
	Body  []Token `json:"body,omitempty"`
}

func (*TokenList) Scan

func (list *TokenList) Scan(row pg.Row) error

func (*TokenList) ScanCount

func (list *TokenList) ScanCount(row pg.Row) error

func (TokenList) String

func (t TokenList) String() string

type TokenListRequest

type TokenListRequest struct {
	Status *string `json:"status,omitempty" help:"Status"`
	pg.OffsetLimit
}

func (*TokenListRequest) Select

func (list *TokenListRequest) Select(bind *pg.Bind, op pg.Op) (string, error)

func (TokenListRequest) String

func (t TokenListRequest) String() string

type TokenMeta

type TokenMeta struct {
	Desc *string `json:"desc,omitempty" help:"Description"`
}

func (TokenMeta) Insert

func (t TokenMeta) Insert(bind *pg.Bind) (string, error)

func (TokenMeta) String

func (t TokenMeta) String() string

func (TokenMeta) Update

func (t TokenMeta) Update(bind *pg.Bind) error

type TokenNew

type TokenNew struct {
	User string `json:"user"`
	TokenMeta
	Value string `json:"token"`
	Hash  string `json:"hash"`
}

func (TokenNew) Insert

func (t TokenNew) Insert(bind *pg.Bind) (string, error)

func (*TokenNew) Scan

func (t *TokenNew) Scan(row pg.Row) error

func (TokenNew) Select

func (t TokenNew) Select(bind *pg.Bind, op pg.Op) (string, error)

func (TokenNew) String

func (t TokenNew) String() string

func (TokenNew) Update

func (t TokenNew) Update(bind *pg.Bind) error

type TokenStatus

type TokenStatus string

func (TokenStatus) Insert

func (status TokenStatus) Insert(bind *pg.Bind) (string, error)

func (TokenStatus) Update

func (status TokenStatus) Update(bind *pg.Bind) error

type User

type User struct {
	UserMeta
	Status string    `json:"status,omitempty" help:"Status"`
	Ts     time.Time `json:"ts,omitempty" help:"Timestamp"`
}

func (*User) Scan

func (user *User) Scan(row pg.Row) error

func (User) String

func (user User) String() string

type UserList

type UserList struct {
	UserListRequest
	Count uint64 `json:"count"`
	Body  []User `json:"body,omitempty"`
}

func (*UserList) Scan

func (list *UserList) Scan(row pg.Row) error

func (*UserList) ScanCount

func (list *UserList) ScanCount(row pg.Row) error

func (UserList) String

func (user UserList) String() string

type UserListRequest

type UserListRequest struct {
	Status *string `json:"status,omitempty" help:"Status"`
	Scope  *string `json:"scope,omitempty" help:"Scope"`
	pg.OffsetLimit
}

func (*UserListRequest) Select

func (list *UserListRequest) Select(bind *pg.Bind, op pg.Op) (string, error)

func (UserListRequest) String

func (user UserListRequest) String() string

type UserMeta

type UserMeta struct {
	Name  *string        `json:"name,omitempty" arg:"" help:"Name"`
	Desc  *string        `json:"desc,omitempty" help:"Description"`
	Scope []string       `json:"scope,omitempty" help:"Scopes"`
	Meta  map[string]any `json:"meta,omitempty" help:"Metadata"`
}

func (UserMeta) Insert

func (user UserMeta) Insert(bind *pg.Bind) (string, error)

func (UserMeta) String

func (user UserMeta) String() string

func (UserMeta) Update

func (user UserMeta) Update(bind *pg.Bind) error

type UserName

type UserName string

func (UserName) Select

func (user UserName) Select(bind *pg.Bind, op pg.Op) (string, error)

type UserStatus

type UserStatus string

func (UserStatus) Insert

func (status UserStatus) Insert(bind *pg.Bind) (string, error)

func (UserStatus) Update

func (status UserStatus) Update(bind *pg.Bind) error

type UserTokenHash

type UserTokenHash string

func (UserTokenHash) Select

func (hash UserTokenHash) Select(bind *pg.Bind, op pg.Op) (string, error)

Jump to

Keyboard shortcuts

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