Documentation
¶
Index ¶
- Variables
- type ACLChecker
- type FSChain
- type InnerRingFetcher
- type Netmapper
- type Option
- type RequestInfo
- type Service
- func (b Service) DeleteRequestToInfo(request *protoobject.DeleteRequest, cnr cid.ID, tokens common.RequestTokens) (RequestInfo, error)
- func (b Service) GetRequestToInfo(request *protoobject.GetRequest, cnr cid.ID, tokens common.RequestTokens) (RequestInfo, error)
- func (b Service) HeadRequestToInfo(request *protoobject.HeadRequest, cnr cid.ID, tokens common.RequestTokens) (RequestInfo, error)
- func (b Service) PutRequestToInfo(request *protoobject.PutRequest, initPart *protoobject.PutRequest_Body_Init, ...) (RequestInfo, user.ID, error)
- func (b Service) RangeRequestToInfo(request *protoobject.GetRangeRequest, cnr cid.ID, tokens common.RequestTokens) (RequestInfo, error)
- func (b Service) ResetTokenCheckCache()
- func (b Service) SearchV2RequestToInfo(request *protoobject.SearchV2Request, id cid.ID, tokens common.RequestTokens) (RequestInfo, error)
- func (b Service) VerifyBearerTokenMessage(m *protoacl.BearerToken) (bearer.Token, error)
- func (b Service) VerifySessionTokenMessage(mV2 *protosession.SessionTokenV2, reqVerb sessionv2.Verb, reqCnr cid.ID) (sessionv2.Token, error)
- func (b Service) VerifySessionV1TokenMessage(m *protosession.SessionToken, reqVerb session.ObjectVerb, reqCnr cid.ID, ...) (session.Object, error)
- type TimeProvider
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNotMatched is returned from CheckEACL() when there were no rules // found that match request/object. Most of the time this means there // were no object headers to check rules against, but it can also // mean the default behavior after the full table scan. ErrNotMatched = errors.New("no matching rule") )
var ErrSkipRequest = errors.New("skip request")
Functions ¶
This section is empty.
Types ¶
type ACLChecker ¶
type ACLChecker interface {
// CheckBasicACL must return true only if request
// passes basic ACL validation.
CheckBasicACL(RequestInfo) bool
// CheckEACL must return non-nil error if request
// doesn't pass extended ACL validation.
CheckEACL(context.Context, any, cid.ID, oid.ID, RequestInfo) error
// StickyBitCheck must return true only if sticky bit
// is disabled or enabled but request contains correct
// owner field.
StickyBitCheck(RequestInfo, user.ID) bool
}
ACLChecker is an interface that must provide ACL related checks.
type FSChain ¶ added in v0.46.0
type FSChain interface {
InvokeContainedScript(tx *transaction.Transaction, header *block.Header, _ *trigger.Type, _ *bool) (*result.Invoke, error)
// InContainerInLastTwoEpochs checks whether given public key belongs to any SN
// from the referenced container either in the current or the previous NeoFS
// epoch.
InContainerInLastTwoEpochs(_ cid.ID, pub []byte) (bool, error)
// HasUserInNNS checks whether given user is listed in the NNS domain.
HasUserInNNS(name string, addr util.Uint160) (bool, error)
}
FSChain provides base non-contract functionality of the FS chain required for Service to work.
type InnerRingFetcher ¶
type InnerRingFetcher interface {
// InnerRingKeys must return list of public keys of
// the actual inner ring.
InnerRingKeys() [][]byte
}
InnerRingFetcher is an interface that must provide Inner Ring information.
type Netmapper ¶ added in v0.43.0
type Netmapper interface {
netmapcore.Source
// ServerInContainer checks if current node belongs to requested containercore.
// Any unknown state must be returned as `(false, error.New("explanation"))`,
// not `(false, nil)`.
ServerInContainer(cid.ID) (bool, error)
// GetEpochBlock returns FS chain height when given NeoFS epoch was ticked.
GetEpochBlock(epoch uint64) (uint32, error)
// GetEpochBlockByTime returns FS chain height of block index when the latest epoch that
// started not later than the provided block time came.
GetEpochBlockByTime(t uint32) (uint32, error)
}
Netmapper must provide network map information.
type Option ¶
type Option func(*cfg)
Option represents Service constructor option.
func WithContainerSource ¶
func WithContainerSource(v containercore.Source) Option
WithContainerSource returns option to set container source.
func WithIRFetcher ¶
func WithIRFetcher(v InnerRingFetcher) Option
WithIRFetcher returns option to set inner ring fetcher.
func WithNetmapper ¶ added in v0.43.0
WithNetmapper return option to set netmap source.
func WithTimeProvider ¶ added in v0.51.0
func WithTimeProvider(p TimeProvider) Option
WithTimeProvider sets external chain time provider updated from header subscriptions.
type RequestInfo ¶
type RequestInfo struct {
RequestRole acl.Role
Operation acl.Op // put, get, head, etc.
Container container.Container
SenderKey []byte
SenderAccount *user.ID
Bearer *bearer.Token // bearer token of request
SrcRequest any
}
RequestInfo groups parsed version-independent (from SDK library) request information and raw API request.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service checks basic ACL rules.
func New ¶
func New(fsChain FSChain, sessionsCache *isessions.ObjectSessionsCache, opts ...Option) Service
New is a constructor for object ACL checking service.
func (Service) DeleteRequestToInfo ¶ added in v0.45.0
func (b Service) DeleteRequestToInfo(request *protoobject.DeleteRequest, cnr cid.ID, tokens common.RequestTokens) (RequestInfo, error)
DeleteRequestToInfo resolves RequestInfo from the request to check it using ACLChecker.
func (Service) GetRequestToInfo ¶ added in v0.45.0
func (b Service) GetRequestToInfo(request *protoobject.GetRequest, cnr cid.ID, tokens common.RequestTokens) (RequestInfo, error)
GetRequestToInfo resolves RequestInfo from the request to check it using ACLChecker.
func (Service) HeadRequestToInfo ¶ added in v0.45.0
func (b Service) HeadRequestToInfo(request *protoobject.HeadRequest, cnr cid.ID, tokens common.RequestTokens) (RequestInfo, error)
HeadRequestToInfo resolves RequestInfo from the request to check it using ACLChecker.
func (Service) PutRequestToInfo ¶ added in v0.45.0
func (b Service) PutRequestToInfo(request *protoobject.PutRequest, initPart *protoobject.PutRequest_Body_Init, cnr cid.ID, op acl.Op, tokens common.RequestTokens) (RequestInfo, user.ID, error)
PutRequestToInfo resolves RequestInfo from the request to check it using ACLChecker. Returns ErrSkipRequest if check should not be performed.
func (Service) RangeRequestToInfo ¶ added in v0.45.0
func (b Service) RangeRequestToInfo(request *protoobject.GetRangeRequest, cnr cid.ID, tokens common.RequestTokens) (RequestInfo, error)
RangeRequestToInfo resolves RequestInfo from the request to check it using ACLChecker.
func (Service) ResetTokenCheckCache ¶ added in v0.48.0
func (b Service) ResetTokenCheckCache()
ResetTokenCheckCache resets cache of session and bearer tokens' check results.
func (Service) SearchV2RequestToInfo ¶ added in v0.45.0
func (b Service) SearchV2RequestToInfo(request *protoobject.SearchV2Request, id cid.ID, tokens common.RequestTokens) (RequestInfo, error)
SearchV2RequestToInfo resolves RequestInfo from the request to check it using ACLChecker.
func (Service) VerifyBearerTokenMessage ¶ added in v0.54.0
VerifyBearerTokenMessage validates m and returns converts it into bearer.Token.
func (Service) VerifySessionTokenMessage ¶ added in v0.54.0
func (b Service) VerifySessionTokenMessage(mV2 *protosession.SessionTokenV2, reqVerb sessionv2.Verb, reqCnr cid.ID) (sessionv2.Token, error)
VerifySessionTokenMessage validates mV2 and returns converts it into sessionv2.Token.
func (Service) VerifySessionV1TokenMessage ¶ added in v0.54.0
func (b Service) VerifySessionV1TokenMessage(m *protosession.SessionToken, reqVerb session.ObjectVerb, reqCnr cid.ID, reqObj oid.ID) (session.Object, error)
VerifySessionV1TokenMessage validates m and converts it into [sessionSDK.Object].
type TimeProvider ¶ added in v0.51.0
TimeProvider supplies current FS chain time without calling the chain. It should be updated from block header subscriptions and return time based on the latest observed header timestamp.