Documentation
¶
Index ¶
- Variables
- func IsUserNotFound(err error) bool
- type Application
- type Args
- type BasicUser
- type DuplicateNamespaceError
- type DuplicateUserError
- type InactiveUserError
- type Plugin
- type User
- type UserDatabase
- func (db *UserDatabase) Authenticate(name string, password string) (*BasicUser, error)
- func (db *UserDatabase) ChangePassword(name string, oldPassword, newPassword string) error
- func (db *UserDatabase) Close() error
- func (db *UserDatabase) Create(user User, password string) error
- func (db *UserDatabase) Find(name string, result User) error
- func (db *UserDatabase) FindByNamespace(namespace string) (User, error)
- func (db *UserDatabase) GetSecret(key string, gen func() []byte) ([]byte, error)
- func (db *UserDatabase) Remove(name string) error
- func (db *UserDatabase) Search(filter interface{}, result interface{}) error
- func (db *UserDatabase) SetNamespace(username, namespace string) error
- func (db *UserDatabase) Update(name string, fields interface{}) error
- type UserNotFoundError
Constants ¶
This section is empty.
Variables ¶
var NewPlugin = func() (Plugin, error) { dbtype := config.Get("userdb.type") dburl := config.Get("userdb.url") if dbtype == "" && dburl != "" { u, err := url.Parse(dburl) if err != nil { return nil, err } dbtype = u.Scheme } if dbtype == "" { return nil, fmt.Errorf("The user database plugin does not configured") } else { return nil, fmt.Errorf("Unsupported user database scheme: %s", dbtype) } }
Functions ¶
func IsUserNotFound ¶
Types ¶
type Application ¶
type BasicUser ¶
type BasicUser struct { Name string Namespace string Password []byte Inactive bool Applications map[string]*Application }
The basic User interface implementation.
type DuplicateNamespaceError ¶
type DuplicateNamespaceError string
The DuplicateNamespaceError indicates that a namespace already exists in the database when creating or modifying user.
func (DuplicateNamespaceError) Error ¶
func (e DuplicateNamespaceError) Error() string
func (DuplicateNamespaceError) HTTPErrorStatusCode ¶
func (e DuplicateNamespaceError) HTTPErrorStatusCode() int
type DuplicateUserError ¶
type DuplicateUserError string
The DuplicateUserError indicates that an user already exists in the database when creating user.
func (DuplicateUserError) Error ¶
func (e DuplicateUserError) Error() string
func (DuplicateUserError) HTTPErrorStatusCode ¶
func (e DuplicateUserError) HTTPErrorStatusCode() int
type InactiveUserError ¶
type InactiveUserError string
The InvalidUserError indicates that a user is not valid to login.
func (InactiveUserError) Error ¶
func (e InactiveUserError) Error() string
func (InactiveUserError) HTTPErrorStatusCode ¶
func (e InactiveUserError) HTTPErrorStatusCode() int
type Plugin ¶
type Plugin interface { // Create a new user in the database. Create(user User) error // Set the namespace for the given user. The namespace must be unique. SetNamespace(username, namespace string) error // Find the user by name. Find(name string, result User) error // Searchs user database by the given filter. Search(filter interface{}, result interface{}) error // Remove the user from the database. Remove(name string) error // Update user with the new data. Update(name string, fields interface{}) error // GetSecret returns a secret key used to sign the JWT token. If the // secret key does not exist in the database, a new key is generated // and saved to the database. GetSecret(key string, gen func() []byte) ([]byte, error) // Close the user database. Close() error }
The Plugin interface represents a user database plugin. This interface provides CRUD operations for users. The user database can be backed by relational or NoSQL database, LDAP or Kerberos services.
type User ¶
type User interface { // Basic returns the core information of a User. Basic() *BasicUser }
The User interface encapsulates a cloud user. The concret User type must embedded a BasicUser struct that contains core information that used by cloudway controller. Extra fields may be maintained by concret User type and these fields will be written to the user database.
type UserDatabase ¶
type UserDatabase struct {
// contains filtered or unexported fields
}
The UserDatabase type is the central point of user management.
func Open ¶
func Open() (*UserDatabase, error)
func (*UserDatabase) Authenticate ¶
func (db *UserDatabase) Authenticate(name string, password string) (*BasicUser, error)
func (*UserDatabase) ChangePassword ¶
func (db *UserDatabase) ChangePassword(name string, oldPassword, newPassword string) error
func (*UserDatabase) Close ¶
func (db *UserDatabase) Close() error
func (*UserDatabase) FindByNamespace ¶
func (db *UserDatabase) FindByNamespace(namespace string) (User, error)
func (*UserDatabase) GetSecret ¶
func (db *UserDatabase) GetSecret(key string, gen func() []byte) ([]byte, error)
GetSecret returns a secret key used to sign the JWT token. If the secret key does not exist in the database, a new key is generated and saved to the database.
func (*UserDatabase) Remove ¶
func (db *UserDatabase) Remove(name string) error
func (*UserDatabase) Search ¶
func (db *UserDatabase) Search(filter interface{}, result interface{}) error
func (*UserDatabase) SetNamespace ¶
func (db *UserDatabase) SetNamespace(username, namespace string) error
func (*UserDatabase) Update ¶
func (db *UserDatabase) Update(name string, fields interface{}) error
type UserNotFoundError ¶
type UserNotFoundError string
The UserNotFoundError indicates that a user not found in the database.
func (UserNotFoundError) Error ¶
func (e UserNotFoundError) Error() string
func (UserNotFoundError) HTTPErrorStatusCode ¶
func (e UserNotFoundError) HTTPErrorStatusCode() int