Documentation ¶
Index ¶
- Constants
- Variables
- func SpringBootRespEncoderV2() web.EncodeResponseFunc
- func SpringBootRespEncoderV3() web.EncodeResponseFunc
- type AccessControlCustomizeFunc
- type AccessControlCustomizer
- func NewAccessControlByPermissions(properties SecurityProperties, defaultPerms ...string) AccessControlCustomizer
- func NewAccessControlByScopes(properties SecurityProperties, usePermissions bool, defaultScopes ...string) AccessControlCustomizer
- func NewSimpleAccessControl(acCreator func(epId string) access.ControlFunc) AccessControlCustomizer
- type BasicEndpointProperties
- type Endpoint
- type EndpointBase
- func (b EndpointBase) EnabledByDefault() bool
- func (b EndpointBase) Id() string
- func (b EndpointBase) Operations() []Operation
- func (b EndpointBase) ReadOperation(ctx context.Context, input interface{}) (interface{}, error)
- func (b EndpointBase) WriteOperation(ctx context.Context, input interface{}) (interface{}, error)
- type EndpointExecutor
- type EndpointOption
- type EndpointOptions
- type EndpointSecurityProperties
- type EndpointsProperties
- type ManagementProperties
- type MappingNameFunc
- type MappingPathFunc
- type Operation
- type OperationFunc
- type OperationMode
- type Registrar
- type SecurityCustomizer
- type SecurityCustomizerFunc
- type SecurityProperties
- type WebEndpoint
- type WebEndpointBase
- func (b WebEndpointBase) MappingName(op Operation) string
- func (b WebEndpointBase) MappingPath(_ Operation, props *WebEndpointsProperties) string
- func (b WebEndpointBase) Mappings(op Operation, group string) ([]web.Mapping, error)
- func (b WebEndpointBase) NegotiableResponseEncoder() web.EncodeResponseFunc
- func (b WebEndpointBase) NegotiateFormat(ctx context.Context) string
- func (b WebEndpointBase) RestMappingBuilder(op Operation, group string, pathFunc MappingPathFunc, nameFunc MappingNameFunc) (*rest.MappingBuilder, error)
- type WebEndpoints
- type WebEndpointsProperties
- type WebExposureProperties
Constants ¶
const ( MinActuatorPrecedence = bootstrap.ActuatorPrecedence MaxActuatorPrecedence = bootstrap.ActuatorPrecedence + bootstrap.FrameworkModulePrecedenceBandwidth )
const ( ContentTypeSpringBootV2 = "application/vnd.spring-boot.actuator.v2+json" ContentTypeSpringBootV3 = "application/vnd.spring-boot.actuator.v3+json" )
const (
ManagementPropertiesPrefix = "management"
)
Variables ¶
var Module = &bootstrap.Module{ Name: "actuate", Precedence: MaxActuatorPrecedence, Options: []fx.Option{ fx.Provide(NewRegistrar, BindManagementProperties), fx.Invoke(initialize), }, }
Functions ¶
func SpringBootRespEncoderV2 ¶
func SpringBootRespEncoderV2() web.EncodeResponseFunc
func SpringBootRespEncoderV3 ¶
func SpringBootRespEncoderV3() web.EncodeResponseFunc
Types ¶
type AccessControlCustomizeFunc ¶
type AccessControlCustomizeFunc func(ac *access.AccessControlFeature, epId string, paths []string)
AccessControlCustomizeFunc convert a function to interface AccessControlCustomizer
func (AccessControlCustomizeFunc) Customize ¶
func (f AccessControlCustomizeFunc) Customize(ac *access.AccessControlFeature, epId string, paths []string)
type AccessControlCustomizer ¶
type AccessControlCustomizer interface {
Customize(ac *access.AccessControlFeature, epId string, paths []string)
}
AccessControlCustomizer Similar to SecurityCustomizer, but is used to customize access control of each endpoint. Implementations of AccessControlCustomizer can be registered via Registrar, and NewAccessControlByPermissions is used if no other customizer is registered. Also See NewSimpleAccessControl, NewAccessControlByPermissions, NewAccessControlByScopes
func NewAccessControlByPermissions ¶
func NewAccessControlByPermissions(properties SecurityProperties, defaultPerms ...string) AccessControlCustomizer
NewAccessControlByPermissions returns a AccessControlCustomizer that uses SecurityProperties and given default permissions to setup access control of each endpoint. 1. If security of any particular endpoint is not enabled, access.PermitAll is used 2. If no permissions are configured in the properties and no defaults are given, access.Authenticated is used
This is the default AccessControlCustomizer if no other AccessControlCustomizer is registered
func NewAccessControlByScopes ¶
func NewAccessControlByScopes(properties SecurityProperties, usePermissions bool, defaultScopes ...string) AccessControlCustomizer
NewAccessControlByScopes returns a AccessControlCustomizer that uses SecurityProperties and given default approved scopes to setup access control of each endpoint. "usePermissions" indicate if we should use permissions configured in SecurityProperties for scope checking
1. If security of any particular endpoint is not enabled, access.PermitAll is used 2. If usePermissions is true but no permissions are configured in SecurityProperties, defaultScopes is used to resolve scoes 3. If no scopes are configured (regardless if usePermissions is enabled), access.Authenticated is used
Note: This customizer is particularly useful for client_credentials grant type
func NewSimpleAccessControl ¶
func NewSimpleAccessControl(acCreator func(epId string) access.ControlFunc) AccessControlCustomizer
NewSimpleAccessControl is a convenient AccessControlCustomizer constructor that create simple access control rule to ALL paths of each endpoint. A mapper function is required to convert each endpoint ID to its corresponding access.ControlFunc
type BasicEndpointProperties ¶
type BasicEndpointProperties struct {
Enabled *bool `json:"enabled"`
}
type EndpointBase ¶
type EndpointBase struct {
// contains filtered or unexported fields
}
EndpointBase implements EndpointExecutor and partially Endpoint, and can be embedded into any Endpoint implementation it calls Operations using reflect
func MakeEndpointBase ¶
func MakeEndpointBase(opts ...EndpointOptions) EndpointBase
func (EndpointBase) EnabledByDefault ¶
func (b EndpointBase) EnabledByDefault() bool
func (EndpointBase) Id ¶
func (b EndpointBase) Id() string
func (EndpointBase) Operations ¶
func (b EndpointBase) Operations() []Operation
func (EndpointBase) ReadOperation ¶
func (b EndpointBase) ReadOperation(ctx context.Context, input interface{}) (interface{}, error)
func (EndpointBase) WriteOperation ¶
func (b EndpointBase) WriteOperation(ctx context.Context, input interface{}) (interface{}, error)
type EndpointExecutor ¶
type EndpointOption ¶
type EndpointOption struct { Id string Ops []Operation Properties *EndpointsProperties EnabledByDefault bool }
type EndpointOptions ¶
type EndpointOptions func(opt *EndpointOption)
type EndpointSecurityProperties ¶
type EndpointSecurityProperties struct { Enabled *bool `json:"enabled"` Permissions utils.CommaSeparatedSlice `json:"permissions"` }
type EndpointsProperties ¶
type EndpointsProperties struct { EnabledByDefault bool `json:"enabled-by-default"` Web WebEndpointsProperties `json:"web"` }
type ManagementProperties ¶
type ManagementProperties struct { Enabled bool `json:"enabled"` Endpoints EndpointsProperties `json:"endpoints"` BasicEndpoint map[string]BasicEndpointProperties `json:"endpoint"` Security SecurityProperties `json:"security"` }
func BindManagementProperties ¶
func BindManagementProperties(ctx *bootstrap.ApplicationContext) ManagementProperties
BindManagementProperties create and bind SessionProperties, with a optional prefix
func NewManagementProperties ¶
func NewManagementProperties() *ManagementProperties
NewManagementProperties create a ManagementProperties with default values
type MappingNameFunc ¶
type MappingPathFunc ¶
type MappingPathFunc func(op Operation, props *WebEndpointsProperties) string
type Operation ¶
type Operation interface { Mode() OperationMode Func() OperationFunc Matches(ctx context.Context, mode OperationMode, input interface{}) bool Execute(ctx context.Context, input interface{}) (interface{}, error) }
func NewReadOperation ¶
func NewReadOperation(opFunc OperationFunc, inputMatchers ...matcher.Matcher) Operation
func NewWriteOperation ¶
func NewWriteOperation(opFunc OperationFunc, inputMatchers ...matcher.Matcher) Operation
type OperationFunc ¶
type OperationFunc interface{}
OperationFunc is a func that have following signature:
func(ctx context.Context, input StructsOrPointerType1) (StructsOrPointerType2, error)
where
- StructsOrPointerType1 and StructsOrPointerType2 can be any structs or struct pointers
- input might be ignored by particular Endpoint impl.
- 1st output is optional for "write" operations
Note: golang doesn't have generics yet...
type OperationMode ¶
type OperationMode int
const ( OperationRead OperationMode = iota OperationWrite )
type Registrar ¶
type Registrar struct {
// contains filtered or unexported fields
}
func NewRegistrar ¶
func NewRegistrar(di constructDI) *Registrar
func (*Registrar) MustRegister ¶
func (r *Registrar) MustRegister(items ...interface{})
type SecurityCustomizer ¶
type SecurityCustomizer interface {
Customize(ws security.WebSecurity)
}
SecurityCustomizer is a single SecurityCustomizer can be registered via Registrar SecurityCustomizer is typically responsible to setup authentication scheme it should not configure access control, which is configured per-endpoint via properties or AccessControlCustomizer
func NewTokenAuthSecurity ¶
func NewTokenAuthSecurity() SecurityCustomizer
NewTokenAuthSecurity returns a SecurityCustomizer config actuator security to use OAuth2 token auth. This is the default SecurityCustomizer if no other SecurityCustomizer is registered
type SecurityCustomizerFunc ¶
type SecurityCustomizerFunc func(ws security.WebSecurity)
SecurityCustomizerFunc convert a function to interface SecurityCustomizer
func (SecurityCustomizerFunc) Customize ¶
func (f SecurityCustomizerFunc) Customize(ws security.WebSecurity)
type SecurityProperties ¶
type SecurityProperties struct { EnabledByDefault bool `json:"enabled-by-default"` Permissions utils.CommaSeparatedSlice `json:"permissions"` Endpoints map[string]EndpointSecurityProperties `json:"endpoint"` }
type WebEndpoint ¶
type WebEndpointBase ¶
type WebEndpointBase struct { EndpointBase // contains filtered or unexported fields }
WebEndpointBase is similar to EndpointBase and implements default WebEndpoint mapping
func MakeWebEndpointBase ¶
func MakeWebEndpointBase(opts ...EndpointOptions) WebEndpointBase
func (WebEndpointBase) MappingName ¶
func (b WebEndpointBase) MappingName(op Operation) string
func (WebEndpointBase) MappingPath ¶
func (b WebEndpointBase) MappingPath(_ Operation, props *WebEndpointsProperties) string
func (WebEndpointBase) NegotiableResponseEncoder ¶
func (b WebEndpointBase) NegotiableResponseEncoder() web.EncodeResponseFunc
func (WebEndpointBase) NegotiateFormat ¶
func (b WebEndpointBase) NegotiateFormat(ctx context.Context) string
func (WebEndpointBase) RestMappingBuilder ¶
func (b WebEndpointBase) RestMappingBuilder(op Operation, group string, pathFunc MappingPathFunc, nameFunc MappingNameFunc) (*rest.MappingBuilder, error)
type WebEndpoints ¶
func (WebEndpoints) EndpointIDs ¶
func (w WebEndpoints) EndpointIDs() (ret []string)
func (WebEndpoints) Paths ¶
func (w WebEndpoints) Paths(id string) []string
Paths returns all path patterns of given endpoint ID. only web.RoutedMapping & web.StaticMapping is possible to extract this information
type WebEndpointsProperties ¶
type WebEndpointsProperties struct { BasePath string `json:"base-path"` Mappings map[string]string `json:"path-mapping"` Exposure WebExposureProperties `json:"exposure"` }