Help us shape the future of Go! Take the 2026 Go Developer Survey

auth

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CookieName         = "quartet_session"
	CSRFHeader         = "X-CSRF-Token"
	UserStatusActive   = "active"
	UserStatusDisabled = "disabled"
	UserStatusDeleted  = "deleted"
	AdminRoleID        = "admin"
	MemberRoleID       = "member"
	ViewerRoleID       = "viewer"
	// PersistentCookieMaxAge only controls how long clients retain the cookie.
	// Auth sessions themselves do not expire and remain valid until explicitly
	// revoked (logout, password reset/change, user disable, or user deletion).
	PersistentCookieMaxAge = 10 * 365 * 24 * time.Hour
)

Variables

View Source
var (
	ErrUninitialized      = errors.New("authentication is not initialized")
	ErrRecovery           = errors.New("authentication configuration requires recovery")
	ErrInvalidCredentials = errors.New("invalid username or password")
	ErrUserDisabled       = errors.New("user is disabled")
	ErrUnauthorized       = errors.New("authentication required")
	ErrForbidden          = errors.New("permission denied")
	ErrRateLimited        = errors.New("too many failed login attempts")
	ErrConflict           = errors.New("record version conflict")
	ErrNotFound           = errors.New("record not found")
)

Functions

This section is empty.

Types

type Permission

type Permission string
const (
	PermissionWorkspaceRead   Permission = "workspace.read"
	PermissionWorkspaceWrite  Permission = "workspace.write"
	PermissionJobRead         Permission = "job.read"
	PermissionJobExecute      Permission = "job.execute"
	PermissionJobManage       Permission = "job.manage"
	PermissionJobShare        Permission = "job.share"
	PermissionWorkflowRead    Permission = "workflow.read"
	PermissionWorkflowWrite   Permission = "workflow.write"
	PermissionWorkflowExecute Permission = "workflow.execute"
	PermissionScheduleRead    Permission = "schedule.read"
	PermissionScheduleWrite   Permission = "schedule.write"
	PermissionScheduleExecute Permission = "schedule.execute"
	PermissionFileRead        Permission = "file.read"
	PermissionFileWrite       Permission = "file.write"
	PermissionFileShare       Permission = "file.share"
	PermissionAgentRead       Permission = "agent.read"
	PermissionAgentManage     Permission = "agent.manage"
	PermissionConfigRead      Permission = "config.read"
	PermissionConfigWrite     Permission = "config.write"
	PermissionIMRead          Permission = "im.read"
	PermissionIMManage        Permission = "im.manage"
	PermissionIMSend          Permission = "im.send"
	PermissionStatsRead       Permission = "stats.read"
	PermissionLogsRead        Permission = "logs.read"
	PermissionLogsManage      Permission = "logs.manage"
	PermissionLogsReport      Permission = "logs.report"
	PermissionSkillsRead      Permission = "skills.read"
	PermissionSkillsManage    Permission = "skills.manage"
	PermissionSystemManage    Permission = "system.manage"
	PermissionUsersRead       Permission = "users.read"
	PermissionUsersManage     Permission = "users.manage"
	PermissionRolesRead       Permission = "roles.read"
	PermissionRolesManage     Permission = "roles.manage"
)

type Service

type Service struct {
	// contains filtered or unexported fields
}

func NewService

func NewService() (*Service, error)

func (*Service) Authenticate

func (s *Service) Authenticate(token string) (*model.AuthPrincipal, error)

func (*Service) ChangePassword

func (s *Service) ChangePassword(id, current, nextPassword string) (string, *model.AuthPrincipal, error)

func (*Service) CreateRole

func (s *Service) CreateRole(req model.CreateRoleRequest, actor string) (model.Role, error)

func (*Service) CreateUser

func (s *Service) CreateUser(req model.CreateUserRequest, actor string) (model.UserView, error)

func (*Service) DeleteRole

func (s *Service) DeleteRole(id string, version int64) error

func (*Service) DeleteUser

func (s *Service) DeleteUser(id string, version int64, actor string) (model.UserView, error)

func (*Service) GetRole

func (s *Service) GetRole(id string) (model.Role, error)

func (*Service) GetUser

func (s *Service) GetUser(id string) (model.UserView, error)

func (*Service) HasPermission

func (s *Service) HasPermission(principal *model.AuthPrincipal, permission Permission) bool

func (*Service) Initialize

func (s *Service) Initialize(req model.InitAdminRequest) (string, *model.AuthPrincipal, error)

func (*Service) ListRoles

func (s *Service) ListRoles() []model.Role

func (*Service) ListUsers

func (s *Service) ListUsers() []model.UserView

func (*Service) Login

func (s *Service) Login(username, password, source string) (string, *model.AuthPrincipal, error)

func (*Service) Logout

func (s *Service) Logout(token string) error

func (*Service) Permissions

func (s *Service) Permissions() []model.PermissionInfo

func (*Service) ResetPassword

func (s *Service) ResetPassword(id string, version int64, password, actor string) (model.UserView, error)

func (*Service) Status

func (s *Service) Status() (State, string)

func (*Service) UpdateProfile

func (s *Service) UpdateProfile(id, display, actor string) (model.UserView, error)

func (*Service) UpdateRole

func (s *Service) UpdateRole(id string, req model.UpdateRoleRequest, actor string) (model.Role, error)

func (*Service) UpdateUser

func (s *Service) UpdateUser(id string, req model.UpdateUserRequest, actor string) (model.UserView, error)

type State

type State string
const (
	StateUninitialized State = "uninitialized"
	StateReady         State = "ready"
	StateRecovery      State = "recovery"
)

Jump to

Keyboard shortcuts

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