feat(auth): Add login, register, session_info and api creation

This commit is contained in:
Björn Benouarets
2026-01-15 20:25:17 +01:00
commit 13d908420a
31 changed files with 1421 additions and 0 deletions

52
app/cache/redis.go vendored Normal file
View File

@@ -0,0 +1,52 @@
package cache
import (
"context"
"fmt"
"git.secnex.io/secnex/auth-api/config"
"github.com/valkey-io/valkey-go"
)
type RedisConfiguration struct {
Host string
Port string
Password string
}
type RedisCache struct {
Client valkey.Client
Context context.Context
}
var Cache RedisCache
func NewRedisConfiguration(host, port, password string) *RedisConfiguration {
return &RedisConfiguration{
Host: host,
Port: port,
Password: password,
}
}
func NewRedisConfigurationFromConfig(config *config.Config) *RedisConfiguration {
return &RedisConfiguration{
Host: config.RedisHost,
Port: config.RedisPort,
Password: config.RedisPassword,
}
}
func Connect(config *config.Config) error {
client, err := valkey.NewClient(valkey.ClientOption{InitAddress: []string{fmt.Sprintf("%s:%s", config.RedisHost, config.RedisPort)}})
if err != nil {
return err
}
ctx := context.Background()
cache := &RedisCache{
Client: client,
Context: ctx,
}
Cache = *cache
return nil
}