Documentation
¶
Overview ¶
Package privileges renders a set of Jamf Platform API capability permissions into the words Jamf Account prints beside its checkboxes.
It exists because the two vocabularies a 403 can be about are not interchangeable, and neither is derivable from the other. A Jamf Pro instance enforces API-role privileges with names like "Read Categories"; the platform gateway enforces GA capability permissions like categories:read, granted in Jamf Account when the API integration is created. The GA consolidation mapped several pre-GA privileges onto one capability, so no per-row translation exists in either direction — the only correct thing to do is print the vocabulary that matches the credential in hand, which is why the caller selects the source (see EnrichPrivilegeError) rather than this package guessing.
The capability slugs come from a spec — specs/gateway/coverage.json for Pro and Classic through the gateway, x-required-privileges for Platform commands. catalogue.go turns a slug into a section and permission name, and nothing else in here invents a requirement.
Index ¶
Constants ¶
const Marker = "Jamf Platform API integration"
Marker opens every hint this package renders, and is the sentinel by which a later enrichment pass recognises one.
It exists because two layers can each answer a 403 and only one vocabulary is correct per credential: internal/client renders the gateway capability permissions for the request it actually sent (only it knows the method and path), while EnrichPrivilegeError would otherwise append the command's Jamf Pro API-role privilege names. Matching on this marker rather than threading the resolved auth method down to the error formatter keeps the test for "has a platform answer already been given" where the answer is.
Variables ¶
This section is empty.
Functions ¶
func GatewayFallbackHint ¶
func GatewayFallbackHint() string
GatewayFallbackHint is the answer for a gateway 403 whose operation has no recorded capability permission — an unserved path, an unauthenticated endpoint, or a tree generated without the coverage manifest. It names the right console and the right vocabulary without inventing a permission, and it carries Marker so the Jamf Pro privilege names are still suppressed: on a gateway credential those name grants that cannot be made.
func Hint ¶
Hint renders the permissions as a remediation hint for a gateway 403, or "" when there is nothing to say. The output is one line: exitcode.Error.Hint is printed as a single "hint:" line and included verbatim in the JSON error envelope.
Every row carries both halves — the picker names to tick and the capability slug behind them — because the two audiences are different and both are reading the same line. The slug is what the gateway's own error, the `commands -o json` catalog and Jamf's spec use; the names are the only way to find the checkbox, since the picker is searched by name.
Types ¶
type Requirement ¶
type Requirement struct {
Category string
Permission string
Actions []string
Slugs []string
// Unknown marks a capability with no catalogue row. Rendered verbatim
// rather than dropped: a permission this CLI cannot name is still a
// permission the operator has to find, and silently omitting it would
// describe an integration that cannot make the call.
Unknown bool
}
Requirement is one row of Jamf Account's permission picker: the section, the permission name, and every action on it the caller needs. One row per capability rather than one per capability-action pair, because that is how the picker presents it — a permission with a checkbox per action — which collapses an ordinary CRUD run into a single row.
Slugs holds the capability permissions that produced the row, in the form the spec declared them. It is rendered alongside the names because the names are what a human ticks and the slugs are what an error message from the gateway, or the commands catalog, will say.
func Collect ¶
func Collect(scopes []string) []Requirement
Collect turns capability permissions in {capability}:{action} form into deduplicated picker rows, sorted by section then permission name. That order comes from the catalogue rather than from a second hand-maintained list: Jamf Account's row order is a weaker contract than its names, since the picker can be reordered without anything being renamed.
A slug this package cannot parse is kept as its own row rather than merged into a sibling, so an unreadable value cannot disappear into another row's checkboxes.
func (Requirement) ActionLabels ¶
func (r Requirement) ActionLabels() []string
ActionLabels renders the row's actions as the picker labels them, in the article's own order — so an ordinary CRUD row reads "Create, Read, Update, Delete" rather than alphabetically. An action with no label is printed verbatim, after the known ones.
func (Requirement) String ¶
func (r Requirement) String() string
String renders one row as "Section > Permission: Read, Update (slug, slug)".