Documentation ¶
Index ¶
- Constants
- Variables
- func RegisterTerminalAccount(coreHost, name, token string) (res model.Terminal, err error)
- func ValidAccessKey(coreHost string, key model.AccessKey) error
- type AuthResponse
- type DataResponse
- type JMService
- func (s *JMService) CancelConfirmByRequestInfo(req model.ReqInfo) (err error)
- func (s *JMService) CheckConfirmStatusByRequestInfo(req model.ReqInfo) (res model.TicketState, err error)
- func (s *JMService) CheckIfNeedAppConnectionConfirm(userID, assetID, systemUserID string) (bool, error)
- func (s *JMService) CheckIfNeedAssetLoginConfirm(userId, assetId, systemUserId, sysUsername string) (res model.AssetLoginTicketInfo, err error)
- func (s *JMService) CheckUserCookie(cookies map[string]string) (user *model.User, err error)
- func (s *JMService) CloneClient() httplib.Client
- func (s *JMService) Copy() *JMService
- func (s *JMService) CreateFileOperationLog(data model.FTPLog) (err error)
- func (s *JMService) CreateSession(sess model.Session) error
- func (s *JMService) CreateSessionTicketRelation(sid, ticketId string) (err error)
- func (s *JMService) CreateShareRoom(sessionId string, expired int, users []string) (res model.SharingSession, err error)
- func (s *JMService) FinishReply(sid string) error
- func (s *JMService) FinishShareRoom(recordId string) (err error)
- func (s *JMService) FinishTask(tid string) error
- func (s *JMService) GetAllUserPermK8s(userId string) ([]map[string]interface{}, error)
- func (s *JMService) GetAllUserPermsAssets(userId string) ([]map[string]interface{}, error)
- func (s *JMService) GetApplicationById(appId string) (app model.Application, err error)
- func (s *JMService) GetAssetById(assetId string) (asset model.Asset, err error)
- func (s *JMService) GetAssetPlatform(assetId string) (platform model.Platform, err error)
- func (s *JMService) GetCommandFilterRules(userId, sysId, assetId, appId string) (rules []model.FilterRule, err error)
- func (s *JMService) GetConnectTokenAuth(token string) (resp TokenAuthInfoResponse, err error)
- func (s *JMService) GetDomainGateways(domainId string) (domain model.Domain, err error)
- func (s *JMService) GetNodeTreeByUserAndNodeKey(userID, nodeKey string) (nodeTrees model.NodeTreeList, err error)
- func (s *JMService) GetPermission(userId, assetId, systemUserId string) (perms model.Permission, err error)
- func (s *JMService) GetProfile() (user *model.User, err error)
- func (s *JMService) GetPublicSetting() (result model.PublicSetting, err error)
- func (s *JMService) GetRemoteApp(remoteAppId string) (remoteApp model.RemoteAPP, err error)
- func (s *JMService) GetSessionById(sid string) (data model.Session, err error)
- func (s *JMService) GetShareUserInfo(query string) (res []*model.MiniUser, err error)
- func (s *JMService) GetSystemUserAuthById(systemUserId, assetId, userId, username string) (sysUser model.SystemUserAuthInfo, err error)
- func (s *JMService) GetSystemUserById(systemUserId string) (sysUser model.SystemUser, err error)
- func (s *JMService) GetSystemUserFilterRules(systemUserID string) (rules []model.FilterRule, err error)
- func (s *JMService) GetSystemUsersByUserIdAndAssetId(userId, assetId string) (sysUsers []model.SystemUser, err error)
- func (s *JMService) GetTerminalConfig() (conf model.TerminalConfig, err error)
- func (s *JMService) GetTokenAsset(token string) (tokenUser model.TokenUser, err error)
- func (s *JMService) GetUserApplicationAuthInfo(systemUserID, appID, userID, username string) (info model.SystemUserAuthInfo, err error)
- func (s *JMService) GetUserApplicationSystemUsers(userId, appId string) (res []model.SystemUser, err error)
- func (s *JMService) GetUserAssetByID(userId, assetId string) (assets []model.Asset, err error)
- func (s *JMService) GetUserById(userID string) (user *model.User, err error)
- func (s *JMService) GetUserNodeAssets(userID, nodeID string, params model.PaginationParam) (resp model.PaginationResponse, err error)
- func (s *JMService) GetUserNodes(userId string) (nodes model.NodeList, err error)
- func (s *JMService) GetUserPermAssetsByIP(userId, assetIP string) (assets []model.Asset, err error)
- func (s *JMService) GetUserPermsAssets(userID string, params model.PaginationParam) (resp model.PaginationResponse, err error)
- func (s *JMService) GetUserPermsDatabase(userId string, param model.PaginationParam, dbTypes ...string) (resp model.PaginationResponse, err error)
- func (s *JMService) GetUserPermsK8s(userId string, param model.PaginationParam) (resp model.PaginationResponse, err error)
- func (s *JMService) GetUserPermsMySQL(userId string, param model.PaginationParam) (resp model.PaginationResponse, err error)
- func (s *JMService) JoinShareRoom(data SharePostData) (res model.ShareRecord, err error)
- func (s *JMService) NotifyCommand(commands []*model.Command) (err error)
- func (s *JMService) PushSessionCommand(commands []*model.Command) (err error)
- func (s *JMService) RefreshUserAllPermsAssets(userId string) ([]map[string]interface{}, error)
- func (s *JMService) RefreshUserNodes(userId string) (nodes model.NodeList, err error)
- func (s *JMService) RenewalToken(token string) (resp TokenRenewalResponse, err error)
- func (s *JMService) SearchPermAsset(userId, key string) (res model.AssetList, err error)
- func (s *JMService) SessionDisconnect(sid string) error
- func (s *JMService) SessionFailed(sid string, err error) error
- func (s *JMService) SessionFinished(sid string, time common.UTCTime) error
- func (s *JMService) SessionSuccess(sid string) error
- func (s *JMService) SetCookie(name, value string)
- func (s *JMService) SubmitCommandConfirm(sid string, ruleId string, cmd string) (res model.CommandTicketInfo, err error)
- func (s *JMService) TerminalHeartBeat(sIds []string) (res []model.TerminalTask, err error)
- func (s *JMService) Upload(sessionID, gZipFile string) error
- func (s *JMService) UploadReplay(sid, gZipFile string, version model.ReplayVersion) error
- func (s *JMService) ValidateApplicationPermission(userId, appId, systemUserId string) (info model.ExpireInfo, err error)
- func (s *JMService) ValidateAssetConnectPermission(userId, assetId, systemUserId string) (info model.ExpireInfo, err error)
- func (s *JMService) ValidateJoinSessionPermission(userId, sessionId string) (result model.ValidateResult, err error)
- func (s *JMService) ValidateRemoteAppPermission(userId, remoteAppId, systemUserId string) (info model.ExpireInfo, err error)
- type OTPRequest
- type Option
- type SharePostData
- type TokenAuthInfoResponse
- type TokenRenewalResponse
- type UserClient
- func (u *UserClient) CancelConfirmAuth() (err error)
- func (u *UserClient) CheckConfirmAuthStatus() (resp AuthResponse, err error)
- func (u *UserClient) GetAPIToken() (resp AuthResponse, err error)
- func (u *UserClient) SelectMFAChoice(mfaType string) (err error)
- func (u *UserClient) SendOTPRequest(optReq *OTPRequest) (resp AuthResponse, err error)
- func (u *UserClient) SetOption(setters ...UserClientOption)
- type UserClientOption
- func UserClientHttpClient(con *httplib.Client) UserClientOption
- func UserClientLoginType(loginType string) UserClientOption
- func UserClientPassword(password string) UserClientOption
- func UserClientPublicKey(publicKey string) UserClientOption
- func UserClientRemoteAddr(remoteAddr string) UserClientOption
- func UserClientUsername(username string) UserClientOption
- type UserClientOptions
Constants ¶
View Source
const ( UserProfileURL = "/api/v1/users/profile/" // 获取当前用户的基本信息 TerminalRegisterURL = "/api/v1/terminal/terminal-registrations/" // 注册 TerminalConfigURL = "/api/v1/terminal/terminals/config/" // 获取配置 TerminalHeartBeatURL = "/api/v1/terminal/terminals/status/" )
与Core交互的API
View Source
const ( TokenAssetURL = "/api/v1/authentication/connection-token/%s/" // Token name UserTokenAuthURL = "/api/v1/authentication/tokens/" // 用户登录验证 UserConfirmAuthURL = "/api/v1/authentication/login-confirm-ticket/status/" AuthMFASelectURL = "/api/v1/authentication/mfa/select/" // 选择 MFA TokenAuthInfoURL = "/api/v1/authentication/connection-token/secret-info/detail/" TokenRenewalURL = "/api/v1/authentication/connection-token/renewal/" )
用户登陆认证使用的API
View Source
const ( SessionListURL = "/api/v1/terminal/sessions/" //上传创建的资产会话session id SessionDetailURL = "/api/v1/terminal/sessions/%s/" // finish session的时候发送 SessionReplayURL = "/api/v1/terminal/sessions/%s/replay/" //上传录像 SessionCommandURL = "/api/v1/terminal/commands/" //上传批量命令 FinishTaskURL = "/api/v1/terminal/tasks/%s/" JoinRoomValidateURL = "/api/v1/terminal/sessions/join/validate/" FTPLogListURL = "/api/v1/audits/ftp-logs/" // 上传 ftp日志 )
Session相关API
View Source
const ( UserPermsAssetsURL = "/api/v1/perms/users/%s/assets/" UserPermsNodesListURL = "/api/v1/perms/users/%s/nodes/" UserPermsNodeAssetsListURL = "/api/v1/perms/users/%s/nodes/%s/assets/" UserPermsNodeTreeWithAssetURL = "/api/v1/perms/users/%s/nodes/children-with-assets/tree/" // 资产树 UserPermsApplicationsURL = "/api/v1/perms/users/%s/applications/?type=%s" UserPermsAssetSystemUsersURL = "/api/v1/perms/users/%s/assets/%s/system-users/" UserPermsApplicationSystemUsersURL = "/api/v1/perms/users/%s/applications/%s/system-users/" ValidateUserAssetPermissionURL = "/api/v1/perms/asset-permissions/user/validate/" ValidateApplicationPermissionURL = "/api/v1/perms/application-permissions/user/validate/" UserPermsDatabaseURL = "/api/v1/perms/users/%s/applications/?category=db&type__in=%s" )
授权相关API
View Source
const ( SystemUserAuthURL = "/api/v1/assets/system-users/%s/auth-info/" SystemUserAppAuthURL = "/api/v1/assets/system-users/%s/applications/%s/auth-info/" // 该系统用户对某应用的授权 SystemUserAssetAuthURL = "/api/v1/assets/system-users/%s/assets/%s/auth-info/" // 该系统用户对某资产的授权 )
系统用户密码相关API
View Source
const ( UserListURL = "/api/v1/users/users/" UserDetailURL = "/api/v1/users/users/%s/" AssetDetailURL = "/api/v1/assets/assets/%s/" AssetPlatFormURL = "/api/v1/assets/assets/%s/platform/" SystemUserDetailURL = "/api/v1/assets/system-users/%s/" ApplicationDetailURL = "/api/v1/applications/applications/%s/" SystemUserCmdFilterRulesListURL = "/api/v1/assets/system-users/%s/cmd-filter-rules/" // 过滤规则url CommandFilterRulesListURL = "/api/v1/assets/cmd-filter-rules/" DomainDetailWithGateways = "/api/v1/assets/domains/%s/?gateway=1" )
各资源详情相关API
View Source
const ( PermissionURL = "/api/v1/perms/asset-permissions/user/actions/" RemoteAPPURL = "/api/v1/applications/remote-apps/%s/connection-info/" )
View Source
const ()
View Source
const (
AssetLoginConfirmURL = "/api/v1/acls/login-asset/check/"
)
View Source
const (
CommandConfirmURL = "/api/v1/assets/cmd-filters/command-confirm/"
)
View Source
const ComponentName = "koko"
View Source
const (
NotificationCommandURL = "/api/v1/terminal/commands/insecure-command/"
)
View Source
const (
PublicSettingURL = "/api/v1/settings/public/"
)
View Source
const (
TicketSessionURL = "/api/v1/tickets/ticket-session-relation/"
)
Variables ¶
View Source
var ( ErrConnect = errors.New("connect failed") ErrInvalid = errors.New("invalid user") )
View Source
var ConnectErr = errors.New("api connect err")
Functions ¶
func RegisterTerminalAccount ¶
Types ¶
type AuthResponse ¶
type AuthResponse struct { Err string `json:"error,omitempty"` Msg string `json:"msg,omitempty"` Data DataResponse `json:"data,omitempty"` Username string `json:"username,omitempty"` Token string `json:"token,omitempty"` Keyword string `json:"keyword,omitempty"` DateExpired string `json:"date_expired,omitempty"` User model.User `json:"user,omitempty"` }
type DataResponse ¶
type JMService ¶
func NewAuthJMService ¶
func (*JMService) CancelConfirmByRequestInfo ¶
func (*JMService) CheckConfirmStatusByRequestInfo ¶
func (*JMService) CheckIfNeedAppConnectionConfirm ¶
func (*JMService) CheckIfNeedAssetLoginConfirm ¶
func (s *JMService) CheckIfNeedAssetLoginConfirm(userId, assetId, systemUserId, sysUsername string) (res model.AssetLoginTicketInfo, err error)
func (*JMService) CheckUserCookie ¶
func (*JMService) CloneClient ¶
func (*JMService) CreateFileOperationLog ¶
func (*JMService) CreateSessionTicketRelation ¶
func (*JMService) CreateShareRoom ¶
func (*JMService) FinishReply ¶
func (*JMService) FinishShareRoom ¶
func (*JMService) FinishTask ¶
func (*JMService) GetAllUserPermK8s ¶
func (*JMService) GetAllUserPermsAssets ¶
func (*JMService) GetApplicationById ¶
func (s *JMService) GetApplicationById(appId string) (app model.Application, err error)
func (*JMService) GetAssetById ¶
func (*JMService) GetAssetPlatform ¶
func (*JMService) GetCommandFilterRules ¶
func (s *JMService) GetCommandFilterRules(userId, sysId, assetId, appId string) (rules []model.FilterRule, err error)
func (*JMService) GetConnectTokenAuth ¶
func (s *JMService) GetConnectTokenAuth(token string) (resp TokenAuthInfoResponse, err error)
func (*JMService) GetDomainGateways ¶
func (*JMService) GetNodeTreeByUserAndNodeKey ¶
func (s *JMService) GetNodeTreeByUserAndNodeKey(userID, nodeKey string) (nodeTrees model.NodeTreeList, err error)
func (*JMService) GetPermission ¶
func (s *JMService) GetPermission(userId, assetId, systemUserId string) (perms model.Permission, err error)
func (*JMService) GetPublicSetting ¶
func (s *JMService) GetPublicSetting() (result model.PublicSetting, err error)
func (*JMService) GetRemoteApp ¶
func (*JMService) GetSessionById ¶
func (*JMService) GetShareUserInfo ¶
func (*JMService) GetSystemUserAuthById ¶
func (s *JMService) GetSystemUserAuthById(systemUserId, assetId, userId, username string) (sysUser model.SystemUserAuthInfo, err error)
func (*JMService) GetSystemUserById ¶
func (s *JMService) GetSystemUserById(systemUserId string) (sysUser model.SystemUser, err error)
func (*JMService) GetSystemUserFilterRules ¶
func (s *JMService) GetSystemUserFilterRules(systemUserID string) (rules []model.FilterRule, err error)
func (*JMService) GetSystemUsersByUserIdAndAssetId ¶
func (s *JMService) GetSystemUsersByUserIdAndAssetId(userId, assetId string) (sysUsers []model.SystemUser, err error)
func (*JMService) GetTerminalConfig ¶
func (s *JMService) GetTerminalConfig() (conf model.TerminalConfig, err error)
func (*JMService) GetTokenAsset ¶
func (*JMService) GetUserApplicationAuthInfo ¶
func (s *JMService) GetUserApplicationAuthInfo(systemUserID, appID, userID, username string) (info model.SystemUserAuthInfo, err error)
func (*JMService) GetUserApplicationSystemUsers ¶
func (s *JMService) GetUserApplicationSystemUsers(userId, appId string) (res []model.SystemUser, err error)
func (*JMService) GetUserAssetByID ¶
func (*JMService) GetUserById ¶
func (*JMService) GetUserNodeAssets ¶
func (s *JMService) GetUserNodeAssets(userID, nodeID string, params model.PaginationParam) (resp model.PaginationResponse, err error)
func (*JMService) GetUserNodes ¶
func (*JMService) GetUserPermAssetsByIP ¶
func (*JMService) GetUserPermsAssets ¶
func (s *JMService) GetUserPermsAssets(userID string, params model.PaginationParam) (resp model.PaginationResponse, err error)
func (*JMService) GetUserPermsDatabase ¶
func (s *JMService) GetUserPermsDatabase(userId string, param model.PaginationParam, dbTypes ...string) (resp model.PaginationResponse, err error)
func (*JMService) GetUserPermsK8s ¶
func (s *JMService) GetUserPermsK8s(userId string, param model.PaginationParam) (resp model.PaginationResponse, err error)
func (*JMService) GetUserPermsMySQL ¶
func (s *JMService) GetUserPermsMySQL(userId string, param model.PaginationParam) (resp model.PaginationResponse, err error)
func (*JMService) JoinShareRoom ¶
func (s *JMService) JoinShareRoom(data SharePostData) (res model.ShareRecord, err error)
func (*JMService) NotifyCommand ¶
func (*JMService) PushSessionCommand ¶
func (*JMService) RefreshUserAllPermsAssets ¶
func (*JMService) RefreshUserNodes ¶
func (*JMService) RenewalToken ¶
func (s *JMService) RenewalToken(token string) (resp TokenRenewalResponse, err error)
func (*JMService) SearchPermAsset ¶
func (*JMService) SessionDisconnect ¶
func (*JMService) SessionFinished ¶
func (*JMService) SessionSuccess ¶
func (*JMService) SubmitCommandConfirm ¶
func (*JMService) TerminalHeartBeat ¶
func (s *JMService) TerminalHeartBeat(sIds []string) (res []model.TerminalTask, err error)
func (*JMService) UploadReplay ¶
func (s *JMService) UploadReplay(sid, gZipFile string, version model.ReplayVersion) error
func (*JMService) ValidateApplicationPermission ¶
func (s *JMService) ValidateApplicationPermission(userId, appId, systemUserId string) (info model.ExpireInfo, err error)
func (*JMService) ValidateAssetConnectPermission ¶
func (s *JMService) ValidateAssetConnectPermission(userId, assetId, systemUserId string) (info model.ExpireInfo, err error)
func (*JMService) ValidateJoinSessionPermission ¶
func (s *JMService) ValidateJoinSessionPermission(userId, sessionId string) (result model.ValidateResult, err error)
func (*JMService) ValidateRemoteAppPermission ¶
func (s *JMService) ValidateRemoteAppPermission(userId, remoteAppId, systemUserId string) (info model.ExpireInfo, err error)
type OTPRequest ¶
type SharePostData ¶
type SharePostData struct {}
type TokenAuthInfoResponse ¶
type TokenAuthInfoResponse struct { Info model.ConnectTokenInfo Err []string }
func (*TokenAuthInfoResponse) UnmarshalJSON ¶
func (t *TokenAuthInfoResponse) UnmarshalJSON(p []byte) error
type TokenRenewalResponse ¶
type UserClient ¶
type UserClient struct { Opts *UserClientOptions // contains filtered or unexported fields }
func NewUserClient ¶
func NewUserClient(setters ...UserClientOption) *UserClient
func (*UserClient) CancelConfirmAuth ¶
func (u *UserClient) CancelConfirmAuth() (err error)
func (*UserClient) CheckConfirmAuthStatus ¶
func (u *UserClient) CheckConfirmAuthStatus() (resp AuthResponse, err error)
func (*UserClient) GetAPIToken ¶
func (u *UserClient) GetAPIToken() (resp AuthResponse, err error)
func (*UserClient) SelectMFAChoice ¶
func (u *UserClient) SelectMFAChoice(mfaType string) (err error)
func (*UserClient) SendOTPRequest ¶
func (u *UserClient) SendOTPRequest(optReq *OTPRequest) (resp AuthResponse, err error)
func (*UserClient) SetOption ¶
func (u *UserClient) SetOption(setters ...UserClientOption)
type UserClientOption ¶
type UserClientOption func(*UserClientOptions)
func UserClientHttpClient ¶
func UserClientHttpClient(con *httplib.Client) UserClientOption
func UserClientLoginType ¶
func UserClientLoginType(loginType string) UserClientOption
func UserClientPassword ¶
func UserClientPassword(password string) UserClientOption
func UserClientPublicKey ¶
func UserClientPublicKey(publicKey string) UserClientOption
func UserClientRemoteAddr ¶
func UserClientRemoteAddr(remoteAddr string) UserClientOption
func UserClientUsername ¶
func UserClientUsername(username string) UserClientOption
Source Files ¶
- jms.go
- jms_application.go
- jms_asset.go
- jms_audit.go
- jms_filter_rules.go
- jms_heartbeat.go
- jms_perm_application.go
- jms_perm_asset.go
- jms_perm_node.go
- jms_perm_node_tree.go
- jms_permission.go
- jms_public_setting.go
- jms_remote_app.go
- jms_session.go
- jms_share.go
- jms_task.go
- jms_ticket.go
- jms_token.go
- jms_user.go
- options.go
- register.go
- url.go
- user_client.go
Click to show internal directories.
Click to hide internal directories.