# Autenticação via Token

## Introdução

Esse manual descreve o procedimento de autenticação via Token do SPID Client com o SPID Server.

## Procedimento

Acesse o servidor onde do SPID Server, entre no arquivo `user.json`. Neste arquivo, faça a adição de usuário e senha ou edite algum usuário que não comprometerá no funcionamento do SPID. Note que a senha deve estar encriptada em SHA-256.

{% hint style="info" %}
Em caso de dúvidas, contate o Time de Suporte da Griaule.
{% endhint %}

Exemplo de como a seção do arquivo deverá estar, considerando um usuário chamado “griaule” e a senha “teste”:

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

{% hint style="warning" %}
Não remova os outros usuários deste arquivo, a remoção poderá comprometer o funcionamento da aplicação.
{% endhint %}

Na máquina do SPID Client, acesse `C:\Griaule\SPID_Griaule\jre\bin` e execute o arquivo encrypt.jar com a senha escolhida no passo anterior.

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

Se tudo ocorrer corretamente, a resposta deverá ser, para a senha `teste`:

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

Acesse o arquivo `GBSSpid2.properties` na pasta `C:\Griaule\SPID\conf\` e insira a senha criptografada no campo `server.password`.

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

Na máquina do servidor, reinicie o SPID Server.

```sh
sudo service spid restart
```

Abra o SPID Services, se o processo for bem sucedido, o servidor mostrará a seguinte mensagem:

```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/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.
