···5555 return jwt.ErrTokenSignatureInvalid
5656 }
57575858- // NOTE: important to use using "lenient" variant here
5858+ // NOTE: important to use using "lenient" variant here. atproto cryptography is strict about details like low-S elliptic curve signatures, but OAuth cryptography is not, and we want to be interoperable with general purpose OAuth implementations
5959 return pub.HashAndVerifyLenient([]byte(signingString), sig)
6060}
6161
···8899// Interface for persisting session data and auth request data, required as part of an OAuth client app.
1010//
1111+// Note that this interface assumes that there is only a single session per account (by DID).
1212+//
1113// Implementations should allow for concurrent access.
1214type ClientAuthStore interface {
1315 GetSession(ctx context.Context, did syntax.DID) (*ClientSessionData, error)
+1-2
atproto/auth/oauth/util.go
···11package oauth
2233import (
44+ "crypto/rand"
45 "crypto/sha256"
56 "encoding/base64"
66- "math/rand"
77)
8899// this generates pseudo-unique nonces to prevent token (JWT) replay. these do not need to be cryptographically resilient
1010func randomNonce() string {
1111- // TODO: make this longer?
1211 buf := make([]byte, 16)
1312 rand.Read(buf)
1413 return base64.RawURLEncoding.EncodeToString(buf)