Versions in this module Expand all Collapse all v0 v0.0.1 Jul 31, 2024 Changes in this version + const DEFAULT_PERMISSION_LEVEL + var ErrAccountAlreadyExists = errors.New("the account to be created already exists") + var ErrMalformedEmail = errors.New("malformed email") + var ErrMalformedSessionID = errors.New("malformed session id") + var ErrNoAccountFound = errors.New("found no account with that id/email") + var ErrNoApiKeyFound = errors.New("found no api key with that id") + var ErrNoSessionFound = errors.New("found no session with that id") + var ErrPasswordHashingFailed = errors.New("failed to hash password") + var ErrWrongCredentials = errors.New("account credentials didn't match") + func IsErrAccountAlreadyExists(err error) bool + func IsErrMalformedEmail(err error) bool + func IsErrMalformedSessionID(err error) bool + func IsErrNoAccountFound(err error) bool + func IsErrNoApiKeyFound(err error) bool + func IsErrNoSessionFound(err error) bool + func IsErrPasswordHashingFailed(err error) bool + func IsErrWrongCredentials(err error) bool + type Account account.Account + type AccountParams struct + CustomData interface{} + PermissionLevel uint8 + type Auth struct + func New(client *mongo.Client, ctx context.Context, config ...AuthConfig) (*Auth, error) + func (auth *Auth) Close() error + func (auth *Auth) CreateAccount(email string, pass string, params ...AccountParams) (*account.Account, error) + func (auth *Auth) CreateApiKey(namespace string, accessibleCollections []string, canRead bool, canWrite bool, ...) (*apikey.ApiKey, error) + func (auth *Auth) CreateSession(account *account.Account, duration time.Duration) (*session.Session, error) + func (auth *Auth) DeleteAccount(account account.Account) error + func (auth *Auth) DeleteAccountByEmail(email string) error + func (auth *Auth) DeleteApiKey(apiKey *apikey.ApiKey) error + func (auth *Auth) FindAccountByEmail(email string) (*account.Account, error) + func (auth *Auth) FindAccountByID(ID primitive.ObjectID) (*account.Account, error) + func (auth *Auth) FindAccountBySession(session *session.Session) (*account.Account, error) + func (auth *Auth) FindApiKeyByKey(key string) (*apikey.ApiKey, error) + func (auth *Auth) FindSessionByID(sessionID primitive.ObjectID) (*session.Session, error) + func (auth *Auth) FindSessionByToken(sessionToken string) (*session.Session, error) + func (auth *Auth) GarbageCollectApiKeys() (int64, error) + func (auth *Auth) GarbageCollectSessions() (int64, error) + func (auth *Auth) InvalidateSession(session *session.Session) error + func (auth *Auth) InvalidateSessionByID(sessionID primitive.ObjectID) error + func (auth *Auth) InvalidateSessionByToken(sessionToken string) error + func (auth *Auth) ValidateApiKey(apiKey *apikey.ApiKey) bool + func (auth *Auth) ValidateApiKeyByKey(key string) (bool, error) + func (auth *Auth) ValidateSession(session *session.Session) bool + func (auth *Auth) ValidateSessionByToken(sessionToken string) (bool, error) + func (auth *Auth) VerifyAccountCredentials(account *account.Account, pass string) bool + func (auth *Auth) VerifyAccountCredentialsByEmail(email string, pass string) (bool, error) + type AuthConfig struct + Database string