session

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2020 License: GPL-3.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ErrWrongFirstEpoch is raised when passed Token contains wrong first epoch.
	// First epoch is an epoch since token is valid
	ErrWrongFirstEpoch = internal.Error("wrong first epoch")

	// ErrWrongLastEpoch is raised when passed Token contains wrong last epoch.
	// Last epoch is an epoch until token is valid
	ErrWrongLastEpoch = internal.Error("wrong last epoch")

	// ErrWrongOwner is raised when passed Token contains wrong OwnerID.
	ErrWrongOwner = internal.Error("wrong owner")

	// ErrEmptyPublicKey is raised when passed Token contains wrong public key.
	ErrEmptyPublicKey = internal.Error("empty public key")

	// ErrWrongObjectsCount is raised when passed Token contains wrong objects count.
	ErrWrongObjectsCount = internal.Error("wrong objects count")

	// ErrWrongObjects is raised when passed Token contains wrong object ids.
	ErrWrongObjects = internal.Error("wrong objects")

	// ErrInvalidSignature is raised when wrong signature is passed to VerificationHeader.VerifyData().
	ErrInvalidSignature = internal.Error("invalid signature")
)

Variables

View Source
var (
	ErrInvalidLengthService        = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowService          = fmt.Errorf("proto: integer overflow")
	ErrUnexpectedEndOfGroupService = fmt.Errorf("proto: unexpected end of group")
)
View Source
var (
	ErrInvalidLengthTypes        = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowTypes          = fmt.Errorf("proto: integer overflow")
	ErrUnexpectedEndOfGroupTypes = fmt.Errorf("proto: unexpected end of group")
)

Functions

func RegisterSessionServer

func RegisterSessionServer(s *grpc.Server, srv SessionServer)

func UnmarshalPublicKeys

func UnmarshalPublicKeys(t *Token) []*ecdsa.PublicKey

UnmarshalPublicKeys returns unmarshal public keys from the token

Types

type CreateRequest

type CreateRequest struct {
	// Message should be one of
	//
	// Types that are valid to be assigned to Message:
	//	*CreateRequest_Init
	//	*CreateRequest_Signed
	Message isCreateRequest_Message `protobuf_oneof:"Message"`
	// RequestMetaHeader contains information about request meta headers (should be embedded into message)
	service.RequestMetaHeader `protobuf:"bytes,98,opt,name=Meta,proto3,embedded=Meta" json:"Meta"`
	// RequestVerificationHeader is a set of signatures of every NeoFS Node that processed request (should be embedded into message)
	service.RequestVerificationHeader `protobuf:"bytes,99,opt,name=Verify,proto3,embedded=Verify" json:"Verify"`
	XXX_NoUnkeyedLiteral              struct{} `json:"-"`
	XXX_unrecognized                  []byte   `json:"-"`
	XXX_sizecache                     int32    `json:"-"`
}

func NewInitRequest

func NewInitRequest(t *Token) *CreateRequest

NewInitRequest returns new initialization CreateRequest from passed Token.

func NewSignedRequest

func NewSignedRequest(t *Token) *CreateRequest

NewSignedRequest returns new signed CreateRequest from passed Token.

func (*CreateRequest) Descriptor

func (*CreateRequest) Descriptor() ([]byte, []int)

func (*CreateRequest) GetInit

func (m *CreateRequest) GetInit() *Token

func (*CreateRequest) GetMessage

func (m *CreateRequest) GetMessage() isCreateRequest_Message

func (*CreateRequest) GetSigned

func (m *CreateRequest) GetSigned() *Token

func (*CreateRequest) Marshal

func (m *CreateRequest) Marshal() (dAtA []byte, err error)

func (*CreateRequest) MarshalTo

func (m *CreateRequest) MarshalTo(dAtA []byte) (int, error)

func (*CreateRequest) MarshalToSizedBuffer

func (m *CreateRequest) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*CreateRequest) ProtoMessage

func (*CreateRequest) ProtoMessage()

func (*CreateRequest) Reset

func (m *CreateRequest) Reset()

func (*CreateRequest) Size

func (m *CreateRequest) Size() (n int)

func (*CreateRequest) String

func (m *CreateRequest) String() string

func (*CreateRequest) Unmarshal

func (m *CreateRequest) Unmarshal(dAtA []byte) error

func (*CreateRequest) XXX_DiscardUnknown

func (m *CreateRequest) XXX_DiscardUnknown()

func (*CreateRequest) XXX_Marshal

func (m *CreateRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*CreateRequest) XXX_Merge

func (m *CreateRequest) XXX_Merge(src proto.Message)

func (*CreateRequest) XXX_OneofWrappers

func (*CreateRequest) XXX_OneofWrappers() []interface{}

XXX_OneofWrappers is for the internal use of the proto package.

func (*CreateRequest) XXX_Size

func (m *CreateRequest) XXX_Size() int

func (*CreateRequest) XXX_Unmarshal

func (m *CreateRequest) XXX_Unmarshal(b []byte) error

type CreateRequest_Init

type CreateRequest_Init struct {
	Init *Token `protobuf:"bytes,1,opt,name=Init,proto3,oneof" json:"Init,omitempty"`
}

func (*CreateRequest_Init) MarshalTo

func (m *CreateRequest_Init) MarshalTo(dAtA []byte) (int, error)

func (*CreateRequest_Init) MarshalToSizedBuffer

func (m *CreateRequest_Init) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*CreateRequest_Init) Size

func (m *CreateRequest_Init) Size() (n int)

type CreateRequest_Signed

type CreateRequest_Signed struct {
	Signed *Token `protobuf:"bytes,2,opt,name=Signed,proto3,oneof" json:"Signed,omitempty"`
}

func (*CreateRequest_Signed) MarshalTo

func (m *CreateRequest_Signed) MarshalTo(dAtA []byte) (int, error)

func (*CreateRequest_Signed) MarshalToSizedBuffer

func (m *CreateRequest_Signed) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*CreateRequest_Signed) Size

func (m *CreateRequest_Signed) Size() (n int)

type CreateResponse

type CreateResponse struct {
	// Types that are valid to be assigned to Message:
	//	*CreateResponse_Unsigned
	//	*CreateResponse_Result
	Message              isCreateResponse_Message `protobuf_oneof:"Message"`
	XXX_NoUnkeyedLiteral struct{}                 `json:"-"`
	XXX_unrecognized     []byte                   `json:"-"`
	XXX_sizecache        int32                    `json:"-"`
}

func (*CreateResponse) Descriptor

func (*CreateResponse) Descriptor() ([]byte, []int)

func (*CreateResponse) GetMessage

func (m *CreateResponse) GetMessage() isCreateResponse_Message

func (*CreateResponse) GetResult

func (m *CreateResponse) GetResult() *Token

func (*CreateResponse) GetUnsigned

func (m *CreateResponse) GetUnsigned() *Token

func (*CreateResponse) Marshal

func (m *CreateResponse) Marshal() (dAtA []byte, err error)

func (*CreateResponse) MarshalTo

func (m *CreateResponse) MarshalTo(dAtA []byte) (int, error)

func (*CreateResponse) MarshalToSizedBuffer

func (m *CreateResponse) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*CreateResponse) ProtoMessage

func (*CreateResponse) ProtoMessage()

func (*CreateResponse) Reset

func (m *CreateResponse) Reset()

func (*CreateResponse) Size

func (m *CreateResponse) Size() (n int)

func (*CreateResponse) String

func (m *CreateResponse) String() string

func (*CreateResponse) Unmarshal

func (m *CreateResponse) Unmarshal(dAtA []byte) error

func (*CreateResponse) XXX_DiscardUnknown

func (m *CreateResponse) XXX_DiscardUnknown()

func (*CreateResponse) XXX_Marshal

func (m *CreateResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*CreateResponse) XXX_Merge

func (m *CreateResponse) XXX_Merge(src proto.Message)

func (*CreateResponse) XXX_OneofWrappers

func (*CreateResponse) XXX_OneofWrappers() []interface{}

XXX_OneofWrappers is for the internal use of the proto package.

func (*CreateResponse) XXX_Size

func (m *CreateResponse) XXX_Size() int

func (*CreateResponse) XXX_Unmarshal

func (m *CreateResponse) XXX_Unmarshal(b []byte) error

type CreateResponse_Result

type CreateResponse_Result struct {
	Result *Token `protobuf:"bytes,2,opt,name=Result,proto3,oneof" json:"Result,omitempty"`
}

func (*CreateResponse_Result) MarshalTo

func (m *CreateResponse_Result) MarshalTo(dAtA []byte) (int, error)

func (*CreateResponse_Result) MarshalToSizedBuffer

func (m *CreateResponse_Result) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*CreateResponse_Result) Size

func (m *CreateResponse_Result) Size() (n int)

type CreateResponse_Unsigned

type CreateResponse_Unsigned struct {
	Unsigned *Token `protobuf:"bytes,1,opt,name=Unsigned,proto3,oneof" json:"Unsigned,omitempty"`
}

func (*CreateResponse_Unsigned) MarshalTo

func (m *CreateResponse_Unsigned) MarshalTo(dAtA []byte) (int, error)

func (*CreateResponse_Unsigned) MarshalToSizedBuffer

func (m *CreateResponse_Unsigned) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*CreateResponse_Unsigned) Size

func (m *CreateResponse_Unsigned) Size() (n int)

type KeyStore

type KeyStore interface {
	Get(ctx context.Context, id refs.OwnerID) ([]*ecdsa.PublicKey, error)
}

KeyStore is an interface that describes storage, that allows to fetch public keys by OwnerID.

type ObjectID

type ObjectID = refs.ObjectID

ObjectID type alias.

type OwnerID

type OwnerID = refs.OwnerID

OwnerID type alias.

type PToken

type PToken struct {
	Token

	PrivateKey *ecdsa.PrivateKey
	// contains filtered or unexported fields
}

PToken is a wrapper around Token that allows to sign data and to do thread-safe manipulations.

func (*PToken) AddSignatures

func (t *PToken) AddSignatures(signH, signT []byte)

AddSignatures adds token signatures.

func (*PToken) SignData

func (t *PToken) SignData(data []byte) ([]byte, error)

SignData signs data with session private key.

type SessionClient

type SessionClient interface {
	// Create is a method that used to open a trusted session to manipulate
	// an object. In order to put or delete object client have to obtain session
	// token with trusted node. Trusted node will modify client's object
	// (add missing headers, checksums, homomorphic hash) and sign id with
	// session key. Session is established during 4-step handshake in one gRPC stream
	//
	// - First client stream message SHOULD BE type of `CreateRequest_Init`.
	// - First server stream message SHOULD BE type of `CreateResponse_Unsigned`.
	// - Second client stream message SHOULD BE type of `CreateRequest_Signed`.
	// - Second server stream message SHOULD BE type of `CreateResponse_Result`.
	Create(ctx context.Context, opts ...grpc.CallOption) (Session_CreateClient, error)
}

SessionClient is the client API for Session service.

For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.

func NewSessionClient

func NewSessionClient(cc *grpc.ClientConn) SessionClient

type SessionServer

type SessionServer interface {
	// Create is a method that used to open a trusted session to manipulate
	// an object. In order to put or delete object client have to obtain session
	// token with trusted node. Trusted node will modify client's object
	// (add missing headers, checksums, homomorphic hash) and sign id with
	// session key. Session is established during 4-step handshake in one gRPC stream
	//
	// - First client stream message SHOULD BE type of `CreateRequest_Init`.
	// - First server stream message SHOULD BE type of `CreateResponse_Unsigned`.
	// - Second client stream message SHOULD BE type of `CreateRequest_Signed`.
	// - Second server stream message SHOULD BE type of `CreateResponse_Result`.
	Create(Session_CreateServer) error
}

SessionServer is the server API for Session service.

type Session_CreateClient

type Session_CreateClient interface {
	Send(*CreateRequest) error
	Recv() (*CreateResponse, error)
	grpc.ClientStream
}

type Session_CreateServer

type Session_CreateServer interface {
	Send(*CreateResponse) error
	Recv() (*CreateRequest, error)
	grpc.ServerStream
}

type Token

type Token struct {
	// Header carries verification data of session key
	Header VerificationHeader `protobuf:"bytes,1,opt,name=Header,proto3" json:"Header"`
	// OwnerID is an owner of manipulation object
	OwnerID OwnerID `protobuf:"bytes,2,opt,name=OwnerID,proto3,customtype=OwnerID" json:"OwnerID"`
	// FirstEpoch is an initial epoch of token lifetime
	FirstEpoch uint64 `protobuf:"varint,3,opt,name=FirstEpoch,proto3" json:"FirstEpoch,omitempty"`
	// LastEpoch is a last epoch of token lifetime
	LastEpoch uint64 `protobuf:"varint,4,opt,name=LastEpoch,proto3" json:"LastEpoch,omitempty"`
	// ObjectID is an object identifier of manipulation object
	ObjectID []ObjectID `protobuf:"bytes,5,rep,name=ObjectID,proto3,customtype=ObjectID" json:"ObjectID"`
	// Signature is a token signature, signed by owner of manipulation object
	Signature []byte `protobuf:"bytes,6,opt,name=Signature,proto3" json:"Signature,omitempty"`
	// ID is a token identifier. valid UUIDv4 represented in bytes
	ID TokenID `protobuf:"bytes,7,opt,name=ID,proto3,customtype=TokenID" json:"ID"`
	// PublicKeys associated with owner
	PublicKeys           [][]byte `protobuf:"bytes,8,rep,name=PublicKeys,proto3" json:"PublicKeys,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

User token granting rights for object manipulation

func (*Token) Descriptor

func (*Token) Descriptor() ([]byte, []int)

func (*Token) GetFirstEpoch

func (m *Token) GetFirstEpoch() uint64

func (*Token) GetHeader

func (m *Token) GetHeader() VerificationHeader

func (*Token) GetLastEpoch

func (m *Token) GetLastEpoch() uint64

func (*Token) GetPublicKeys

func (m *Token) GetPublicKeys() [][]byte

func (*Token) GetSignature

func (m *Token) GetSignature() []byte

func (*Token) IsSame

func (m *Token) IsSame(t *Token) error

IsSame checks if the passed token is valid and equal to current token

func (*Token) Marshal

func (m *Token) Marshal() (dAtA []byte, err error)

func (*Token) MarshalTo

func (m *Token) MarshalTo(dAtA []byte) (int, error)

func (*Token) MarshalToSizedBuffer

func (m *Token) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*Token) ProtoMessage

func (*Token) ProtoMessage()

func (*Token) Reset

func (m *Token) Reset()

func (*Token) SetPublicKeys

func (m *Token) SetPublicKeys(keys ...*ecdsa.PublicKey)

SetPublicKeys sets owner's public keys to the token

func (*Token) Sign

func (m *Token) Sign(key *ecdsa.PrivateKey) error

Sign tries to sign current Token data and stores signature inside it.

func (*Token) Size

func (m *Token) Size() (n int)

func (*Token) String

func (m *Token) String() string

func (*Token) Unmarshal

func (m *Token) Unmarshal(dAtA []byte) error

func (*Token) Verify

func (m *Token) Verify(keys ...*ecdsa.PublicKey) bool

Verify checks if token is correct and signed.

func (*Token) XXX_DiscardUnknown

func (m *Token) XXX_DiscardUnknown()

func (*Token) XXX_Marshal

func (m *Token) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Token) XXX_Merge

func (m *Token) XXX_Merge(src proto.Message)

func (*Token) XXX_Size

func (m *Token) XXX_Size() int

func (*Token) XXX_Unmarshal

func (m *Token) XXX_Unmarshal(b []byte) error

type TokenID

type TokenID = refs.UUID

TokenID type alias.

type TokenParams

type TokenParams struct {
	FirstEpoch uint64
	LastEpoch  uint64
	ObjectID   []ObjectID
	OwnerID    OwnerID
	PublicKeys [][]byte
}

TokenParams contains params to create new PToken.

type TokenStore

type TokenStore interface {
	// New returns new token with specified parameters.
	New(p TokenParams) *PToken

	// Fetch tries to fetch a token with specified id.
	Fetch(id TokenID) *PToken

	// Remove removes token with id from store.
	Remove(id TokenID)
}

TokenStore is a PToken storage manipulation interface.

func NewSimpleStore

func NewSimpleStore() TokenStore

NewSimpleStore creates simple token storage

type UnimplementedSessionServer

type UnimplementedSessionServer struct {
}

UnimplementedSessionServer can be embedded to have forward compatible implementations.

func (*UnimplementedSessionServer) Create

type VerificationHeader

type VerificationHeader struct {
	// PublicKey is a session public key
	PublicKey []byte `protobuf:"bytes,1,opt,name=PublicKey,proto3" json:"PublicKey,omitempty"`
	// KeySignature is a session public key signature. Signed by trusted side
	KeySignature         []byte   `protobuf:"bytes,2,opt,name=KeySignature,proto3" json:"KeySignature,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func (*VerificationHeader) Descriptor

func (*VerificationHeader) Descriptor() ([]byte, []int)

func (*VerificationHeader) GetKeySignature

func (m *VerificationHeader) GetKeySignature() []byte

func (*VerificationHeader) GetPublicKey

func (m *VerificationHeader) GetPublicKey() []byte

func (*VerificationHeader) Marshal

func (m *VerificationHeader) Marshal() (dAtA []byte, err error)

func (*VerificationHeader) MarshalTo

func (m *VerificationHeader) MarshalTo(dAtA []byte) (int, error)

func (*VerificationHeader) MarshalToSizedBuffer

func (m *VerificationHeader) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*VerificationHeader) ProtoMessage

func (*VerificationHeader) ProtoMessage()

func (*VerificationHeader) Reset

func (m *VerificationHeader) Reset()

func (*VerificationHeader) Sign

func (m *VerificationHeader) Sign(key *ecdsa.PrivateKey) error

Sign signs contents of the header with the private key.

func (*VerificationHeader) Size

func (m *VerificationHeader) Size() (n int)

func (*VerificationHeader) String

func (m *VerificationHeader) String() string

func (*VerificationHeader) Unmarshal

func (m *VerificationHeader) Unmarshal(dAtA []byte) error

func (*VerificationHeader) Verify

func (m *VerificationHeader) Verify(keys ...*ecdsa.PublicKey) bool

Verify checks if verification header was issued by id.

func (*VerificationHeader) VerifyData

func (m *VerificationHeader) VerifyData(data, sign []byte) error

VerifyData checks if signature of data by token is equal to sign.

func (*VerificationHeader) XXX_DiscardUnknown

func (m *VerificationHeader) XXX_DiscardUnknown()

func (*VerificationHeader) XXX_Marshal

func (m *VerificationHeader) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*VerificationHeader) XXX_Merge

func (m *VerificationHeader) XXX_Merge(src proto.Message)

func (*VerificationHeader) XXX_Size

func (m *VerificationHeader) XXX_Size() int

func (*VerificationHeader) XXX_Unmarshal

func (m *VerificationHeader) XXX_Unmarshal(b []byte) error

Jump to

Keyboard shortcuts

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