hook

package
v0.0.0-...-ee57881 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2024 License: Apache-2.0 Imports: 22 Imported by: 1

Documentation

Index

Constants

View Source
const HeaderRequestBodySignature = "x-authgear-body-signature"

Variables

View Source
var ContextKeyDenoClient = denoClientContextKeyType{}
View Source
var DenoCheckError = apierrors.Invalid.WithReason("DenoCheckError")
View Source
var DenoFileFilenameRegexp = regexp.MustCompile(`^deno/[.0-9a-zA-Z]+\.ts$`)
View Source
var DenoRunError = apierrors.BadRequest.WithReason("DenoRunError")
View Source
var WebHookDeliveryTimeout = apierrors.InternalError.WithReason("WebHookDeliveryTimeout")
View Source
var WebHookDisallowed = apierrors.Forbidden.WithReason("WebHookDisallowed")
View Source
var WebHookInvalidResponse = apierrors.InternalError.WithReason("WebHookInvalidResponse")

Functions

This section is empty.

Types

type AsyncDenoClient

type AsyncDenoClient interface {
	DenoClient
}

func NewAsyncDenoClient

func NewAsyncDenoClient(endpoint config.DenoEndpoint, logger Logger) AsyncDenoClient

type AsyncHTTPClient

type AsyncHTTPClient struct {
	*http.Client
}

func NewAsyncHTTPClient

func NewAsyncHTTPClient() AsyncHTTPClient

type CheckRequest

type CheckRequest struct {
	Script string `json:"script"`
}

type CheckResponse

type CheckResponse struct {
	Stderr string `json:"stderr,omitempty"`
}

type CustomAttributesServiceNoEvent

type CustomAttributesServiceNoEvent interface {
	UpdateAllCustomAttributes(ctx context.Context, role accesscontrol.Role, userID string, reprForm map[string]interface{}) error
}

type DenoClient

type DenoClient interface {
	Run(ctx context.Context, script string, input interface{}) (out interface{}, err error)
}

type DenoClientImpl

type DenoClientImpl struct {
	Endpoint   string
	HTTPClient *http.Client
	Logger     Logger
}

func (*DenoClientImpl) Check

func (c *DenoClientImpl) Check(ctx context.Context, snippet string) error

func (*DenoClientImpl) Run

func (c *DenoClientImpl) Run(ctx context.Context, snippet string, input interface{}) (interface{}, error)

type DenoFileDescriptor

type DenoFileDescriptor struct{}

func (DenoFileDescriptor) FindResources

func (d DenoFileDescriptor) FindResources(fs resource.Fs) ([]resource.Location, error)

func (DenoFileDescriptor) MatchResource

func (DenoFileDescriptor) MatchResource(path string) (*resource.Match, bool)

func (DenoFileDescriptor) UpdateResource

func (DenoFileDescriptor) ViewResources

func (DenoFileDescriptor) ViewResources(resources []resource.ResourceFile, rawView resource.View) (interface{}, error)

type DenoHook

type DenoHook struct {
	ResourceManager ResourceManager
	Logger          DenoHookLogger
}

func (*DenoHook) RunAsync

func (h *DenoHook) RunAsync(ctx context.Context, client DenoClient, u *url.URL, input interface{}) (err error)

func (*DenoHook) RunSync

func (h *DenoHook) RunSync(ctx context.Context, client DenoClient, u *url.URL, input interface{}) (out interface{}, err error)

func (*DenoHook) SupportURL

func (h *DenoHook) SupportURL(u *url.URL) bool

type DenoHookLogger

type DenoHookLogger struct{ *log.Logger }

func NewDenoHookLogger

func NewDenoHookLogger(lf *log.Factory) DenoHookLogger

type EventDenoHook

type EventDenoHook interface {
	SupportURL(u *url.URL) bool
	DeliverBlockingEvent(ctx context.Context, u *url.URL, e *event.Event) (*event.HookResponse, error)
	DeliverNonBlockingEvent(ctx context.Context, u *url.URL, e *event.Event) error
}

type EventDenoHookImpl

type EventDenoHookImpl struct {
	DenoHook
	SyncDenoClient  SyncDenoClient
	AsyncDenoClient AsyncDenoClient
}

func (*EventDenoHookImpl) DeliverBlockingEvent

func (h *EventDenoHookImpl) DeliverBlockingEvent(ctx context.Context, u *url.URL, e *event.Event) (*event.HookResponse, error)

func (*EventDenoHookImpl) DeliverNonBlockingEvent

func (h *EventDenoHookImpl) DeliverNonBlockingEvent(ctx context.Context, u *url.URL, e *event.Event) error

type EventWebHook

type EventWebHook interface {
	SupportURL(u *url.URL) bool
	DeliverBlockingEvent(ctx context.Context, u *url.URL, e *event.Event) (*event.HookResponse, error)
	DeliverNonBlockingEvent(ctx context.Context, u *url.URL, e *event.Event) error
}

type EventWebHookImpl

type EventWebHookImpl struct {
	WebHookImpl
	SyncHTTP  SyncHTTPClient
	AsyncHTTP AsyncHTTPClient
}

func (*EventWebHookImpl) DeliverBlockingEvent

func (h *EventWebHookImpl) DeliverBlockingEvent(ctx context.Context, u *url.URL, e *event.Event) (*event.HookResponse, error)

func (*EventWebHookImpl) DeliverNonBlockingEvent

func (h *EventWebHookImpl) DeliverNonBlockingEvent(ctx context.Context, u *url.URL, e *event.Event) error

type Logger

type Logger struct{ *log.Logger }

func NewLogger

func NewLogger(lf *log.Factory) Logger

type OperationDisallowedItem

type OperationDisallowedItem struct {
	Title  string `json:"title"`
	Reason string `json:"reason"`
}

type ResourceManager

type ResourceManager interface {
	Read(desc resource.Descriptor, view resource.View) (interface{}, error)
}

type RolesAndGroupsServiceNoEvent

type RolesAndGroupsServiceNoEvent interface {
	ResetUserRole(ctx context.Context, options *rolesgroups.ResetUserRoleOptions) error
	ResetUserGroup(ctx context.Context, options *rolesgroups.ResetUserGroupOptions) error
}

type RunRequest

type RunRequest struct {
	Script string      `json:"script"`
	Input  interface{} `json:"input"`
}

type RunResponse

type RunResponse struct {
	Error  string      `json:"error,omitempty"`
	Output interface{} `json:"output,omitempty"`
	Stderr *Stream     `json:"stderr,omitempty"`
	Stdout *Stream     `json:"stdout,omitempty"`
}

type Sink

type Sink struct {
	Logger             Logger
	Config             *config.HookConfig
	Clock              clock.Clock
	EventWebHook       EventWebHook
	EventDenoHook      EventDenoHook
	StandardAttributes StandardAttributesServiceNoEvent
	CustomAttributes   CustomAttributesServiceNoEvent
	RolesAndGroups     RolesAndGroupsServiceNoEvent
}

func (*Sink) DeliverBlockingEvent

func (s *Sink) DeliverBlockingEvent(ctx context.Context, e *event.Event) error

func (*Sink) DeliverNonBlockingEvent

func (s *Sink) DeliverNonBlockingEvent(ctx context.Context, e *event.Event) error

func (*Sink) ReceiveBlockingEvent

func (s *Sink) ReceiveBlockingEvent(ctx context.Context, e *event.Event) (err error)

func (*Sink) ReceiveNonBlockingEvent

func (s *Sink) ReceiveNonBlockingEvent(ctx context.Context, e *event.Event) (err error)

func (*Sink) WillDeliverBlockingEvent

func (s *Sink) WillDeliverBlockingEvent(eventType event.Type) bool

func (*Sink) WillDeliverNonBlockingEvent

func (s *Sink) WillDeliverNonBlockingEvent(eventType event.Type) bool

type StandardAttributesServiceNoEvent

type StandardAttributesServiceNoEvent interface {
	UpdateStandardAttributes(ctx context.Context, role accesscontrol.Role, userID string, stdAttrs map[string]interface{}) error
}

type Stream

type Stream struct {
	String    string `json:"string,omitempty"`
	Truncated bool   `json:"truncated,omitempty"`
}

type SyncDenoClient

type SyncDenoClient interface {
	DenoClient
}

func NewSyncDenoClient

func NewSyncDenoClient(endpoint config.DenoEndpoint, c *config.HookConfig, logger Logger) SyncDenoClient

type SyncHTTPClient

type SyncHTTPClient struct {
	*http.Client
}

func NewSyncHTTPClient

func NewSyncHTTPClient(c *config.HookConfig) SyncHTTPClient

type WebHook

type WebHook interface {
	SupportURL(u *url.URL) bool
	PrepareRequest(ctx context.Context, u *url.URL, body interface{}) (*http.Request, error)
	PerformWithResponse(client *http.Client, request *http.Request) (resp *http.Response, err error)
	PerformNoResponse(client *http.Client, request *http.Request) error
}

type WebHookImpl

type WebHookImpl struct {
	Logger WebHookLogger
	Secret *config.WebhookKeyMaterials
}

func (*WebHookImpl) PerformNoResponse

func (h *WebHookImpl) PerformNoResponse(
	client *http.Client,
	request *http.Request) error

func (*WebHookImpl) PerformWithResponse

func (h *WebHookImpl) PerformWithResponse(
	client *http.Client,
	request *http.Request) (resp *http.Response, err error)

The caller should close the response body if the response is not nil.

func (*WebHookImpl) PrepareRequest

func (h *WebHookImpl) PrepareRequest(ctx context.Context, u *url.URL, body interface{}) (*http.Request, error)

func (*WebHookImpl) SupportURL

func (h *WebHookImpl) SupportURL(u *url.URL) bool

type WebHookLogger

type WebHookLogger struct{ *log.Logger }

func NewWebHookLogger

func NewWebHookLogger(lf *log.Factory) WebHookLogger

Jump to

Keyboard shortcuts

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