docs.rodeo

MDN Web Docs mirror

WebXR permissions and security

{{DefaultAPISidebar("WebXR Device API")}} 

The WebXR Device API has several areas of security to contend with, from establishing Permissions Policy to ensuring the user intends to use the mixed reality presentation before activating it. Among other things, you need to confirm access to device features such as the microphone and/or camera, get permission to use immersive VR mode (if applicable), and so forth. The variety of hardware and software involved in XR brings multiple APIs and technologies into play. In this guide, we’ll cover how to ensure your app has the permissions it needs to provide a secure and private XR experience.

The WebXR Device API is subject to a number of permission and security controls. While not onerous, they are worth being aware of. These mostly revolve around the fully-immersive immersive-vr session mode, but there are things to be aware of when setting up an AR session, as well.

Immersive presentation of VR

First, any requests to activate the immersive-vr mode are rejected if the domain issuing the request does not have permission to enable an immersive session. This permission comes from the xr-spatial-tracking Permissions Policy.

Once that check is passed, the request to enter immersive-vr mode is allowed if all of the following are true:

If all of that is true, the promise returned by requestSession() is resolved, and the new {{domxref("XRSession")}}  object is passed into the fulfillment handler. Otherwise, an appropriate exception is thrown, such as SecurityError if the document doesn’t have permission to enter immersive mode.

Inline presentation

When you request an {{domxref("XRSession")}}  with the mode set to inline, and any features are required or requested, the browser will only allow the session to be created if the call to {{domxref("XRSystem/requestSession", "requestSession()")}}  was made by code which is executing expressly due to user intent.

Specifically:

[!NOTE] Additional requirements may be put into effect due to the specific features requested by the options object when calling requestSession().

User intent

User intent is the concept of whether or not an action being performed by code is being performed because of something the user intends to do or not. There are two kinds of user intent: implicit and explicit.

Explicit user intent (explicit user consent) is granted when the user has specifically and expressly been asked for permission to perform an action.

Implicit user intent (implicit user consent) is assumed if either of the following scenarios is the case:

In this article

View on MDN