Skip to content

Commit 8b9bf4f

Browse files
committed
tweaks to scenario 12,13
1 parent 7b85099 commit 8b9bf4f

File tree

3 files changed

+23
-15
lines changed

3 files changed

+23
-15
lines changed
53.5 KB
Loading
132 KB
Loading

articles/frontdoor/rules-engine-scenarios.md

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -636,7 +636,7 @@ However, you can emulate "if-elseif-else" logic by using the **Stop evaluating r
636636

637637
You can remove query strings from incoming URLs by implementing a 3xx URL redirect that guides users back to the Azure Front Door endpoint with the query strings removed.
638638

639-
[!NOTE]
639+
> [!NOTE]
640640
> Users will notice the change of the request URL with this operation.
641641
642642
The following example demonstrates how to remove the entire query string from incoming URLs. If you need to strip part of it, you can adjust the offset/length as desired. For more information, see [Server variable format](/azure/frontdoor/rule-set-server-variables#server-variable-format).
@@ -684,15 +684,24 @@ The following example demonstrates how to remove the entire query string from in
684684
}
685685
```
686686

687-
### Scenario 12: Append SAS token in query string to authenticate AFD to Azure Storage
687+
### Scenario 12: Append SAS token in query string to authenticate Azure Front Door to Azure Storage
688+
689+
You can protect files in your storage account by changing the access to your storage containers from public to private and using Shared Access Signatures (SAS) to grant restricted access rights to your Azure Storage resources from Azure Front Door without exposing your account key. You can also accomplish this using Managed Identity. For more information, see [Use managed identities to authenticate to origins](/azure/frontdoor/origin-authentication-with-managed-identities).
690+
691+
**How SAS token injection works:** Capture the incoming URL path and append the SAS token to the query string using redirect or rewrite rules. Since URL rewrite only acts on the path, use redirect rules when you need to modify query strings.
692+
693+
For example, if you want to append a SAS token to the incoming URL: `https://www.contoso.com/dccp/grammars/0.1.0-59/en-US/grammars/IVR/ssn0100_CollectTIN_QA_dtmf.grxml?version=1.0_1719342835399`, the rewrite URL will be: `https://www.contoso.com/grammars/0.1.0-59/en-US/grammars/IVR/ssn0100_CollectTIN_QA_dtmf.grxml?version=1.0_1719342835399&<SASTOKEN>`
688694

689-
To protect the files in your storage account, you can set the access of your storage containers from public to private and use the Shared Access Signature (SAS) to grant restricted access rights to your Azure Storage resources from Azure Front Door without exposing your account key. You can also accomplish this using Managed Identity, which is currently in preview on AFD. Or you can inject a SAS token into the route of the call to storage. This can be achieved by capturing an incoming URL path and appending the SAS token to the query string in the rewrite or redirect rule.
690-
Here is an example of appending SAS token on AFD.
691-
• Incoming URL: https://www.contoso.com/dccp/grammars/0.1.0-59/en-US/grammars/IVR/ssn0100_CollectTIN_QA_dtmf.grxml?version=1.0_1719342835399
692-
• Rewrite URL: https://www.contoso.com/grammars/0.1.0-59/en-US/grammars/IVR/ssn0100_CollectTIN_QA_dtmf.grxml?version=1.0_1719342835399&<SASTOKEN>
693-
In this case, the incoming URL already has query string, and you want the keep the query string while appending the SAS token, please use redirect rule as URL rewrite only acts on path. To achieve this, you can configure URL redirect using /url_path:seg1:20}?{query_string}&sp=racwl&<SASToken>. Please make proper updates to Routes to make sure the routes for /grammars/* are properly configured after redirect.
694-
Example in portal
695-
Please replace the SAS token with the proper token. In this case, the SAS token starts with sp=rl, and you want to redirect all requests to apply this rule which doesn’t contain the sp=rl.
695+
In this example, the incoming URL already has query parameters, and you want to preserve the existing query string while appending the SAS token by configuring URL redirect using `/{url_path:seg1:20}?{query_string}&sp=racwl&<SASToken>`.
696+
697+
The rule configuration redirects all HTTPS requests that don't already contain the SAS token (identified by the absence of `sp=rl` in the query string).
698+
699+
:::image type="content" source="./media/rules-engine-scenarios/append-sas-token.png" alt-text="Screenshot that shows how to append SAS token in query string." lightbox="./media/rules-engine-scenarios/append-sas-token.png":::
700+
701+
> [!IMPORTANT]
702+
> - Update your route configuration to ensure routes for `/grammars/*` are properly configured after the redirect
703+
>
704+
> - Replace the SAS token with the proper token. In the example, the SAS token starts with `sp=rl`, and you want to redirect all requests to apply this rule which doesn’t contain the `sp=rl`
696705
697706
```json
698707
{
@@ -750,8 +759,11 @@ Please replace the SAS token with the proper token. In this case, the SAS token
750759

751760
### Scenario 13: Add security headers with rules engine
752761

753-
When you want to add security headers to prevent browser-based vulnerabilities, such as HTTP Strict-Transport-Security (HSTS), X-XSS-Protection, Content-Security-Policy, and X-Frame-Options, you can use AFD rules engine to achieve it.
754-
Here is an example that shows how to add a Content-Security-Policy header to all incoming requests that match the path defined in the route associated with your rules engine configuration. In this scenario, only scripts from the trusted site https://apiphany.portal.azure-api.net are allowed to run on the application. Use script-src 'self' https://apiphany.portal.azure-api.net as the header value.
762+
You can use the Azure Front Door rules engine to add security headers that help prevent browser-based vulnerabilities, such as HTTP Strict-Transport-Security (HSTS), X-XSS-Protection, Content-Security-Policy, and X-Frame-Options.
763+
764+
For example, you can add a *Content-Security-Policy* header to all incoming requests that match the path defined in the route associated with your rules engine configuration. In this configuration, use `script-src 'self' https://apiphany.portal.azure-api.net`as the header value to only allow scripts from the trusted site `https://apiphany.portal.azure-api.net` to run on the application.
765+
766+
:::image type="content" source="./media/rules-engine-scenarios/add-security-headers.png" alt-text="Screenshot that shows how to add security headers with rules engine." lightbox="./media/rules-engine-scenarios/add-security-headers.png":::
755767

756768
```json
757769
{
@@ -780,7 +792,3 @@ Here is an example that shows how to add a Content-Security-Policy header to all
780792
}
781793
}
782794
```
783-
784-
785-
786-

0 commit comments

Comments
 (0)