bobbai00 opened a new issue, #9486:
URL: https://github.com/apache/texera/issues/9486

   ### Task Summary
   
   Every service checks the same session token, but not with the same code. 
Five Dropwizard 4 services register the shared filter from `common/auth`, 
notebook-migration-service registers its own copy (#5982), the Dashboard 
Service and the computing unit use another filter on Dropwizard 1.3 (#5428), 
and the agent service decodes the token without checking its signature until 
#9043 lands. All of them rely on one HS256 secret, which both signs and 
verifies, so every service that checks a token could also issue one. As the 
agent service, and later an MCP endpoint, start checking tokens too, the rules 
should be written once, and signing should stay with the issuer.
   
   This task makes token verification one set of rules, implemented once per 
language and used everywhere a request arrives.
   
   #### Before
   
   ```mermaid
   flowchart LR
     req["A request<br/>with a session token"]
     v1["Five Dropwizard 4 services<br/>shared filter in common/auth"]
     v2["Notebook migration service<br/>its own copy of the filter"]
     v3["Dashboard Service, computing unit<br/>another filter, Dropwizard 1.3"]
     v4["Agent service<br/>decodes, no signature check"]
     req --> v1
     req --> v2
     req --> v3
     req --> v4
   ```
   
   #### After
   
   With the key pair of discussion point 1:
   
   ```mermaid
   flowchart TB
     iss["Issuer<br/>signs with the private key"]
     cl["Browser, agent, MCP client"]
     jvm["Every JVM service<br/>one filter in common/auth"]
     ts["Agent service, MCP endpoint<br/>one TypeScript module, same rules"]
     iss -- "token" --> cl
     cl -- "bearer token" --> jvm
     cl -- "bearer token" --> ts
     iss -. "public key" .-> jvm
     iss -. "public key" .-> ts
   ```
   
   #### Scope
   
   1. **One verifier on the JVM.** Every Dropwizard service registers the 
filter in `common/auth`. This finishes #5428, after the Dropwizard 4 upgrade in 
#5423, and #5982.
   2. **The same rules in TypeScript.** The agent service, and later the MCP 
endpoint, check tokens with one module that applies the same algorithm, claims, 
expiry and clock skew as the JVM filter. #9043 adds the first check.
   3. **One scheme in the contract.** The bearer scheme is declared once in the 
contract of #9485, so every generated client sends the token the same way.
   4. **A key pair, if agreed.** The issuer signs with a private key, and every 
verifier checks with the public key.
   
   This task does not decide who may do what, which is #9488. It adds no 
identity provider or sign-in method (#7513), and the agent's own access rules 
stay in #5268 and #5561.
   
   #### Discussion Points
   
   1. **A key pair now or later.** RS256 or ES256 now, with a window in which 
both old and new tokens are accepted so that no one is signed out; or HS256 
until an identity provider is discussed. An identity provider would need the 
same verifiers, so the key pair is not wasted work.
   2. **How verifiers get the public key.** A JWKS endpoint on the issuer, 
which allows keys to be rotated, or the key in each service's configuration.
   3. **Which places sign.** Four places sign tokens today: the Dashboard 
Service at sign-in, the Computing Unit Managing Service for a unit, the Access 
Control Service for a mount, and the computing unit when it exports a result to 
a dataset. Each either keeps the private key or asks the issuer for a token.
   
   Done when every service verifies tokens through the shared code, the agent 
service rejects a token with a bad signature, and, if a key pair is agreed, 
only the issuer holds the signing key.
   
   ### Task Type
   
   - [x] Refactor / Cleanup
   - [ ] DevOps / Deployment / CI
   - [ ] Testing / QA
   - [ ] Documentation
   - [ ] Performance
   - [ ] Other
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to