Box 1: No
Unauthenticated users are challenged to authenticate with Azure Active Directory.
Note:
401
Unauthorized
Request to restricted pages while unauthenticated.
Note: Restricting access to entire application
It's common to require authentication for every route in an application. To enable this, add a rule that matches all routes and include the built-in authenticated role in the allowedRoles array.
The following example configuration blocks anonymous access and redirects all unauthenticated users to the Azure Active Directory login page.
{
"routes": [
{
"route": "/*",
"allowedRoles": ["authenticated"]
}
],
"responseOverrides": {
"401": {
"statusCode": 302,
"redirect": "/.auth/login/aad"
}
}
}
Box 2: No
It depends on the file extension of the file. 404 response codes is only generated for png, jpg and gif files.
Note: Fallback routes
Single Page Applications often rely on client-side routing. These client-side routing rules update the browser's window location without making requests back to the server. If you refresh the page, or navigate directly to URLs generated by client-side routing rules, a server-side fallback route is required to serve the appropriate HTML page (which is generally the index.html for your client-side app).
You can define a fallback rule by adding a navigationFallback section. The following example returns / index.html for all static file requests that do not match a deployed file.
{
"navigationFallback": {
"rewrite": "/index.html"
}
}
You can control which requests return the fallback file by defining a filter. In the following example, requests for certain routes in the /images folder and all files in the /css folder are excluded from returning the fallback file.
{
"navigationFallback": {
"rewrite": "/index.html",
"exclude": ["/images/*.{png,jpg,gif}", "/css/*"]
}
}
The example file structure below, the following outcomes are possible with this rule.
Requests to...
/images/unknown.png
Return File not found error
With status: 404
/images/icon.svg
Returns the /index.html file - since the svg file extension is not listed in the /images/*.{png,jpg,gif} filter
With status: 200
Box 3: Yes
Only the route and methods (if specified) properties are used to determine whether a rule matches a request.
Routes are secured by adding one or more role names into a rule's allowedRoles array.
For instance, to restrict a route to only authenticated users, add the built-in authenticated role to the allowedRoles array.
{
"route": "/profile*",
"allowedRoles": ["authenticated"]
}
Box 4: No
Unauthenticated users are challanged to authenticate with Azure Active Directory.
See box 1 above.
References:
https://learn.microsoft.com/en-us/azure/static-web-apps/configuration