memory

package
v1.43.0 Latest Latest
Warning

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

Go to latest
Published: May 30, 2024 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option func(*Store)

Option is a type which configures a *Store

func WithIDGeneratorFunc

func WithIDGeneratorFunc(fn func() string) Option

WithIDGeneratorFunc overrides the stores ID generator function used to generate new random ID strings, when creating new instances of Authentications. The default is a string containing a valid UUID (V4).

func WithNowFunc

func WithNowFunc(fn func() *timestamppb.Timestamp) Option

WithNowFunc overrides the stores now() function used to obtain a protobuf timestamp representative of the current time of evaluation.

func WithTokenGeneratorFunc

func WithTokenGeneratorFunc(fn func() string) Option

WithTokenGeneratorFunc overrides the stores token generator function used to generate new random token strings as client tokens, when creating new instances of Authentication. The default is a pseudo-random string of bytes base64 encoded.

type Store

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

Store is an in-memory implementation of storage.AuthenticationStore

Authentications are stored in a map by hashedClientToken. Access to the map is protected by a mutex, meaning this is implementation is safe to use concurrently.

func NewStore

func NewStore(opts ...Option) *Store

NewStore instantiates a new in-memory implementation of storage.AuthenticationStore

func (*Store) CreateAuthentication

CreateAuthentication creates a new instance of an Authentication and returns a unique clientToken string which can be used to retrieve the Authentication again via GetAuthenticationByClientToken.

func (*Store) DeleteAuthentications

func (s *Store) DeleteAuthentications(_ context.Context, req *authn.DeleteAuthenticationsRequest) error

func (*Store) ExpireAuthenticationByID

func (s *Store) ExpireAuthenticationByID(ctx context.Context, id string, expireAt *timestamppb.Timestamp) error

ExpireAuthenticationByID attempts to expire an Authentication by ID string and the provided expiry time.

func (*Store) GetAuthenticationByClientToken

func (s *Store) GetAuthenticationByClientToken(ctx context.Context, clientToken string) (*rpcauth.Authentication, error)

GetAuthenticationByClientToken retrieves an instance of Authentication from the backing store using the provided clientToken string as the key.

func (*Store) GetAuthenticationByID

func (s *Store) GetAuthenticationByID(ctx context.Context, id string) (*rpcauth.Authentication, error)

GetAuthenticationByID retrieves an instance of Authentication from the backing store using the provided id string.

Jump to

Keyboard shortcuts

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