Documentation
¶
Index ¶
- func GenerateRandomBytes(n int) ([]byte, error)
- func GenerateRandomString(s int) (string, error)
- func NewSession(Host string, Username string, Password string, Database string) *mgo.Session
- func PrepareDB(session *mgo.Session, db string, dbCollection string, indexes [][]string) *mgo.Collection
- type AppRepository
- type ClientApp
- type DB
- func (db *DB) DeleteApp(appID string) error
- func (db *DB) FindApp(ID, secret string) (*ClientApp, error)
- func (db *DB) GetApp(appID string) (*app.Apps, error)
- func (db *DB) GetMyApps(userID string) ([]byte, error)
- func (db *DB) GetUserApps(userID string) ([]byte, error)
- func (db *DB) RegenerateSecret(appID string) ([]byte, error)
- func (db *DB) RegisterApp(payload *app.AppPayload, userID string) (*app.RegApps, error)
- func (db *DB) UpdateApp(payload *app.AppPayload, appID string) (*app.Apps, error)
- type MongoCollection
- func (c *MongoCollection) DeleteApp(appID string) error
- func (c *MongoCollection) FindApp(ID, secret string) (*ClientApp, error)
- func (c *MongoCollection) GetApp(appID string) (*app.Apps, error)
- func (c *MongoCollection) GetMyApps(userID string) ([]byte, error)
- func (c *MongoCollection) GetUserApps(userID string) ([]byte, error)
- func (c *MongoCollection) RegenerateSecret(appID string) ([]byte, error)
- func (c *MongoCollection) RegisterApp(payload *app.AppPayload, userID string) (*app.RegApps, error)
- func (c *MongoCollection) UpdateApp(payload *app.AppPayload, appID string) (*app.Apps, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GenerateRandomBytes ¶
GenerateRandomBytes returns securely generated random bytes. It will return an error if the system's secure random number generator fails to function correctly, in which case the caller should not continue.
func GenerateRandomString ¶
GenerateRandomString returns a URL-safe, base64 encoded securely generated random string. It will return an error if the system's secure random number generator fails to function correctly, in which case the caller should not continue.
func NewSession ¶
NewSession returns a new Mongo Session.
Types ¶
type AppRepository ¶
type AppRepository interface {
// GetApp looks up a applications by the app ID.
GetApp(appID string) (*app.Apps, error)
GetMyApps(userID string) ([]byte, error)
GetUserApps(userID string) ([]byte, error)
RegisterApp(payload *app.AppPayload, userID string) (*app.RegApps, error)
DeleteApp(appID string) error
UpdateApp(payload *app.AppPayload, appID string) (*app.Apps, error)
RegenerateSecret(appID string) ([]byte, error)
FindApp(id, secret string) (*ClientApp, error)
}
AppRepository defaines the interface for accessing the application data.
type ClientApp ¶
type ClientApp struct {
ID string `json:"id" bson:"_id"`
Name string `json:"name" bson:"name"`
Description string `json:"description,omitempty" bson:"description"`
Domain string `json:"domain,omitempty" bson:"domain"`
Owner string `json:"owner" bson:"owner"`
RegisteredAt int64 `json:"registeredAt" bson:"registeredAt"`
Secret string `json:"secret" bson:"secret"`
}
ClientApp holds the data for a registered application (client).
type DB ¶
DB emulates a database driver using in-memory data structures.
func (*DB) GetUserApps ¶
Mock GetUserApps method
func (*DB) RegenerateSecret ¶
Mock RegenerateSecret method
func (*DB) RegisterApp ¶
Mock RegisterApp method
type MongoCollection ¶
type MongoCollection struct {
*mgo.Collection
}
MongoCollection wraps a mgo.Collection to embed methods in models.
func (*MongoCollection) DeleteApp ¶
func (c *MongoCollection) DeleteApp(appID string) error
func (*MongoCollection) FindApp ¶
func (c *MongoCollection) FindApp(ID, secret string) (*ClientApp, error)
FindApp tries to find an application (client) by its ID and secret. Returns nil if no such app is found.
func (*MongoCollection) GetMyApps ¶
func (c *MongoCollection) GetMyApps(userID string) ([]byte, error)
func (*MongoCollection) GetUserApps ¶
func (c *MongoCollection) GetUserApps(userID string) ([]byte, error)
func (*MongoCollection) RegenerateSecret ¶
func (c *MongoCollection) RegenerateSecret(appID string) ([]byte, error)
func (*MongoCollection) RegisterApp ¶
func (c *MongoCollection) RegisterApp(payload *app.AppPayload, userID string) (*app.RegApps, error)
func (*MongoCollection) UpdateApp ¶
func (c *MongoCollection) UpdateApp(payload *app.AppPayload, appID string) (*app.Apps, error)