Documentation ¶
Index ¶
- type Manager
- type MongoManager
- func (m *MongoManager) Authenticate(username string, secret []byte) (*User, error)
- func (m *MongoManager) AuthenticateByID(id string, secret []byte) (*User, error)
- func (m *MongoManager) AuthenticateByUsername(username string, secret []byte) (*User, error)
- func (m *MongoManager) CreateUser(u *User) error
- func (m *MongoManager) DeleteUser(id string) error
- func (m *MongoManager) GetUser(id string) (*User, error)
- func (m *MongoManager) GetUserByUsername(username string) (*User, error)
- func (m *MongoManager) GetUsers(orgid string) (map[string]User, error)
- func (m *MongoManager) GrantScopeToUser(id string, scope string) error
- func (m *MongoManager) RemoveScopeFromUser(id string, scope string) error
- func (m *MongoManager) UpdateUser(u *User) error
- type Storer
- type User
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MongoManager ¶
type MongoManager struct { // DB is the Mongo connection that holds the base session that can be copied and closed. DB *mgo.Database Hasher fosite.Hasher }
MongoManager manages the Mongo Session instance of a User. Implements user.Manager.
func (*MongoManager) Authenticate ¶
func (m *MongoManager) Authenticate(username string, secret []byte) (*User, error)
Authenticate wraps AuthenticateByUsername to allow users to be found via their username. Returns a user record if authentication is successful.
func (*MongoManager) AuthenticateByID ¶
func (m *MongoManager) AuthenticateByID(id string, secret []byte) (*User, error)
AuthenticateByID gets the stored user by ID and authenticates it using a hasher
func (*MongoManager) AuthenticateByUsername ¶
func (m *MongoManager) AuthenticateByUsername(username string, secret []byte) (*User, error)
AuthenticateByUsername gets the stored user by username and authenticates it using a hasher
func (*MongoManager) CreateUser ¶
func (m *MongoManager) CreateUser(u *User) error
CreateUser stores a new user into mongo
func (*MongoManager) DeleteUser ¶
func (m *MongoManager) DeleteUser(id string) error
DeleteUser removes a user from mongo
func (*MongoManager) GetUser ¶
func (m *MongoManager) GetUser(id string) (*User, error)
GetUser gets a user document that has been previously stored in mongo
func (*MongoManager) GetUserByUsername ¶
func (m *MongoManager) GetUserByUsername(username string) (*User, error)
GetUserByUsername gets a user document by searching for a username that has been previously stored in mongo
func (*MongoManager) GetUsers ¶
func (m *MongoManager) GetUsers(orgid string) (map[string]User, error)
GetUsers returns a map of IDs mapped to a User object that are stored in mongo
func (*MongoManager) GrantScopeToUser ¶
func (m *MongoManager) GrantScopeToUser(id string, scope string) error
GrantScopeToUser adds a scope to a user if it doesn't already exist in the mongo record
func (*MongoManager) RemoveScopeFromUser ¶
func (m *MongoManager) RemoveScopeFromUser(id string, scope string) error
RemoveScopeFromUser takes a scoped right away from the given user.
func (*MongoManager) UpdateUser ¶
func (m *MongoManager) UpdateUser(u *User) error
UpdateUser updates a user record. This is done using the equivalent of an object replace.
type Storer ¶
type Storer interface { GetConcreteUser(id string) (*User, error) GetUser(id string) (User, error) GetUsers() (map[string]User, error) CreateUser(u *User) error UpdateUser(u *User) error DeleteUser(id string) error GrantScope(scope string) error RemoveScope(scope string) error AuthenticateByID(id string, secret []byte) (*User, error) AuthenticateByUsername(username string, secret []byte) (*User, error) }
Storer provides a definition of specific methods that are required to store a User in a data store.
type User ¶
type User struct { // ID is the uniquely assigned uuid that references the user ID string `bson:"_id" json:"id" xml:"id"` // The organisation the user belongs to OrganisationID string `bson:"organisation_id,omitempty" json:"organisation_id,omitempty" xml:"organisation_id,omitempty"` // Username is used to authenticate a user Username string `bson:"username" json:"username" xml:"username"` // Password string `bson:"password" json:"-" xml:"-"` // Scopes contains the scopes that have been granted to Scopes []string `bson:"scopes" json:"scopes" xml:"scopes"` // FirstName stores the user's Last Name FirstName string `bson:"first_name" json:"first_name" xml:"first_name"` // LastName stores the user's Last Name LastName string `bson:"last_name" json:"last_name" xml:"last_name"` // ProfileURI is a pointer to where their profile picture lives ProfileURI string `bson:"profile_uri" json:"profile_uri,omitempty" xml:"profile_uri,omitempty"` }
User provides the specific types for storing, editing, deleting and retrieving a User record in mongo.
func (User) Authenticate ¶
Authenticate compares a cleartext string against the user's
func (User) GetFullName ¶
GetFullName concatenates the User's First Name and Last Name for templating purposes
func (*User) GetHashedSecret ¶
GetHashedSecret returns the Users's Hashed Secret as a byte array