PhoenixOauth2Provider v0.5.0 PhoenixOauth2Provider.Router View Source

Handles routes for PhoenixOauth2Provider.

Usage

Configure lib/my_app_web/router.ex the following way:

defmodule MyAppWeb.Router do
  use MyAppWeb, :router
  use PhoenixOauth2Provider.Router

  pipeline :browser do
    plug :accepts, ["html"]
    plug :fetch_session
    plug :fetch_flash
    plug :protect_from_forgery
    plug :put_secure_browser_headers
  end

  pipeline :api do
    plug :accepts, ["json"]
  end

  pipeline :protected do
    # Require user authentication
  end

  scope "/" do
    pipe_through [:browser, :protected]

    oauth_routes()
  end

  scope "/" do
    pipe_through :api

    oauth_api_routes()
  end

  # ...
end

Link to this section Summary

Functions

OAuth 2.0 API routes macro.

OAuth 2.0 browser routes macro.

Link to this section Functions

Link to this macro

oauth_api_routes(options \\ []) View Source (macro)

OAuth 2.0 API routes macro.

Use this macro to define the public API oauth routes. These routes should not have CSRF protection.

Example

scope "/" do
  pipe_through :api

  oauth_api_routes()
end
Link to this macro

oauth_routes(options \\ []) View Source (macro)

OAuth 2.0 browser routes macro.

Use this macro to define the protected browser oauth routes.

Example

scope "/" do
  pipe_through [:browser, :protected]

  oauth_routes()
end