Documentation
¶
Index ¶
- type AccessLogCountryStat
- type AccessLogQuery
- type AccessLogView
- type AddressView
- type DeviceDetail
- type DeviceView
- type GroupRef
- type HTTPHandler
- func (h *HTTPHandler) GetAccessLog(ctx context.Context, request httpapi.GetAccessLogRequestObject) (httpapi.GetAccessLogResponseObject, error)
- func (h *HTTPHandler) GetAccessLogByCountry(ctx context.Context, request httpapi.GetAccessLogByCountryRequestObject) (httpapi.GetAccessLogByCountryResponseObject, error)
- func (h *HTTPHandler) GetDevice(ctx context.Context, request httpapi.GetDeviceRequestObject) (httpapi.GetDeviceResponseObject, error)
- func (h *HTTPHandler) GetDeviceAddresses(ctx context.Context, request httpapi.GetDeviceAddressesRequestObject) (httpapi.GetDeviceAddressesResponseObject, error)
- func (h *HTTPHandler) GetDevices(ctx context.Context, _ httpapi.GetDevicesRequestObject) (httpapi.GetDevicesResponseObject, error)
- func (h *HTTPHandler) GetDevicesByUser(ctx context.Context, request httpapi.GetDevicesByUserRequestObject) (httpapi.GetDevicesByUserResponseObject, error)
- func (h *HTTPHandler) GetPolicyUserMap(ctx context.Context, _ httpapi.GetPolicyUserMapRequestObject) (httpapi.GetPolicyUserMapResponseObject, error)
- func (h *HTTPHandler) GetUserHostDetails(ctx context.Context, request httpapi.GetUserHostDetailsRequestObject) (httpapi.GetUserHostDetailsResponseObject, error)
- func (h *HTTPHandler) ListHostGroups(ctx context.Context, _ httpapi.ListHostGroupsRequestObject) (httpapi.ListHostGroupsResponseObject, error)
- func (h *HTTPHandler) ListHostSuggestions(ctx context.Context, _ httpapi.ListHostSuggestionsRequestObject) (httpapi.ListHostSuggestionsResponseObject, error)
- func (h *HTTPHandler) ListKnownHosts(ctx context.Context, _ httpapi.ListKnownHostsRequestObject) (httpapi.ListKnownHostsResponseObject, error)
- func (h *HTTPHandler) ListUsers(ctx context.Context, _ httpapi.ListUsersRequestObject) (httpapi.ListUsersResponseObject, error)
- func (h *HTTPHandler) ListUsersHostAccess(ctx context.Context, _ httpapi.ListUsersHostAccessRequestObject) (httpapi.ListUsersHostAccessResponseObject, error)
- type HostAccessKind
- type HostGroupWithMembers
- type HostSuggestion
- type HostSuggestionsPage
- type KnownHostStats
- type PolicyMapReader
- type Repository
- func (r *Repository) BuildPolicyUserMap(ctx context.Context, reader PolicyMapReader) (httpapi.PolicyUserMapAudit, error)
- func (r *Repository) DeviceExists(ctx context.Context, deviceID device.DeviceID) (bool, error)
- func (r *Repository) GetAllUsers(ctx context.Context) ([]UserView, error)
- func (r *Repository) GetDeviceAddresses(ctx context.Context, deviceID device.DeviceID) ([]AddressView, error)
- func (r *Repository) GetDeviceDetail(ctx context.Context, id device.DeviceID) (*DeviceDetail, error)
- func (r *Repository) GetDevices(ctx context.Context, ownerID *auth.UserID) ([]DeviceView, error)
- func (r *Repository) GetDevicesByUser(ctx context.Context, targetUserID auth.UserID) ([]DeviceView, error)
- func (r *Repository) GetHostGroupsWithMembers(ctx context.Context) ([]HostGroupWithMembers, error)
- func (r *Repository) GetHostSuggestionsPage(ctx context.Context) (HostSuggestionsPage, error)
- func (r *Repository) GetKnownHostsWithStats(ctx context.Context) ([]KnownHostStats, error)
- func (r *Repository) GetUserAccessEditor(ctx context.Context, userID auth.UserID) (UserAccessEditor, error)
- func (r *Repository) ListAccessLog(ctx context.Context, q AccessLogQuery) ([]AccessLogView, int, error)
- func (r *Repository) ListAccessLogStatsByCountry(ctx context.Context, from, to time.Time) ([]AccessLogCountryStat, error)
- func (r *Repository) ListUserAccessRows(ctx context.Context) ([]UserAccessRow, error)
- type UserAccessEditor
- type UserAccessGroupOption
- type UserAccessHostOption
- type UserAccessRow
- type UserAccessSummary
- type UserSummary
- type UserView
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AccessLogCountryStat ¶
type AccessLogCountryStat struct {
CountryCode string
CountryName string
ContinentCode string
Total int64
Allowed int64
Denied int64
}
AccessLogCountryStat holds aggregated request counts for a single country.
type AccessLogQuery ¶
type AccessLogQuery struct {
From time.Time
To time.Time
BeforeID *int64 // cursor: return rows with id < BeforeID; nil for first page
ClientIP *string
Outcome *bool
DenyReason *string
DeviceID *device.DeviceID
TargetHost *string
CountryCode *string
ContinentCode *string
Limit int
}
func NewAccessLogQuery ¶
func NewAccessLogQuery(params httpapi.GetAccessLogParams) AccessLogQuery
type AccessLogView ¶
type AccessLogView struct {
ID int64
ClientIP string
Outcome bool
DenyReason *string
DeviceID *device.DeviceID
DeviceName *string
AddressID *device.AddressID
CreatedAt time.Time
DurationUs int64
XFFChain *string
TargetHost *string
TargetURI *string
HTTPMethod *string
Headers map[string][]string
CountryCode *string
CountryName *string
ContinentCode *string
ASN *int64
ASNOrg *string
}
type AddressView ¶
type DeviceDetail ¶ added in v0.3.0
type DeviceDetail struct {
ID device.DeviceID `db:"id"`
Name string `db:"name"`
DeviceType device.DeviceType `db:"device_type"`
Description *string `db:"description"`
Icon *string `db:"icon"`
CreatedAt time.Time `db:"created_at"`
UpdatedAt time.Time `db:"updated_at"`
KeyPrefix *string `db:"key_prefix"`
AddressCount int `db:"address_count"`
LastSeenAt *database.DBTime `db:"last_seen_at"`
OwnerID auth.UserID `db:"owner_id"`
OwnerName string `db:"owner_name"`
}
type DeviceView ¶
type DeviceView struct {
ID device.DeviceID `db:"id"`
Name string `db:"name"`
DeviceType device.DeviceType `db:"device_type"`
Description *string `db:"description"`
Icon *string `db:"icon"`
CreatedAt time.Time `db:"created_at"`
UpdatedAt time.Time `db:"updated_at"`
KeyPrefix *string `db:"key_prefix"`
AddressCount int `db:"address_count"`
LastSeenAt *database.DBTime `db:"last_seen_at"`
OwnerID auth.UserID `db:"owner_id"`
OwnerName string `db:"owner_name"`
}
type GroupRef ¶ added in v0.3.0
type GroupRef struct {
ID hostaccess.HostGroupID
Name string
}
type HTTPHandler ¶
type HTTPHandler struct {
// contains filtered or unexported fields
}
func NewHTTPHandler ¶
func NewHTTPHandler(repo *Repository, policyReader PolicyMapReader, logger *slog.Logger) *HTTPHandler
func (*HTTPHandler) GetAccessLog ¶
func (h *HTTPHandler) GetAccessLog( ctx context.Context, request httpapi.GetAccessLogRequestObject, ) (httpapi.GetAccessLogResponseObject, error)
func (*HTTPHandler) GetAccessLogByCountry ¶
func (h *HTTPHandler) GetAccessLogByCountry( ctx context.Context, request httpapi.GetAccessLogByCountryRequestObject, ) (httpapi.GetAccessLogByCountryResponseObject, error)
func (*HTTPHandler) GetDevice ¶ added in v0.3.0
func (h *HTTPHandler) GetDevice(ctx context.Context, request httpapi.GetDeviceRequestObject) (httpapi.GetDeviceResponseObject, error)
func (*HTTPHandler) GetDeviceAddresses ¶
func (h *HTTPHandler) GetDeviceAddresses( ctx context.Context, request httpapi.GetDeviceAddressesRequestObject, ) (httpapi.GetDeviceAddressesResponseObject, error)
func (*HTTPHandler) GetDevices ¶
func (h *HTTPHandler) GetDevices( ctx context.Context, _ httpapi.GetDevicesRequestObject, ) (httpapi.GetDevicesResponseObject, error)
func (*HTTPHandler) GetDevicesByUser ¶ added in v0.3.0
func (h *HTTPHandler) GetDevicesByUser( ctx context.Context, request httpapi.GetDevicesByUserRequestObject, ) (httpapi.GetDevicesByUserResponseObject, error)
func (*HTTPHandler) GetPolicyUserMap ¶ added in v0.3.0
func (h *HTTPHandler) GetPolicyUserMap( ctx context.Context, _ httpapi.GetPolicyUserMapRequestObject, ) (httpapi.GetPolicyUserMapResponseObject, error)
GetPolicyUserMap returns the user-pivoted policy cache audit view.
func (*HTTPHandler) GetUserHostDetails ¶ added in v0.3.0
func (h *HTTPHandler) GetUserHostDetails( ctx context.Context, request httpapi.GetUserHostDetailsRequestObject, ) (httpapi.GetUserHostDetailsResponseObject, error)
func (*HTTPHandler) ListHostGroups ¶ added in v0.3.0
func (h *HTTPHandler) ListHostGroups( ctx context.Context, _ httpapi.ListHostGroupsRequestObject, ) (httpapi.ListHostGroupsResponseObject, error)
func (*HTTPHandler) ListHostSuggestions ¶ added in v0.3.0
func (h *HTTPHandler) ListHostSuggestions( ctx context.Context, _ httpapi.ListHostSuggestionsRequestObject, ) (httpapi.ListHostSuggestionsResponseObject, error)
func (*HTTPHandler) ListKnownHosts ¶ added in v0.3.0
func (h *HTTPHandler) ListKnownHosts( ctx context.Context, _ httpapi.ListKnownHostsRequestObject, ) (httpapi.ListKnownHostsResponseObject, error)
func (*HTTPHandler) ListUsers ¶ added in v0.3.0
func (h *HTTPHandler) ListUsers( ctx context.Context, _ httpapi.ListUsersRequestObject, ) (httpapi.ListUsersResponseObject, error)
func (*HTTPHandler) ListUsersHostAccess ¶ added in v0.3.0
func (h *HTTPHandler) ListUsersHostAccess( ctx context.Context, _ httpapi.ListUsersHostAccessRequestObject, ) (httpapi.ListUsersHostAccessResponseObject, error)
type HostAccessKind ¶ added in v0.3.0
type HostAccessKind string
HostAccessKind is the computed access state for a single host in the drawer.
const ( HostAccessNone HostAccessKind = "none" HostAccessDirect HostAccessKind = "direct" HostAccessViaGroup HostAccessKind = "via_group" HostAccessDirectAndVia HostAccessKind = "direct_and_via_group" HostAccessAllowAll HostAccessKind = "allow_all" )
type HostGroupWithMembers ¶ added in v0.3.0
type HostGroupWithMembers struct {
ID hostaccess.HostGroupID
Name string
Color *string
Description *string
Icon *string
CreatedAt time.Time
Hosts []hostaccess.KnownHostRef
MemberIDs []hostaccess.KnownHostID
}
type HostSuggestion ¶ added in v0.3.0
type HostSuggestionsPage ¶ added in v0.3.0
type HostSuggestionsPage struct {
Suggestions []HostSuggestion
Ignored []hostaccess.IgnoredHostSuggestion
}
type KnownHostStats ¶ added in v0.3.0
type KnownHostStats struct {
ID hostaccess.KnownHostID `db:"id"`
FQDN string `db:"fqdn"`
Icon *string `db:"icon"`
CreatedAt time.Time `db:"created_at"`
UserCount int `db:"user_count"`
Groups []GroupRef
}
type PolicyMapReader ¶ added in v0.3.0
type PolicyMapReader interface {
GetPolicyMap() policy.PolicyMapSnapshot
}
PolicyMapReader is the cross-domain interface consumed by the queries package. Implemented by policy.Service.
type Repository ¶
type Repository struct {
// contains filtered or unexported fields
}
func NewRepository ¶
func NewRepository(db *database.DB) *Repository
func (*Repository) BuildPolicyUserMap ¶ added in v0.3.0
func (r *Repository) BuildPolicyUserMap( ctx context.Context, reader PolicyMapReader, ) (httpapi.PolicyUserMapAudit, error)
BuildPolicyUserMap is the single business-logic entry point for the user-pivoted policy audit view. The handler is a thin wrapper around it. This is the integration-test target for orchestration; pure assembly is tested separately via assemblePolicyUserMap.
func (*Repository) DeviceExists ¶
func (*Repository) GetAllUsers ¶ added in v0.3.0
func (r *Repository) GetAllUsers(ctx context.Context) ([]UserView, error)
func (*Repository) GetDeviceAddresses ¶
func (r *Repository) GetDeviceAddresses(ctx context.Context, deviceID device.DeviceID) ([]AddressView, error)
func (*Repository) GetDeviceDetail ¶ added in v0.3.0
func (r *Repository) GetDeviceDetail(ctx context.Context, id device.DeviceID) (*DeviceDetail, error)
func (*Repository) GetDevices ¶
func (r *Repository) GetDevices(ctx context.Context, ownerID *auth.UserID) ([]DeviceView, error)
GetDevices retrieves devices for a specific user or all users when ownerID is nil
func (*Repository) GetDevicesByUser ¶ added in v0.3.0
func (r *Repository) GetDevicesByUser(ctx context.Context, targetUserID auth.UserID) ([]DeviceView, error)
func (*Repository) GetHostGroupsWithMembers ¶ added in v0.3.0
func (r *Repository) GetHostGroupsWithMembers(ctx context.Context) ([]HostGroupWithMembers, error)
func (*Repository) GetHostSuggestionsPage ¶ added in v0.3.0
func (r *Repository) GetHostSuggestionsPage(ctx context.Context) (HostSuggestionsPage, error)
func (*Repository) GetKnownHostsWithStats ¶ added in v0.3.0
func (r *Repository) GetKnownHostsWithStats(ctx context.Context) ([]KnownHostStats, error)
func (*Repository) GetUserAccessEditor ¶ added in v0.3.0
func (r *Repository) GetUserAccessEditor(ctx context.Context, userID auth.UserID) (UserAccessEditor, error)
func (*Repository) ListAccessLog ¶
func (r *Repository) ListAccessLog(ctx context.Context, q AccessLogQuery) ([]AccessLogView, int, error)
func (*Repository) ListAccessLogStatsByCountry ¶
func (r *Repository) ListAccessLogStatsByCountry(ctx context.Context, from, to time.Time) ([]AccessLogCountryStat, error)
ListAccessLogStatsByCountry returns request counts grouped by country for all rows within the [from, to] time window. Only rows with GeoIP data are included.
func (*Repository) ListUserAccessRows ¶ added in v0.3.0
func (r *Repository) ListUserAccessRows(ctx context.Context) ([]UserAccessRow, error)
type UserAccessEditor ¶ added in v0.3.0
type UserAccessEditor struct {
User UserSummary
AllowAllHosts bool
Summary UserAccessSummary
GroupOptions []UserAccessGroupOption
HostOptions []UserAccessHostOption
}
type UserAccessGroupOption ¶ added in v0.3.0
type UserAccessGroupOption struct {
ID hostaccess.HostGroupID
Name string
Icon *string
Selected bool
Hosts []hostaccess.KnownHostRef
}
type UserAccessHostOption ¶ added in v0.3.0
type UserAccessHostOption struct {
ID hostaccess.KnownHostID
FQDN string
Icon *string
DirectSelected bool
Effective bool
GrantingGroups []GroupRef
AccessKind HostAccessKind
}
type UserAccessRow ¶ added in v0.3.0
type UserAccessSummary ¶ added in v0.3.0
type UserSummary ¶ added in v0.3.0
type UserView ¶ added in v0.3.0
type UserView struct {
ID auth.UserID `db:"id"`
Username string `db:"username"`
DisplayName string `db:"display_name"`
Email string `db:"email"`
Role auth.Role `db:"role"`
MustChangePassword bool `db:"must_change_password"`
BypassHostAllowlist bool `db:"bypass_host_allowlist"`
CreatedBy *auth.UserID `db:"created_by"`
CreatedAt time.Time `db:"created_at"`
}