Skip to content

alanraul/resuelve-auth-plug

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ResuelveAuth

Plug para validar peticiones firmadas

Agregar al proyecto

def deps do
  [{:resuelve_auth, github: "resuelve/resuelve-auth-plug", tag: "v1.2"}]
end

Agregar Plug a un pipeline

pipeline :api_auth do
  ...
  plug ResuelveAuth.Plugs.TokenAuth, "my-api"
end

Configuración

Sin token logs:

config :resuelve_auth,
  no_logs: true

Crear token y validarlo

iex> alias ResuelveAuth.Helpers.TokenData
iex> alias ResuelveAuth.Helpers.TokenHelper
iex> token_data = %TokenData{
  service: "my-service",
  meta: %{
    stuff: "some-stuff"
  }
}
iex> token = TokenHelper.create_token(token_data, "super-secret")
iex> {:ok, %{"meta" => meta}} = TokenHelper.verify_token(token, "super-secret")
iex> {:error, "Unauthorized"} = TokenHelper.verify_token(token, "invalid-secret-or-invalid-token")

About

Plug para validar peticiones firmadas

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Elixir 100.0%