Provide a method to fetch an OAuth token and its key in a single operation
Categories
(Firefox :: Firefox Accounts, enhancement)
Tracking
()
| Tracking | Status | |
|---|---|---|
| firefox78 | --- | fixed |
People
(Reporter: rfkelly, Assigned: vladikoff)
References
Details
(Whiteboard: SACI)
Attachments
(1 file)
Over in Bug 1631830, we're refactoring the Sync client code to use OAuth tokens rather than BrowserID assertions. The code there needs to obtain an OAuth access with with "oldsync" scope as well as the FxA scoped key for the same scope, and it currently has to jump through a few awkward API hoops in order to do so.
By contrast, our FxA rust component and its bindings offer a nice getAccessToken method call that can return the OAuth token and its corresponding key in a single operation. I think the code from Bug 1631830 would be both cleaner and more performant if we added a similar method to the desktop codebase.
My strawman proposal would be to exactly mirror the API offered by the rust component:
fxa.getAccessToken(scope, ttl) => {
scope, // the scope you requested
token, // the access token for including in `Authorization` header
key, // the corresponding JWK for that scope, if any
expiresAt, // how long the token is good for, in seconds
}
Under the hood, this API would need to call fxa.keys.getScopedKeys in order to obtain the JWK for the requested scope, and would probably need to do a bit of caching in order to avoid hitting the network for /account/scoped-key-data on every call. But we should be able to hide that complexity from API consumers.
| Assignee | ||
Comment 1•5 years ago
|
||
Thank you for filing this follow up bug!
| Reporter | ||
Comment 2•5 years ago
|
||
Sketch of what I think we should do here:
- Add a new field to
signedInUser.jsonnamed, say,"scopedKeyData". Use it for caching the result of calling/account/scoped-key-datawith the"oldsync"scope and our ownclient_id. - Add the new
getAccessTokenor equivalent bikeshedded method, so that it:- Have it share the same cache as the exising
getOAuthTokenmethod - If called with the
"oldsync"scope, have it fetch (or populate) the"scopedKeyData"field from storage, and synthesize the appropriate scoped-key JWK.
- Have it share the same cache as the exising
| Assignee | ||
Updated•5 years ago
|
| Assignee | ||
Updated•5 years ago
|
| Assignee | ||
Comment 3•5 years ago
|
||
| Assignee | ||
Comment 4•5 years ago
|
||
| Assignee | ||
Comment 5•5 years ago
|
||
Comment 7•5 years ago
|
||
| bugherder | ||
Description
•