# Autenticación vía Token

## Introducción

Este manual describe el procedimiento de autenticación mediante Token del SPID Client con el SPID Server.

## Procedimiento

Acceda al servidor donde está el SPID Server, entre en el archivo `user.json`. En este archivo, agregue el usuario y la contraseña o edite algún usuario que no comprometa el funcionamiento del SPID. Tenga en cuenta que la contraseña debe estar encriptada en SHA-256.

{% hint style="info" %}
En caso de dudas, contacte al Equipo de Soporte de Griaule.
{% endhint %}

Ejemplo de cómo deberá estar la sección del archivo, considerando un usuario llamado “griaule” y la contraseña “teste”:

```json
{
	"user": "griaule",
	"pass": 46070d4bf934fb0d4b06d9e2c46e346944e322444900a435d7d9a95e6d7435f5,
	"role": [
		"ROLE_ADMIN",
		"ROLE_USER"
	]
}
```

{% hint style="warning" %}
No elimine los demás usuarios de este archivo, la eliminación podría comprometer el funcionamiento de la aplicación.
{% endhint %}

En la máquina del SPID Client, acceda a `C:\Griaule\SPID_Griaule\jre\bin` y ejecute el archivo encrypt.jar con la contraseña elegida en el paso anterior.

```sh
.\java.exe -jar .\encrypt.jar teste
```

Si todo ocurre correctamente, la respuesta deberá ser, para la contraseña `teste`:

```
Encrypted password is: 2JnIAzJa4ZwiamcKOAnJNg==
```

Abra el archivo `GBSSpid2.properties` en la carpeta `C:\Griaule\SPID\conf\` e inserte la contraseña encriptada en el campo `server.password`.

```properties
#GBDS Server connection
server.url=<URL>
server.username=griaule
server.password=2JnIAzJa4ZwiamcKOAnJNg==
```

En la máquina del servidor, reinicie el SPID Server.

```sh
sudo service spid restart
```

Abra el SPID Services, si el proceso tiene éxito, el servidor mostrará el siguiente mensaje:

```json
{
	"event": "Authorization",
	"eventResult": "JWT Token Authorized"
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.griaule.com/psbio/es/spid/spidtoken.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
