Documentation ¶
Index ¶
- type Option
- type Store
- func (s *Store) CreateAuthentication(_ context.Context, r *auth.CreateAuthenticationRequest) (string, *rpcauth.Authentication, error)
- func (s *Store) DeleteAuthentications(_ context.Context, req *auth.DeleteAuthenticationsRequest) error
- func (s *Store) ExpireAuthenticationByID(ctx context.Context, id string, expireAt *timestamppb.Timestamp) error
- func (s *Store) GetAuthenticationByClientToken(ctx context.Context, clientToken string) (*rpcauth.Authentication, error)
- func (s *Store) GetAuthenticationByID(ctx context.Context, id string) (*rpcauth.Authentication, error)
- func (s *Store) ListAuthentications(ctx context.Context, ...) (storage.ResultSet[*rpcauth.Authentication], error)
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 ¶
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 ¶
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 (*Store) CreateAuthentication ¶
func (s *Store) CreateAuthentication(_ context.Context, r *auth.CreateAuthenticationRequest) (string, *rpcauth.Authentication, error)
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 (*Store) ExpireAuthenticationByID ¶ added in v1.18.0
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.
func (*Store) ListAuthentications ¶
func (s *Store) ListAuthentications(ctx context.Context, req *storage.ListRequest[auth.ListAuthenticationsPredicate]) (storage.ResultSet[*rpcauth.Authentication], error)