event

package
v0.0.0-...-5ab21f3 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const ContextSchema = `` /* 141-byte string literal not displayed */

@JSONSchema

Variables

View Source
var HookResponseSchema = validation.NewSimpleSchema(`
{
	"oneOf": [
		{
			"type": "object",
			"additionalProperties": false,
			"properties": {
				"is_allowed": { "const": true },
				"mutations": {
					"type": "object",
					"properties": {
						"user": {
							"type": "object",
							"properties": {
								"standard_attributes": {
									"type": "object"
								},
								"custom_attributes": {
									"type": "object"
								}
							}
						},
						"jwt": {
							"type": "object",
							"properties": {
								"payload": {
									"type": "object"
								}
							}
						}
					}
				}
			},
			"required": ["is_allowed"]
		},
		{
			"type": "object",
			"additionalProperties": false,
			"properties": {
				"is_allowed": { "const": false },
				"title": { "type": "string" },
				"reason": { "type": "string" }
			},
			"required": ["is_allowed"]
		}
	]
}
`)

Functions

This section is empty.

Types

type BlockingPayload

type BlockingPayload interface {
	Payload
	BlockingEventType() Type
	// ApplyMutations applies mutations to itself.
	ApplyMutations(ctx context.Context, mutations Mutations) bool
	// PerformEffects performs the side effects of the mutations.
	PerformEffects(ctx context.Context, effectCtx MutationsEffectContext) error
}

type Context

type Context struct {
	Timestamp          int64           `json:"timestamp"`
	UserID             *string         `json:"user_id"`
	TriggeredBy        TriggeredByType `json:"triggered_by"`
	AuditContext       interface{}     `json:"audit_context"`
	PreferredLanguages []string        `json:"preferred_languages"`
	Language           string          `json:"language"`

	OAuth     *OAuthContext `json:"oauth,omitempty"`
	IPAddress string        `json:"ip_address,omitempty"`
	UserAgent string        `json:"user_agent,omitempty"`
	AppID     string        `json:"app_id,omitempty"`
	ClientID  string        `json:"client_id,omitempty"`
}

type CustomAttributesServiceNoEvent

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

type Event

type Event struct {
	ID            string  `json:"id"`
	Seq           int64   `json:"seq"`
	Type          Type    `json:"type"`
	Payload       Payload `json:"payload"`
	Context       Context `json:"context"`
	IsNonBlocking bool    `json:"-"`
}

func (*Event) ApplyMutations

func (e *Event) ApplyMutations(ctx context.Context, mutations Mutations) bool

func (*Event) PerformEffects

func (e *Event) PerformEffects(ctx context.Context, effectCtx MutationsEffectContext) error

type HookResponse

type HookResponse struct {
	IsAllowed bool      `json:"is_allowed"`
	Title     string    `json:"title,omitempty"`
	Reason    string    `json:"reason,omitempty"`
	Mutations Mutations `json:"mutations,omitempty"`
}

func ParseHookResponse

func ParseHookResponse(r io.Reader) (*HookResponse, error)

type JWTMutations

type JWTMutations struct {
	Payload map[string]interface{} `json:"payload,omitempty"`
}

type Mutations

type Mutations struct {
	User UserMutations `json:"user,omitempty"`
	JWT  JWTMutations  `json:"jwt,omitempty"`
}

type MutationsEffectContext

type MutationsEffectContext struct {
	StandardAttributes StandardAttributesServiceNoEvent
	CustomAttributes   CustomAttributesServiceNoEvent
	RolesAndGroups     RolesAndGroupsServiceNoEvent
}

type NonBlockingPayload

type NonBlockingPayload interface {
	Payload
	NonBlockingEventType() Type
	ForHook() bool
	ForAudit() bool
	RequireReindexUserIDs() []string
	DeletedUserIDs() []string
}

type OAuthContext

type OAuthContext struct {
	State  string `json:"state,omitempty"`
	XState string `json:"x_state,omitempty"`
}

type Payload

type Payload interface {
	UserID() string
	GetTriggeredBy() TriggeredByType
	FillContext(ctx *Context)
}

type RolesAndGroupsServiceNoEvent

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

type StandardAttributesServiceNoEvent

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

type TriggeredByType

type TriggeredByType string
const (
	// TriggeredByTypeUser means the event originates from a end-user facing UI.
	TriggeredByTypeUser TriggeredByType = "user"
	// TriggeredByTypeAdminAPI means the event originates from the Admin API.
	TriggeredByTypeAdminAPI TriggeredByType = "admin_api"
	// TriggeredBySystem means the event originates from a background job.
	TriggeredBySystem TriggeredByType = "system"
	// TriggeredByPortal means the event originates from the management portal.
	TriggeredByPortal TriggeredByType = "portal"
)

type Type

type Type string

type UserMutations

type UserMutations struct {
	StandardAttributes map[string]interface{} `json:"standard_attributes,omitempty"`
	CustomAttributes   map[string]interface{} `json:"custom_attributes,omitempty"`
	Roles              []string               `json:"roles,omitempty"`
	Groups             []string               `json:"groups,omitempty"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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