session

package
v0.12.1 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2023 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package session implements session attributes for stream connections.

Index

Constants

View Source
const (
	AttributeMetadataKey = "x-session-attribute"
	AttributeLabelKey    = "opni.io/session-attribute"

	KeyLength = 32
)
View Source
const (
	AttributesKey sessionAttributesKeyType = "session_attributes"
)
View Source
const (
	DomainString = "session auth v1"
)

Variables

This section is empty.

Functions

func ShouldEnableIncoming

func ShouldEnableIncoming(streamContext context.Context) (bool, error)

Checks if the incoming context has the session attribute metadata key. Can be used in conjunction with a conditional challenge handler on the server side.

Types

type Attribute

type Attribute interface {
	// Name returns the attribute name. This should be a unique identifier.
	Name() string
}

func NewAttribute

func NewAttribute(name string) Attribute

func StreamAuthorizedAttributes

func StreamAuthorizedAttributes(ctx context.Context) []Attribute

type ClientChallenge

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

func NewClientChallenge

func NewClientChallenge(kr keyring.Keyring) (*ClientChallenge, error)

func (*ClientChallenge) Attributes

func (a *ClientChallenge) Attributes() []string

func (*ClientChallenge) DoChallenge

func (a *ClientChallenge) DoChallenge(cs streams.Stream) (context.Context, error)

func (*ClientChallenge) HasAttributes

func (a *ClientChallenge) HasAttributes(_ context.Context) (bool, error)

Matches challenges.ConditionFunc

func (*ClientChallenge) InterceptContext

func (a *ClientChallenge) InterceptContext(ctx context.Context) context.Context

type SecretAttribute

type SecretAttribute interface {
	Attribute

	// Given a challenge string, Solve will compute a MAC using an
	// implementation-specific secret key and return the result.
	Solve(id string, challenge []byte) []byte

	// Verify will check if a mac is valid for a given id and challenge.
	Verify(id string, challenge []byte, response []byte) bool
}

func NewSecretAttribute

func NewSecretAttribute(name string, key []byte) (SecretAttribute, error)

type ServerChallenge

type ServerChallenge struct {
	ServerChallengeOptions
	// contains filtered or unexported fields
}

func NewServerChallenge

func NewServerChallenge(kr keyring.Keyring, opts ...ServerChallengeOption) (*ServerChallenge, error)

func (*ServerChallenge) Attributes

func (a *ServerChallenge) Attributes() []string

func (*ServerChallenge) DoChallenge

func (a *ServerChallenge) DoChallenge(ss streams.Stream) (context.Context, error)

func (*ServerChallenge) HasAttributes

func (a *ServerChallenge) HasAttributes(_ context.Context) (bool, error)

Matches challenges.ConditionFunc

func (*ServerChallenge) InterceptContext

func (a *ServerChallenge) InterceptContext(ctx context.Context) context.Context

type ServerChallengeOption

type ServerChallengeOption func(*ServerChallengeOptions)

func WithAttributeRequestLimit

func WithAttributeRequestLimit(attributeRequestLimit int) ServerChallengeOption

type ServerChallengeOptions

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

Jump to

Keyboard shortcuts

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