-
Notifications
You must be signed in to change notification settings - Fork 0
Auth
Ronaldo Meneguite edited this page May 2, 2018
·
1 revision
POST/v1/auth/login - Processa login do usuárioPOST/v1/auth/2fa - Autentica usuário usando 2faGET/v1/auth/logout - Invalida um token gerado previamenteGET/v1/auth/refresh - Atualiza um token gerado previamenteGET/v1/auth/2fa/enable - Solicita a ativação do 2fa para o usuárioPOST/v1/auth/2fa/enable - Confirma a ativação do 2fa para o usuárioGET/v1/auth/2fa/disable - Desabilita o 2fa para o usuárioPOST/v1/auth/password/forgot - Solicita a redefinição da senhaPOST/v1/auth/password/reset - Redefine a senha do usuário
O endpoint para autenticação atende a duas demandas diferentes. É possível o usar para autenticar um usuário por seu email e senha, ou usando uma chave de api gerada dentro da aplicação. O que define qual será usado são os parâmetros enviados na requisição, sendo que a autenticação via chave de API tem precedência sobre o acesso via email e password.
[
{
"name": "email",
"in": "formData",
"type": "string",
"required": false,
"description": "E-mail do usuário",
"comments": "Obrigatório para se autenticar com um usuário via email e senha"
},
{
"name": "password",
"in": "formData",
"type": "string",
"required": false,
"description": "Senha de acesso",
"comments": "Obrigatório para se autenticar com um usuário via email e senha"
},
{
"name": "key",
"in": "formData",
"type": "string",
"required": false,
"description": "Chave de acesso do usuário",
"comments": "Obrigatório para se autenticar com um usuário via API key"
},
{
"name": "secret",
"in": "formData",
"type": "string",
"required": false,
"description": "Chave secreta gerada pelo sistema",
"comments": "Obrigatório para se autenticar com um usuário via API key"
}
]Exemplo de envio para autenticar um usuário via email e senha
{
"email": "user@email.com",
"password": "user-password"
}Exemplo de envio para autenticar um usuário via Api Key
{
"key": "cc2a7f59-286a-3491-ae49-40309ed4df6f",
"secret": "rg2a7f59-286a-3491-ae49-40309e788"
}{
"data": {
"token": "eyJ0eXAiOiJKV1Qi1NiJ9.eyJpc3MiOiJodHRwOi8vbG9jiOjE1MjE1NTMwNjAsImV4cCI6MTTUzMDYwLCJqdGkiOdHJjczVQIiwickNWM4OTQ5ZjYwMGFkYjM5ZTcwMWM0MDA4NzJkYjdhNTk3NmY3In0.VEZZPXY_jiCxKKaxsMugqFNf05n204sF5A7mOoV4kwo",
"type": "bearer",
"expires_in": 36000000
}
}{
"message": "It is necessary to inform 2fa code",
"data": {
"reference": "b7082e1a-d201-4dab-ac42-1ea788f11da3"
}
}{
"message":"Unauthorized"
}{
"message":"Exceeded the limit of attempts. Wait for 5 minutes for another try."
}[
{
"name": "reference",
"in": "formData",
"type": "string",
"required": true,
"description": "Referência retornada após o login inicial"
},
{
"name": "code",
"in": "formData",
"type": "string",
"required": true,
"description": "Código gerado pelo sistema de 2fa"
}
]{
"reference": "a66ec339-d51b-4985-aa4a-c6b82ec5cd2d",
"code": "126666"
}{
"data": {
"token": "eyJ0eXAiOiJKV1Qi1NiJ9.eyJpc3MiOiJodHRwOi8vbG9jiOjE1MjE1NTMwNjAsImV4cCI6MTTUzMDYwLCJqdGkiOdHJjczVQIiwickNWM4OTQ5ZjYwMGFkYjM5ZTcwMWM0MDA4NzJkYjdhNTk3NmY3In0.VEZZPXY_jiCxKKaxsMugqFNf05n204sF5A7mOoV4kwo",
"type": "bearer",
"expires_in": 36000000
}
}{
"message": "The given data was invalid.",
"errors": {
"reference": [
"The reference field is required."
],
"code": [
"The code field is required."
]
}
}{
"message":"Unauthorized"
}{
"message":"Exceeded the limit of attempts. Wait for 5 minutes for another try."
}[
{
"name": "Authorization",
"in": "header",
"type": "string",
"required": true,
"description": "Token válido",
"example": "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOi8vbG9jYWxob3N0L3YxL2F1dGgvMmZhIiwiaWF0IjoxNTIyMTY4NTM0LCJleHAiOjE1NTgxNjg1MzQsIm5iZiI6MTUyMjE2ODUzNCwianRpIjoiY0ZSaHRGV2VXN0hZTGVyTiIsI"
}
]{
"message": "Successfully logged out"
}{
"message":"Unauthorized"
}{
"message":"Exceeded the limit of attempts. Wait for 5 minutes for another try."
}[
{
"name": "Authorization",
"in": "header",
"type": "string",
"required": true,
"description": "Token válido"
}
]{
"data": {
"token": "eyJ0eXAiOiJKV1Qi1NiJ9.eyJpc3MiOiJodHRwOi8vbG9jiOjE1MjE1NTMwNjAsImV4cCI6MTTUzMDYwLCJqdGkiOdHJjczVQIiwickNWM4OTQ5ZjYwMGFkYjM5ZTcwMWM0MDA4NzJkYjdhNTk3NmY3In0.VEZZPXY_jiCxKKaxsMugqFNf05n204sF5A7mOoV4kwo",
"type": "bearer",
"expires_in": 36000000
}
}{
"message":"Unauthorized"
}{
"message":"Exceeded the limit of attempts. Wait for 5 minutes for another try."
}[
{
"name": "Authorization",
"in": "header",
"type": "string",
"required": true,
"description": "Token válido",
"example": "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOi8vbG9jYWxob3N0L3YxL2F1dGgvMmZhIiwiaWF0IjoxNTIyMTY4NTM0LCJleHAiOjE1NTgxNjg1MzQsIm5iZiI6MTUyMjE2ODUzNCwianRpIjoiY0ZSaHRGV2VXN0hZTGVyTiIsI"
}
]{
"data": {
"secret": "XYMAHMDY26BVZTK2JHSLCHRWKB5NWZZ6ATSFRYFC7IDRE7Z63HYQ====",
"url": "https://chart.googleapis.com/chart?chs=200x200&chld=M|0&cht=qr&chl=otpauth%3A%2F%2Ftotp%2FPague%2520Com%2520Bitcoin%2520Local%253AAdministrator%3Fsecret%3DXYMAHMDY26BVZTK2JHSLCHRWKB5NWZZ6ATSFRYFC7IDRE7Z63HYQ%3D%3D%3D%3D%26issuer%3DPague%2520Com%2520Bitcoin%2520Local"
}
}{
"message": "User already has 2fa enabled"
}{
"message":"Unauthorized"
}{
"message":"Exceeded the limit of attempts. Wait for 5 minutes for another try."
}[
{
"name": "Authorization",
"in": "header",
"type": "string",
"required": true,
"description": "Token válido"
},
{
"name": "secret",
"in": "formData",
"type": "string",
"required": true,
"description": "Secret gerado pelo sistema na etapa anterior"
},
{
"name": "code",
"in": "formData",
"type": "string",
"required": true,
"description": "Código gerado pelo sistema de 2fa"
}
]{
"message": "Enabled 2fa"
}{
"message": "Invalid Code 2fa"
}{
"message": "The given data was invalid.",
"errors": {
"secret": [
"The secret field is required."
]
}
}{
"message":"Unauthorized"
}{
"message":"Exceeded the limit of attempts. Wait for 5 minutes for another try."
}[
{
"name": "Authorization",
"in": "header",
"type": "string",
"required": true,
"description": "Token válido",
"example": "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOi8vbG9jYWxob3N0L3YxL2F1dGgvMmZhIiwiaWF0IjoxNTIyMTY4NTM0LCJleHAiOjE1NTgxNjg1MzQsIm5iZiI6MTUyMjE2ODUzNCwianRpIjoiY0ZSaHRGV2VXN0hZTGVyTiIsI"
}
]{
"message": "Disabled 2fa"
}{
"message":"Unauthorized"
}{
"message":"Exceeded the limit of attempts. Wait for 5 minutes for another try."
}[
{
"name": "email",
"in": "formData",
"type": "string",
"required": true,
"description": "E-mail do usuário"
},
{
"name": "redirect",
"in": "formData",
"type": "string",
"required": true,
"description": "Url que ira ser incluída junto ao token no e-mail",
"comments": "Para 'https://grupocitar.com.br' será gerado o link 'https://grupocitar.com.br?token=TOKEN_GERADO'"
}
]{}{
"message": "The given data was invalid.",
"errors": {
"email": [
"The email field is required."
],
"redirect": [
"The redirect field is required."
]
}
}{
"message":"Unauthorized"
}{
"message":"Exceeded the limit of attempts. Wait for 5 minutes for another try."
}[
{
"name": "token",
"in": "formData",
"type": "string",
"required": true,
"description": "Token enviado ao usuário pelo e-mail"
},
{
"name": "email",
"in": "formData",
"type": "string",
"required": true,
"description": "E-mail do usuário"
},
{
"name": "password",
"in": "formData",
"type": "string",
"required": true,
"description": "Novo password do usuário"
}
]{}{
"message": "The given data was invalid.",
"errors": {
"email": [
"The email field is required."
],
"password": [
"The password field is required."
]
}
}{
"message":"Unauthorized"
}{
"message":"Exceeded the limit of attempts. Wait for 5 minutes for another try."
}