privacy

package
v0.0.0-...-d88ec87 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	//RequestPrivacyContextKey is the key under which PrivacyContext can be found in context.Context
	RequestPrivacyContextKey = log.ContextKey("RequestPrivacyContextKey")
)

Variables

View Source
var ErrPrivacyContextNotPresent = errors.New("privacy context not present")

ErrPrivacyContextNotPresent indicates that the privacy.Context is not present in request's context.Context

Functions

func NewChainRoundTripper

func NewChainRoundTripper(onErrorDrop, onValidationDrop bool, violationErrorCode int, chain Chain, roundTripper http.RoundTripper) http.RoundTripper

NewChainRoundTripper creates an instance of ChainRoundTripper

func NewPrivacyContextSupplierRoundTripper

func NewPrivacyContextSupplierRoundTripper(roundTripper http.RoundTripper, supplier ContextSupplier) http.RoundTripper

NewPrivacyContextSupplierRoundTripper creates an instance of SupplierRoundTripper

Types

type BasicChain

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

BasicChain runs each of the filters on the request until the first violation/errror is returned

func (*BasicChain) Filter

func (basicChain *BasicChain) Filter(req *http.Request) (ViolationType, error)

Filter checks for privacy context presence and runs the supplied filters on the req

type BasicPrivacyContextSupplier

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

BasicPrivacyContextSupplier is a basic implemtation of ContextSupplier

func (*BasicPrivacyContextSupplier) Supply

func (basicSupplier *BasicPrivacyContextSupplier) Supply(req *http.Request) (*http.Request, error)

Supply supplies the request with basic privacy info

type BucketPrivacyFilter

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

BucketPrivacyFilter checks if any of the bucket policies are violated

func NewBucketPrivacyFilter

func NewBucketPrivacyFilter(fetcher metadata.BucketMetaDataFetcher) *BucketPrivacyFilter

NewBucketPrivacyFilter creates an instance of BucketPrivacyFilter

func (*BucketPrivacyFilter) Filter

func (filter *BucketPrivacyFilter) Filter(req *http.Request, prvCtx *Context) (ViolationType, error)

Filter checks for bucket-based violations

type Chain

type Chain interface {
	Filter(req *http.Request) (ViolationType, error)
}

Chain runs a set of filters on a req to determine wether any privacy policies have been violated

func NewBasicChain

func NewBasicChain(filters []Filter) Chain

NewBasicChain creates an instance of BasicChain

type ChainRoundTripper

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

ChainRoundTripper uses the supplied Chain to determine any privacy policy violations

func (*ChainRoundTripper) RoundTrip

func (chainRT *ChainRoundTripper) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip checks for violations on req

type Config

type Config struct {
	IsInternalNetworkHeaderName  string `yaml:"IsInternalNetworkHeaderName"`
	IsInternalNetworkHeaderValue string `yaml:"IsInternalNetworkHeaderValue"`
	ShouldDropRequests           bool   `yaml:"ShouldDropRequests"`
	DropOnError                  bool   `yaml:"DropOnError"`
	DropOnValidation             bool   `yaml:"DropOnValidation"`
	ViolationErrorCode           int    `yaml:"ViolationErrorCode"`
}

Config is a configuration for ContextSupplier

type Context

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

Context holds the privacy settings associated with the request

type ContextSupplier

type ContextSupplier interface {
	Supply(req *http.Request) (*http.Request, error)
}

ContextSupplier supplies the context.Context of req with a privacy context

func NewBasicPrivacyContextSupplier

func NewBasicPrivacyContextSupplier(config *Config) ContextSupplier

NewBasicPrivacyContextSupplier creates an instance of BasicPrivacyContextSupplier

type Filter

type Filter = func(req *http.Request, prvCtx *Context) (ViolationType, error)

Filter is a funcion that check requests for a specific violation

func NewBucketPrivacyFilterFunc

func NewBucketPrivacyFilterFunc(fetcher metadata.BucketMetaDataFetcher) Filter

NewBucketPrivacyFilterFunc BucketPrivacyFilter in Filter so it can be used in Chain

type SupplierRoundTripper

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

SupplierRoundTripper supplies the request with a privacy context using the given Supplier

func (*SupplierRoundTripper) RoundTrip

func (supplierRT *SupplierRoundTripper) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip supplies the request with basic privacy info

type ViolationType

type ViolationType int

ViolationType is an code indiciating which (if any) privacy policy has been violated

const (
	//NoViolation means that no violations have been deteced
	NoViolation ViolationType = iota
	//InternalNetworkBucket means that access to internal-network-only bucket has been requested
	//from an external network
	InternalNetworkBucket
)

Jump to

Keyboard shortcuts

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