Documentation
¶
Index ¶
- Variables
- func CreateAuthToken(user *User) (string, error)
- func CreateUser(user User) error
- func DeleteDataFromUser(name string, key string) error
- func DeleteUser(name string) error
- func GetAllDataFromUser(name string) ([]byte, error)
- func GetDataCountForUser(name, includedKey string) int64
- func GetDataFromUser(name string, key string) ([]byte, error)
- func InitializeUsers()
- func IsTokenBlacklisted(jti string) (bool, error)
- func ResetDatabase()
- func SetDataForUser(name string, key string, data []byte) error
- func StoreInvalidatedToken(jti string, expiration time.Duration) error
- func UpdateUser(name string, user PartialUser) error
- type AppConfig
- type JWTClaim
- type PartialUser
- type PublicUser
- type User
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrUserAlreadyExists = errors.New("a user with this name already exists") ErrUserNotFound = errors.New("user not found") )
View Source
var Config = func() AppConfig { config := AppConfig{ DbPath: resolvePath(os.Getenv("GENESIS_DB_PATH")), BaseUrl: os.Getenv("GENESIS_BASE_URL"), JWTSecret: []byte(os.Getenv("GENESIS_JWT_SECRET")), JWTExpiration: time.Duration(parseInt(os.Getenv("GENESIS_JWT_TOKEN_EXPIRATION"))) * time.Minute, JWTCookieAllowHTTP: os.Getenv("GENESIS_JWT_COOKIE_ALLOW_HTTP") == "true", AppBuildVersion: os.Getenv("GENESIS_BUILD_VERSION"), AppBuildDate: os.Getenv("GENESIS_BUILD_DATE"), AppBuildCommit: os.Getenv("GENESIS_BUILD_COMMIT"), AppGinMode: os.Getenv("GENESIS_GIN_MODE"), AppPort: os.Getenv("GENESIS_PORT"), AppUsersToCreate: parseInitialUserList(os.Getenv("GENESIS_CREATE_USERS")), AppUserPattern: regexp.MustCompile(os.Getenv("GENESIS_USERNAME_PATTERN")), AppKeyPattern: regexp.MustCompile(os.Getenv("GENESIS_KEY_PATTERN")), AppDataMaxSize: parseInt(os.Getenv("GENESIS_DATA_MAX_SIZE")) * 1000, AppKeysPerUser: parseInt(os.Getenv("GENESIS_KEYS_PER_USER")), } Logger.Debug("build info", zap.String("version", config.AppBuildVersion), zap.String("date", config.AppBuildDate), zap.String("commit", config.AppBuildCommit), ) return config }()
View Source
var Logger = func() *zap.Logger { _, filename, _, _ := runtime.Caller(0) var root = path.Join(path.Dir(filename), "..") envFile := path.Join(root, ".env") if testing.Testing() { envFile = path.Join(root, ".env.test") } envSkipped := godotenv.Load(envFile) var cfg zap.Config if os.Getenv("GENESIS_LOG_MODE") == "production" { cfg = zap.NewProductionConfig() } else { cfg = zap.NewDevelopmentConfig() } logger, err := cfg.Build(zap.AddCallerSkip(1)) if err != nil { log.Fatal(err) } if envSkipped != nil { logger.Debug(".env file skipped") } return logger }()
Functions ¶
func CreateAuthToken ¶
func CreateUser ¶
func DeleteDataFromUser ¶
func DeleteUser ¶
func GetAllDataFromUser ¶
func GetDataCountForUser ¶
func InitializeUsers ¶ added in v1.4.0
func InitializeUsers()
func IsTokenBlacklisted ¶
func ResetDatabase ¶
func ResetDatabase()
func UpdateUser ¶
func UpdateUser(name string, user PartialUser) error
Types ¶
type AppConfig ¶
type AppConfig struct {
DbPath string
BaseUrl string
JWTSecret []byte
JWTExpiration time.Duration
JWTCookieAllowHTTP bool
AppBuildVersion string
AppBuildDate string
AppBuildCommit string
AppGinMode string
AppPort string
AppUsersToCreate []User
AppUserPattern *regexp.Regexp
AppKeyPattern *regexp.Regexp
AppDataMaxSize int64
AppKeysPerUser int64
}
type JWTClaim ¶
type JWTClaim struct {
User string `json:"user"`
jwt.RegisteredClaims
}
func ParseAuthToken ¶
type PartialUser ¶
type PublicUser ¶
func GetAllUsers ¶ added in v1.3.0
func GetAllUsers() ([]*PublicUser, error)
func GetUsers ¶
func GetUsers(skip string) ([]*PublicUser, error)
Click to show internal directories.
Click to hide internal directories.