Documentation ¶
Index ¶
- Constants
- Variables
- func AddSkipBodyEncryptRoutes(routes ...string)
- func BodyDecrypt(body []byte, keys ...string) ([]byte, error)
- func BuildBody(agentInfo meta.AgentInfoInterface, param interface{}) (encryptedBody interface{}, Key, Iv []byte, err error)
- func BuildBodyAndHeader(agentInfo meta.AgentInfoInterface, uri string, param interface{}) (encryptedBody interface{}, header map[string]string, err error)
- func BuildHeader(agentInfo meta.AgentInfoInterface, uri string, isForword bool, keys ...[]byte) map[string]string
- func BuildHeaderForForward(agentInfo meta.AgentInfoInterface, uri string, keys ...[]byte) map[string]string
- func CheckPasswordInSqlite() error
- func Decrypt(value string) (res string, err error)
- func DecryptPwdInObConfigMap(configs map[string]sqlite.ObConfig) (err error)
- func DecryptPwdInObConfigs(configs []sqlite.ObConfig) (err error)
- func DeleteToken(agent meta.AgentInfoInterface) (err error)
- func Dump() error
- func Encrypt(value string) (res string, err error)
- func EncryptBodyWithAes(body interface{}) (encryptedBody interface{}, key []byte, iv []byte, err error)
- func EncryptBodyWithRsa(agentInfo meta.AgentInfoInterface, body interface{}) (encryptedBody interface{}, err error)
- func EncryptBodyWithSm4(body interface{}) (encryptedBody interface{}, key []byte, iv []byte, err error)
- func EncryptForAgent(value string, agent meta.AgentInfoInterface) (res string, err error)
- func EncryptPwdInObConfigMap(configs map[string]sqlite.ObConfig) (pwd string, err error)
- func EncryptPwdInObConfigMapForOther(configs map[string]sqlite.ObConfig, otherAgent meta.AgentInfoInterface) (err error)
- func EncryptPwdInObConfigs(configs []sqlite.ObConfig) (err error)
- func EncryptPwdInObConfigsForOther(configs []sqlite.ObConfig, otherAgent meta.AgentInfoInterface) (err error)
- func EncryptToOther(raw []byte, other meta.AgentInfoInterface) (string, error)
- func GetAgentPublicKey(agent meta.AgentInfoInterface) string
- func GetSecret(ctx context.Context) *meta.AgentSecret
- func GetSkipBodyEncryptRoutes() []string
- func Init() (err error)
- func LoadPassword(password *string) error
- func New() (err error)
- func NewToken(targetAgent meta.AgentInfoInterface) (string, error)
- func Public() string
- func RepackageHeaderForAutoForward(header *HttpHeader, agentInfo meta.AgentInfoInterface) (headers map[string]string, err error)
- func RestoreKey() error
- func SendDeleteRequest(agentInfo meta.AgentInfoInterface, uri string, param interface{}, ...) error
- func SendDeleteRequestAndReturnResponse(agentInfo meta.AgentInfoInterface, uri string, param interface{}, ...) (*resty.Response, error)
- func SendGetRequest(agentInfo meta.AgentInfoInterface, uri string, param interface{}, ...) error
- func SendGetRequestAndReturnResponse(agentInfo meta.AgentInfoInterface, uri string, param interface{}, ...) (*resty.Response, error)
- func SendPatchRequest(agentInfo meta.AgentInfoInterface, uri string, param interface{}, ...) error
- func SendPatchRequestAndReturnResponse(agentInfo meta.AgentInfoInterface, uri string, param interface{}, ...) (*resty.Response, error)
- func SendPostRequest(agentInfo meta.AgentInfoInterface, uri string, param interface{}, ...) error
- func SendPostRequestAndReturnResponse(agentInfo meta.AgentInfoInterface, uri string, param interface{}, ...) (*resty.Response, error)
- func SendPutRequest(agentInfo meta.AgentInfoInterface, uri string, param interface{}, ...) error
- func SendPutRequestAndReturnResponse(agentInfo meta.AgentInfoInterface, uri string, param interface{}, ...) (*resty.Response, error)
- func SendRequestAndReturnResponse(agentInfo meta.AgentInfoInterface, uri string, method string, ...) (*resty.Response, error)
- func TryDecrypt(value string) string
- func TryEncrypt(value string) string
- func UpdateObPassword(password string) (err error)
- func UpdateObPasswordInTransaction(tx *gorm.DB, password string) (err error)
- func VerifyAuth(pwd string, ts string, curTs int64) error
- func VerifyOceanbasePassword(password string) error
- func VerifyToken(token string) error
- func VerifyTokenByAgentInfo(token string, agentInfo meta.AgentInfo) error
- type AgentAuth
- type GetPasswordResp
- type HttpHeader
- type SecureConfig
Constants ¶
const ( EncryptMethodAes = "aes" EncryptMethodRsa = "rsa" EncryptMethodSm4 = "sm4" )
const ( NotForward = iota AutoForward ManualForward )
Variables ¶
var (
Crypter *crypto.RSACrypto
)
Functions ¶
func AddSkipBodyEncryptRoutes ¶
func AddSkipBodyEncryptRoutes(routes ...string)
func BuildBody ¶
func BuildBody(agentInfo meta.AgentInfoInterface, param interface{}) (encryptedBody interface{}, Key, Iv []byte, err error)
func BuildBodyAndHeader ¶
func BuildHeader ¶
func BuildHeaderForForward ¶
func CheckPasswordInSqlite ¶
func CheckPasswordInSqlite() error
CheckPasswordInSqlite will try connecting ob using password stored in sqlite.
func DecryptPwdInObConfigMap ¶
func DecryptPwdInObConfigs ¶
func DeleteToken ¶
func DeleteToken(agent meta.AgentInfoInterface) (err error)
func EncryptBodyWithAes ¶
func EncryptBodyWithRsa ¶
func EncryptBodyWithRsa(agentInfo meta.AgentInfoInterface, body interface{}) (encryptedBody interface{}, err error)
func EncryptBodyWithSm4 ¶
func EncryptForAgent ¶
func EncryptForAgent(value string, agent meta.AgentInfoInterface) (res string, err error)
func EncryptPwdInObConfigMap ¶
func EncryptPwdInObConfigs ¶
func EncryptPwdInObConfigsForOther ¶
func EncryptPwdInObConfigsForOther(configs []sqlite.ObConfig, otherAgent meta.AgentInfoInterface) (err error)
func EncryptToOther ¶
func EncryptToOther(raw []byte, other meta.AgentInfoInterface) (string, error)
EncryptToOther will encrypt data using other agent's public key.
func GetAgentPublicKey ¶
func GetAgentPublicKey(agent meta.AgentInfoInterface) string
GetAgentPublicKey will get public key of specific agent.
func GetSkipBodyEncryptRoutes ¶
func GetSkipBodyEncryptRoutes() []string
func LoadPassword ¶
LoadPassword will load password from environment variable or sqlite.
func NewToken ¶
func NewToken(targetAgent meta.AgentInfoInterface) (string, error)
NewToken generates a token for the agent to join/scale-out an existing cluster
func RepackageHeaderForAutoForward ¶
func RepackageHeaderForAutoForward(header *HttpHeader, agentInfo meta.AgentInfoInterface) (headers map[string]string, err error)
func SendDeleteRequest ¶
func SendDeleteRequest(agentInfo meta.AgentInfoInterface, uri string, param interface{}, ret interface{}) error
SendDeleteRequest will send http delete request to the agent. If ret is not nil, it should be a pointer.
func SendDeleteRequestAndReturnResponse ¶
func SendDeleteRequestAndReturnResponse(agentInfo meta.AgentInfoInterface, uri string, param interface{}, ret interface{}) (*resty.Response, error)
SendDeleteRequestAndReturnResponse will return http response and error. If ret is not nil, it should be a pointer.
func SendGetRequest ¶
func SendGetRequest(agentInfo meta.AgentInfoInterface, uri string, param interface{}, ret interface{}) error
SendGetRequest will send http get request to the agent. If ret is not nil, it should be a pointer.
func SendGetRequestAndReturnResponse ¶
func SendGetRequestAndReturnResponse(agentInfo meta.AgentInfoInterface, uri string, param interface{}, ret interface{}) (*resty.Response, error)
SendGetRequestAndReturnResponse will return http response and error. If ret is not nil, it should be a pointer.
func SendPatchRequest ¶
func SendPatchRequest(agentInfo meta.AgentInfoInterface, uri string, param interface{}, ret interface{}) error
SendPatchRequest will send http patch request to the agent. If ret is not nil, it should be a pointer.
func SendPatchRequestAndReturnResponse ¶
func SendPatchRequestAndReturnResponse(agentInfo meta.AgentInfoInterface, uri string, param interface{}, ret interface{}) (*resty.Response, error)
SendPatchRequestAndReturnResponse will return http response and error. If ret is not nil, it should be a pointer.
func SendPostRequest ¶
func SendPostRequest(agentInfo meta.AgentInfoInterface, uri string, param interface{}, ret interface{}) error
SendPostRequest will send http post request to the agent. If ret is not nil, it should be a pointer.
func SendPostRequestAndReturnResponse ¶
func SendPostRequestAndReturnResponse(agentInfo meta.AgentInfoInterface, uri string, param interface{}, ret interface{}) (*resty.Response, error)
SendPostRequestAndReturnResponse will return http response and error. If ret is not nil, it should be a pointer.
func SendPutRequest ¶
func SendPutRequest(agentInfo meta.AgentInfoInterface, uri string, param interface{}, ret interface{}) error
SendPutRequest will send http put request to the agent. If ret is not nil, it should be a pointer.
func SendPutRequestAndReturnResponse ¶
func SendPutRequestAndReturnResponse(agentInfo meta.AgentInfoInterface, uri string, param interface{}, ret interface{}) (*resty.Response, error)
SendPutRequestAndReturnResponse will return http response and error. If ret is not nil, it should be a pointer.
func SendRequestAndReturnResponse ¶
func SendRequestAndReturnResponse(agentInfo meta.AgentInfoInterface, uri string, method string, param interface{}, ret interface{}) (*resty.Response, error)
func TryDecrypt ¶
func TryEncrypt ¶
func UpdateObPassword ¶
UpdateObPassword recieve a encrypted password
func UpdateObPasswordInTransaction ¶
UpdateObPasswordInTransaction recieve a encrypted password
func VerifyOceanbasePassword ¶
func VerifyToken ¶
Types ¶
type GetPasswordResp ¶
type GetPasswordResp struct {
Password string `json:"password"`
}
type HttpHeader ¶
type HttpHeader struct { Auth string Ts string Token string Uri string Keys []byte ForwardType int ForwardAgent meta.AgentInfo }
func DecryptHeader ¶
func DecryptHeader(ciphertext string) (HttpHeader, error)