Documentation
¶
Index ¶
- Constants
- func RandString(size int) string
- type Database
- func (db *Database) AddGroupMember(site, group, name string) error
- func (db *Database) AddGroupPermission(site, group, name string) error
- func (db *Database) AddSiteMember(site, name, data, admin string) error
- func (db *Database) AuthUser(name, password string) bool
- func (db *Database) CreateGroup(name, site string) error
- func (db *Database) CreatePermission(name, description string) error
- func (db *Database) CreateProfile(username, site, data string, admin bool) error
- func (db *Database) CreateSite(name string) error
- func (db *Database) CreateTables() error
- func (db *Database) CreateUser(name, password string) error
- func (db *Database) DeleteGroup(name, site string) error
- func (db *Database) DeleteGroupByID(id int64) error
- func (db *Database) DeletePermission(name string) error
- func (db *Database) DeleteSite(name string) error
- func (db *Database) DeleteUser(name string) error
- func (db *Database) GenerateToken(name string) string
- func (db *Database) GetGroupMembers(site, group string) (UserList, error)
- func (db *Database) GetGroupPermissions(site, group string) (PermissionList, error)
- func (db *Database) GetGroups(start, max int64, site string) (GroupList, error)
- func (db *Database) GetPermission(name string) (Permission, error)
- func (db *Database) GetPermissions() (PermissionList, error)
- func (db *Database) GetSiteID(name string) (int64, error)
- func (db *Database) GetSiteMembers(site string) ([]User, error)
- func (db *Database) GetSites(start, max int64) ([]Site, error)
- func (db *Database) GetUser(name string) (User, error)
- func (db *Database) GetUsers(start, max int64) ([]User, error)
- func (db *Database) Has(name, permission string) bool
- func (db *Database) InitDatabase(pw string) error
- func (db *Database) IsSiteAdmin(name, site string) bool
- func (db *Database) RemoveGroupMember(site, group, name string) error
- func (db *Database) RemoveGroupPermission(site, group, name string) error
- func (db *Database) RemoveProfile(username, site string) error
- func (db *Database) RemoveSiteMember(site, name string) error
- func (db *Database) SetPassword(name, password string, c int) error
- func (db *Database) ToggleSiteAdmin(site, name string, on bool) error
- func (db *Database) UpdatePermission(name, description string) error
- func (db *Database) UpdateProfile(username, site, data string) error
- func (db *Database) UpdateUser(name, newname, fullname, email string) error
- func (db *Database) VerifyToken(username, token string) bool
- type Group
- type GroupList
- type Permission
- type PermissionList
- type Profile
- type Request
- type Site
- type User
- type UserList
Constants ¶
const ( // EPAuth authenticates a user and returns a token. EPAuth = "/auth" // EPVerifyToken compares a username and token to stored tokens, then returns OK if valid. EPVerifyToken = "/verifytoken" // EPUsers is the bulk user endpoint. // GET lists all users. // POST creates multiple users. // PUT updates multiple users. // DELETE deletes multiple users. EPUsers = "/users" // EPUser is the single user endpoint. // GET returns a single user. // POST creates a single user. // PUT updates a single user. // DELETE deletes a single user. EPUser = "/user" // EPSetPassword sets the password for a user. EPSetPassword = "/password" // EPSites is the bulk site endpoint. // GET lists all sites. // POST creates multiple sites. // PUT updates multiple sites. // DELETE removes multiple sites. EPSites = "/sites" // EPSite is the single site endpoint. // POST creates a single site. // PUT updates a single site. // DELETE removes a single site. EPSite = "/site" // EPSetAdmin sets a user as an admin on a site. // PUT updates a single member. EPSetAdmin = "/setadmin" // EPSetProfile updates profike data for a user on a site. // PUT updates a single profile. EPSetProfile = "/updateprofile" //EPGroups is the bulk group endpoint. //GET lists all groups. //POST creates multiple groups. //DELETE removes multiple groups. EPGroups = "/groups" //EPGroup is the single group endpoint. //POST creates a single group. //DELETE removes a single group. EPGroup = "/group" // EPPermissions is the bulk permission endpoint. // GET lists all permissions. // POST creates multiple permissions. // DELETE removes multiple permissions. EPPermissions = "/permissions" // EPPermission is the single permission endpoint. // GET returns a single permission. // POST creates a single permission. // DELETE removes a single permission. EPPermission = "/permission" // EPMembers is the bulk member endpoint. // GET lists all members. // POST creates multiple members. // PUT updates multiple members. // DELETE removes multiple members. EPMembers = "/members" // EPMember is the single member endpoint. // POST creates a single member. // PUT updates a single member. // DELETE removes a single member. EPMember = "/member" // EPAdmin enables and disables admin status for a user on a site. // PUT enables admin status. // DELETE disables admin status. EPAdmin = "/admin" )
Variables ¶
This section is empty.
Functions ¶
func RandString ¶
RandString generates a random string suitable for passwords.
Types ¶
type Database ¶
Database pools for Sprawl.
func NewDatabase ¶
NewDatabase connects to the database and creates a connection pool.
func (*Database) AddGroupMember ¶ added in v0.2.0
AddGroupMember adds a user to a group.
func (*Database) AddGroupPermission ¶ added in v0.3.0
AddGroupPermission adds a permission to a group.
func (*Database) AddSiteMember ¶ added in v0.2.0
AddSiteMember adds a profile for a user.
func (*Database) AuthUser ¶ added in v0.11.0
AuthUser returns true if the uwername and password match.
func (*Database) CreateGroup ¶
CreateGroup creates a new group.
func (*Database) CreatePermission ¶ added in v0.2.0
CreatePermission adds a new keyword and optional description.
func (*Database) CreateProfile ¶ added in v0.2.0
CreateProfile both adds a user to a site and creates its site-specific profile entry.
func (*Database) CreateSite ¶
Createsite in the database.
func (*Database) CreateTables ¶
CreateTables sets up the database.
func (*Database) CreateUser ¶
CreateUser in database.
func (*Database) DeleteGroup ¶
DeleteGroup deletes a group.
func (*Database) DeleteGroupByID ¶
DeleteGroupByID deletes a group by ID.
func (*Database) DeletePermission ¶ added in v0.2.0
DeletePermission deletes a permission keyword.
func (*Database) DeleteSite ¶
DeleteSite from the database.
func (*Database) DeleteUser ¶
DeleteUser deletes a user from the database.
func (*Database) GenerateToken ¶ added in v0.8.0
GenerateToken if needed.
func (*Database) GetGroupMembers ¶ added in v0.2.0
GetGroupMembers returns a UserList.
func (*Database) GetGroupPermissions ¶ added in v0.3.0
func (db *Database) GetGroupPermissions(site, group string) (PermissionList, error)
func (*Database) GetPermission ¶ added in v0.3.0
func (db *Database) GetPermission(name string) (Permission, error)
GetPermission returns a permission keyword and its description.
func (*Database) GetPermissions ¶ added in v0.2.0
func (db *Database) GetPermissions() (PermissionList, error)
GetPermissions returns all permission keywords and their descriptions.
func (*Database) GetSiteMembers ¶ added in v0.2.0
GetSiteMembers returns a slice of users for a site.
func (*Database) InitDatabase ¶ added in v0.9.0
InitDatabase sets up the system site and admin user.
func (*Database) IsSiteAdmin ¶ added in v0.9.0
IsSiteAdmin returns true if the user is a site admin for the specified site.
func (*Database) RemoveGroupMember ¶ added in v0.2.0
RemoveGroupMember removes a user from a group.
func (*Database) RemoveGroupPermission ¶ added in v0.3.0
func (*Database) RemoveProfile ¶ added in v0.2.0
RemoveProfile removes a user from a site.
func (*Database) RemoveSiteMember ¶ added in v0.2.0
RemoveSiteMember deletes a profile for a user.
func (*Database) SetPassword ¶
SetPassword sets the password.
func (*Database) ToggleSiteAdmin ¶ added in v0.2.0
ToggleSiteAdmin status of a user.
func (*Database) UpdatePermission ¶ added in v0.3.0
UpdatePermission updates a permission description.
func (*Database) UpdateProfile ¶ added in v0.2.0
UpdateProfile updates the profile for a user+site combination.
func (*Database) UpdateUser ¶ added in v0.3.0
UpdateUser with new details.
func (*Database) VerifyToken ¶ added in v0.8.0
VerifyToken against expiry.
type GroupList ¶
type GroupList struct { // Groups on the site. Groups []Group `json:"groups"` }
GroupList is returned from the list groups endpoint.
type Permission ¶
type Permission struct { // ID is uthe unique identifier. ID int64 // Name is the keyword of the permission. Name string // Description is optional. Description string }
Permission is just a keyword with actual meaning defined by a client app.
type PermissionList ¶ added in v0.2.0
type PermissionList struct {
Permissions []Permission `json:"permissions"`
}
PermissionList is a list of permissions.
type Profile ¶
type Profile struct { // Site the profile is for. Site string // Data is a site-specific JSON structure. Data string // Groups for this site. Groups map[string]interface{} }
Prfile for a user+site combination.
type Site ¶
type Site struct { // ID is auto-generated on insert. ID int64 // Name is the domain name. Name string }
Site is the struct for a domain.
type User ¶
type User struct { // ID of the user (unique). ID int64 `json:"id"` // Name may be an e-mail address. Name string `json:"name"` // Fullname is the user's full name. Fullname string `json:"fullname,omitempty"` // Email is the user's e-mail address. Email string `json:"email"` // Password is a bcrypt hash. Password string `json:"password,omitempty"` // Profiles for different sites. Profile string `json:"profile,omitempty"` // Admin is true if the user is an admin. Admin bool `json:"admin,omitempty"` }
User data contains the barebones login info and site membership.
func (*User) CheckPassword ¶
CheckPassword checks the password.