Documentation
¶
Overview ¶
Package acl talks to the command pre-approval ledger held by the signer.
Index ¶
- Constants
- func FormatServerScope(serverIDs []string, serverNames map[string]string) string
- func RevokeAdmin(ac *client.AlpaconClient, adminID string) error
- func RevokeEntries(ac *client.AlpaconClient, entryIDs []string) (int, error)
- func RevokeEntry(ac *client.AlpaconClient, entryID string) error
- type AdminAttributes
- type AdminResponse
- type Capability
- type EntryAttributes
- type EntryRequest
- type EntryResponse
- func GetEntry(ac *client.AlpaconClient, entryID string) (EntryResponse, error)
- func IssueEntries(ac *client.AlpaconClient, workspaceID string, entries []EntryRequest) ([]EntryResponse, error)
- func ListEntries(ac *client.AlpaconClient, workspaceID, principalID string) ([]EntryResponse, error)
- func SetEntryEnabled(ac *client.AlpaconClient, entryID string, enabled bool) (EntryResponse, error)
Constants ¶
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 ¶
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 string `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 {
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"`
Servers string `json:"servers" table:"Servers"`
Enabled bool `json:"enabled" table:"Enabled"`
ExpiresAt string `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.