Skip to content

Commit 9db533c

Browse files
hamishwilleewbamberggithub-actions[bot]
authored
FF123 updates for permission publickey-credentials-create (#32135)
* FF123 updates for permission publickey-credentials-create * Add req for transient activation * Apply suggestions from code review * Clarify transient activation in the Permission-Policy docs * Update files/en-us/web/api/web_authentication_api/index.md * Update files/en-us/web/api/web_authentication_api/index.md * CredentialsContainer.create() - webauthn add transient activation req. * Update files/en-us/web/api/credentialscontainer/create/index.md Co-authored-by: wbamberg <[email protected]> * Add link from iframe allow attribute to exmaples * Update files/en-us/web/api/web_authentication_api/index.md * Transient activation only required for create() cross-platform calls * Update files/en-us/web/api/web_authentication_api/index.md Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: wbamberg <[email protected]> --------- Co-authored-by: wbamberg <[email protected]> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
1 parent d9b3aa2 commit 9db533c

File tree

6 files changed

+39
-14
lines changed

6 files changed

+39
-14
lines changed

files/en-us/web/api/credentialscontainer/create/index.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -313,8 +313,11 @@ A {{jsxref("Promise")}} that resolves with an {{domxref("PublicKeyCredential")}}
313313

314314
### Exceptions
315315

316-
- `SecurityError` {{domxref("DOMException")}}
317-
- : Usage was blocked by a {{HTTPHeader("Permissions-Policy/publickey-credentials-create","publickey-credentials-create")}} [Permissions Policy](/en-US/docs/Web/HTTP/Permissions_Policy).
316+
- `NotAllowedError` {{domxref("DOMException")}}
317+
- : Possible causes include:
318+
- Usage was blocked by a {{HTTPHeader("Permissions-Policy/publickey-credentials-create","publickey-credentials-create")}} [Permissions Policy](/en-US/docs/Web/HTTP/Permissions_Policy).
319+
- The function is called cross-origin but the iframe's [`allow`](/en-US/docs/Web/HTML/Element/iframe#allow) attribute does not set an appropriate {{HTTPHeader("Permissions-Policy/publickey-credentials-create","publickey-credentials-create")}} policy.
320+
- The function is called cross-origin and the `<iframe>` does not have {{glossary("transient activation")}}.
318321

319322
## Examples
320323

files/en-us/web/api/credentialscontainer/get/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ A {{jsxref("Promise")}} that resolves with an {{domxref("PublicKeyCredential")}}
336336

337337
### Exceptions
338338

339-
- `SecurityError` {{domxref("DOMException")}}
339+
- `NotAllowedError` {{domxref("DOMException")}}
340340
- : Usage was blocked by a {{HTTPHeader("Permissions-Policy/publickey-credentials-get","publickey-credentials-get")}} [Permissions Policy](/en-US/docs/Web/HTTP/Permissions_Policy).
341341

342342
### Examples

files/en-us/web/api/web_authentication_api/index.md

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,12 @@ The availability of WebAuthn can be controlled using a [Permissions Policy](/en-
121121
- {{httpheader("Permissions-Policy/publickey-credentials-create", "publickey-credentials-create")}}: Controls the availability of {{domxref("CredentialsContainer.create", "navigator.credentials.create()")}} with the `publicKey` option.
122122
- {{httpheader("Permissions-Policy/publickey-credentials-get", "publickey-credentials-get")}}: Controls the availability of {{domxref("CredentialsContainer.get", "navigator.credentials.get()")}} with the `publicKey` option.
123123

124-
Both directives have a default allowlist value of `"self"`, meaning that by default these methods can be used in top-level document contexts. In addition, `get()` can be used in nested browsing contexts loaded from the same origin as the top-most document; `create()` on the other hand cannot be used in {{htmlelement("iframe")}}s.
124+
Both directives have a default allowlist value of `"self"`, meaning that by default these methods can be used in top-level document contexts.
125+
In addition, `get()` can be used in nested browsing contexts loaded from the same origin as the top-most document.
126+
`get()` and `create()` can be used in nested browsing contexts loaded from the different origins to the top-most document (i.e. in cross-origin `<iframes>`), if allowed by the [`publickey-credentials-get`](/en-US/docs/Web/HTTP/Headers/Permissions-Policy/publickey-credentials-get) and [`publickey-credentials-create`](/en-US/docs/Web/HTTP/Headers/Permissions-Policy/publickey-credentials-create) `Permission-Policy` directives, respectively.
127+
For cross-origin `create()` calls, where the permission was granted by [`allow=` on an iframe](/en-US/docs/Web/HTTP/Headers/Permissions-Policy#iframes), the frame must also have {{glossary("Transient activation")}}.
125128

126-
> **Note:** Where a policy forbids use of these methods, the {{jsxref("Promise", "promises")}} returned by them will reject with a `SecurityError` {{domxref("DOMException")}}.
129+
> **Note:** Where a policy forbids use of these methods, the {{jsxref("Promise", "promises", "", "nocode")}} returned by them will reject with a `NotAllowedError` {{domxref("DOMException")}}.
127130
128131
### Basic access control
129132

@@ -134,28 +137,44 @@ Permissions-Policy: publickey-credentials-get=("https://subdomain.example.com")
134137
Permissions-Policy: publickey-credentials-create=("https://subdomain.example.com")
135138
```
136139

137-
### Allowing embedded `get()` calls in an `<iframe>`
140+
### Allowing embedded `create` and `get()` calls in an `<iframe>`
138141

139-
If you wish to authenticate with `get()` in an `<iframe>`, there are a couple of steps to follow:
142+
If you wish to authenticate with `get()` or `create()` in an `<iframe>`, there are a couple of steps to follow:
140143

141144
1. The site embedding the relying party site must provide permission via an `allow` attribute:
142145

143-
```html
144-
<iframe
145-
src="https://auth.provider.com"
146-
allow="publickey-credentials-get *" />
147-
```
146+
- If using `get()`:
147+
148+
```html
149+
<iframe
150+
src="https://auth.provider.com"
151+
allow="publickey-credentials-get *">
152+
</iframe>
153+
```
154+
155+
- If using `create()`:
156+
157+
```html
158+
<iframe
159+
src="https://auth.provider.com"
160+
allow="publickey-credentials-create 'self' https://a.auth.provider.com https://b.auth.provider.com">
161+
</iframe>
162+
```
163+
164+
The `<iframe>` must also have {{glossary("Transient activation")}} if `create()` is called cross-origin.
148165

149166
2. The relying party site must provide permission for the above access via a `Permissions-Policy` header:
150167

151168
```http
152169
Permissions-Policy: publickey-credentials-get=*
170+
Permissions-Policy: publickey-credentials-create=*
153171
```
154172

155173
Or to allow only a specific URL to embed the relying party site in an `<iframe>`:
156174

157175
```http
158176
Permissions-Policy: publickey-credentials-get=("https://subdomain.example.com")
177+
Permissions-Policy: publickey-credentials-create=("https://*.auth.provider.com")
159178
```
160179

161180
## Interfaces

files/en-us/web/html/element/iframe/index.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ This element includes the [global attributes](/en-US/docs/Web/HTML/Global_attrib
2323

2424
- : Specifies a [Permissions Policy](/en-US/docs/Web/HTTP/Permissions_Policy) for the `<iframe>`. The policy defines what features are available to the `<iframe>` (for example, access to the microphone, camera, battery, web-share, etc.) based on the origin of the request.
2525

26+
See [iframes](/en-US/docs/Web/HTTP/Headers/Permissions-Policy#iframes) in the `Permissions-Policy` topic for examples.
27+
2628
> **Note:** A Permissions Policy specified by the `allow` attribute implements a further restriction on top of the policy specified in the {{httpheader("Permissions-Policy")}} header. It doesn't replace it.
2729
2830
- `allowfullscreen`

files/en-us/web/http/headers/permissions-policy/publickey-credentials-create/index.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ browser-compat: http.headers.Permissions-Policy.publickey-credentials-create
1111

1212
The HTTP {{HTTPHeader("Permissions-Policy")}} header `publickey-credentials-create` directive controls whether the current document is allowed to use the [Web Authentication API](/en-US/docs/Web/API/Web_Authentication_API) to create new WebAuthn credentials, i.e., via {{domxref("CredentialsContainer.create","navigator.credentials.create({publicKey})")}}.
1313

14-
Specifically, where a defined policy blocks use of this feature, the {{jsxref("Promise")}} returned by `navigator.credentials.create({publicKey})` will reject with a `SecurityError` {{domxref("DOMException")}}.
14+
Specifically, where a defined policy blocks use of this feature, the {{jsxref("Promise")}} returned by `navigator.credentials.create({publicKey})` will reject with a `NotAllowedError` {{domxref("DOMException")}}.
15+
If the method is called cross-origin. the {{jsxref("Promise")}} will also reject with a `NotAllowedError` if the feature is granted by [`allow=` on an iframe](/en-US/docs/Web/HTTP/Headers/Permissions-Policy#iframes) and the frame does not also have {{glossary("Transient activation")}}.
1516

1617
## Syntax
1718

files/en-us/web/http/headers/permissions-policy/publickey-credentials-get/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ browser-compat: http.headers.Permissions-Policy.publickey-credentials-get
99

1010
The HTTP {{HTTPHeader("Permissions-Policy")}} header `publickey-credentials-get` directive controls whether the current document is allowed to access the [Web Authentication API](/en-US/docs/Web/API/Web_Authentication_API) to retrieve public-key credentials, i.e., via {{domxref("CredentialsContainer.get","navigator.credentials.get({publicKey})")}}.
1111

12-
Specifically, where a defined policy blocks the use of this feature, the {{jsxref("Promise")}} returned by `navigator.credentials.get({publicKey})` will reject with a `SecurityError` {{domxref("DOMException")}}.
12+
Specifically, where a defined policy blocks the use of this feature, the {{jsxref("Promise")}} returned by `navigator.credentials.get({publicKey})` will reject with a `NotAllowedError` {{domxref("DOMException")}}.
1313

1414
## Syntax
1515

0 commit comments

Comments
 (0)