# How to use OTP in Soffid

## Introduction

Soffid allows administrator users to config the access authentication with OTP as the second-factor authentication (2FA). This is the way to add a extra layer of protection used to ensure the security of online accounts beyond just a username and password.

The administrator user could config the proper OTP implementations that wants to use.

<p class="callout info">To know how to config the diffent options you can visit the [OTP settings page.](https://bookstack.soffid.com/books/two-factor-authentication-2fa-VsJ/page/otp-settings)</p>

There are three points where OTP can be used in Soffid

1. [Login Federation](#bkmrk-authentication%C2%A0)
2. [Access to pages](#bkmrk-authentication%C2%A0-0)
3. [XACML Rules](#bkmrk-xacml)
4. [Password Recovery](#bkmrk-password-recovery)

## Federation

When you are configuring Soffid as Identity Provider, on the Authentication section you could config the OTP as a second authentication factor (2FA).

<p class="callout info">You can visit the [How to deploy the identity &amp; service provider step by step page](https://bookstack.soffid.com/books/federation/page/how-to-deploy-the-identity-service-provider) for more detailed information</p>

### Example

First of all, configure the OTP as a second factor authentication at the Identity &amp; service providers page

`Main Menu > Administration > Configuration > Web SSO > Identity & Service providers`

[![image-1643376367536.png](https://bookstack.soffid.com/uploads/images/gallery/2022-01/scaled-1680-/image-1643376367536.png)](https://bookstack.soffid.com/uploads/images/gallery/2022-01/image-1643376367536.png)

Then, when users login, they must write their credentials[![image-1643614241346.png](https://bookstack.soffid.com/uploads/images/gallery/2022-01/scaled-1680-/image-1643614241346.png)](https://bookstack.soffid.com/uploads/images/gallery/2022-01/image-1643614241346.png)

If the credentials written are ok, finally Soffid will ask for the 2FA

[![image-1643376347362.png](https://bookstack.soffid.com/uploads/images/gallery/2022-01/scaled-1680-/image-1643376347362.png)](https://bookstack.soffid.com/uploads/images/gallery/2022-01/image-1643376347362.png)

## Authentication 

Regarding to the access to pages, you will be able to config the specific Soffid console pages that will require OTP authentication. In addition, you will be able to config if the second-factor authentication will be required to all the users or only to users with enabled token.

<p class="callout info">You can visit the [Authentication page](https://bookstack.soffid.com/books/soffid-3-reference-guide/page/authentication "Authentication") for more information</p>

### Example

The following is an example of how for a given configuration, a user can access certain pages, or how a second authentication factor is required for the user.

#### Second factor authentication configuration

Soffid will require the PIN to access to the specified pages to users with a enabled token

`Main Menu > Administration > Configuration > Security settings > Authentication`

[![image-1639997201805.png](https://bookstack.soffid.com/uploads/images/gallery/2021-12/scaled-1680-/image-1639997201805.png)](https://bookstack.soffid.com/uploads/images/gallery/2021-12/image-1639997201805.png)

#### User access

<iframe allowfullscreen="allowfullscreen" height="314" src="//www.youtube.com/embed/D0m8kWgFLGg?rel=0" width="560"></iframe>

## XACML

OTP can also be used at **XACML Policy Management**. This policies allow adding more complex and restricted rules to the authorizations.

<p class="callout info">You can visit the [XACML book](https://bookstack.soffid.com/books/xacml) for more information. </p>

### Example

A 2FA is required to launch the connection to some servers.

Administrator user can configure the XACML policies.

`Main Menu > Administration > Configuration > Security settings > XACML Policy Management`

[![image-1643901144825.png](https://bookstack.soffid.com/uploads/images/gallery/2022-02/scaled-1680-/image-1643901144825.png)](https://bookstack.soffid.com/uploads/images/gallery/2022-02/image-1643901144825.png)

When dilbert launch the connection, Soffid will ask for the 2FA

[![image-1643901062838.png](https://bookstack.soffid.com/uploads/images/gallery/2022-02/scaled-1680-/image-1643901062838.png)](https://bookstack.soffid.com/uploads/images/gallery/2022-02/image-1643901062838.png)

## Password Recovery

OTP can be use by end-user to recover the password.

<p class="callout info">You can visit the [Password Recovery book](https://bookstack.soffid.com/books/password-recovery) for more information.</p>

### Example

A end-user wants to recover his password.

Soffid allows to recover by clicking on the recover password option:

[![image-1646815422309.png](https://bookstack.soffid.com/uploads/images/gallery/2022-03/scaled-1680-/image-1646815422309.png)](https://bookstack.soffid.com/uploads/images/gallery/2022-03/image-1646815422309.png)

Then, the end-user must identify himself:

[![image-1646815286342.png](https://bookstack.soffid.com/uploads/images/gallery/2022-03/scaled-1680-/image-1646815286342.png)](https://bookstack.soffid.com/uploads/images/gallery/2022-03/image-1646815286342.png)

And Soffid requires to enter the PIN

[![image-1646813762060.png](https://bookstack.soffid.com/uploads/images/gallery/2022-03/scaled-1680-/image-1646813762060.png)](https://bookstack.soffid.com/uploads/images/gallery/2022-03/image-1646813762060.png)

If the end-user has not configured the OTP devices, a error message will be display.

[![image-1646815538898.png](https://bookstack.soffid.com/uploads/images/gallery/2022-03/scaled-1680-/image-1646815538898.png)](https://bookstack.soffid.com/uploads/images/gallery/2022-03/image-1646815538898.png)