feat: secure service connections and login
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user