Skip to content

Commit 88f85c9

Browse files
committed
edits to service worker section
for #19
1 parent e514a8d commit 88f85c9

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

draft-ietf-oauth-browser-based-apps.md

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -377,29 +377,30 @@ Remarks and mitigations:
377377
* The application designer SHOULD consider not having refresh tokens at all to avoid the risk of giving prolonged access to the attacker.
378378

379379
### Tokens Securely Handled by a Service worker
380-
In this scenario, a [Service Worker](https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API) is responsible for obtaining tokens from the authorization server and passing them to the resource API.
380+
In this scenario, a [Service Worker](https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API) is responsible for obtaining tokens from the authorization server and making requests to the resource server.
381381

382-
Service workers are inherently safe from XSS, because the browser APIs allowing to register one take an origin-constrained URL.
383-
They can thus be used as a safe store for tokens.
382+
Service workers are run in a separate context from the DOM, have no access to the DOM, and the DOM has no access to the service worker. This makes service workers inherently safe from XSS, thus they can be used as a safe store for tokens.
384383

385-
In this architecture, a service worker intercepts calls from the frontend to the resource server. As such, it completely isolates calls to the authorization server from XSS attack surface, as all tokens and PKCE secrets are safely kept there without any access from other JavaScript contexts. The service worker is then solely responsible for adding authentication headers to calls to the resource server.
384+
In this architecture, a service worker intercepts calls from the frontend to the resource server. As such, it completely isolates calls to the authorization server from XSS attack surface, as all tokens are safely kept in the service worker context without any access from other JavaScript contexts. The service worker is then solely responsible for adding the token in the authorization header to calls to the resource server.
386385

387386
Resource Authorization
388387
User Application Service Worker server server
389388
| browse | | | |
390389
| ------------>| | | |
391-
| |-------------------> | /authorize |
390+
| |-------------------> | /authorize |
392391
| | -------------------------------------------------------->
393-
| | | redirect + authorization code |
392+
| | | redirect w/ authorization code |
394393
| | < - - - - - - - - - - - - - - - - - - - - - - - - - - - |
395-
| | | auth code |
396-
| | | -------------------> /token |
394+
| | | | |
395+
| | | token request w/ auth code | /token |
397396
| | | ------------------------------------------------------>
398-
| | resource request | <- - - - - - - - - - - - - - - - - - - - - - - - - - -|
397+
| | | <- - - - - - - - - - - - - - - - - - - - - - - - - - -|
398+
| | | | |
399+
| | resource request | | |
399400
| |-------------------> resource request with token | |
400401
| | | ---------------------------->| |
401402
| | | | |
402-
User Application Service Worker Resource Authorization
403+
User Application Service Worker Resource Authorization
403404
server server
404405

405406
#### Security Considerations
@@ -409,6 +410,7 @@ In this architecture, a service worker intercepts calls from the frontend to the
409410
* The service worker MUST not transmit tokens, authorization codes or PKCE secrets (e.g. code verifier) to the frontend application.
410411
* The service worker MUST block /token or /authorize calls initiating from the frontend application in order to avoid any front-end side-channel for getting credentials: the only way of starting the authorization flow is through the service worker. This protects against re-authorization from XSS-injected code.
411412

413+
412414
Authorization Code Flow {#authorization_code_flow}
413415
=======================
414416

0 commit comments

Comments
 (0)