ЛР7 на 4: HTTPS, mTLS, OpenBao AppRole и ротация leaf.
Skeleton contracts / contracts (pull_request) Blocked by required conditions

Smoke/security/grade4/persistence/failover пройдены; REPORT и DEFENSE.
This commit is contained in:
2026-12-02 23:08:27 +03:00
parent 20afc2c790
commit 2f2047909f
182 changed files with 15169 additions and 90 deletions
+41
View File
@@ -0,0 +1,41 @@
package service
import (
"encoding/base64"
"encoding/json"
"errors"
"time"
"github.com/google/uuid"
)
var ErrInvalidCursor = errors.New("invalid cursor")
type Cursor struct {
ChatID uuid.UUID `json:"chat_id"`
CreatedAt time.Time `json:"created_at"`
ID uuid.UUID `json:"id"`
}
func encodeCursor(cursor Cursor) string {
data, _ := json.Marshal(cursor)
return base64.RawURLEncoding.EncodeToString(data)
}
func decodeCursor(raw string, chatID uuid.UUID) (Cursor, error) {
data, err := base64.RawURLEncoding.DecodeString(raw)
if err != nil {
return Cursor{}, ErrInvalidCursor
}
var cursor Cursor
if err := json.Unmarshal(data, &cursor); err != nil {
return Cursor{}, ErrInvalidCursor
}
if cursor.ID == uuid.Nil || cursor.CreatedAt.IsZero() || cursor.ChatID != chatID {
return Cursor{}, ErrInvalidCursor
}
return cursor, nil
}