feat: secure service connections and login

This commit is contained in:
2026-11-06 21:14:49 +03:00
parent cb51354889
commit 48918e8b19
59 changed files with 1980 additions and 316 deletions
+7 -2
View File
@@ -4,6 +4,7 @@ import (
"context"
"crypto/rand"
"crypto/sha256"
"crypto/tls"
"encoding/base64"
"encoding/hex"
"encoding/json"
@@ -14,7 +15,7 @@ import (
"github.com/valkey-io/valkey-go"
"gitea.privcloud.tech/dizi/mtusi2026lab6/internal/model"
"gitea.privcloud.tech/dizi/mtusi2026lab7/internal/model"
)
const (
@@ -40,11 +41,15 @@ type Store struct {
client valkey.Client
}
func New(rawURL string) (*Store, error) {
func New(rawURL string, tlsConfiguration ...*tls.Config) (*Store, error) {
option, err := valkey.ParseURL(rawURL)
if err != nil {
return nil, fmt.Errorf("%w: parse Valkey URL: %w", ErrStore, err)
}
if len(tlsConfiguration) > 0 && tlsConfiguration[0] != nil {
option.TLSConfig = tlsConfiguration[0].Clone()
}
option.DisableCache = true
client, err := valkey.NewClient(option)
if err != nil {