Documentation ¶
Index ¶
- Variables
- func AddCreateHook(f func(*AdminDB) error)
- func CanSubscribe(db DB, e *events.Event) error
- func CheckPassword(password, hashed string) error
- func Create(a *assets.Assets) error
- func ErrAccessDenied(err string, args ...interface{}) error
- func ErrBadQuery(err string, args ...interface{}) error
- func FillEvent(db *AdminDB, e *events.Event) error
- func GenerateKey(length int) (string, error)
- func GetExecError(result sql.Result, err error) error
- func HashPassword(password string) (string, error)
- func QQ(size int) string
- func ValidGroupScopes(s *ScopeArray) error
- func ValidIcon(icon string) error
- func ValidUserName(name string) error
- type AdminDB
- func (db *AdminDB) AdminDB() *AdminDB
- func (db *AdminDB) As(identifier string) (DB, error)
- func (db *AdminDB) Assets() *assets.Assets
- func (db *AdminDB) AuthUser(username string, password string) (string, string, error)
- func (db *AdminDB) CanCreateObject(s *Object) error
- func (db *AdminDB) Close() error
- func (db *AdminDB) CreateApp(c *App) (string, string, error)
- func (db *AdminDB) CreateObject(s *Object) (string, error)
- func (db *AdminDB) CreateUser(u *User) error
- func (db *AdminDB) CreateUserSession(username string, description string) (token string, sessionid string, err error)
- func (db *AdminDB) DelApp(id string) error
- func (db *AdminDB) DelObject(id string) error
- func (db *AdminDB) DelUser(name string) error
- func (db *AdminDB) DelUserSession(username, sessionid string) error
- func (db *AdminDB) DelUserSessionByToken(token string) error
- func (db *AdminDB) GetAppByAccessToken(accessToken string) (*App, error)
- func (db *AdminDB) GetObjectShares(objectid string) (m map[string]*ScopeArray, err error)
- func (db *AdminDB) GetUserSessionByToken(token string) (string, string, error)
- func (db *AdminDB) ID() string
- func (db *AdminDB) ListApps(o *ListAppOptions) ([]*App, error)
- func (db *AdminDB) ListObjects(o *ListObjectsOptions) ([]*Object, error)
- func (db *AdminDB) ListUserSessions(username string) (u []UserSession, err error)
- func (db *AdminDB) ListUsers(o *ListUsersOptions) (u []*User, err error)
- func (db *AdminDB) ReadApp(aid string, o *ReadAppOptions) (*App, error)
- func (db *AdminDB) ReadObject(id string, o *ReadObjectOptions) (s *Object, err error)
- func (db *AdminDB) ReadPluginDatabaseVersion(plugin string) (int, error)
- func (db *AdminDB) ReadUser(name string, o *ReadUserOptions) (*User, error)
- func (db *AdminDB) ReadUserPluginSettings(username string, plugin string) (v map[string]interface{}, err error)
- func (db *AdminDB) ReadUserSettings(username string) (map[string]map[string]interface{}, error)
- func (db *AdminDB) ShareObject(objectid, userid string, sa *ScopeArray) error
- func (db *AdminDB) Type() DBType
- func (db *AdminDB) UnshareObject(objectid string) error
- func (db *AdminDB) UnshareObjectFromUser(objectid, userid string) error
- func (db *AdminDB) UpdateApp(c *App) (err error)
- func (db *AdminDB) UpdateObject(s *Object) error
- func (db *AdminDB) UpdateUser(u *User) error
- func (db *AdminDB) UpdateUserPluginSettings(username string, plugin string, preferences map[string]interface{}) (err error)
- func (db *AdminDB) User() (*User, error)
- func (db *AdminDB) WritePluginDatabaseVersion(plugin string, version int) error
- type App
- type AppDB
- func (db *AppDB) AdminDB() *AdminDB
- func (db *AppDB) CanCreateObject(s *Object) error
- func (db *AppDB) CreateApp(c *App) (string, string, error)
- func (db *AppDB) CreateObject(s *Object) (string, error)
- func (db *AppDB) CreateUser(u *User) error
- func (db *AppDB) DelApp(cid string) error
- func (db *AppDB) DelObject(id string) error
- func (db *AppDB) DelUser(name string) error
- func (db *AppDB) DelUserSession(name, id string) error
- func (c *AppDB) GetObjectAccess(s *Object) (sa ScopeArray)
- func (db *AppDB) GetObjectShares(objectid string) (m map[string]*ScopeArray, err error)
- func (db *AppDB) ID() string
- func (db *AppDB) ListApps(o *ListAppOptions) ([]*App, error)
- func (db *AppDB) ListObjects(o *ListObjectsOptions) ([]*Object, error)
- func (db *AppDB) ListUserSessions(name string) ([]UserSession, error)
- func (db *AppDB) ListUsers(o *ListUsersOptions) ([]*User, error)
- func (db *AppDB) ReadApp(cid string, o *ReadAppOptions) (*App, error)
- func (db *AppDB) ReadObject(id string, o *ReadObjectOptions) (*Object, error)
- func (db *AppDB) ReadUser(name string, o *ReadUserOptions) (*User, error)
- func (db *AppDB) ReadUserPluginSettings(username string, plugin string) (map[string]interface{}, error)
- func (db *AppDB) ReadUserSettings(username string) (map[string]map[string]interface{}, error)
- func (db *AppDB) ShareObject(objectid, userid string, sa *ScopeArray) error
- func (db *AppDB) Type() DBType
- func (db *AppDB) UnshareObject(objectid string) error
- func (db *AppDB) UnshareObjectFromUser(objectid, userid string) error
- func (db *AppDB) UpdateApp(c *App) error
- func (db *AppDB) UpdateObject(s *Object) error
- func (db *AppDB) UpdateUser(u *User) error
- func (db *AppDB) UpdateUserPluginSettings(username string, plugin string, preferences map[string]interface{}) error
- func (db *AppDB) User() (*User, error)
- type AppScopeArray
- type DB
- type DBType
- type Details
- type FilledHandler
- type ListAppOptions
- type ListObjectsOptions
- type ListUsersOptions
- type Object
- type PublicDB
- func (db *PublicDB) AdminDB() *AdminDB
- func (db *PublicDB) CanCreateObject(s *Object) error
- func (db *PublicDB) CreateApp(c *App) (string, string, error)
- func (db *PublicDB) CreateObject(s *Object) (string, error)
- func (db *PublicDB) CreateUser(u *User) error
- func (db *PublicDB) DelApp(cid string) error
- func (db *PublicDB) DelObject(id string) error
- func (db *PublicDB) DelUser(name string) error
- func (db *PublicDB) DelUserSession(name, id string) error
- func (db *PublicDB) GetObjectShares(objectid string) (m map[string]*ScopeArray, err error)
- func (db *PublicDB) ID() string
- func (db *PublicDB) ListApps(o *ListAppOptions) ([]*App, error)
- func (db *PublicDB) ListObjects(o *ListObjectsOptions) ([]*Object, error)
- func (db *PublicDB) ListUserSessions(name string) ([]UserSession, error)
- func (db *PublicDB) ListUsers(o *ListUsersOptions) ([]*User, error)
- func (db *PublicDB) ReadApp(cid string, o *ReadAppOptions) (*App, error)
- func (db *PublicDB) ReadObject(id string, o *ReadObjectOptions) (*Object, error)
- func (db *PublicDB) ReadUser(name string, o *ReadUserOptions) (*User, error)
- func (db *PublicDB) ReadUserPluginSettings(username string, plugin string) (map[string]interface{}, error)
- func (db *PublicDB) ReadUserSettings(username string) (map[string]map[string]interface{}, error)
- func (db *PublicDB) ShareObject(objectid, userid string, sa *ScopeArray) error
- func (db *PublicDB) Type() DBType
- func (db *PublicDB) UnshareObject(objectid string) error
- func (db *PublicDB) UnshareObjectFromUser(objectid, userid string) error
- func (db *PublicDB) UpdateApp(c *App) error
- func (db *PublicDB) UpdateObject(s *Object) error
- func (db *PublicDB) UpdateUser(u *User) error
- func (db *PublicDB) UpdateUserPluginSettings(username string, plugin string, preferences map[string]interface{}) error
- func (db *PublicDB) User() (*User, error)
- type ReadAppOptions
- type ReadObjectOptions
- type ReadUserOptions
- type ScopeArray
- func (s *ScopeArray) HasScope(sv string) (ok bool)
- func (s *ScopeArray) Load(total string)
- func (s *ScopeArray) MarshalJSON() ([]byte, error)
- func (s *ScopeArray) Scan(val interface{}) error
- func (s *ScopeArray) String() string
- func (s *ScopeArray) UnmarshalJSON(b []byte) error
- func (s *ScopeArray) Update()
- func (s *ScopeArray) Value() (driver.Value, error)
- type SqlxCache
- func (db *SqlxCache) BeginImmediatex() (*TxWrapper, error)
- func (db *SqlxCache) Beginx() (*TxWrapper, error)
- func (db *SqlxCache) Exec(query string, args ...interface{}) (sql.Result, error)
- func (db *SqlxCache) ExecUncached(query string, args ...interface{}) (sql.Result, error)
- func (db *SqlxCache) Get(dest interface{}, query string, args ...interface{}) error
- func (db *SqlxCache) GetOrPrepare(query string) (*sqlx.Stmt, error)
- func (db *SqlxCache) GetOrPrepareNamed(query string) (*sqlx.NamedStmt, error)
- func (c *SqlxCache) InitCache(sqldb *sqlx.DB)
- func (db *SqlxCache) NamedExec(query string, arg interface{}) (sql.Result, error)
- func (db *SqlxCache) Queryx(query string, args ...interface{}) (*sqlx.Rows, error)
- func (db *SqlxCache) Select(dest interface{}, query string, args ...interface{}) error
- type TxWrapper
- func (tx *TxWrapper) Commit() error
- func (tx *TxWrapper) Exec(query string, args ...interface{}) (sql.Result, error)
- func (tx *TxWrapper) Get(dest interface{}, query string, args ...interface{}) error
- func (tx *TxWrapper) Queryx(query string, args ...interface{}) (*sqlx.Rows, error)
- func (tx *TxWrapper) Rollback() error
- func (tx *TxWrapper) Select(dest interface{}, query string, args ...interface{}) error
- type User
- type UserDB
- func (db *UserDB) AdminDB() *AdminDB
- func (db *UserDB) CanCreateObject(s *Object) error
- func (db *UserDB) CreateApp(c *App) (string, string, error)
- func (db *UserDB) CreateObject(s *Object) (string, error)
- func (db *UserDB) CreateUser(u *User) error
- func (db *UserDB) DelApp(cid string) error
- func (db *UserDB) DelObject(id string) error
- func (db *UserDB) DelUser(name string) error
- func (db *UserDB) DelUserSession(username, id string) error
- func (db *UserDB) GetObjectShares(objectid string) (m map[string]*ScopeArray, err error)
- func (db *UserDB) ID() string
- func (db *UserDB) ListApps(o *ListAppOptions) ([]*App, error)
- func (db *UserDB) ListObjects(o *ListObjectsOptions) ([]*Object, error)
- func (db *UserDB) ListUserSessions(username string) ([]UserSession, error)
- func (db *UserDB) ListUsers(o *ListUsersOptions) ([]*User, error)
- func (db *UserDB) ReadApp(cid string, o *ReadAppOptions) (*App, error)
- func (db *UserDB) ReadObject(id string, o *ReadObjectOptions) (*Object, error)
- func (db *UserDB) ReadUser(name string, o *ReadUserOptions) (*User, error)
- func (db *UserDB) ReadUserPluginSettings(username string, plugin string) (map[string]interface{}, error)
- func (db *UserDB) ReadUserSettings(username string) (map[string]map[string]interface{}, error)
- func (db *UserDB) ShareObject(objectid, userid string, sa *ScopeArray) error
- func (db *UserDB) Type() DBType
- func (db *UserDB) UnshareObject(objectid string) error
- func (db *UserDB) UnshareObjectFromUser(objectid, userid string) error
- func (db *UserDB) UpdateApp(c *App) error
- func (db *UserDB) UpdateObject(s *Object) error
- func (db *UserDB) UpdateUser(u *User) error
- func (db *UserDB) UpdateUserPluginSettings(username string, plugin string, preferences map[string]interface{}) error
- func (db *UserDB) User() (*User, error)
- type UserSession
Constants ¶
This section is empty.
Variables ¶
var ( ErrNotFound = errors.New("not_found: The selected resource was not found") ErrNoUpdate = errors.New("nop: Nothing to update") ErrNoPasswordGiven = errors.New("bad_request: A user cannot have an empty password") ErrUserNotFound = errors.New("not_found: User was not found") ErrInvalidUserName = errors.New("bad_request: Invalid Username") ErrInvalidName = errors.New("bad_request: Invalid name") ErrInvalidQuery = errors.New("invalid_query: Invalid query") )
var ErrSAccessDenied = errors.New("access_denied: You don't have necessary permissions for the given query")
var ErrUnimplemented = errors.New("The given functionality is currently unimplemented")
Functions ¶
func AddCreateHook ¶
AddCreateHook executes code when a database is created
func CanSubscribe ¶
Check if the given DB can perform the given subscription
func CheckPassword ¶
CheckPassword checks if the password is valid
func ErrAccessDenied ¶
func ErrBadQuery ¶
func GenerateKey ¶
GenerateKey creates a random API key
func GetExecError ¶
Performs a set of tests on the result and error of a call to see what kind of error we should return.
func HashPassword ¶
HashPassword generates a bcrypt hash for the given password
func ValidGroupScopes ¶
func ValidGroupScopes(s *ScopeArray) error
Checks whether the given group access level is OK
func ValidUserName ¶
Types ¶
type AdminDB ¶
type AdminDB struct { SqlxCache // contains filtered or unexported fields }
AdminDB holds the main database, with admin access
func (*AdminDB) AuthUser ¶
AuthUser returns the username corresponding to the username and password, or an authentication error
func (*AdminDB) CanCreateObject ¶
CanCreateObject returns whether the given object can be
func (*AdminDB) CreateObject ¶
CreateObject creates the object
func (*AdminDB) CreateUser ¶
CreateUser is the administrator version of create
func (*AdminDB) CreateUserSession ¶
func (db *AdminDB) CreateUserSession(username string, description string) (token string, sessionid string, err error)
CreateUserSession creates a new session for the given user
func (*AdminDB) DelUserSession ¶
func (*AdminDB) DelUserSessionByToken ¶
DelUserSessionByToken deletes the given token from the database
func (*AdminDB) GetAppByAccessToken ¶
GetAppByAccessToken reads the app corresponding to the given access token, and sets the last access date if not today
func (*AdminDB) GetObjectShares ¶
func (db *AdminDB) GetObjectShares(objectid string) (m map[string]*ScopeArray, err error)
GetObjectShares returns the shares of the object
func (*AdminDB) GetUserSessionByToken ¶
GetUserSessionByToken gets an active login token's username/session ID, and sets the last access date if not today
func (*AdminDB) ListApps ¶
func (db *AdminDB) ListApps(o *ListAppOptions) ([]*App, error)
ListApps lists apps
func (*AdminDB) ListObjects ¶
func (db *AdminDB) ListObjects(o *ListObjectsOptions) ([]*Object, error)
ListObjects lists the given objects
func (*AdminDB) ListUserSessions ¶
func (db *AdminDB) ListUserSessions(username string) (u []UserSession, err error)
func (*AdminDB) ListUsers ¶
func (db *AdminDB) ListUsers(o *ListUsersOptions) (u []*User, err error)
func (*AdminDB) ReadApp ¶
func (db *AdminDB) ReadApp(aid string, o *ReadAppOptions) (*App, error)
ReadApp gets the app associated with the given API key
func (*AdminDB) ReadObject ¶
func (db *AdminDB) ReadObject(id string, o *ReadObjectOptions) (s *Object, err error)
ReadObject gets the object by ID
func (*AdminDB) ReadPluginDatabaseVersion ¶
func (*AdminDB) ReadUser ¶
func (db *AdminDB) ReadUser(name string, o *ReadUserOptions) (*User, error)
ReadUser reads a user
func (*AdminDB) ReadUserPluginSettings ¶
func (*AdminDB) ReadUserSettings ¶
ReadUserSettings gets the given user's preferences. Returns default preferences if the user does not exist.
func (*AdminDB) ShareObject ¶
func (db *AdminDB) ShareObject(objectid, userid string, sa *ScopeArray) error
ShareObject shares the given object with the given user, allowing the given set of scope
func (*AdminDB) UnshareObject ¶
UnshareObject deletes ALL the shares fro mthe object
func (*AdminDB) UnshareObjectFromUser ¶
UnshareObjectFromUser Removes the given share from the object
func (*AdminDB) UpdateApp ¶
UpdateApp updates the given app (by ID). Note that the inserted values will be written directly to the object.
func (*AdminDB) UpdateObject ¶
UpdateObject updates the given object by ID
func (*AdminDB) UpdateUser ¶
UpdateUser updates the given portions of a user
func (*AdminDB) UpdateUserPluginSettings ¶
type App ¶
type App struct { Details Owner *string `json:"owner" db:"owner"` Plugin *string `json:"plugin,omitempty" db:"plugin"` Enabled *bool `json:"enabled,omitempty" db:"enabled"` AccessToken *string `json:"access_token,omitempty" db:"access_token"` CreatedDate dbutil.Date `json:"created_date,omitempty" db:"created_date"` LastAccessDate *dbutil.Date `json:"last_access_date" db:"last_access_date"` Scope *AppScopeArray `json:"scope" db:"scope"` Settings *dbutil.JSONObject `json:"settings" db:"settings"` SettingsSchema *dbutil.JSONObject `json:"settings_schema" db:"settings_schema"` }
type AppDB ¶
type AppDB struct {
// contains filtered or unexported fields
}
func (*AppDB) CanCreateObject ¶
CanCreateObject returns whether the given object can be
func (*AppDB) CreateObject ¶
CreateObject creates the object.
func (*AppDB) CreateUser ¶
func (*AppDB) DelUserSession ¶
func (*AppDB) GetObjectAccess ¶
func (c *AppDB) GetObjectAccess(s *Object) (sa ScopeArray)
GetObjectAccess returns a ScopeArray that merges the current access
func (*AppDB) GetObjectShares ¶
func (db *AppDB) GetObjectShares(objectid string) (m map[string]*ScopeArray, err error)
func (*AppDB) ListObjects ¶
func (db *AppDB) ListObjects(o *ListObjectsOptions) ([]*Object, error)
ListObjects lists the given objects
func (*AppDB) ListUserSessions ¶
func (db *AppDB) ListUserSessions(name string) ([]UserSession, error)
func (*AppDB) ReadObject ¶
func (db *AppDB) ReadObject(id string, o *ReadObjectOptions) (*Object, error)
ReadObject reads the given object if the user has sufficient permissions
func (*AppDB) ReadUserPluginSettings ¶
func (*AppDB) ReadUserSettings ¶
func (*AppDB) ShareObject ¶
func (db *AppDB) ShareObject(objectid, userid string, sa *ScopeArray) error
func (*AppDB) UnshareObject ¶
func (*AppDB) UnshareObjectFromUser ¶
func (*AppDB) UpdateObject ¶
UpdateObject allows editing a object
func (*AppDB) UpdateUser ¶
UpdateUser updates the given portions of a user
func (*AppDB) UpdateUserPluginSettings ¶
type AppScopeArray ¶
type AppScopeArray struct {
ScopeArray
}
AppScopeArray works with app scope, which have different details than object scope
func (*AppScopeArray) HasScope ¶
func (s *AppScopeArray) HasScope(sv string) (ok bool)
HasScope checks if the given scope is present
func (*AppScopeArray) Update ¶
func (s *AppScopeArray) Update()
Update cleans out the scope to remove repeated items
type DB ¶
type DB interface { AdminDB() *AdminDB // Returns the underlying administrative database ID() string // This is an identifier for the database Type() DBType // Returns the database type CreateUser(u *User) error ReadUser(name string, o *ReadUserOptions) (*User, error) UpdateUser(u *User) error DelUser(name string) error ListUsers(o *ListUsersOptions) ([]*User, error) ListUserSessions(name string) ([]UserSession, error) DelUserSession(name, id string) error CreateApp(c *App) (string, string, error) ReadApp(cid string, o *ReadAppOptions) (*App, error) UpdateApp(c *App) error DelApp(cid string) error ListApps(o *ListAppOptions) ([]*App, error) CanCreateObject(s *Object) error CreateObject(s *Object) (string, error) ReadObject(id string, o *ReadObjectOptions) (*Object, error) UpdateObject(s *Object) error DelObject(id string) error ListObjects(o *ListObjectsOptions) ([]*Object, error) ReadUserSettings(username string) (map[string]map[string]interface{}, error) UpdateUserPluginSettings(username string, plugin string, preferences map[string]interface{}) error ReadUserPluginSettings(username string, plugin string) (map[string]interface{}, error) }
DB represents the database. This interface is implemented in many ways:
once for admin once for users once for apps once for public
type Details ¶
type Details struct { // The ID is used as a handle for all modification, and as such is also present in users ID string `json:"id,omitempty" db:"id"` Name *string `json:"name,omitempty" db:"name"` Description *string `json:"description,omitempty" db:"description"` Icon *string `json:"icon,omitempty" db:"icon"` }
Details is used in groups, users, apps and objects to hold info
type FilledHandler ¶
func NewFilledHandler ¶
func NewFilledHandler(db *AdminDB, h events.Handler) FilledHandler
func (FilledHandler) Fire ¶
func (fh FilledHandler) Fire(e *events.Event)
type ListAppOptions ¶
type ListAppOptions struct { ReadAppOptions // Limit the results either to enabled or disabled apps Enabled *bool `json:"enabled,omitempty" schema:"enabled"` // Limit results to the given user's apps Owner *string `json:"owner,omitempty" schema:"owner"` // Find the apps with the given plugin key Plugin *string `json:"plugin,omitempty" schema:"plugin"` }
ListAppOptions holds the options associated with listing apps
type ListObjectsOptions ¶
type ListObjectsOptions struct { ReadObjectOptions // Limit results to the given user's objects. Owner *string `json:"owner,omitempty" schema:"owner"` // Limit the results to the given app's objects App *string `json:"app,omitempty" schema:"app"` // Get by plugin key Key *string `json:"key,omitempty" schema:"key"` // Get objects with the given tags Tags *string `json:"tags,omitempty" schema:"tags"` // Limit results to objects of the given type Type *string `json:"type,omitempty" schema:"type"` // Maximum number of results to return Limit *int `json:"limit,omitempty" schema:"limit"` // This is only allowed for user==current user Shared bool }
ListObjectsOptions shows the options for listing objects
type ListUsersOptions ¶
type ListUsersOptions struct {
ReadUserOptions
}
type Object ¶
type Object struct { Details Owner *string `json:"owner,omitempty" db:"owner"` App *string `json:"app" db:"app"` Tags *dbutil.StringArray `json:"tags,omitempty" db:"tags"` Key *string `json:"key,omitempty" db:"key"` Type *string `json:"type,omitempty" db:"type"` Meta *dbutil.JSONObject `json:"meta,omitempty" db:"meta"` CreatedDate *dbutil.Date `json:"created_date,omitempty" db:"created_date"` ModifiedDate *dbutil.Date `json:"modified_date" db:"modified_date"` // The scope the owner has to the object. This allows apps to control objects belonging to them. OwnerScope *ScopeArray `json:"owner_scope,omitempty" db:"owner_scope"` // The access array, giving the permissions the currently logged in thing has // It is generated manually for each read query, it does not exist in the database. Access ScopeArray `json:"access,omitempty" db:"access"` }
type PublicDB ¶
type PublicDB struct {
// contains filtered or unexported fields
}
func NewPublicDB ¶
func (*PublicDB) CanCreateObject ¶
CanCreateObject returns whether the given object can be
func (*PublicDB) CreateUser ¶
func (*PublicDB) DelUserSession ¶
func (*PublicDB) GetObjectShares ¶
func (db *PublicDB) GetObjectShares(objectid string) (m map[string]*ScopeArray, err error)
func (*PublicDB) ListObjects ¶
func (db *PublicDB) ListObjects(o *ListObjectsOptions) ([]*Object, error)
ListObjects lists the given objects
func (*PublicDB) ListUserSessions ¶
func (db *PublicDB) ListUserSessions(name string) ([]UserSession, error)
func (*PublicDB) ReadObject ¶
func (db *PublicDB) ReadObject(id string, o *ReadObjectOptions) (*Object, error)
ReadObject reads the given object if it is shared
func (*PublicDB) ReadUser ¶
func (db *PublicDB) ReadUser(name string, o *ReadUserOptions) (*User, error)
func (*PublicDB) ReadUserPluginSettings ¶
func (*PublicDB) ReadUserSettings ¶
func (*PublicDB) ShareObject ¶
func (db *PublicDB) ShareObject(objectid, userid string, sa *ScopeArray) error
func (*PublicDB) UnshareObject ¶
func (*PublicDB) UnshareObjectFromUser ¶
func (*PublicDB) UpdateObject ¶
UpdateObject allows editing a object
func (*PublicDB) UpdateUser ¶
func (*PublicDB) UpdateUserPluginSettings ¶
type ReadAppOptions ¶
type ReadAppOptions struct { Icon bool `json:"icon,omitempty" schema:"icon"` AccessToken bool `json:"token,omitempty" schema:"token"` // using "token" instead of access_token, since the API uses access_token param }
ReadAppOptions gives options for reading
type ReadObjectOptions ¶
type ReadObjectOptions struct {
Icon bool `json:"icon,omitempty" schema:"icon"`
}
ReadObjectOptions gives options for reading
type ReadUserOptions ¶
type ReadUserOptions struct {
Icon bool `json:"icon,omitempty" schema:"icon"`
}
ReadUserOptions gives options for reading a user
type ScopeArray ¶
type ScopeArray struct { Scope []string // contains filtered or unexported fields }
ScopeArray represents a json column in a table. To handle it correctly, we need to manually scan it and output a value.
func (*ScopeArray) HasScope ¶
func (s *ScopeArray) HasScope(sv string) (ok bool)
HasScope checks if the given scope is present
func (*ScopeArray) Load ¶
func (s *ScopeArray) Load(total string)
func (*ScopeArray) MarshalJSON ¶
func (s *ScopeArray) MarshalJSON() ([]byte, error)
func (*ScopeArray) Scan ¶
func (s *ScopeArray) Scan(val interface{}) error
func (*ScopeArray) String ¶
func (s *ScopeArray) String() string
func (*ScopeArray) UnmarshalJSON ¶
func (s *ScopeArray) UnmarshalJSON(b []byte) error
func (*ScopeArray) Update ¶
func (s *ScopeArray) Update()
Update cleans out the scope to remove repeated items
type SqlxCache ¶
func (*SqlxCache) BeginImmediatex ¶ added in v0.5.1
func (*SqlxCache) Exec ¶
* This is a wrapper for the Exec done in sqlx, it does auto conversion to stored procedures executes them, and does conversion to the given query style for the given database. *
func (*SqlxCache) ExecUncached ¶
func (*SqlxCache) Get ¶
* This is a wrapper for the Get done in sqlx, it does auto conversion to stored procedures executes them, and does conversion to the given query style for the given database.
Gets a single item from the DB, remember to add LIMIT 1 if the DB doesn't know about the query being for a unique item. *
func (*SqlxCache) GetOrPrepare ¶
This function returns a prepared statement, or prepares one for the given query stores it and returns it
func (*SqlxCache) GetOrPrepareNamed ¶
This function returns a prepared statement, or prepares one for the given query stores it and returns it
type User ¶
type User struct { Details UserName *string `json:"username" db:"username"` PublicRead *bool `json:"public_read" db:"public_read"` UsersRead *bool `json:"users_read" db:"users_read"` Password *string `json:"password,omitempty" db:"password"` }
User holds a user's data
type UserDB ¶
type UserDB struct {
// contains filtered or unexported fields
}
func (*UserDB) CanCreateObject ¶
CanCreateObject returns whether the given object can be
func (*UserDB) CreateObject ¶
CreateObject creates the object.
func (*UserDB) CreateUser ¶
func (*UserDB) DelUserSession ¶
func (*UserDB) GetObjectShares ¶
func (db *UserDB) GetObjectShares(objectid string) (m map[string]*ScopeArray, err error)
func (*UserDB) ListObjects ¶
func (db *UserDB) ListObjects(o *ListObjectsOptions) ([]*Object, error)
ListObjects lists the given objects
func (*UserDB) ListUserSessions ¶
func (db *UserDB) ListUserSessions(username string) ([]UserSession, error)
func (*UserDB) ReadObject ¶
func (db *UserDB) ReadObject(id string, o *ReadObjectOptions) (*Object, error)
ReadObject reads the given object if the user has sufficient permissions
func (*UserDB) ReadUser ¶
func (db *UserDB) ReadUser(name string, o *ReadUserOptions) (*User, error)
func (*UserDB) ReadUserPluginSettings ¶
func (*UserDB) ReadUserSettings ¶
func (*UserDB) ShareObject ¶
func (db *UserDB) ShareObject(objectid, userid string, sa *ScopeArray) error
func (*UserDB) UnshareObject ¶
func (*UserDB) UnshareObjectFromUser ¶
func (*UserDB) UpdateObject ¶
UpdateObject allows editing a object
func (*UserDB) UpdateUser ¶
UpdateUser updates the given portions of a user