feat(auth): implement user and device authentication

This commit is contained in:
QiuSW
2026-07-26 15:18:48 +08:00
parent c5d3b215ff
commit 49db5b8305
66 changed files with 6216 additions and 271 deletions
@@ -0,0 +1,20 @@
package usecase
import (
"crypto/rand"
"encoding/base64"
"errors"
"io"
)
const opaqueTokenBytes = 32
type CryptoTokenGenerator struct{}
func (CryptoTokenGenerator) NewToken() (string, error) {
value := make([]byte, opaqueTokenBytes)
if _, err := io.ReadFull(rand.Reader, value); err != nil {
return "", errors.New("generate opaque token")
}
return base64.RawURLEncoding.EncodeToString(value), nil
}