auth

The auth submodule allows you to work with Wix authentication and permissions.

Important:

This submodule is not intended for use with self-hosted Apps.

Import statement

Copy

Methods

elevate()

Receives an SDK function and returns an instance of the same function that runs with the authentication and permissions of the current app.

Use elevate() in frontend environments such as site or dashboard extensions when you need to make a call with Wix app authentication.

Learn more about elevated permissions.

Important:
  • Exposed elevated function calls create a security risk for privilege escalation attacks. Make sure to protect your exposed function calls with the appropriate logic.
  • This method can only be used in the code for an app's backend extensions.

Syntax

Copy

Parameters

NameTypeDescription
sourceFunctionfunctionSDK function to elevate.

Returns

An SDK function that runs with app-level permissions.

Example

Create a new product with elevated permissions:

Copy

getTokenInfo()

Returns the information encoded in the currently active token in backend extensions.

When developing backend extensions for an app or web methods, you might need to access information about the session making the request to your backend.

This information is encoded in the token sent with the request, and can be accessed using getTokenInfo(). It can include the user ID, the site ID, the instance ID, and more.

Syntax

Copy

Returns

A promise that resolves to the token info.

Backend extension example

Code for extracting information from a request to a backend extension in a Wix CLI project:

Copy

Web method example

Code for extracting information from a request to a web method:

Copy
Did this help?