accessrequests

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2026 License: AGPL-3.0 Imports: 19 Imported by: 0

Documentation

Overview

Package accessrequests backs the "Request Editor access" action on the 403 screen: it names the smallest built-in role that grants a missing permission and sends the request to the members who manage the team. Nothing changes until one of them does.

Index

Constants

View Source
const KindAccessRequested = "access_requested"

KindAccessRequested is the notification kind team managers receive.

Variables

This section is empty.

Functions

func Register

func Register(h huma.API, s *Service)

Register adds the access request operations. Any member may call them (no permission needed); API keys and agents may not.

func SmallestRole

func SmallestRole(perm authz.Permission) authz.BuiltinRole

SmallestRole returns the first built-in role, from Viewer up, that holds perm.

Types

type AccessRequestResult

type AccessRequestResult struct {
	RoleName string   `json:"roleName"`
	Notified []string `json:"notified" doc:"Members who received the request"`
}

AccessRequestResult says who was asked.

type AccessSuggestion

type AccessSuggestion struct {
	Permission string `json:"permission" doc:"The missing permission"`
	Action     string `json:"action" doc:"What the permission allows, as a sentence subject" example:"Managing providers"`
	RoleKey    string `json:"roleKey" doc:"Smallest built-in role that grants it" example:"editor"`
	RoleName   string `json:"roleName" example:"Editor"`
	YourRole   string `json:"yourRole" example:"Viewer"`
	// Owners are the workspace's Owners; Managers can change roles (team:manage).
	Owners   []string `json:"owners"`
	Managers []string `json:"managers"`
	// RequestedAt is set when you asked for this role in the last 24 hours.
	RequestedAt *time.Time `json:"requestedAt,omitempty"`
}

AccessSuggestion is what the 403 screen shows before the person asks.

type Service

type Service struct {
	Pool  *pgxpool.Pool
	Q     *store.Queries
	Audit *audit.Logger
}

Service suggests roles and records access requests.

func (*Service) Request

func (s *Service) Request(ctx context.Context, permission, note string) (AccessRequestResult, error)

Request asks the team's managers for the role that grants permission.

func (*Service) Suggest

func (s *Service) Suggest(ctx context.Context, permission string) (AccessSuggestion, error)

Suggest describes the role that would grant perm and who can grant it.

Jump to

Keyboard shortcuts

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