Documentation ¶
Index ¶
- func Bootstrap(ctx context.Context, store Store, opts ...BootstrapOption) (string, error)
- func GenerateRandomToken() string
- func HashClientToken(token string) (string, error)
- func WithExpiredBefore(t time.Time) containers.Option[DeleteAuthenticationsRequest]
- func WithID(id string) containers.Option[DeleteAuthenticationsRequest]
- func WithMethod(method auth.Method) containers.Option[DeleteAuthenticationsRequest]
- type BootstrapOption
- type CreateAuthenticationRequest
- type DeleteAuthenticationsRequest
- type ListAuthenticationsPredicate
- type Store
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Bootstrap ¶
Bootstrap creates an initial static authentication of type token if one does not already exist.
func GenerateRandomToken ¶
func GenerateRandomToken() string
GenerateRandomToken produces a URL safe base64 encoded string of random characters the data is sourced from a pseudo-random input stream
func HashClientToken ¶
HashClientToken performs a SHA256 sum on the input string it returns the result as a URL safe base64 encoded string
func WithExpiredBefore ¶
func WithExpiredBefore(t time.Time) containers.Option[DeleteAuthenticationsRequest]
WithExpiredBefore is an option which ensures a delete only applies to Auhentications with an expires_at timestamp occurring before the supplied timestamp.
func WithID ¶
func WithID(id string) containers.Option[DeleteAuthenticationsRequest]
WithID is an option which predicates a delete with a specific authentication ID.
func WithMethod ¶
func WithMethod(method auth.Method) containers.Option[DeleteAuthenticationsRequest]
WithMethod is an option which ensures a delete applies to Authentications of the provided method.
Types ¶
type BootstrapOption ¶
type BootstrapOption func(*bootstrapOpt)
BootstrapOption is a type which configures the bootstrap or initial static token.
func WithExpiration ¶
func WithExpiration(expiration time.Duration) BootstrapOption
WithExpiration sets the expiration of the generated token.
func WithMetadataAttribute ¶ added in v1.44.0
func WithMetadataAttribute(key, value string) BootstrapOption
WithMetadataAttribute can be used to add additional metadata k/v pairs to the resulting bootstrap token
func WithToken ¶
func WithToken(token string) BootstrapOption
WithToken overrides the generated token with the provided token.
type CreateAuthenticationRequest ¶
type CreateAuthenticationRequest struct { Method auth.Method ExpiresAt *timestamppb.Timestamp Metadata map[string]string // ClientToken is an (optional) explicit client token to be associated with the authentication. // When it is not supplied a random token will be generated and returned instead. ClientToken string }
CreateAuthenticationRequest is the argument passed when creating instances of an Authentication on a target AuthenticationStore.
type DeleteAuthenticationsRequest ¶
type DeleteAuthenticationsRequest struct { ID *string Method *auth.Method ExpiredBefore *timestamppb.Timestamp }
DeleteAuthenticationsRequest is a request to delete one or more Authentication instances in a backing auth.Store.
func Delete ¶
func Delete(opts ...containers.Option[DeleteAuthenticationsRequest]) *DeleteAuthenticationsRequest
Delete constructs a new *DeleteAuthenticationsRequest using the provided options.
func (*DeleteAuthenticationsRequest) Valid ¶
func (d *DeleteAuthenticationsRequest) Valid() error
type ListAuthenticationsPredicate ¶
ListAuthenticationsPredicate contains the fields necessary to predicate a list operation on a authentications storage backend.
func ListMethod ¶
func ListMethod(method auth.Method) ListAuthenticationsPredicate
ListMethod can be passed to storage.NewListRequest. The request can then be used to predicate ListAuthentications by auth method.
type Store ¶
type Store interface { // 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. CreateAuthentication(context.Context, *CreateAuthenticationRequest) (string, *auth.Authentication, error) // GetAuthenticationByClientToken retrieves an instance of Authentication from the backing // store using the provided clientToken string as the key. GetAuthenticationByClientToken(ctx context.Context, clientToken string) (*auth.Authentication, error) // GetAuthenticationByID retrieves an instance of Authentication from the backing // store using the provided id string. GetAuthenticationByID(ctx context.Context, id string) (*auth.Authentication, error) // ListAuthenticationsRequest retrieves a set of Authentication instances based on the provided // predicates with the supplied ListAuthenticationsRequest. ListAuthentications(context.Context, *storage.ListRequest[ListAuthenticationsPredicate]) (storage.ResultSet[*auth.Authentication], error) // DeleteAuthentications attempts to delete one or more Authentication instances from the backing store. // Use DeleteByID to construct a request to delete a single Authentication by ID string. // Use DeleteByMethod to construct a request to delete 0 or more Authentications by Method and optional expired before constraint. DeleteAuthentications(context.Context, *DeleteAuthenticationsRequest) error // ExpireAuthenticationByID attempts to expire an Authentication by ID string and the provided expiry time. ExpireAuthenticationByID(context.Context, string, *timestamppb.Timestamp) error }
Store persists Authentication instances.