Documentation
¶
Index ¶
Constants ¶
const ( APIKeyDocumentV1Type = "apikey" APIKeysCollection = "apikeys" )
const ( SessionDocumentV1Type = "session" SessionsCollection = "sessions" )
Variables ¶
This section is empty.
Functions ¶
func Connect ¶
Connect establishes a connection to the database server and a handle to the actual database if neither have been connected.
The following errors are returned by this function: DBConnectFailure
func RemoveExpiredAPIKeysV1 ¶
RemoveExpiredAPIKeysV1 removes APIKeyDocumentV1 documents with expired API keys.
The following errors are returned by this function: DBDeleteFailure
func RemoveExpiredSessionsV1 ¶
RemoveExpiredSessionsV1 removes SessionDocumentV1 documents with expired sessions.
The following errors are returned by this function: DBDeleteFailure
Types ¶
type APIKeyDocumentV1 ¶
type APIKeyDocumentV1 struct { Expires int64 `bson:"expires"` ID primitive.ObjectID `bson:"_id,omitempty"` Key string `bson:"key"` ObjectType string `bson:"_objectType"` Secret string `bson:"secret"` Username string `bson:"username"` Version uint `bson:"_version"` }
APIKeyDocumentV1 represents an individual API key.
func AuthenticateAPIKeyV1 ¶
func AuthenticateAPIKeyV1(ctx context.Context, apiKey, apiSecret string) (*APIKeyDocumentV1, error)
AuthenticateAPIKeyV1 checks to see if there is an APIKeyDocumentV1 with a matching API key and secret for the given user in the database.
The following errors are returned by this function: DBQueryFailure
func CreateAPIKeyV1 ¶
func CreateAPIKeyV1(ctx context.Context, username, apiKey, apiSecret string, expires int64) ( *APIKeyDocumentV1, error)
CreateAPIKeyV1 inserts a new APIKeyDocumentV1 object into the database.
The following errors are returned by this function: GeneralFailure, DBInsertFailure
func (*APIKeyDocumentV1) ToJSON ¶
func (d *APIKeyDocumentV1) ToJSON() string
ToJSON renders the document as a JSON string.
type SessionDocumentV1 ¶
type SessionDocumentV1 struct { Data map[string]interface{} `bson:"data"` Expires int64 `bson:"expires"` ID primitive.ObjectID `bson:"_id,omitempty"` ObjectType string `bson:"_objectType"` SessionID string `bson:"sessionID"` Version uint `bson:"_version"` }
SessionDocumentV1 represents an individual session.
func GetSessionV1 ¶
func GetSessionV1(ctx context.Context, sessionID string) (*SessionDocumentV1, error)
GetSessionV1 returns the SessionDocumentV1 object with the matching session ID from the database.
The following errors are returned by this function: DBQueryFailure
func SaveSessionV1 ¶
func SaveSessionV1(ctx context.Context, id string, expires int64, data map[string]interface{}) ( *SessionDocumentV1, error)
SaveSessionV1 creates or updates a SessionDocumentV1 object in the database.
The following errors are returned by this function: GeneralFailure, DBInsertFailure, DBUpdateFailure
func (*SessionDocumentV1) ToJSON ¶
func (d *SessionDocumentV1) ToJSON() string
ToJSON renders the document as a JSON string.