Documentation
¶
Overview ¶
Package assets looks up JumpServer assets and resolves their connection parameters.
Endpoints and selection rules mirror the Python reference implementation (DESIGN.md「KoKo 协议」的「认证」). The account-selection order in particular is not arbitrary: the connection-token API requires the account *alias* (e.g. "@USER"), and the server rejects the display name.
Dependency direction: assets depends on api.
Index ¶
Constants ¶
const (
PathSelfAssets = "/api/v1/perms/users/self/assets/"
)
PathSelfAssets is the listing endpoint; a detail request appends "<id>/".
Variables ¶
var ErrNotFound = errors.New("asset not found")
ErrNotFound is returned when no asset matches a name.
Functions ¶
func SelectAccount ¶
SelectAccount picks the best account alias: @USER > a named account > @INPUT.
The connection-token API needs the account *alias* (e.g. "@USER"), not the display name (e.g. "Dynamic user"). An entry that carries neither a usable alias nor username is skipped, which is why the "@USER" scan is a separate pass.
func SelectProtocol ¶
SelectProtocol picks the best protocol, preferring ssh (case insensitive). It returns the canonical lower-case "ssh" so callers do not have to normalize.
Types ¶
type Asset ¶
type Asset struct {
ID string `json:"id"`
Name string `json:"name"`
Address string `json:"address"`
Platform string `json:"platform"`
// Type is the asset type label (e.g. "Linux", "网站"). The API returns
// it as {"label":...,"value":...} or as a bare string.
Type string `json:"type"`
}
Asset is one row of an asset listing.
type Info ¶
type Info struct {
ID string
Name string
Address string
Account string
Protocol string
Platform string
Type string
OrgID string
}
Info is a resolved, connectable asset.
func Resolve ¶
Resolve searches an asset by name and resolves its connection parameters. An exact name match wins; otherwise the first decodable search result is used.
account and protocol override the automatic selection when non-empty.
Errors: ErrNotFound (wrapped) when the search yields no usable asset.