refactor(auth): shared JWT, DPoP and base64url primitives #118
Labels
No labels
breaking-change
bug
documentation
duplicate
enhancement
good first issue
help wanted
performance
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Grandiras/ATProto.NET#118
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Part of the v0.7.0 update cycle (wave 2). Base64url, JWT and DPoP code is written independently in core and Server, and the client and server DPoP copies have drifted. This issue gives each of them one internal implementation.
Scope
InternalsVisibleTo ATProtoNet.Serveron the core project, so Server stops re-rolling primitives.System.Buffers.Text.Base64Url(in-box) everywhere, replacing 6 encoders and 5 decoders. Delete the internalBase64Urlclass inPlcOperationBuilder, which shadows the BCL type.Jwt.Sign(header, payload, AtProtoKey)andJwt.TryDecode, plus aGetStringOrNullJSON helper, replacing 3 signers and 4 parsers (DPoPProofGenerator,ServiceAuthGenerator,SpaceTokens, the serverDPoPProof,ISpaceServiceAuthVerifier). Use onejtischeme. Each caller keeps its own exception wrapping and rationale comments.NormalizeHtu,AccessTokenHash, the RFC 7638Thumbprint,TokenType) shared by client and server. Today the client keepsuser:pw@inhtuwhile the server strips it, and there are two separate thumbprint implementations.DPoPProofGeneratorwrapsAtProtoKey, which fixes a stored K-256 key silently producing proofs labelledES256. Use a typed JWK and compute the thumbprint once.athper access token, write the payload withUtf8JsonWriter, and sign into a stack buffer. Measured 18.6 → 15.0 µs and 11.2 → 2.1 KB per proof. Apply the same pattern toServiceAuthGeneratorandSpaceTokens.Create.SpaceTokens.Verify(SpaceToken parsed, …).ReadBoundedAsync) replacesLengthLimitedStreamand the OAuth discovery copy. Add size-cap tests first; nothing tests the caps today.Characterization tests (add first)
DPoPProofValidator, with a bound thumbprint and access token.SpaceTokensand the service-auth verifier.No intended public behaviour change; CHANGELOG
Changed(allocation) andFixed(curve label,htudrift).