Documentation ¶
Index ¶
- Constants
- Variables
- type DataStoreMongo
- func (db *DataStoreMongo) CountPersonalAccessTokens(ctx context.Context, userID string) (int64, error)
- func (db *DataStoreMongo) CreateUser(ctx context.Context, u *model.User) error
- func (db *DataStoreMongo) DeleteToken(ctx context.Context, userID, tokenID oid.ObjectID) error
- func (db *DataStoreMongo) DeleteTokens(ctx context.Context) error
- func (db *DataStoreMongo) DeleteTokensByUserId(ctx context.Context, userId string) error
- func (db *DataStoreMongo) DeleteTokensByUserIdExceptCurrentOne(ctx context.Context, userId string, tokenID oid.ObjectID) error
- func (db *DataStoreMongo) DeleteUser(ctx context.Context, id string) error
- func (db *DataStoreMongo) EnsureSessionTokensLimit(ctx context.Context, userID oid.ObjectID, tokensLimit int) error
- func (db *DataStoreMongo) GetPersonalAccessTokens(ctx context.Context, userID string) ([]model.PersonalAccessToken, error)
- func (db *DataStoreMongo) GetSettings(ctx context.Context) (*model.Settings, error)
- func (db *DataStoreMongo) GetTokenById(ctx context.Context, id oid.ObjectID) (*jwt.Token, error)
- func (db *DataStoreMongo) GetUserAndPasswordById(ctx context.Context, id string) (*model.User, error)
- func (db *DataStoreMongo) GetUserByEmail(ctx context.Context, email model.Email) (*model.User, error)
- func (db *DataStoreMongo) GetUserById(ctx context.Context, id string) (*model.User, error)
- func (db *DataStoreMongo) GetUserSettings(ctx context.Context, userID string) (*model.Settings, error)
- func (db *DataStoreMongo) GetUsers(ctx context.Context, fltr model.UserFilter) ([]model.User, error)
- func (db *DataStoreMongo) Migrate(ctx context.Context, version string) error
- func (db *DataStoreMongo) MigrateTenant(ctx context.Context, version string, tenant string) error
- func (db *DataStoreMongo) Ping(ctx context.Context) error
- func (db *DataStoreMongo) SaveSettings(ctx context.Context, s *model.Settings, etag string) error
- func (db *DataStoreMongo) SaveToken(ctx context.Context, token *jwt.Token) error
- func (db *DataStoreMongo) SaveUserSettings(ctx context.Context, userID string, s *model.Settings, etag string) error
- func (db *DataStoreMongo) UpdateLoginTs(ctx context.Context, id string) error
- func (db *DataStoreMongo) UpdateTokenLastUsed(ctx context.Context, id oid.ObjectID) error
- func (db *DataStoreMongo) UpdateUser(ctx context.Context, id string, u *model.UserUpdate) (*model.User, error)
- func (db *DataStoreMongo) WithAutomigrate() *DataStoreMongo
- func (db *DataStoreMongo) WithMultitenant() *DataStoreMongo
- type DataStoreMongoConfig
Constants ¶
View Source
const ( DbUsersColl = "users" DbTokensColl = "tokens" DbSettingsColl = "settings" DbUserSettingsColl = "user_settings" DbUserEmail = "email" DbUserPass = "password" DbUserLoginTs = "login_ts" DbTokenSubject = "sub" DbTokenExpiresAt = "exp" DbTokenExpireTime = "exp.time" DbTokenIssuedAt = "iat" DbTokenTenant = "tenant" DbTokenUser = "user" DbTokenIssuer = "iss" DbTokenScope = "scp" DbTokenAudience = "aud" DbTokenNotBefore = "nbf" DbTokenLastUsed = "last_used" DbTokenName = "name" DbID = "_id" DbTokenIssuedAtTime = DbTokenIssuedAt + ".time" DbUniqueEmailIndexName = "email_1" DbUniqueTokenNameIndexName = "token_name_1" DbTokenSubjectIndexName = "token_subject_1" DbTenantUniqueTokenNameIndexName = "tenant_1_subject_1_name_1" DbTenantTokenSubjectIndexName = "tenant_1_subject_1" DbSettingsEtag = "etag" DbSettingsTenantIndexName = "tenant" DbSettingsUserID = "user_id" )
View Source
const ( DbVersion = "2.0.3" DbName = "useradm" )
View Source
const ErrCodeIndexOptionsError = 85
View Source
const IndexNameTokenExpire = "exp_time"
View Source
const (
OldDbUniqueEmailIndexName = "uniqueEmail"
)
Variables ¶
Functions ¶
This section is empty.
Types ¶
type DataStoreMongo ¶
type DataStoreMongo struct {
// contains filtered or unexported fields
}
func GetDataStoreMongo ¶
func GetDataStoreMongo(config DataStoreMongoConfig) (*DataStoreMongo, error)
func NewDataStoreMongo ¶
func NewDataStoreMongo(config DataStoreMongoConfig) (*DataStoreMongo, error)
func NewDataStoreMongoWithClient ¶
func NewDataStoreMongoWithClient(client *mongo.Client) (*DataStoreMongo, error)
func (*DataStoreMongo) CountPersonalAccessTokens ¶
func (*DataStoreMongo) CreateUser ¶
func (*DataStoreMongo) DeleteToken ¶
func (*DataStoreMongo) DeleteTokens ¶
func (db *DataStoreMongo) DeleteTokens(ctx context.Context) error
deletes all tenant's tokens (identity in context)
func (*DataStoreMongo) DeleteTokensByUserId ¶
func (db *DataStoreMongo) DeleteTokensByUserId(ctx context.Context, userId string) error
deletes all user's tokens
func (*DataStoreMongo) DeleteTokensByUserIdExceptCurrentOne ¶
func (db *DataStoreMongo) DeleteTokensByUserIdExceptCurrentOne( ctx context.Context, userId string, tokenID oid.ObjectID, ) error
deletes all user's tokens except the current one
func (*DataStoreMongo) DeleteUser ¶
func (db *DataStoreMongo) DeleteUser(ctx context.Context, id string) error
func (*DataStoreMongo) EnsureSessionTokensLimit ¶
func (*DataStoreMongo) GetPersonalAccessTokens ¶
func (db *DataStoreMongo) GetPersonalAccessTokens( ctx context.Context, userID string, ) ([]model.PersonalAccessToken, error)
func (*DataStoreMongo) GetSettings ¶
func (*DataStoreMongo) GetTokenById ¶
func (*DataStoreMongo) GetUserAndPasswordById ¶
func (*DataStoreMongo) GetUserByEmail ¶
func (*DataStoreMongo) GetUserById ¶
func (*DataStoreMongo) GetUserSettings ¶
func (*DataStoreMongo) GetUsers ¶
func (db *DataStoreMongo) GetUsers( ctx context.Context, fltr model.UserFilter, ) ([]model.User, error)
func (*DataStoreMongo) Migrate ¶
func (db *DataStoreMongo) Migrate(ctx context.Context, version string) error
func (*DataStoreMongo) MigrateTenant ¶
MigrateTenant migrates a single tenant database.
func (*DataStoreMongo) SaveSettings ¶
func (*DataStoreMongo) SaveUserSettings ¶
func (*DataStoreMongo) UpdateLoginTs ¶
func (db *DataStoreMongo) UpdateLoginTs(ctx context.Context, id string) error
func (*DataStoreMongo) UpdateTokenLastUsed ¶
func (*DataStoreMongo) UpdateUser ¶
func (db *DataStoreMongo) UpdateUser( ctx context.Context, id string, u *model.UserUpdate, ) (*model.User, error)
UpdateUser updates the user of a given ID. NOTE: This function supports using ETag matching using UserUpdate, but defaults to wildcard matching
func (*DataStoreMongo) WithAutomigrate ¶
func (db *DataStoreMongo) WithAutomigrate() *DataStoreMongo
WithAutomigrate enables automatic migration and returns a new datastore based on current one
func (*DataStoreMongo) WithMultitenant ¶
func (db *DataStoreMongo) WithMultitenant() *DataStoreMongo
WithMultitenant enables multitenant support and returns a new datastore based on current one
Click to show internal directories.
Click to hide internal directories.