LeetCode auth (LAS / LASS)¶
Codebloom calls LeetCode's API as a logged-in user. The LeetCode session cookies
it needs (LEETCODE_SESSION + csrftoken) are handled by two internal gRPC services:
| Service | Source | Does |
|---|---|---|
| LAS (LeetCode Auth Service, Rust) | internal/leetcode-auth-service |
Owns the credentials. Stores them in Redis, serves them, and decides when to refresh. |
| LASS (LeetCode Auth Stealer Service, Python) | internal/leetcode-auth-stealer-service |
Logs into leetcode.com in a headless browser (Camoufox) and returns the cookies. Stateless. |
Codebloom only talks to LAS; LAS is the only thing that talks to LASS.
Flow¶
flowchart LR
CB["Codebloom backend"] -->|"getToken / refreshToken (gRPC)"| LAS["LAS"]
LAS <-->|"read / write credentials"| R[("Redis")]
LAS -->|"Authenticate (gRPC)"| LASS["LASS"]
LASS -->|"browser login"| LC["leetcode.com"]
CB -->|"API calls with cookies"| LC
- Getting credentials: before each LeetCode request, Codebloom calls LAS
getToken, which returns whatever is stored in Redis. - Refreshing: LAS refreshes in the background by calling LASS
Authenticateand writing the result to Redis. A refresh happens when:- LAS's periodic check finds the stored credentials missing or too old (default 4h), or
- Codebloom calls
refreshToken, e.g. after LeetCode throttles/rejects a request, or an admin hitsPOST /api/admin/leetcode/token.
- Only one refresh runs at a time across all LAS pods (Redis lock); extra triggers are ignored.
- A failed refresh leaves the old credentials in place, so Codebloom keeps using them.
See each service's README.md for config, metrics, and local setup.