Skip to content

Commit b07646b

Browse files
committed
Add security api page
1 parent d66b951 commit b07646b

2 files changed

Lines changed: 33 additions & 0 deletions

File tree

Writerside/boson.tree

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
<toc-element topic="bindings-api.md" />
4343
<toc-element topic="data-api.md" />
4444
<toc-element topic="web-components-api.md" />
45+
<toc-element topic="security-api.md" />
4546
</toc-element>
4647
<toc-element topic="events.md" />
4748
</toc-element>
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Security API
2+
3+
<show-structure for="chapter" depth="2"/>
4+
5+
This API provides information about
6+
[security context](https://developer.mozilla.org/en-US/docs/Web/Security/Secure_Contexts)
7+
used to access [other APIs](https://developer.mozilla.org/en-US/docs/Web/Security/Secure_Contexts/features_restricted_to_secure_contexts).
8+
9+
The API is available in the `WebView::$security` property.
10+
11+
```php
12+
$app = new Boson\Application();
13+
14+
$app->webview->security; // Access to Security API
15+
```
16+
17+
<note>
18+
Your context will most likely be <b>secure</b> if you don't use the
19+
<code>data:</code> or <code>about:</code> protocol schemes
20+
</note>
21+
22+
## Current Context
23+
<secondary-label ref="read-only"/>
24+
25+
To get the current security status you can use the read-only
26+
`$isSecureContext` property.
27+
28+
```php
29+
$isSecure = $app->webview->security->isSecureContext;
30+
31+
echo 'Context is ' . ($isSecure ? 'secure' : 'insecure');
32+
```

0 commit comments

Comments
 (0)