Documentation ¶
Index ¶
- func GenerateRandomBytes(n int) ([]byte, error)
- func GenerateRandomString(s int) (string, error)
- type AppsManagementStore
- type BackendAppsManagementStore
- func (c *BackendAppsManagementStore) DeleteApp(appID string) error
- func (c *BackendAppsManagementStore) FindApp(ID, secret string) (*ClientApp, error)
- func (c *BackendAppsManagementStore) GetApp(appID string) (*app.Apps, error)
- func (c *BackendAppsManagementStore) GetMyApps(userID string) ([]byte, error)
- func (c *BackendAppsManagementStore) GetUserApps(userID string) ([]byte, error)
- func (c *BackendAppsManagementStore) RegenerateSecret(appID string) ([]byte, error)
- func (c *BackendAppsManagementStore) RegisterApp(payload *app.AppPayload, userID string) (*app.RegApps, error)
- func (c *BackendAppsManagementStore) UpdateApp(payload *app.AppPayload, appID string) (*app.Apps, error)
- 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)
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.
Types ¶
type AppsManagementStore ¶
type AppsManagementStore 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) }
AppsManagementStore defaines the interface for accessing the application data.
func NewAppsManagementStore ¶
func NewAppsManagementStore(cfg *config.DBConfig) (store AppsManagementStore, cleanup func(), err error)
NewAppsManagementStore creates new AppsManagementStore implementation that supports multiple backend types.
type BackendAppsManagementStore ¶
type BackendAppsManagementStore struct {
// contains filtered or unexported fields
}
BackendAppsManagementStore holds a repository for a certain backend. Implements the AppsManagementStore interface.
func (*BackendAppsManagementStore) DeleteApp ¶
func (c *BackendAppsManagementStore) DeleteApp(appID string) error
DeleteApp deletes an application by id
func (*BackendAppsManagementStore) FindApp ¶
func (c *BackendAppsManagementStore) 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 (*BackendAppsManagementStore) GetApp ¶
func (c *BackendAppsManagementStore) GetApp(appID string) (*app.Apps, error)
GetApp retrieves an application by id
func (*BackendAppsManagementStore) GetMyApps ¶
func (c *BackendAppsManagementStore) GetMyApps(userID string) ([]byte, error)
GetMyApps retrieves applications for current user
func (*BackendAppsManagementStore) GetUserApps ¶
func (c *BackendAppsManagementStore) GetUserApps(userID string) ([]byte, error)
GetUserApps retrieves applications for a user
func (*BackendAppsManagementStore) RegenerateSecret ¶
func (c *BackendAppsManagementStore) RegenerateSecret(appID string) ([]byte, error)
RegenerateSecret creates a new secret for an application by id
func (*BackendAppsManagementStore) RegisterApp ¶
func (c *BackendAppsManagementStore) RegisterApp(payload *app.AppPayload, userID string) (*app.RegApps, error)
RegisterApp creates a new application for a user
func (*BackendAppsManagementStore) UpdateApp ¶
func (c *BackendAppsManagementStore) UpdateApp(payload *app.AppPayload, appID string) (*app.Apps, error)
UpdateApp updates an application by id
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