Skip to content

Instantly share code, notes, and snippets.

@nikneroz
Created July 20, 2017 13:56
Show Gist options
  • Save nikneroz/d8d6b6cfed08bfd43e4d0d48c599bb2d to your computer and use it in GitHub Desktop.
Save nikneroz/d8d6b6cfed08bfd43e4d0d48c599bb2d to your computer and use it in GitHub Desktop.
Elixir + Phoenix Framework 1.3 + Sentinel. This is tutorial and step by step installation guide.

Phoenix Framework 1.3 + Sentinel

Preparing environment

We need to generate secret key for development environment.

mix phoenix.gen.secret
# ednkXywWll1d2svDEpbA39R5kfkc9l96j0+u7A8MgKM+pbwbeDsuYB8MP2WUW1hf

Add sentinel and guardian_db dependency to your mix.exs

defp deps do
  [
    # ...
    {:sentinel, "~> 2.0"},
    {:guardian_db, "~> 0.8.0"},
    # ...
  ]
end

Also we need to add 
```elixir
config :guardian, Guardian,
  allowed_algos: ["HS512"], # optional
  verify_module: Guardian.JWT,  # optional
  issuer: "MyApp",
  ttl: { 30, :days },
  verify_issuer: true, # optional
  secret_key: "ednkXywWll1d2svDEpbA39R5kfkc9l96j0+u7A8MgKM+pbwbeDsuYB8MP2WUW1hf",
  serializer: Sentinel.GuardianSerializer,
  hooks: GuardianDb # optional if using guardiandb

config :guardian_db, GuardianDb,
  repo: MyAppName.Repo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment