# Auth0 Security

## 🔐 What is Auth0 security ?

Using the [Auth0](https://www.auth0.com) security item you can integrate your surveys using your existing auth0 infrastructure to authenticate users before taking the survey.&#x20;

Using Auth0 you can restrict access and ask login credential using any of the activated user provider of your auth0 account like Active Directory, LinkedIn, Google, FaceBook accounts.

{% hint style="info" %}
You may use [data attributes](https://docs.ngsurvey.com/form-management/security/data-attributes) to pipe or use your auth0 logged in user attributes in your survey texts or [survey logic](https://docs.ngsurvey.com/form-management/form-designer/condition-rules).&#x20;
{% endhint %}

## 🚀 Setup Auth0

To configure the Auth0 security you need to create in your [Auth0 account](https://manage.auth0.com/) an Application and a back end API.

To create the application go to the Auth0 administration section and **create the application.**

![](https://1025048312-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M8fLhS0bmfBRyq0HdUm%2F-MDDqCH6macAHox3TX2x%2F-MDE0huWvStKQLVBBa-m%2Fimage.png?alt=media\&token=052ef49f-2140-4c05-98d2-824e68f891df)

Select the **Single Page Web Applications** as your application type

![](https://1025048312-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M8fLhS0bmfBRyq0HdUm%2F-MD3ZkFipqSbG5mrdxXO%2F-MD3_ccKyLznkbcGw-Xq%2Fimage.png?alt=media\&token=f9205128-0aca-4d6c-b6e2-26696d1f6d35)

In your application settings set the Allow **Callback URLs** to `https://www.ngsurvey.com/s/auth0redirect`&#x20;

![](https://1025048312-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M8fLhS0bmfBRyq0HdUm%2F-MD3rvJ6PbFiwmTFaEmJ%2F-MD3sHHW8U0mj42yZhSk%2Fimage.png?alt=media\&token=f0b3f9ed-7da0-4adb-baac-b79e01805874)

{% hint style="warning" %}
If you're using a self-hosted on-premise version make sure to replace the [www.ngsurvey.com](http://www.ngsurvey.com) domain by the domain used that runs your own ngSurvey instance.  &#x20;
{% endhint %}

Once you have your application is setup copy from its Settings tab the **Domain** and **Client ID** and paste the values in your ngSurvey security item settings.

![](https://1025048312-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M8fLhS0bmfBRyq0HdUm%2F-MD3ZkFipqSbG5mrdxXO%2F-MD3aOIBFTHGHWQTLc64%2Fimage.png?alt=media\&token=cfd62d80-4d28-49d2-9552-c1d6c6d9ca3c)

Go back to your [Auth0 administration section](https://manage.auth0.com/) and in the API section **create a new API.**

![](https://1025048312-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M8fLhS0bmfBRyq0HdUm%2F-MD3ZkFipqSbG5mrdxXO%2F-MD3bJejQlK3itgMeoWu%2Fimage.png?alt=media\&token=a0c8ec83-cc06-47db-ac1f-ae184e0cc62e)

Create the new API using a unique identifier.

![](https://1025048312-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M8fLhS0bmfBRyq0HdUm%2F-MD3ZkFipqSbG5mrdxXO%2F-MD3bpQvcH2wliwtB1Ua%2Fimage.png?alt=media\&token=65e13b83-eb77-4118-8788-661d4abf5c49)

Copy the **Identifier** and paste it in your ngSurvey Auth0 security item settings.

![](https://1025048312-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M8fLhS0bmfBRyq0HdUm%2F-MD3ZkFipqSbG5mrdxXO%2F-MD3cNRn4ilKb1iVYHiq%2Fimage.png?alt=media\&token=94cc9a2e-6a0a-4cd7-b679-931a097a6e69)

Thats it! Your survey is now only available to users that have been authenticated using your Auth0 server settings.

## 🔅 Auth0 security properties

* **`Domain`** is your auth0 domain.&#x20;
* **`Client Id`** client id of your auth0 single page application.
* **`Identifier / Audience`** audience identifier of your auth0 web api.
* **`Allow multiple submissions`** can a respondent take part multiple time to the same survey.
