-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: default enable allowDynamicBackends with better unsupported err…
…ors (#995)
- Loading branch information
1 parent
c5986c2
commit bb858fe
Showing
20 changed files
with
368 additions
and
167 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
--- | ||
hide_title: false | ||
hide_table_of_contents: false | ||
pagination_next: null | ||
pagination_prev: null | ||
--- | ||
import {Fiddle} from '@site/src/components/fiddle'; | ||
|
||
# name | ||
|
||
The read-only **`name`** property of the backend returns the backend name string. | ||
|
||
## Value | ||
|
||
A `string`. | ||
|
||
## Description | ||
|
||
Provides the name of the backend. | ||
|
||
## Examples | ||
|
||
### Using name | ||
|
||
The following example logs the string value of a [Backend](../Backend.mdx) object: | ||
|
||
<Fiddle config={{ | ||
"type": "javascript", | ||
"title": "Backend.prototype.name Example", | ||
"origins": [ | ||
"https://http-me.glitch.me" | ||
], | ||
"src": { | ||
"deps": "{\n \"@fastly/js-compute\": \"^1.0.1\"\n}", | ||
"main": ` | ||
/// <reference types=\"@fastly/js-compute\" /> | ||
import { Backend } from "fastly:backend"; | ||
async function app() { | ||
const backend = new Backend({ | ||
name: "fastly", | ||
target: "fastly.com", | ||
}); | ||
console.log(backend.name); // "fastly" | ||
} | ||
addEventListener("fetch", event => event.respondWith(app(event))); | ||
` | ||
}, | ||
"requests": [ | ||
{ | ||
"enableCluster": true, | ||
"enableShield": false, | ||
"enableWAF": false, | ||
"method": "GET", | ||
"path": "/status=200", | ||
"useFreshCache": false, | ||
"followRedirects": false, | ||
"tests": "", | ||
"delay": 0 | ||
} | ||
], | ||
"srcVersion": 1 | ||
}}> | ||
|
||
```js | ||
import { Backend } from "fastly:backend"; | ||
async function app() { | ||
const backend = new Backend({ | ||
name: "fastly", | ||
target: "fastly.com", | ||
}); | ||
console.log(backend.name); // "fastly" | ||
} | ||
addEventListener("fetch", event => event.respondWith(app(event))); | ||
``` | ||
|
||
</Fiddle> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
--- | ||
hide_title: false | ||
hide_table_of_contents: false | ||
pagination_next: null | ||
pagination_prev: null | ||
--- | ||
import {Fiddle} from '@site/src/components/fiddle'; | ||
|
||
# allowDynamicBackends | ||
|
||
:::info | ||
|
||
This method is deprecated, and dynamic backends are now always supported when enabled at the service level. See [`enforceExplicitBackends`](./enforceExplicitBackends.mdx) instead. | ||
|
||
::: | ||
|
||
The **`allowDynamicBackends()`** function is used to control whether or not Dynamic Backends should be allowed within this Fastly Compute Service. | ||
|
||
By default, Dynamic Backends are enabled, but can be a potential security concern since third-party JavaScript code may send arbitrary requests, potentially including sensitive/secret data, off to destinations that the JavaScript project was not intending. | ||
|
||
Using `allowDynamicBackends(false)` this security property can be restored to only use explicit backend definitions. | ||
|
||
>**Note**: By default, while dynamic backends are allowed in the SDK, they are by default disabled at the Fastly service level. | ||
## Syntax | ||
|
||
```js | ||
allowDynamicBackends(enabledOrConfig) | ||
``` | ||
|
||
### Parameters | ||
|
||
- `enabled` _: boolean_ | ||
- Whether or not to allow Dynamic Backends | ||
|
||
### Return value | ||
|
||
`undefined`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
--- | ||
hide_title: false | ||
hide_table_of_contents: false | ||
pagination_next: null | ||
pagination_prev: null | ||
--- | ||
|
||
# enforceExplicitBackends | ||
|
||
Call this function to enforce the security property of explicitly-defined backends, even when dynamic backends are enabled at | ||
the Fastly service level. | ||
|
||
By default, if dynamic backends are supported for the Fastly service, they will be automatically used when creating a new | ||
`fetch()` request. This default behaviour for dynamic backends can be a potential security concern since third-party JavaScript | ||
code may send arbitrary requests, including sensitive/secret data, off to destinations that the JavaScript project was not | ||
intending. | ||
|
||
When calling this function, an optional default backend name can be provided. | ||
|
||
>**Note**: This is a separate option to the service-level dynamic backend support for Fastly services, which is by deault disabled for Fastly services. | ||
The **`enforceExplicitBackends()`** function is used to control whether or not Dynamic Backends should be allowed within this Fastly Compute Service. | ||
|
||
By default, Dynamic Backends are enabled, but can be a potential security concern since third-party JavaScript code may send arbitrary requests, potentially including sensitive/secret data, off to destinations that the JavaScript project was not intending. | ||
|
||
Using `allowDynamicBackends(false)` this security property can be restored to only use explicit backend definitions. | ||
|
||
>**Note**: Dynamic Backends are disabled by default for Fastly Services. Please contact [Fastly Support](https://support.fastly.com/hc/requests/new?ticket_form_id=360000269711) to request the feature be enabled or disabled on Fastly Services. | ||
## Syntax | ||
|
||
```js | ||
enforceExplicitBackends(defaultBackend?) | ||
``` | ||
### Parameters | ||
- `defaultBackend` _: string_ _**optional**_ | ||
- An optional default backend string name to use in `fetch()` requests. | ||
### Return value | ||
`undefined`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.