service

package
v0.0.0-...-503ec33 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2024 License: GPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

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 (
	UserTokenAuthURL   = "/api/v1/authentication/tokens/" // 用户登录验证
	UserConfirmAuthURL = "/api/v1/authentication/login-confirm-ticket/status/"
	AuthMFASelectURL   = "/api/v1/authentication/mfa/select/" // 选择 MFA

)

用户登陆认证使用的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日志
	FTPLogUpdateURL     = "/api/v1/audits/ftp-logs/%s/"
	FTPLogFileURL       = "/api/v1/audits/ftp-logs/%s/upload/"

	SessionLifecycleLogURL = "/api/v1/terminal/sessions/%s/lifecycle_log/"
)

Session相关API

View Source
const (
	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/" // 资产树
)

授权相关API

View Source
const (
	UserListURL      = "/api/v1/users/users/"
	UserDetailURL    = "/api/v1/users/users/%s/"
	AssetPlatFormURL = "/api/v1/assets/assets/%s/platform/"

	DomainDetailWithGateways = "/api/v1/assets/domains/%s/?gateway=1"
)

各资源详情相关API

View Source
const (
	ShareCreateURL        = "/api/v1/terminal/session-sharings/"
	ShareSessionJoinURL   = "/api/v1/terminal/session-join-records/"
	ShareSessionFinishURL = "/api/v1/terminal/session-join-records/%s/finished/"
)
View Source
const (
	SuperConnectTokenSecretURL = "/api/v1/authentication/super-connection-token/secret/"
	SuperConnectTokenInfoURL   = "/api/v1/authentication/super-connection-token/"

	UserPermsAssetAccountsURL = "/api/v1/perms/users/%s/assets/%s/"
	AccountSecretURL          = "/api/v1/assets/account-secrets/%s/"
	UserPermsAssetsURL        = "/api/v1/perms/users/%s/assets/"

	AssetLoginConfirmURL = "/api/v1/acls/login-asset/check/"
	AclCommandReviewURL  = "/api/v1/acls/command-filter-acls/command-review/"
)
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/"
)
View Source
const (
	UserKoKoPreferenceURL = "/api/v1/users/preference/?category=koko"
)

Variables

View Source
var (
	ErrConnect      = errors.New("connect failed")
	ErrUnauthorized = errors.New("unauthorized")
	ErrInvalid      = errors.New("invalid user")
)
View Source
var AccessKeyUnauthorized = errors.New("access key unauthorized")
View Source
var ConnectErr = errors.New("api connect err")

Functions

func DecryptECB

func DecryptECB(ciphertext string, key string) (string, error)

func EncryptECB

func EncryptECB(plaintext string, key string) (string, error)

func GenerateEncryptKey

func GenerateEncryptKey(key string) (string, error)

func RegisterTerminalAccount

func RegisterTerminalAccount(coreHost, name, token string) (res model.Terminal, err error)

func ValidAccessKey

func ValidAccessKey(coreHost string, key model.AccessKey) error

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 DataResponse struct {
	Choices []string `json:"choices,omitempty"`
	Url     string   `json:"url,omitempty"`
}

type JMService

type JMService struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func NewAuthJMService

func NewAuthJMService(opts ...Option) (*JMService, error)

func (*JMService) CancelConfirmByRequestInfo

func (s *JMService) CancelConfirmByRequestInfo(req model.ReqInfo) (err error)

func (*JMService) CheckConfirmStatusByRequestInfo

func (s *JMService) CheckConfirmStatusByRequestInfo(req model.ReqInfo) (res model.TicketState, err error)

func (*JMService) CheckIfNeedAssetLoginConfirm

func (s *JMService) CheckIfNeedAssetLoginConfirm(userId, assetId,
	accountUsername string) (res model.AssetLoginTicketInfo, err error)

func (*JMService) CheckUserCookie

func (s *JMService) CheckUserCookie(cookies map[string]string) (user *model.User, err error)

func (*JMService) CloneClient

func (s *JMService) CloneClient() httplib.Client

func (*JMService) Copy

func (s *JMService) Copy() *JMService

func (*JMService) CreateFileOperationLog

func (s *JMService) CreateFileOperationLog(data model.FTPLog) (err error)

func (*JMService) CreateSession

func (s *JMService) CreateSession(sess model.Session) (ret model.Session, err error)

func (*JMService) CreateSessionTicketRelation

func (s *JMService) CreateSessionTicketRelation(sid, ticketId string) (err error)

func (*JMService) CreateShareRoom

func (s *JMService) CreateShareRoom(data model.SharingSessionRequest) (res model.SharingSession, err error)

func (*JMService) CreateSuperConnectToken

func (s *JMService) CreateSuperConnectToken(data *SuperConnectTokenReq) (resp model.ConnectTokenInfo, err error)

func (*JMService) FinishFTPFile

func (s *JMService) FinishFTPFile(fid string) error

func (*JMService) FinishReply

func (s *JMService) FinishReply(sid string) error

func (*JMService) FinishShareRoom

func (s *JMService) FinishShareRoom(recordId string) (err error)

func (*JMService) FinishTask

func (s *JMService) FinishTask(tid string) error

func (*JMService) GetAccountSecretById

func (s *JMService) GetAccountSecretById(accountId string) (res model.AccountDetail, err error)

func (*JMService) GetAllUserPermsAssets

func (s *JMService) GetAllUserPermsAssets(userId string) ([]model.PermAsset, error)

func (*JMService) GetAssetPlatform

func (s *JMService) GetAssetPlatform(assetId string) (platform model.Platform, err error)

func (*JMService) GetConnectTokenInfo

func (s *JMService) GetConnectTokenInfo(tokenId string) (resp model.ConnectToken, err error)

func (*JMService) GetDomainGateways

func (s *JMService) GetDomainGateways(domainId string) (domain model.Domain, err error)

func (*JMService) GetNodeTreeByUserAndNodeKey

func (s *JMService) GetNodeTreeByUserAndNodeKey(userID, nodeKey string) (nodeTrees model.NodeTreeList, err error)

func (*JMService) GetProfile

func (s *JMService) GetProfile() (user *model.User, err error)

func (*JMService) GetPublicSetting

func (s *JMService) GetPublicSetting() (result model.PublicSetting, err error)

func (*JMService) GetSessionById

func (s *JMService) GetSessionById(sid string) (data model.Session, err error)

func (*JMService) GetShareUserInfo

func (s *JMService) GetShareUserInfo(query string) (res []*model.MiniUser, err error)

func (*JMService) GetTerminalConfig

func (s *JMService) GetTerminalConfig() (conf model.TerminalConfig, err error)

func (*JMService) GetUserAssetByID

func (s *JMService) GetUserAssetByID(userId, assetId string) (assets []model.PermAsset, err error)

func (*JMService) GetUserById

func (s *JMService) GetUserById(userID string) (user *model.User, err error)

func (*JMService) GetUserNodeAssets

func (s *JMService) GetUserNodeAssets(userID, nodeID string,
	params model.PaginationParam) (resp model.PaginationResponse, err error)

func (*JMService) GetUserNodes

func (s *JMService) GetUserNodes(userId string) (nodes model.NodeList, err error)

func (*JMService) GetUserPermAssetById

func (s *JMService) GetUserPermAssetById(userId, assetId string) (assets []model.PermAsset, err error)

func (*JMService) GetUserPermAssetDetailById

func (s *JMService) GetUserPermAssetDetailById(userId, assetId string) (resp model.PermAssetDetail, err error)

func (*JMService) GetUserPermAssetsByIP

func (s *JMService) GetUserPermAssetsByIP(userId, assetIP string) (assets []model.PermAsset, err error)

func (*JMService) GetUserPermsAssets

func (s *JMService) GetUserPermsAssets(userId string, params model.PaginationParam) (resp model.PaginationResponse, err error)

func (*JMService) GetWsClient

func (s *JMService) GetWsClient() (*websocket.Conn, error)

func (*JMService) JoinShareRoom

func (s *JMService) JoinShareRoom(data model.SharePostData) (res model.ShareRecord, err error)

func (*JMService) NotifyCommand

func (s *JMService) NotifyCommand(commands []*model.Command) (err error)

func (*JMService) PushSessionCommand

func (s *JMService) PushSessionCommand(commands []*model.Command) (err error)

func (*JMService) RecordSessionLifecycleLog

func (s *JMService) RecordSessionLifecycleLog(sid string, event model.LifecycleEvent, logObj model.SessionLifecycleLog) (err error)

func (*JMService) RefreshUserAllPermsAssets

func (s *JMService) RefreshUserAllPermsAssets(userId string) ([]model.PermAsset, error)

func (*JMService) RefreshUserNodes

func (s *JMService) RefreshUserNodes(userId string) (nodes model.NodeList, err error)

func (*JMService) SearchPermAsset

func (s *JMService) SearchPermAsset(userId, key string) (res model.PermAssetList, err error)

func (*JMService) SessionDisconnect

func (s *JMService) SessionDisconnect(sid string) error

func (*JMService) SessionFailed

func (s *JMService) SessionFailed(sid string, err error) error

func (*JMService) SessionFinished

func (s *JMService) SessionFinished(sid string, time common.UTCTime) error

func (*JMService) SessionReplayFailed

func (s *JMService) SessionReplayFailed(sid string, err model.ReplayError) error

func (*JMService) SessionSuccess

func (s *JMService) SessionSuccess(sid string) error

func (*JMService) SetCookie

func (s *JMService) SetCookie(name, value string)

func (*JMService) SetHeader

func (s *JMService) SetHeader(key, value string)

func (*JMService) SubmitCommandReview

func (s *JMService) SubmitCommandReview(sid string, aclId string,
	cmd string) (res model.CommandTicketInfo, err error)

func (*JMService) SyncUserKokoPreference

func (s *JMService) SyncUserKokoPreference(cookies map[string]string, data model.UserKokoPreference) (err error)

func (*JMService) TerminalHeartBeat

func (s *JMService) TerminalHeartBeat(sIds []string) (res []model.TerminalTask, err error)

func (*JMService) UploadFTPFile

func (s *JMService) UploadFTPFile(fid, file string) error

func (*JMService) UploadReplay

func (s *JMService) UploadReplay(sid, gZipFile string) error

func (*JMService) ValidateJoinSessionPermission

func (s *JMService) ValidateJoinSessionPermission(userId, sessionId string) (result model.ValidateResult, err error)

type OTPRequest

type OTPRequest struct {
	ReqURL  string
	ReqBody map[string]interface{}
}

type Option

type Option func(*option)

func JMSAccessKey

func JMSAccessKey(keyID, secretID string) Option

func JMSCoreHost

func JMSCoreHost(coreHost string) Option

func JMSTimeOut

func JMSTimeOut(t time.Duration) Option

type SuperConnectTokenReq

type SuperConnectTokenReq struct {
	UserId        string `json:"user"`
	AssetId       string `json:"asset"`
	Account       string `json:"account"`
	Protocol      string `json:"protocol"`
	ConnectMethod string `json:"connect_method"`
	InputUsername string `json:"input_username"`
	InputSecret   string `json:"input_secret"`
	RemoteAddr    string `json:"remote_addr"`

	Params map[string]string `json:"-"`
}

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 UserClientSvcSignKey

func UserClientSvcSignKey(key model.AccessKey) UserClientOption

func UserClientUsername

func UserClientUsername(username string) UserClientOption

type UserClientOptions

type UserClientOptions struct {
	Username   string
	Password   string
	PublicKey  string
	RemoteAddr string
	LoginType  string
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

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