acl

package
v1.20.1 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2026 License: MIT Imports: 8 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package acl talks to the command pre-approval ledger held by the signer.

Index

Constants

View Source
const PrincipalTypeServiceToken = "service_token"

PrincipalTypeServiceToken is the only principal type IssueEntries issues; api_token entries already on the ledger are still listed and revocable.

Variables

This section is empty.

Functions

func FormatServerScope

func FormatServerScope(serverIDs []string, serverNames map[string]string) string

FormatServerScope renders an entry's server scope. An empty list is not "no servers"—it is every server in the workspace.

func RevokeAdmin

func RevokeAdmin(ac *client.AlpaconClient, adminID string) error

RevokeAdmin withdraws one admin grant by its id.

func RevokeEntries

func RevokeEntries(ac *client.AlpaconClient, entryIDs []string) (int, error)

RevokeEntries withdraws every entry in entryIDs or none, returning how many the signer revoked.

func RevokeEntry

func RevokeEntry(ac *client.AlpaconClient, entryID string) error

RevokeEntry withdraws one entry. The signer keeps the row readable by id for the audit trail; it stops matching at once.

Types

type AdminAttributes

type AdminAttributes struct {
	ID        string          `json:"id" table:"ID"`
	Subject   string          `json:"subject" table:"Subject"`
	Email     string          `json:"email" table:"Email"`
	GrantedBy string          `json:"granted_by" table:"Granted by"`
	CreatedAt utils.Timestamp `json:"created_at" table:"Granted at"`
}

func ToAdminAttributes

func ToAdminAttributes(admins []AdminResponse) []AdminAttributes

type AdminResponse

type AdminResponse struct {
	ID               string `json:"id"`
	WorkspaceID      string `json:"workspace_id"`
	Subject          string `json:"subject"`
	Email            string `json:"email"`
	GrantedBySubject string `json:"granted_by_subject"`
	CreatedAt        string `json:"created_at"`
}

func FindAdmin

func FindAdmin(admins []AdminResponse, ref string) (AdminResponse, error)

FindAdmin picks the grant ref names—a grant id, subject or email—among one workspace's admins, refusing an email two grants share rather than guess.

func GrantAdmin

func GrantAdmin(ac *client.AlpaconClient, workspaceID, subject, email string) (AdminResponse, error)

GrantAdmin makes subject a Command ACL admin of the workspace. email is recorded for people to read; the subject is what authorizes.

func ListAdmins

func ListAdmins(ac *client.AlpaconClient, workspaceID string) ([]AdminResponse, error)

ListAdmins returns the workspace's active Command ACL admins.

type Capability

type Capability struct {
	IsLedgerAdmin bool     `json:"is_ledger_admin"`
	WorkspaceIDs  []string `json:"workspace_ids"`
}

Capability is the signer's answer to what the caller may do with the ledger.

func GetCapability

func GetCapability(ac *client.AlpaconClient) (Capability, error)

GetCapability asks the signer which workspaces the caller administers. It answers 200 even for none, so "not an admin" is not confused with a 403.

func (Capability) Administers

func (c Capability) Administers(workspaceID string) bool

Administers reports whether the caller is a Command ACL admin of workspaceID: the flag and the listed workspace must agree.

type EntryAttributes

type EntryAttributes struct {
	AppliesToToken *bool           `json:"applies_to_token,omitempty" table:"-"`
	ID             string          `json:"id" table:"ID"`
	Principal      string          `json:"principal" table:"Service token"`
	Command        string          `json:"command_pattern" table:"Command"`
	Username       string          `json:"username" table:"User"`
	Groupname      string          `json:"groupname" table:"Group"`
	Applies        string          `json:"-" table:"Applies"`
	Servers        string          `json:"servers" table:"Servers"`
	Enabled        bool            `json:"enabled" table:"Enabled"`
	ExpiresAt      utils.Timestamp `json:"expires_at" table:"Expires at"`
	CreatedBy      string          `json:"created_by" table:"Created by"`
}

func ToEntryAttributes

func ToEntryAttributes(entries []EntryResponse, tokenNames, serverNames map[string]string) []EntryAttributes

ToEntryAttributes projects entries for a table, showing names where the workspace supplied them and the id otherwise.

type EntryRequest

type EntryRequest struct {
	PrincipalID    string   `json:"principal_id"`
	CommandPattern string   `json:"command_pattern"`
	Username       string   `json:"username"`
	Groupname      string   `json:"groupname,omitempty"`
	ServerIDs      []string `json:"server_ids"`
	ExpiresAt      string   `json:"expires_at,omitempty"`
	Enabled        bool     `json:"enabled"`
}

EntryRequest is one entry to issue, for the service token PrincipalID names. IssueEntries states the principal type on the wire.

type EntryResponse

type EntryResponse struct {
	ID             string   `json:"id"`
	WorkspaceID    string   `json:"workspace_id"`
	PrincipalType  string   `json:"principal_type"`
	PrincipalID    string   `json:"principal_id"`
	CommandPattern string   `json:"command_pattern"`
	Username       string   `json:"username"`
	Groupname      string   `json:"groupname"`
	ServerIDs      []string `json:"server_ids"`
	EntryKind      string   `json:"entry_kind"`
	ExpiresAt      *string  `json:"expires_at"`
	Enabled        bool     `json:"enabled"`
	CreatedByEmail string   `json:"created_by_email"`
	CreatedAt      string   `json:"created_at"`
	// Warnings carries the signer's write-time advisories, such as an entry
	// with no server scope applying to every server in the workspace.
	Warnings []string `json:"warnings"`
}

func GetEntry

func GetEntry(ac *client.AlpaconClient, entryID string) (EntryResponse, error)

GetEntry reads one entry by id, from any workspace the caller administers, so the caller compares its workspace_id with the one it means to act on.

func IssueEntries

func IssueEntries(ac *client.AlpaconClient, workspaceID string, entries []EntryRequest) ([]EntryResponse, error)

IssueEntries issues every entry or none, one entry included, through the bulk route. Every entry goes out as a service token's: the console cannot show an api_token one.

func ListEntries

func ListEntries(ac *client.AlpaconClient, workspaceID, principalID string) ([]EntryResponse, error)

ListEntries returns the workspace's active entries, narrowed to one service token when principalID is set; the signer refuses a list naming no workspace.

func SetEntryEnabled

func SetEntryEnabled(ac *client.AlpaconClient, entryID string, enabled bool) (EntryResponse, error)

SetEntryEnabled turns an entry off or back on without withdrawing it.

Jump to

Keyboard shortcuts

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