You'll need an Auth0 account to manage authentication. You can sign up for a free account here. Next, set up an Auth0 Client and API so Auth0 can interface with your app and API.
- Go to your Auth0 Dashboard and click the "create a new client" button.
- Name your new app and select "Regular Web Applications".
- In the Settings for your new Auth0 client app, add
http://0.0.0.0:4000/auth
to the Allowed Callback URLs andhttp://0.0.0.0:4000/auth
to the Allowed Origins (CORS). You might need to addhttp://localhost:4000/auth
depending on how your version of Phoenix renders the routes. - Scroll down to the bottom of the Settings section and click "Show Advanced Settings". Choose the OAuth tab and change the JsonWebToken Signature Algorithm to
RS256
. - If you'd like, you can set up some social connections. You can then enable them for your app in the Client options under the Connections tab. The example shown in the screenshot above utilizes username/password database, Facebook, Google, and Twitter.
Follow the Elixir install guide here: http://elixir-lang.org/install.html
Next we run a mix
command to install the Hex package manager. Mix is a build tool that provides tasks for creating, compiling, and testing Elixir projects, managing its dependencies, and more. If you know Ruby well, Mix is Rake, Bundler, and RubyGems combined.
Now use mix to install hex: https://hexdocs.pm/mix/1.0.5/Mix.Tasks.Local.Hex.html
$ mix local.hex
Phoenix needs at least Elixir 1.4 and Erlang 18 or later, run:
$ elixir -v
Erlang/OTP 19 [erts-8.3] [source] [64-bit] [smp:8:8] [async-threads:10] [hipe] [kernel-poll:false] [dtrace]
Elixir 1.4.2
Now we can install Phoenix v1.3.0:
$ mix archive.install https://github.com/phoenixframework/archives/raw/master/phx_new-1.3.0.ez
Follow the instructions here: http://postgresguide.com/setup/install.html
Set up your database config by editing config/dev.exs
(and config/{env}.exs
where appropriate), and edit the username and password near the bottom of the file. (They will both be set to “postgres” by default.)
...
config :countdown, Countdown.Repo,
adapter: Ecto.Adapters.Postgres,
username: "postgres",
password: "postgres",
database: "elixir",
...
npm may also be required as well (dependant on your operating system, you might already have it): https://docs.npmjs.com/getting-started/installing-node
If you choose to use another database provider, make sure you edit the configuration appropriately: https://phoenixframework.readme.io/docs/using-mysql
- Install dependencies with
mix deps.get
- Create and migrate your database with
mix ecto.create && mix ecto.migrate
. - Install Node.js dependencies with
cd assets && npm install
- Start Phoenix endpoint with
AUTH0_DOMAIN=<your domain> AUTH0_MGMT_CLIENT_ID=<your client id> AUTH0_MGMT_CLIENT_SECRET=<your secret> mix phx.server
Now you can visit localhost:4000
from your browser.
Ready to run in production? Please check our deployment guides.
- Official website: http://www.phoenixframework.org/
- Guides: http://phoenixframework.org/docs/overview
- Docs: https://hexdocs.pm/phoenix
- Mailing list: http://groups.google.com/group/phoenix-talk
- Source: https://github.com/phoenixframework/phoenix
- Auth0 for authentication: https://www.auth0.com