Exercise - Verify that unauthenticated requests are denied
In this exercise, you inspect the controls that govern hosting and anonymous access without enabling anonymous access. You then confirm that a request without a session is denied.
Inspect the controls
- Open
rayfin/rayfin.ymland findservices.staticHosting.assetAccess. Note whether it'sprotectedorpublic. The Universal App template setsprotected. - Search your data package for
@anonymousor@role('anonymous'). Confirm that no entity grants anonymous access. The entities in this module use@authenticated()only. - Decide who can change the tenant control. The Enable anonymous data access for Fabric Apps (Preview) setting belongs to a Fabric tenant administrator, and it's off by default. Don't ask for it to be enabled for this exercise.
Send a request without a session
Add this function inside
PermissionLab, next torun, and a second button that calls it.async function unauthenticatedCheck() { await client.auth.signOut(); await attempt('Read without a session', () => client.data.LabIssueReport.select(['id', 'title']).execute()); }<button onClick={unauthenticatedCheck}>Run signed-out check</button>Run the app, sign in, and then select Run signed-out check. If the template's sign-in gate hides
PermissionLabafter sign-out, read the result in the browser console, becauseattemptalso writes each line there.Confirm that the call is rejected, or at minimum that it returns no rows. Open the Network tab, find the request, and note its status code and message.
Sign in again, run Run permission check, and confirm that your own record is visible again.
The call reached the data API through the same client, with no session. The server refused it, regardless of what your UI would have shown.