entity

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2026 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ApiKey

type ApiKey struct {
	bun.BaseModel `bun:"table:access.auth_apikey,alias:ak"`

	ApiKey string   `bun:"api_key,pk" db:"api_key"`
	UserId string   `bun:"user_id" db:"user_id"`
	User   AuthUser `bun:"rel:belongs-to,join:user_id=id" json:"users"`
}

ApiKey merepresentasikan satu baris pada tabel access.auth_apikey, relasi 1:1 ke access.auth_users (satu user boleh punya paling banyak 1 API key -- lihat constraint UNIQUE(user_id) di migration).

Field `User` (relasi bun `belongs-to`) TIDAK diisi otomatis oleh kode di backend.go -- lookup dilakukan lewat 2 query terpisah (cari baris ApiKey, lalu cari AuthUser by user_id), karena port.IDatabase (interface generik webcore) tidak menjamin dukungan eager-loading relasi bun. Field ini dibiarkan ada untuk dipakai kode lain yang mungkin query langsung lewat bun (mis. tooling admin), bukan dipakai backend.go.

func (ApiKey) GetPkName

func (ApiKey) GetPkName() string

func (ApiKey) TableName

func (ApiKey) TableName() string

type AuthResource

type AuthResource struct {
	bun.BaseModel `bun:"table:access.auth_resources,alias:ar"`

	ID             string   `bun:"id,pk,default:gen_random_uuid()" db:"id"`
	Action         string   `bun:"action" db:"action"`
	Path           string   `bun:"path" db:"path"`     // prefix path, mis: "/auth/token"
	Method         string   `bun:"method" db:"method"` // GET, POST, PUT, DELETE, dst
	PermittedRoles []string `bun:"permitted_roles,array" db:"permitted_roles"`
}

AuthResource merepresentasikan satu baris resource/permission pada tabel access.auth_resources. Dipetakan ke auth.ResourceInfoRBAC.

func (AuthResource) GetPkName

func (AuthResource) GetPkName() string

func (AuthResource) TableName

func (AuthResource) TableName() string

type AuthUser

type AuthUser struct {
	bun.BaseModel `bun:"table:access.auth_users,alias:au"`

	ID           string   `bun:"id,pk,default:gen_random_uuid()" db:"id"`
	Username     string   `bun:"username" db:"username"`
	PasswordHash string   `bun:"password_hash" db:"password_hash"` // bcrypt hash, JANGAN simpan plaintext
	Groups       []string `bun:"groups,array" db:"groups"`         // mis: ["admin", "operator"]
	Roles        []string `bun:"roles,array" db:"roles"`           // mis: ["read","write"] -> jadi Permissions
	Active       bool     `bun:"active" db:"active"`
}

func (AuthUser) GetPkName

func (AuthUser) GetPkName() string

func (AuthUser) TableName

func (AuthUser) TableName() string

Jump to

Keyboard shortcuts

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