Documentation ¶
Index ¶
- Constants
- Variables
- func FromBoolArray(s BoolArray) []bool
- func FromCIDArray(s CIDArray) []string
- func FromDataArray(s DataArray) [][]byte
- func FromFloatArray(s FloatArray) []float64
- func FromIntArray(s IntArray) []int64
- func FromStringArray(s StringArray) []string
- func FromUintArray(s UintArray) []uint64
- func Traverse(v interface{}, f func(string, interface{}) bool)
- func UnloadReferences(ctx context.Context, obj *Object) (result *Object, unloaded []*Object, err error)
- func Verify(o *Object) error
- type ArrayValue
- type Bool
- type BoolArray
- type CID
- type CIDArray
- type CIDSlice
- type Certificate
- type CertificateRequest
- type Data
- type DataArray
- type EvaluationResult
- type Float
- type FloatArray
- type Getter
- type GetterFunc
- type Hint
- type Int
- type IntArray
- type Map
- type MapArray
- type Metadata
- type Object
- type ObjectArray
- type ParsedType
- type Policies
- type Policy
- type PolicyAction
- type PolicyEffect
- type PolicyType
- type ReadCloser
- type Reader
- type Request
- type Response
- type Signature
- type String
- type StringArray
- type Typed
- type Uint
- type UintArray
- type Value
Constants ¶
const ( // Policy types SignaturePolicy PolicyType = "signature" // Policy actions ReadAction PolicyAction = "read" // Policy effects AllowEffect PolicyEffect = "allow" DenyEffect PolicyEffect = "deny" // Policy Evaluation results ExplicitDeny EvaluationResult = "ExplicitDeny" ImplicitDeny EvaluationResult = "ImplicitDeny" ExplicitAllow EvaluationResult = "ExplicitAllow" )
const ( ErrInvalidSigner = errors.Error("signer is does not match owner") ErrMissingSignature = errors.Error("missing signature") ErrCouldNotVerify = errors.Error("could not verify signature") )
const (
// AlgorithmObjectCID for creating ObjectCID+ES256 based signatures
AlgorithmObjectCID = "OH_ES256"
)
const (
EmptyCID = CID("")
)
const (
ErrReaderDone = errors.Error("reader done")
)
const (
ErrSourceNotSupported = errors.Error("encoding source not supported")
)
Variables ¶
var ( // ErrInvalidObjectType is returned when the signature being verified // is not an encoded object of type "signature". ErrInvalidObjectType = errors.New("invalid object type") // ErrAlgorithNotImplemented is returned when the algorithm specified // has not been implemented ErrAlgorithNotImplemented = errors.New("algorithm not implemented") )
var (
ErrTimeout = errors.New("timeout")
)
Functions ¶
func FromBoolArray ¶ added in v0.15.7
func FromCIDArray ¶ added in v0.17.0
func FromDataArray ¶ added in v0.15.7
func FromFloatArray ¶ added in v0.15.7
func FromFloatArray(s FloatArray) []float64
func FromIntArray ¶ added in v0.15.7
func FromStringArray ¶ added in v0.15.7
func FromStringArray(s StringArray) []string
func FromUintArray ¶ added in v0.15.7
func UnloadReferences ¶ added in v0.11.0
Types ¶
type ArrayValue ¶ added in v0.15.7
type Bool ¶ added in v0.10.0
type Bool bool
basic types
func (*Bool) UnmarshalJSON ¶ added in v0.15.7
type BoolArray ¶ added in v0.15.7
type BoolArray []Bool
array types
func ToBoolArray ¶ added in v0.15.7
type CID ¶ added in v0.17.0
type CID string
func GetReferences ¶ added in v0.11.0
type Certificate ¶ added in v0.5.0
type Certificate struct { Metadata Metadata `nimona:"metadata:m,omitempty"` Nonce string Created string Expires string }
func NewCertificate ¶ added in v0.5.0
func NewCertificate( subject crypto.PublicKey, issuer crypto.PrivateKey, ) (*Certificate, error)
func NewCertificateSelfSigned ¶ added in v0.11.0
func NewCertificateSelfSigned(k crypto.PrivateKey) (*Certificate, error)
func (*Certificate) FromObject ¶ added in v0.5.0
func (e *Certificate) FromObject(o *Object) error
func (Certificate) ToObject ¶ added in v0.5.0
func (e Certificate) ToObject() *Object
func (*Certificate) Type ¶ added in v0.12.0
func (e *Certificate) Type() string
type CertificateRequest ¶ added in v0.11.0
type CertificateRequest struct { Metadata Metadata `nimona:"metadata:m,omitempty"` ApplicationName string ApplicationDescription string ApplicationURL string Subject string Resources []string Actions []string Nonce string }
func (*CertificateRequest) FromObject ¶ added in v0.11.0
func (e *CertificateRequest) FromObject(o *Object) error
func (CertificateRequest) ToObject ¶ added in v0.11.0
func (e CertificateRequest) ToObject() *Object
func (*CertificateRequest) Type ¶ added in v0.12.0
func (e *CertificateRequest) Type() string
type EvaluationResult ¶ added in v0.17.1
type EvaluationResult string
type FloatArray ¶ added in v0.15.7
type FloatArray []Float
func ToFloatArray ¶ added in v0.15.7
func ToFloatArray(s []float64) FloatArray
func (FloatArray) Hint ¶ added in v0.15.7
func (v FloatArray) Hint() Hint
func (FloatArray) Len ¶ added in v0.15.7
func (v FloatArray) Len() int
type GetterFunc ¶ added in v0.11.0
GetterFunc is an adapter to allow the use of ordinary functions as object.Getter
type Hint ¶ added in v0.15.7
type Hint string
const ( // basic hints BoolHint Hint = "b" DataHint Hint = "d" FloatHint Hint = "f" IntHint Hint = "i" MapHint Hint = "m" ObjectHint Hint = "o" StringHint Hint = "s" UintHint Hint = "u" CIDHint Hint = "r" // array hints BoolArrayHint Hint = "ab" DataArrayHint Hint = "ad" FloatArrayHint Hint = "af" IntArrayHint Hint = "ai" MapArrayHint Hint = "am" ObjectArrayHint Hint = "ao" StringArrayHint Hint = "as" UintArrayHint Hint = "au" CIDArrayHint Hint = "ar" )
type Map ¶ added in v0.10.0
func (Map) MarshalJSON ¶ added in v0.15.7
func (Map) UnmarshalJSON ¶ added in v0.15.7
type Metadata ¶ added in v0.11.0
type Metadata struct { Owner crypto.PublicKey Datetime string Parents []CID Policies Policies Stream CID Signature Signature }
Metadata for object
func MetadataFromMap ¶ added in v0.15.7
type Object ¶
Object
func LoadReferences ¶ added in v0.11.0
LoadReferences will look for references in the given object, request the referred objects using the getter, and will replace the references with the actual object before returning the complete
func (Object) MarshalJSON ¶ added in v0.15.7
func (*Object) UnmarshalJSON ¶ added in v0.15.7
type ObjectArray ¶ added in v0.15.7
type ObjectArray []*Object // nolint: golint
func (ObjectArray) Hint ¶ added in v0.15.7
func (v ObjectArray) Hint() Hint
func (ObjectArray) Len ¶ added in v0.15.7
func (v ObjectArray) Len() int
type ParsedType ¶ added in v0.11.0
func ParseType ¶ added in v0.11.0
func ParseType(objectType string) ParsedType
type Policies ¶ added in v0.17.1
type Policies []Policy
Policies
func PoliciesFromValue ¶ added in v0.17.1
func (Policies) Evaluate ¶ added in v0.17.1
func (ps Policies) Evaluate( subject crypto.PublicKey, resource string, action PolicyAction, ) EvaluationResult
type Policy ¶
type Policy struct { Type PolicyType Subjects []crypto.PublicKey Resources []string Actions []PolicyAction Effect PolicyEffect }
Policy for object metadata
func PolicyFromMap ¶ added in v0.15.7
func (Policy) Evaluate ¶ added in v0.17.1
func (p Policy) Evaluate( subject crypto.PublicKey, resource string, action PolicyAction, ) EvaluationResult
type PolicyAction ¶ added in v0.17.1
type PolicyAction string
type PolicyEffect ¶ added in v0.17.1
type PolicyEffect string
type PolicyType ¶
type PolicyType string
type ReadCloser ¶ added in v0.11.0
func FetchWithReferences ¶ added in v0.11.0
func FetchWithReferences( ctx context.Context, getter GetterFunc, objectCID CID, ) (ReadCloser, error)
FetchWithReferences will look for references in the given object, request the primary object and all referred objects using the getter, and will return them in a lazy loaded result.
func NewReadCloser ¶ added in v0.11.0
func NewReadCloser( ctx context.Context, objects <-chan *Object, errs <-chan error, closer chan<- struct{}, ) ReadCloser
func NewReadCloserFromObjects ¶ added in v0.11.0
func NewReadCloserFromObjects(objects []*Object) ReadCloser
NewReadCloserFromObjects is mainly used for testing and mocks that return a Reader, or ReadCloser.
type Request ¶ added in v0.11.0
type Request struct { Metadata Metadata `nimona:"metadata:m,omitempty"` RequestID string ObjectCID CID }
func (*Request) FromObject ¶ added in v0.11.0
type Response ¶ added in v0.11.0
type Response struct { Metadata Metadata `nimona:"metadata:m,omitempty"` RequestID string Object *Object }
func (*Response) FromObject ¶ added in v0.11.0
type Signature ¶ added in v0.5.0
type Signature struct { Signer crypto.PublicKey `nimona:"signer:s,omitempty"` Alg string `nimona:"alg:s,omitempty"` X []byte `nimona:"x:d,omitempty"` Certificate *Certificate `nimona:"certificate:m,omitempty"` }
func NewSignature ¶ added in v0.5.0
func NewSignature( k crypto.PrivateKey, o *Object, ) (Signature, error)
NewSignature returns a signature given some bytes and a private key
func SignatureFromMap ¶ added in v0.15.7
type StringArray ¶ added in v0.15.7
type StringArray []String
func ToStringArray ¶ added in v0.15.7
func ToStringArray(s []string) StringArray
func (StringArray) Hint ¶ added in v0.15.7
func (v StringArray) Hint() Hint
func (StringArray) Len ¶ added in v0.15.7
func (v StringArray) Len() int