handler

package
v0.0.0-...-6410feb Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2024 License: Apache-2.0 Imports: 77 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HOST_MAC                    = "*MAC地址"
	HOST_NAME                   = "*名称"
	HOST_IPMI_ADDR              = "*IPMI地址"
	HOST_IPMI_USERNAME          = "*IPMI用户名"
	HOST_IPMI_PASSWORD          = "*IPMI密码"
	HOST_MNG_IP_ADDR            = "*管理口IP地址"
	HOST_IPMI_ADDR_OPTIONAL     = "IPMI地址"
	HOST_IPMI_USERNAME_OPTIONAL = "IPMI用户名"
	HOST_IPMI_PASSWORD_OPTIONAL = "IPMI密码"
	HOST_MNG_IP_ADDR_OPTIONAL   = "管理口IP地址"
	HOST_MNG_MAC_ADDR_OPTIONAL  = "管理口MAC地址"
)
View Source
const (
	BATCH_USER_REGISTER_QUANTITY_LIMITATION = 1000
	BATCH_HOST_REGISTER_QUANTITY_LIMITATION = 1000
)
View Source
const (
	// OIDC code expires in 5 minutes
	OIDC_CODE_EXPIRE_SECONDS = 300
	// OIDC token expires in 2 hours
	OIDC_TOKEN_EXPIRE_SECONDS = 7200
)
View Source
const (
	APIVer   = "<apiver>"
	ResName  = "<resname>"
	ResID    = "<resid>"
	ResName2 = "<resname2>"
	ResID2   = "<resid2>"
	ResName3 = "<resname3>"
	ResID3   = "<resid3>"
	Spec     = "<spec>"
	Action   = "<action>"

	GET    = "GET"
	PUT    = "PUT"
	POST   = "POST"
	DELETE = "DELETE"
	PATCH  = "PATCH"
)

Variables

View Source
var IMAGE_DOWNLOAD_PUBLIC_KEY = stringutils.UUID4()

Functions

func AppContextToken

func AppContextToken(ctx context.Context) mcclient.TokenCredential

func Base64UrlDecode

func Base64UrlDecode(str string) ([]byte, error)

func Base64UrlEncode

func Base64UrlEncode(data []byte) string

func FetchRegion

func FetchRegion(req *http.Request) string

func FetchSession

func FetchSession(ctx context.Context, r *http.Request) *mcclient.ClientSession

func GetUploaderWorker

func GetUploaderWorker() *appsrv.SWorkerManager

func NewMethodHandlerFactory

func NewMethodHandlerFactory(method string, mf appsrv.MiddlewareFunc, prefix string) func(handleFunc, ...string) SHandler

func RpcHandler

func RpcHandler(ctx context.Context, w http.ResponseWriter, req *http.Request)

func UploadHandlerInfo

func UploadHandlerInfo(method, prefix string, handler func(context.Context, http.ResponseWriter, *http.Request)) *appsrv.SHandlerInfo

Types

type AuthHandlers

type AuthHandlers struct {
	*SHandlers
	// contains filtered or unexported fields
}

func NewAuthHandlers

func NewAuthHandlers(prefix string, preLoginHook PreLoginFunc) *AuthHandlers

func (*AuthHandlers) AddMethods

func (h *AuthHandlers) AddMethods()

func (*AuthHandlers) Bind

func (h *AuthHandlers) Bind(app *appsrv.Application)

func (*AuthHandlers) GetRegionsResponse

func (h *AuthHandlers) GetRegionsResponse(ctx context.Context, w http.ResponseWriter, req *http.Request) (*agapi.SRegionsReponse, error)

type CSRFResourceHandler

type CSRFResourceHandler struct {
	*SHandlers
}

func NewCSRFResourceHandler

func NewCSRFResourceHandler(prefix string) *CSRFResourceHandler

func (*CSRFResourceHandler) Bind

func (h *CSRFResourceHandler) Bind(app *appsrv.Application)

type HandlerPath

type HandlerPath struct {
	// contains filtered or unexported fields
}

func NewHP

func NewHP(f handleFunc, paths ...string) HandlerPath

type IHandler

type IHandler interface {
	Bind(*appsrv.Application)
}

type InfluxdbProxyHandler

type InfluxdbProxyHandler struct {
	// contains filtered or unexported fields
}

func NewInfluxdbProxyHandler

func NewInfluxdbProxyHandler(prefix string) *InfluxdbProxyHandler

func NewProxyHandlerWithService

func NewProxyHandlerWithService(prefix string, serviceName string) *InfluxdbProxyHandler

func (*InfluxdbProxyHandler) Bind

func (h *InfluxdbProxyHandler) Bind(app *appsrv.Application)

type K8sResourceHandler

type K8sResourceHandler struct {
	// contains filtered or unexported fields
}

func NewK8sResourceHandler

func NewK8sResourceHandler(prefix string) *K8sResourceHandler

func (*K8sResourceHandler) Bind

func (h *K8sResourceHandler) Bind(app *appsrv.Application)

func (*K8sResourceHandler) Delete

func (*K8sResourceHandler) Get

func (*K8sResourceHandler) GetYAML

func (*K8sResourceHandler) Put

type Message

type Message struct {
	RiskLevel int `json:"riskLevel"`

	SendIP string `json:"sendIP"`

	ManufacturerCode string `json:"manufacturerCode"`

	EventId string `json:"eventId"`

	Username string `json:"username"`

	ModuleType string `json:"moduleType"`

	EventDate string `json:"eventDate"`

	EventType string `json:"eventType"`

	EventResult string `json:"eventResult"`

	EventDesc string `json:"eventDesc"`

	BehaviorType int `json:"behaviorType"`
}

type MiscHandler

type MiscHandler struct {
	// contains filtered or unexported fields
}

func NewMiscHandler

func NewMiscHandler(prefix string) *MiscHandler

func (*MiscHandler) Bind

func (h *MiscHandler) Bind(app *appsrv.Application)

func (*MiscHandler) DoBatchHostRegister

func (mh *MiscHandler) DoBatchHostRegister(ctx context.Context, w http.ResponseWriter, req *http.Request)

func (*MiscHandler) DoBatchUserRegister

func (mh *MiscHandler) DoBatchUserRegister(ctx context.Context, w http.ResponseWriter, req *http.Request)

func (*MiscHandler) GetPrefix

func (h *MiscHandler) GetPrefix() string

func (*MiscHandler) PostUploads

func (mh *MiscHandler) PostUploads(ctx context.Context, w http.ResponseWriter, req *http.Request)

type PreLoginFunc

type PreLoginFunc func(ctx context.Context, req *http.Request, body jsonutils.JSONObject) error

type RPCHandlers

type RPCHandlers struct {
	*SHandlers
}

func NewRPCHandlers

func NewRPCHandlers(prefix string) *RPCHandlers

func (*RPCHandlers) AddGet

func (*RPCHandlers) AddPost

func (h *RPCHandlers) AddPost(mf appsrv.MiddlewareFunc) *RPCHandlers

type Request

type Request struct {
	// contains filtered or unexported fields
}

func (*Request) Action

func (req *Request) Action() string

func (*Request) Body

func (req *Request) Body() jsonutils.JSONObject

func (*Request) Error

func (req *Request) Error() error

func (*Request) Mod1

func (req *Request) Mod1() modulebase.Manager

func (*Request) Mod2

func (req *Request) Mod2() modulebase.Manager

func (*Request) Mod3

func (req *Request) Mod3() modulebase.Manager

func (*Request) Params

func (req *Request) Params() map[string]string

func (*Request) Query

func (req *Request) Query() jsonutils.JSONObject

func (*Request) ResID

func (req *Request) ResID() string

func (*Request) ResID2

func (req *Request) ResID2() string

func (*Request) ResID3

func (req *Request) ResID3() string

func (*Request) ResName

func (req *Request) ResName() string

func (*Request) ResName2

func (req *Request) ResName2() string

func (*Request) ResName3

func (req *Request) ResName3() string

func (*Request) Session

func (req *Request) Session() *mcclient.ClientSession

func (*Request) Spec

func (req *Request) Spec() string

func (*Request) WithMod1

func (req *Request) WithMod1() *Request

func (*Request) WithMod2

func (req *Request) WithMod2() *Request

func (*Request) WithMod3

func (req *Request) WithMod3() *Request

type ResourceHandlers

type ResourceHandlers struct {
	*SHandlers
}

func NewResourceHandlers

func NewResourceHandlers(prefix string) *ResourceHandlers

func (*ResourceHandlers) AddDelete

func (*ResourceHandlers) AddGet

func (*ResourceHandlers) AddPatch

func (*ResourceHandlers) AddPost

func (*ResourceHandlers) AddPut

type SActionLog

type SActionLog struct {
	User     string
	Severity string
	Service  string
	Ip       string
	Notes    string
	Kind     string
	OpsTime  time.Time
	ObjType  string
	Id       uint64
	Success  *bool
	Action   string
}

type SBackendServiceProxyHandler

type SBackendServiceProxyHandler struct {
	// contains filtered or unexported fields
}

func NewBackendServiceProxyHandler

func NewBackendServiceProxyHandler(prefix string) *SBackendServiceProxyHandler

func (*SBackendServiceProxyHandler) Bind

type SHandler

type SHandler struct {
	Method         string
	Prefix         string
	MiddlewareFunc appsrv.MiddlewareFunc
	HandleFunc     handleFunc
}

func NewHandler

func NewHandler(method string, mf appsrv.MiddlewareFunc, hf handleFunc, paths ...string) SHandler

func (SHandler) Bind

func (h SHandler) Bind(app *appsrv.Application)

type SHandlers

type SHandlers struct {
	// contains filtered or unexported fields
}

func NewHandlers

func NewHandlers(prefix string) *SHandlers

func (*SHandlers) AddByMethod

func (f *SHandlers) AddByMethod(method string, mf appsrv.MiddlewareFunc, hs ...HandlerPath) *SHandlers

func (*SHandlers) Bind

func (f *SHandlers) Bind(app *appsrv.Application)

func (*SHandlers) GetPrefix

func (f *SHandlers) GetPrefix() string

type SOIDCClientInfo

type SOIDCClientInfo struct {
	Timestamp int64
	Ip        netutils.IPV4Addr
	UserId    string
	ProjectId string
	Region    string
}

type SOIDCClientToken

type SOIDCClientToken struct {
	Info SOIDCClientInfo
}

type SOIDCRPInitLogoutRequest

type SOIDCRPInitLogoutRequest struct {
	// RECOMMENDED. ID Token previously issued by the OP to the RP passed to the Logout Endpoint
	// as a hint about the End-User's current authenticated session with the Client. This is used
	// as an indication of the identity of the End-User that the RP is requesting be logged out by the OP.
	IdTokenHint string `json:"id_token_hint"`
	// OPTIONAL. Hint to the Authorization Server about the End-User that is logging out. The value
	// and meaning of this parameter is left up to the OP's discretion. For instance, the value might
	// contain an email address, phone number, username, or session identifier pertaining to the RP's
	// session with the OP for the End-User. (This parameter is intended to be analogous to the
	// login_hint parameter defined in Section 3.1.2.1 of OpenID Connect Core 1.0 [OpenID.Core] that
	// is used in Authentication Requests; whereas, logout_hint is used in RP-Initiated Logout Requests.)
	LogoutHint string `json:"logout_hint"`
	// OPTIONAL. OAuth 2.0 Client Identifier valid at the Authorization Server. When both client_id and
	// id_token_hint are present, the OP MUST verify that the Client Identifier matches the one used when
	// issuing the ID Token. The most common use case for this parameter is to specify the Client Identifier
	// when post_logout_redirect_uri is used but id_token_hint is not. Another use is for symmetrically
	// encrypted ID Tokens used as id_token_hint values that require the Client Identifier to be specified
	// by other means, so that the ID Tokens can be decrypted by the OP.
	ClientId string `json:"client_id"`
	// OPTIONAL. URI to which the RP is requesting that the End-User's User Agent be redirected after a
	// logout has been performed. This URI SHOULD use the https scheme and MAY contain port, path, and
	// query parameter components; however, it MAY use the http scheme, provided that the Client Type is
	// confidential, as defined in Section 2.1 of OAuth 2.0 [RFC6749], and provided the OP allows the use
	// of http RP URIs. The URI MAY use an alternate scheme, such as one that is intended to identify a
	// callback into a native application. The value MUST have been previously registered with the OP,
	// either using the post_logout_redirect_uris Registration parameter or via another mechanism. An
	// id_token_hint is also RECOMMENDED when this parameter is included.
	PostLogoutRedirectUri string `json:"post_logout_redirect_uri"`
	// OPTIONAL. Opaque value used by the RP to maintain state between the logout request and the callback
	// to the endpoint specified by the post_logout_redirect_uri parameter. If included in the logout request,
	// the OP passes this value back to the RP using the state parameter when redirecting the User Agent back to the RP.
	State string `json:"state"`
	// OPTIONAL. End-User's preferred languages and scripts for the user interface, represented as a
	// space-separated list of BCP47 [RFC5646] language tag values, ordered by preference. For instance,
	// the value "fr-CA fr en" represents a preference for French as spoken in Canada, then French (without
	// a region designation), followed by English (without a region designation). An error SHOULD NOT result
	// if some or all of the requested locales are not supported by the OpenID Provider.
	UiLocales string `json:"ui_locales"`
}

Jump to

Keyboard shortcuts

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