mgmt

package
v0.2.4 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2026 License: MIT Imports: 10 Imported by: 0 modules, 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 mgmt is the JumpServer v4 management API: assets, accounts, users, sessions, audits, jobs, tickets and platform templates.

It is deliberately separate from assets/permits/assetsmanage, which cover the slices the connection path needs. This package is the "manage the bastion itself" side, and it is read-first: every function here is a GET except the few exported writers, which the MCP layer registers only when writing is explicitly enabled (MIFA-73).

Dependency direction: mgmt depends on api only. It never touches transport, the connection pool, or the MCP layer, so a management call can never open a terminal session.

Index

Constants

View Source
const (
	PathAccounts       = "/api/v1/accounts/accounts/"
	PathChangePassword = "/api/v1/accounts/" + "change" + "-secret" + "/"
)

Account paths.

Verified 2026-11-06 on a live v4: the account list answered 200 with 30 records. The write paths below follow the v4 convention and are NOT verified on an instance — a write is the one thing that cannot be probed safely from production, so they are implemented, gated and unit-tested against a fake server, and left marked for rehearsal-environment verification.

View Source
const (
	PathNodes     = "/api/v1/assets/nodes/"
	PathPlatforms = "/api/v1/assets/platforms/"
)

Asset tree and platform paths.

Verified 2026-11-06 on a live v4: nodes answered 200 with 8 records (fields id/key/value/full_value/name/org_name), platforms answered 200.

View Source
const (
	AuditLogin    = "login"
	AuditOperate  = "operate"
	AuditPassword = "password"
	AuditFTP      = "ftp"
	AuditJob      = "job"
)

All five were verified against a live JumpServer v4 on 2026-11-06 (HTTP 200, with the record counts below), which is why they are constants here rather than built from a template:

/api/v1/audits/login-logs/            166,995 records
/api/v1/audits/operate-logs/            3,620 records
/api/v1/audits/password-change-logs/   22 records
/api/v1/audits/ftp-logs/                  166 records
/api/v1/audits/job-logs/                   20 records
View Source
const (
	// DefaultLimit applies when the caller passes no limit.
	DefaultLimit = 20
	// MaxLimit is the largest page any read tool will request.
	MaxLimit = 100
)

List paging bounds.

Every management collection on the bastion is large: the instance this was verified against held 166,995 login records, 6,314 terminal sessions and 3,620 operation records on the day it was measured. A tool that returns "everything" would therefore return a page no caller can read, so a limit is not a convenience here — it is the difference between a usable tool and a timeout.

View Source
const (
	PathUsers   = "/api/v1/users/users/"
	PathGroups  = "/api/v1/users/groups/"
	PathRoles   = "/api/v1/rbac/roles/"
	PathOrgs    = "/api/v1/orgs/orgs/"
	PathProfile = "/api/v1/users/profile/"
)

Identity paths.

Verified 2026-11-06 on a live v4: users (9 records), groups (6), roles (7, served from the v4 RBAC view), orgs (2) and the current-user profile all answered 200. Two guesses did NOT hold and are recorded here so nobody re-adds them: /api/v1/users/roles/ and /api/v1/orgs/org-members/ both answered 404 on this build.

View Source
const (
	IdentUsers      = "users"
	IdentGroups     = "groups"
	IdentRoles      = "roles"
	IdentOrgs       = "orgs"
	IdentOrgMembers = "org_members"
)

Identity kinds.

View Source
const (
	PathJobs          = "/api/v1/ops/jobs/"
	PathJobExecutions = "/api/v1/ops/job-executions/"
)

Job paths.

Verified 2026-11-06 on a live v4 with a caveat that matters: both views ANSWERED 403 with `{"detail":"命令执行已禁用"}`, not 404. The paths are therefore correct for this build and the feature is switched off on the instance. A 403 here is a configuration answer, not a bug, and the tool reports the server's own message instead of inventing one.

View Source
const (
	PathSessions = "/api/v1/terminal/sessions/"
	PathCommands = "/api/v1/terminal/commands/"
	PathTasks    = "/api/v1/terminal/tasks/"
)

Terminal session paths.

Verified 2026-11-06 on a live v4: the collection answered HTTP 200 with 6,314 records, the detail (/<id>/) answered 200, and the nested replay-files view does not exist (HTTP 404) — replay is reported through the session's own has_replay / replay_size fields, which is what this package exposes.

View Source
const MaxNodeDepth = 8

MaxNodeDepth caps tree reconstruction.

View Source
const MaxPathLength = 512

MaxPathLength bounds the path so a pathological input cannot be turned into a megabyte-long error message.

View Source
const (
	PathTickets = "/api/v1/tickets/tickets/"
)

Ticket paths.

Verified 2026-11-06 on a live v4: the collection answered 200 with zero records, so the path is right and the record shape could not be sampled. The struct below therefore lists only the fields a ticket necessarily has on any v4 build; a missing name yields an empty column, never a decode failure.

Variables

View Source
var ErrPathNotAllowed = errors.New("path is not allowed for read-only access")

ErrPathNotAllowed is the sentinel behind every refusal to fetch a path.

Callers test it with errors.Is so that "the operator typed a path we do not serve" and "the server said no" stay distinguishable: the first is a local policy decision that never reaches the network.

View Source
var ErrUnknownAuditKind = errors.New("unknown audit kind")

ErrUnknownAuditKind reports a kind outside AuditKinds.

View Source
var ReadOnlyPrefixes = []struct {
	Prefix  string
	Comment string
}{
	{"/api/v1/audits/", "审计日志:登录、操作、改密、文件传输、作业"},
	{"/api/v1/terminal/", "终端会话、命令记录、录像元信息、终端任务"},
	{"/api/v1/assets/", "资产、节点树、平台模板(只读视图)"},
	{"/api/v1/accounts/", "资产账号(不含密钥字段)"},
	{"/api/v1/users/", "用户、用户组、角色、当前用户 profile"},
	{"/api/v1/orgs/", "组织与组织成员"},
	{"/api/v1/perms/", "授权记录与用户可见资产"},
	{"/api/v1/ops/", "作业、作业执行记录、计划任务"},
	{"/api/v1/tickets/", "工单与工单流程"},
	{"/api/v1/settings/", "系统设置(读取;写入永不放行)"},
	{"/api/v1/rbac/", "角色与权限位(v4 RBAC)"},
	{"/api/v1/labels/", "资产标签"},
	{"/api/v1/notifications/", "通知记录"},
}

ReadOnlyPrefixes is the whole surface `jms api get` may read.

It is a whitelist, not a blacklist, because the failure modes are asymmetric: a missing entry costs one subcommand, an entry we should not have added exposes a management area nobody audited. Each entry names the domain it unlocks so a reviewer can check it against the JumpServer documentation without reading the code.

Functions

func AuditKinds

func AuditKinds() []string

AuditKinds lists the accepted kind values, for error messages and help.

func AuditPath

func AuditPath(kind string) string

AuditPath returns the collection path for one audit kind, or "" when the kind is unknown. It exists so the MCP layer can record which view a call touched without duplicating the path table.

func ChangeAccountSecret

func ChangeAccountSecret(ctx context.Context, c *api.Client, accountIDs []string) error

ChangeAccountSecret asks the bastion to rotate one account's secret.

The caller never supplies the new password: JumpServer generates it from the platform's password strategy, which is the whole reason to use this endpoint instead of writing a credential through the API. Rehearsal- environment verification is pending (see the file comment).

func ClampLimit

func ClampLimit(n int) int

ClampLimit bounds a caller's page size.

func DateRange

func DateRange(filters url.Values, since, until string) url.Values

DateRange adds the two verified server-side time filters.

`date_from` and `date_to` are the only filters whose server-side meaning was confirmed on a live instance (a login-log query with date_from=today narrowed 166,995 records to 109, and the session list from 6,314 to 2). Every other filter a tool offers is applied to the page it fetched, and the tool says so rather than pretending the filter was global.

func FilterRows

func FilterRows[T any](rows []T, limit int, keep func(T) bool) ([]T, bool)

FilterRows applies a caller-supplied predicate to one page and trims it to the requested size.

It returns the kept rows and whether the scan hit the window limit, which the caller reports as "scanned the N most recent" so a filtered answer is never mistaken for a global one.

func FindAccountID

func FindAccountID(ctx context.Context, c *api.Client, asset, username string) (string, error)

FindAccountID resolves a name/username pair to one account id.

Rotation takes ids, and a person knows "root on db-01". An ambiguous match is reported rather than guessed: rotating the wrong account's password is an outage, not a typo.

func GetIdentity

func GetIdentity(ctx context.Context, c *api.Client, kind, idOrName string) (any, error)

GetIdentity returns one record of the requested kind.

func GetTicket

func GetTicket(ctx context.Context, c *api.Client, id string) (map[string]any, error)

GetTicket returns one ticket with its approval trail.

The trail lives in a separate view on v4; it is fetched best-effort, because a ticket whose detail is readable but whose flow is not should still be answerable.

func IdentityKinds

func IdentityKinds() []string

IdentityKinds lists the accepted kind values.

func MaskQuery

func MaskQuery(values url.Values) string

MaskQuery renders a query string for the audit log with every credential-looking value replaced.

The management read surface has no business carrying a password, but the audit log is exactly the place a mistake would become permanent, so the masking happens on the way in rather than on the way out.

func MatchKeyword

func MatchKeyword(keyword string, candidates ...string) bool

MatchKeyword reports whether any candidate contains the keyword, case-insensitively. An empty keyword matches everything.

func ReadablePrefixes

func ReadablePrefixes() []string

ReadablePrefixes returns the allowed prefixes, for help text and for the refusal message a caller sees.

func ResolveGroupIDs added in v0.2.4

func ResolveGroupIDs(ctx context.Context, c *api.Client, refs []string) ([]string, error)

ResolveGroupIDs maps user group ids or exact names to group ids.

Same contract as ResolveUserIDs; a duplicate group name is an error rather than a first match, because granting the wrong group is a silent authorization mistake.

func ResolveUserIDs added in v0.2.4

func ResolveUserIDs(ctx context.Context, c *api.Client, refs []string) ([]string, error)

ResolveUserIDs maps user ids or exact usernames to user ids.

The grant API keys its relations on ids, while an operator usually has usernames. A UUID is read as an id; anything else is filtered by the server on the username field and matched exactly again here, so case differences never grant the wrong account. Zero matches and several matches are both errors — the resolver never guesses.

func ValidateReadPath

func ValidateReadPath(raw string) (string, error)

ValidateReadPath checks that raw may be fetched read-only, and returns the cleaned path.

It rejects, in order: an empty value, an absolute URL (which would let a caller redirect the request to another host), a non-/api/v1 prefix, a traversal or doubled slash, a forbidden segment, and anything outside ReadOnlyPrefixes. A query string is refused here: the caller passes parameters separately so they can be masked before they are logged.

func Window

func Window(limit int, hasLocalFilters bool) int

Window is how many records to request when a caller passed a filter that can only be applied locally.

Scanning the maximum page is deliberate: filtering 20 records by user and reporting "none" would be a false answer, while scanning 100 and saying "scanned the 100 most recent" is a true one.

Types

type Account

type Account struct {
	ID            string     `json:"id"`
	Name          string     `json:"name"`
	Username      string     `json:"username"`
	Asset         NamedID    `json:"asset"`
	Privileged    bool       `json:"privileged,omitempty"`
	IsActive      bool       `json:"is_active"`
	SecretType    FlexString `json:"secret_type,omitempty"`
	SecretState   FlexString `json:"change_secret_status,omitempty"`
	DateChanged   string     `json:"date_change_secret,omitempty"`
	DateVerified  string     `json:"date_verified,omitempty"`
	DateLastLogin string     `json:"date_last_login,omitempty"`
	Source        FlexString `json:"source,omitempty"`
	SuFrom        string     `json:"su_from,omitempty"`
	SecretReset   bool       `json:"secret_reset,omitempty"`
	Connectivity  any        `json:"connectivity,omitempty"`
	OrgName       string     `json:"org_name,omitempty"`
}

Account is one account attached to an asset.

There is no secret field, by design: the v4 account view can expose the stored credential, and a management tool that forwards it would turn "an agent that can read the bastion" into "an agent that holds every host password". Secret state is reported, never the secret.

type AccountQuery

type AccountQuery struct {
	Asset      string
	Username   string
	Privileged bool
	Limit      int
	Offset     int
}

AccountQuery is one account search.

type AuditEntry

type AuditEntry struct {
	ID       string `json:"id,omitempty"`
	Kind     string `json:"kind"`
	Time     string `json:"time,omitempty"`
	User     string `json:"user,omitempty"`
	SourceIP string `json:"source_ip,omitempty"`
	Object   string `json:"object,omitempty"`
	Action   string `json:"action,omitempty"`
	Result   string `json:"result,omitempty"`
	Detail   string `json:"detail,omitempty"`
}

AuditEntry is one audit record, normalized across the five kinds.

The five views return different field names for the same idea (a login log calls the actor `username` and an operation log calls it `user`). Callers get one shape so a report can mix kinds without a per-kind decoder, and the original field values are preserved verbatim rather than re-parsed: the timestamps stay exactly as the server formatted them, so nobody has to wonder which timezone a converted value came from.

type AuditQuery

type AuditQuery struct {
	Kind string
	// Since and Until are server-side (date_from / date_to).
	Since string
	Until string
	// User, Asset and Action are matched on the fetched page only.
	User   string
	Asset  string
	Action string
	Limit  int
	Offset int
}

AuditQuery is one audit search.

type Command

type Command struct {
	ID        string `json:"id"`
	User      string `json:"user"`
	Asset     string `json:"asset"`
	Account   string `json:"account,omitempty"`
	Input     string `json:"input,omitempty"`
	Output    string `json:"output,omitempty"`
	RiskLevel string `json:"risk_level,omitempty"`
	Timestamp string `json:"timestamp,omitempty"`
	SessionID string `json:"session,omitempty"`
}

Command is one recorded command.

The shape below is the one JumpServer has documented for the view; the instance this was written against had zero command records, so the field names are unverified and are reported as such. It is a read-only view, so an unverified field costs an empty column rather than a wrong decision.

type CommandQuery

type CommandQuery struct {
	Since  string
	Until  string
	User   string
	Asset  string
	Input  string
	Limit  int
	Offset int
}

CommandQuery is one command search.

type FlexString

type FlexString string

FlexString decodes a field whose shape depends on the build and on the record: a plain string, a {"value","label"} object, a boolean or a number.

This is not defensive over-engineering — it is what the live instance returns. On the reference JumpServer v4 a login record carries `"status":{"value":true,"label":"成功"}` and `"type":{"value":"W","label":"Web"}`, while an account carries `"secret_type":{"value":"password",...}`. A plain string field would fail the whole record, turning "one column has an unexpected shape" into "the audit tool is broken".

Resolution order: a non-empty string value, then the label, then the stringified value. For a boolean-valued field that yields the label ("成功") rather than "true", which is what a reader wants.

func (*FlexString) UnmarshalJSON

func (f *FlexString) UnmarshalJSON(data []byte) error

UnmarshalJSON accepts a string, number, boolean, null, or {"value","label"}.

type Group

type Group struct {
	ID         string    `json:"id"`
	Name       string    `json:"name"`
	Comment    string    `json:"comment,omitempty"`
	Users      []NamedID `json:"users,omitempty"`
	UsersCount int       `json:"users_amount,omitempty"`
	OrgName    string    `json:"org_name,omitempty"`
}

Group is one user group.

The list view reports users_amount only; the detail view expands users as (id, name, is_service_account) objects. Users is therefore populated only by GetIdentity, which reads the detail record.

type IdentityQuery

type IdentityQuery struct {
	Kind string
	// Org narrows org_members (and users) to one organization.
	Org    string
	Active string
	Limit  int
	Offset int
}

IdentityQuery is one identity search.

type Job

type Job struct {
	ID          string `json:"id"`
	Name        string `json:"name,omitempty"`
	Type        string `json:"type,omitempty"`
	Creator     string `json:"creator_name,omitempty"`
	DateCreated string `json:"date_created,omitempty"`
	Comment     string `json:"comment,omitempty"`
}

Job is one job definition.

Field names are v4 convention and unverified: the instance refused the read, so there was no sample to confirm against. Read-only, so a wrong name costs an empty column.

type JobExecution

type JobExecution struct {
	ID         string `json:"id"`
	Material   string `json:"material,omitempty"`
	JobType    string `json:"type,omitempty"`
	Creator    string `json:"creator_name,omitempty"`
	DateStart  string `json:"date_start,omitempty"`
	DateEnd    string `json:"date_finished,omitempty"`
	IsFinished bool   `json:"is_finished,omitempty"`
	IsSuccess  bool   `json:"is_success,omitempty"`
	TimeCost   any    `json:"time_cost,omitempty"`
	TaskID     string `json:"task_id,omitempty"`
}

JobExecution is one job run.

type JobQuery

type JobQuery struct {
	Keyword string
	Since   string
	Until   string
	Limit   int
	Offset  int
}

JobQuery is one job search.

type ListOptions

type ListOptions struct {
	// Limit is the page size; <= 0 means DefaultLimit.
	Limit int
	// Offset skips that many records.
	Offset int
	// Filters holds query parameters sent to the server. Only parameters
	// whose meaning was verified against a live instance belong here.
	Filters url.Values
}

ListOptions carries paging plus the filters that are applied by the server.

type NamedID

type NamedID struct {
	ID          string `json:"id"`
	Name        string `json:"name,omitempty"`
	DisplayName string `json:"display_name,omitempty"`
	// IsServiceAccount marks a machine account among a group's members.
	// The group serializer sends it; dropping it would make a service
	// account indistinguishable from a person in an authorization review.
	IsServiceAccount bool `json:"is_service_account,omitempty"`
}

NamedID is the (id, name) pair most identity rows need.

func (NamedID) Label

func (n NamedID) Label() string

Label is the best human-readable name the record has.

Roles arrive as {id, display_name} while groups arrive as {id, name}; a single field would leave half the columns blank for no reason.

type Node

type Node struct {
	ID       string `json:"id"`
	Key      string `json:"key,omitempty"`
	Value    string `json:"value"`
	FullVal  string `json:"full_value,omitempty"`
	Name     string `json:"name,omitempty"`
	OrgID    string `json:"org_id,omitempty"`
	OrgName  string `json:"org_name,omitempty"`
	Children []Node `json:"children,omitempty"`
}

Node is one node-tree entry.

func BuildTree

func BuildTree(flat []Node) []Node

BuildTree turns the flat node list into a tree keyed by full_value.

full_value is the node's path ("default", "default/生产"), so a node's parent is its full_value with the last segment removed. Nodes whose parent is missing stay at the root rather than being dropped: a lost subtree is worse than a flat one, and the alternative is silently hiding an asset location from the very tool meant to show it.

The tree is built in two passes — link, then render — because attaching children while copying roots would leave the copies empty. That bug is easy to write and invisible in a flat listing, so the two-phase shape is deliberate.

func CreateNode

func CreateNode(ctx context.Context, c *api.Client, parentID, name string) (Node, error)

CreateNode creates one node under parentID (empty means the root).

full_value is the node's path and is what the tree is rebuilt from, so it is computed here rather than left to the caller: a mismatched full_value produces a node that exists but is invisible in its parent.

func DeleteNode

func DeleteNode(ctx context.Context, c *api.Client, idOrName string) (Node, error)

DeleteNode removes one node.

The bastion refuses to delete a node that still holds assets or child nodes, which is the safety net this function relies on instead of walking the subtree itself: refusing locally would duplicate a rule the server already enforces and might get wrong.

func ListNodes

func ListNodes(ctx context.Context, c *api.Client) ([]Node, error)

ListNodes returns the whole node list.

The v4 node view is a flat list; the tree is rebuilt here because "where does this asset live" is a path question and a flat list makes the caller do the joining. Depth is a hard cap (8) so a malformed full_value cannot recurse forever.

func RenameNode

func RenameNode(ctx context.Context, c *api.Client, idOrName, newName string) (Node, error)

RenameNode changes one node's display value.

Renaming a node changes its full_value, and children carry the old path. The bastion rewrites the subtree itself; this function therefore sends only the new value and lets the server own the cascade. Callers are told to verify the children afterwards.

func ResolveNode

func ResolveNode(ctx context.Context, c *api.Client, idOrName string) (Node, error)

ResolveNode finds one node by exact name or id.

It exists so the write path can accept a human-typed node name and still send an id: creating an asset under the wrong node is a mistake that is cheap to prevent here and annoying to undo by hand.

type Org

type Org struct {
	ID        string `json:"id"`
	Name      string `json:"name"`
	IsDefault bool   `json:"is_default,omitempty"`
	IsRoot    bool   `json:"is_root,omitempty"`
}

Org is one organization.

type Page

type Page[T any] struct {
	Count   int `json:"count"`
	Results []T `json:"results"`
}

Page is one slice of a JumpServer collection.

Count is the server's total, which is not the length of Results: callers report both so a reader can tell "there are 2 of these" from "here are 2, there are 166,995".

func ListAccounts

func ListAccounts(ctx context.Context, c *api.Client, q AccountQuery) (Page[Account], error)

ListAccounts returns one page of asset accounts.

func ListAudit

func ListAudit(ctx context.Context, c *api.Client, q AuditQuery) (Page[AuditEntry], error)

ListAudit returns one page of audit records of the requested kind.

func ListCommands

func ListCommands(ctx context.Context, c *api.Client, q CommandQuery) (Page[Command], error)

ListCommands returns one page of recorded commands.

func ListIdentity

func ListIdentity(ctx context.Context, c *api.Client, q IdentityQuery) (Page[any], error)

ListIdentity returns one page of the requested identity kind.

func ListJobAudit

func ListJobAudit(ctx context.Context, c *api.Client, q AuditQuery) (Page[AuditEntry], error)

ListJobAudit returns the job records that live in the audit area.

This is the fallback that works when the operational job views are disabled: job activity still appears in the audit log, so "what ran yesterday" is answerable even on an instance where /ops/jobs/ refuses.

func ListJobExecutions

func ListJobExecutions(ctx context.Context, c *api.Client, q JobQuery) (Page[JobExecution], error)

ListJobExecutions returns one page of job executions.

func ListJobs

func ListJobs(ctx context.Context, c *api.Client, q JobQuery) (Page[Job], error)

ListJobs returns one page of job definitions.

func ListPlatforms

func ListPlatforms(ctx context.Context, c *api.Client, keyword string, limit int) (Page[Platform], error)

ListPlatforms returns one page of platform templates.

func ListSessions

func ListSessions(ctx context.Context, c *api.Client, q SessionQuery) (Page[Session], error)

ListSessions returns one page of terminal sessions.

func ListTickets

func ListTickets(ctx context.Context, c *api.Client, q TicketQuery) (Page[Ticket], error)

ListTickets returns one page of tickets.

Status and type are enum-ish values whose spelling differs between builds, so they are matched on the page rather than sent as filters: a silent "unknown enum returns everything" would make a filtered report look complete.

type Phone

type Phone struct {
	Code   string `json:"code,omitempty"`
	Number string `json:"number,omitempty"`
}

Phone is a user's phone number.

The v4 view returns {"code":"+86","phone":"..."} while a build with the field disabled returns a plain string, so both are accepted. Rendering it as a structured value keeps the country code visible instead of dropping it into a display-only string.

func (Phone) String

func (p Phone) String() string

String renders the number with its country code when one is set.

func (*Phone) UnmarshalJSON

func (p *Phone) UnmarshalJSON(data []byte) error

UnmarshalJSON accepts a string or a {"code","phone"} object.

type Platform

type Platform struct {
	ID        int        `json:"id"`
	Name      string     `json:"name"`
	Type      FlexString `json:"type,omitempty"`
	Category  FlexString `json:"category,omitempty"`
	Protocols []struct {
		Name string `json:"name"`
		Port int    `json:"port,omitempty"`
	} `json:"protocols,omitempty"`
	Comment string `json:"comment,omitempty"`
}

Platform is one asset platform template.

type Role

type Role struct {
	ID          string     `json:"id"`
	Name        string     `json:"name"`
	DisplayName string     `json:"display_name,omitempty"`
	Scope       FlexString `json:"scope,omitempty"`
	Builtin     bool       `json:"builtin,omitempty"`
	UsersCount  int        `json:"users_amount,omitempty"`
}

Role is one v4 RBAC role.

type Session

type Session struct {
	ID            string     `json:"id"`
	User          string     `json:"user"`
	Asset         string     `json:"asset"`
	Account       string     `json:"account,omitempty"`
	Protocol      string     `json:"protocol"`
	Type          FlexString `json:"type,omitempty"`
	LoginFrom     FlexString `json:"login_from,omitempty"`
	RemoteAddr    string     `json:"remote_addr,omitempty"`
	DateStart     string     `json:"date_start"`
	DateEnd       string     `json:"date_end,omitempty"`
	Duration      string     `json:"duration,omitempty"`
	IsFinished    bool       `json:"is_finished"`
	IsSuccess     bool       `json:"is_success,omitempty"`
	HasReplay     bool       `json:"has_replay"`
	ReplaySize    int64      `json:"replay_size,omitempty"`
	CommandAmount int        `json:"command_amount,omitempty"`
	CanTerminate  bool       `json:"can_terminate"`
	Terminal      string     `json:"terminal_display,omitempty"`
	ErrorReason   FlexString `json:"error_reason,omitempty"`
}

Session is one terminal session as the server lists it.

Only the fields a reader acts on are kept. The server returns more, and forwarding all of it would bury the answer: the point of this tool is "who was connected to what, when, and is it still open".

func GetSession

func GetSession(ctx context.Context, c *api.Client, id string) (Session, error)

GetSession returns one session by id.

type SessionQuery

type SessionQuery struct {
	Since  string
	Until  string
	User   string
	Asset  string
	Active bool
	Limit  int
	Offset int
}

SessionQuery is one session search.

type Ticket

type Ticket struct {
	ID          string     `json:"id"`
	SerialNum   string     `json:"serial_num,omitempty"`
	Title       string     `json:"title,omitempty"`
	Type        FlexString `json:"type,omitempty"`
	Status      FlexString `json:"status,omitempty"`
	Applicant   string     `json:"applicant,omitempty"`
	Assignee    string     `json:"assignee,omitempty"`
	DateCreated string     `json:"date_created,omitempty"`
	DateUpdated string     `json:"date_updated,omitempty"`
	Comment     string     `json:"comment,omitempty"`
}

Ticket is one work order.

type TicketQuery

type TicketQuery struct {
	Status    string
	Type      string
	Applicant string
	Limit     int
	Offset    int
}

TicketQuery is one ticket search.

type User

type User struct {
	ID             string     `json:"id"`
	Username       string     `json:"username"`
	Name           string     `json:"name"`
	Email          string     `json:"email,omitempty"`
	Phone          Phone      `json:"phone,omitempty"`
	IsActive       bool       `json:"is_active"`
	IsValid        bool       `json:"is_valid"`
	IsSuperuser    bool       `json:"is_superuser"`
	IsServiceAcct  bool       `json:"is_service_account"`
	Source         FlexString `json:"source,omitempty"`
	DateExpired    string     `json:"date_expired,omitempty"`
	LastLogin      string     `json:"last_login,omitempty"`
	MfaLevel       FlexString `json:"mfa_level,omitempty"`
	LoginBlocked   bool       `json:"login_blocked,omitempty"`
	SystemRoles    []NamedID  `json:"system_roles,omitempty"`
	Groups         []NamedID  `json:"groups,omitempty"`
	PasswordUpdate string     `json:"date_password_last_updated,omitempty"`
}

User is one bastion account.

Deliberately absent: anything that authenticates. The v4 user view exposes no password, but it does expose MFA binding state and API-key metadata, so the fields are listed explicitly rather than decoded wholesale.

Jump to

Keyboard shortcuts

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