Documentation ¶
Index ¶
- Variables
- func DuplicateKeyError(key string) error
- func DuplicateUsernameError(username string) error
- func KeyNotFoundError(key string) error
- func NotFoundError(id string, providerID ProviderIdentity, username string) error
- type Comparison
- type Field
- type Filter
- type Identity
- type KeyValueStore
- type Operation
- type ProviderDataStore
- type ProviderIdentity
- type Sort
- type Store
- type Update
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNotFound is the error cause used when an identity cannot be // found in storage. ErrNotFound = errgo.New("not found") // ErrDuplicateUsername is the error cause used when an update // attempts to set a username that is already in use. ErrDuplicateUsername = errgo.New("duplicate username") // ErrDuplicateKey is the error cause used when trying to set a // new key in a KeyValueStore where the key already exists. ErrDuplicateKey = errgo.New("duplicate key") )
Functions ¶
func DuplicateKeyError ¶
DuplicateKeyError creates a new error with a cause of ErrDuplicateKey and an appropriate message.
func DuplicateUsernameError ¶
DuplicateUsernameError creates a new error with a cause of ErrDuplicateUsername and an appropriate message.
func KeyNotFoundError ¶
KeyNotFoundError creates a new error with a cause of ErrNotFound and an appropriate message.
func NotFoundError ¶
func NotFoundError(id string, providerID ProviderIdentity, username string) error
NotFoundError creates a new error with a cause of ErrNotFound and an appropriate message.
Types ¶
type Comparison ¶
type Comparison byte
A Comparison represents a type of comparison that can be used in a filter in a Store.FindIdentities call.
const ( NoComparison Comparison = iota Equal NotEqual GreaterThan LessThan GreaterThanOrEqual LessThanOrEqual )
type Filter ¶
type Filter [NumFields]Comparison
A Filter is used in a Store.FindEntities call to specify how the identities should be filtered.
type Identity ¶
type Identity struct { // ID is the internal ID of the Identity, this is allocated by // the store when the identity is created. ID string // ProviderID contains the provider specific ID of the identity. ProviderID ProviderIdentity // Username contains the username of the identity. Username string // Name contains the display name of the identity. Name string // Email contains the email address of the identity. Email string // Groups contains the stored set of groups of which the identity // is a member. This should not be used by identity providers // to store group information acquired at login time (that's // what ProviderInfo is for). Groups []string // PublicKeys contains any public keys associated with the // identity. PublicKeys []bakery.PublicKey // LastLogin contains the time that the identity last logged in. LastLogin time.Time // LastDischarge contains the time that the identity last logged // in. LastDischarge time.Time // ProviderInfo contains provider specific information associated // with the identity. This field is reserved for the provider to // add any additional data the provider requires to manage the // identity. ProviderInfo map[string][]string // ExtraInfo contains extra information associated with the // identity. This field is used for any additional data that is // stored with the identity, but is not directly required by the // identity manager. ExtraInfo map[string][]string }
Identity represents an identity in the store.
type KeyValueStore ¶
type KeyValueStore interface { // Context returns a context that is suitable for passing to the // other KeyValueStore methods. KeyValueStore methods called with // such a context will be sequentially consistent; for example, a // value that is set in Set will immediately be available from // Get. // // The returned close function must be called when the returned // context will no longer be used, to allow for any required // cleanup. Context(ctx context.Context) (_ context.Context, close func()) // Get retrieves the value associated with the given key. If // there is no such key an error with a cause of ErrNotFound will // be returned. Get(ctx context.Context, key string) ([]byte, error) // Set updates the given key to have the specified value. // // If the expire time is non-zero then the entry may be garbage // collected at some point after that time. Clients should not // rely on the value being removed at the given time. Set(ctx context.Context, key string, value []byte, expire time.Time) error // Add is like Set except that if the key already has a value // associated with it it returns an error with the cause of // ErrDuplicateKey. // // If the expire time is non-zero then the entry may be garbage // collected at some point after that time. Clients should not // rely on the value being removed at the given time. Add(ctx context.Context, key string, value []byte, expire time.Time) error }
A KeyValueStore is a store that associates a value with a specified key.
type Operation ¶
type Operation byte
An Operation represents a type of update that can be applied to an identity record in a Store.UpdateIdentity call.
const ( // NoUpdate makes no changes to the field. NoUpdate Operation = iota // Set overrides the value of the field with the specified value. // // For the ProviderInfo and ExtraInfo fields the values are // replaced on each specified key individually. Set // Clear removes the field from the document. // // For the ProviderInfo and ExtraInfo fields the values are // cleared on each specified key individually. Clear // Push ensures that all the values in the field are added to any // that are already present. // // For the ProviderInfo and ExtraInfo fields the new values are // added to each specified key individually. Push // Pull ensures that all the values in the field are removed from // those present. It is legal to remove values that aren't // already stored. // // For the ProviderInfo and ExtraInfo fields the values are // removed from each specified key individually. Pull )
type ProviderDataStore ¶
type ProviderDataStore interface { // KeyValueStore gets a KeyValueStore for use by the given // identity provider. KeyValueStore(ctx context.Context, idp string) (KeyValueStore, error) }
An ProviderDataStore is a data store that supports identity provider specific KeyValueStores. These stores can be used by identity providers to store data that is not directly related to an identity.
type ProviderIdentity ¶
type ProviderIdentity string
A ProviderIdentity is a provider-specific unique identity.
func MakeProviderIdentity ¶
func MakeProviderIdentity(provider, id string) ProviderIdentity
MakeProviderIdentity creates a ProviderIdentitiy from the given provider name and provider-specific identity.
func (ProviderIdentity) Provider ¶
func (p ProviderIdentity) Provider() string
Provider returns the provider part of the identity.
func (*ProviderIdentity) Scan ¶
func (p *ProviderIdentity) Scan(src interface{}) error
Scan implements sql.Scanner by converting a string value into a ProviderIdentity.
func (ProviderIdentity) Split ¶
func (p ProviderIdentity) Split() (provider, id string)
Split splits a ProviderIdentity into provider and id parts.
type Store ¶
type Store interface { // Context returns a context that is suitable for passing to the // other store methods. Store methods called with such a context // will be sequentially consistent; for example, a value that is // set in UpdateIdentity will immediately be available from // Identity. // // The returned close function must be called when the returned // context will no longer be used, to allow for any required // cleanup. Context(ctx context.Context) (_ context.Context, close func()) // Identity reads the given identity from persistant storage and // completes all the fields. The given identity will be matched // using the first non-zero value of ID, ProviderID or Username. // If no match can found for the given identity then an error // with the cause ErrNotFound will be returned. Identity(ctx context.Context, identity *Identity) error // FindIdentities searches for all identities that match the // given ref when the given filter has been applied. The results // will be sorted in the order specified by sort. If limit is // greater than 0 then the results will contain at most that many // identities. If skip is greater than 0 then that many results // will be skipped before those that are returned. FindIdentities(ctx context.Context, ref *Identity, filter Filter, sort []Sort, skip, limit int) ([]Identity, error) // UpdateIdentity stores the data from the given identity in // persistant storage. The identity that is updated will be the // one matching the first non-zero value of ID, ProviderID or // Username. If the ID or username does not find a match then an // error with a cause of ErrNotFound will be returned. If there // is no match for an identity specified by ProviderID and the // update specifies setting the username then a new record will // be created for the identity, in this case the assigned ID will // be written back into the given identity. // // The fields that are written to the database are dictated by // the given UpdateOperations parameter. For each updatable field // this parameter will be consulted for the type of update to // perform. If the update would result in a duplicate username // being used then an error with the cause ErrDuplicateUsername // will be returned. UpdateIdentity(ctx context.Context, identity *Identity, update Update) error }
Store is the interface that represents the data storage mechanism for the identity manager.