This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function () { | |
'use strict'; | |
angular.module('adbrain.app.reporting').controller('ReportingV2Controller', ReportingV2Controller); | |
ReportingV2Controller.$inject= ['$scope', 'logger', 'advertisers', 'reportingV2Service']; | |
function ReportingV2Controller($scope, logger, advertisers, reportingV2Service) { | |
var vm = this; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Generate your sample application | |
# mix phx.new orders-sample --app orders --no-webpack --no-html | |
# Add this to your deps in mix config | |
[ | |
{:guardian, "~> 1.2.1"}, # Guardian library | |
{:httpoison, "~> 1.5"} # We'll use it to make HTTP Requests to Auth0 | |
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Configure auth zero for the Auth module | |
config :orders, | |
auth0: %{ | |
url: %URI{ | |
host: "orders-sample.eu.auth0.com", | |
port: 443, | |
scheme: "https" | |
}, | |
client_id: "6NeT3VHSzKK4mMXVq7BhSvAq0fUSUXUB", | |
client_secret: "9aAIvTnSL-09QyP-ttbxy9l0NavpyySHulTMTqUYpyfTG0Clt8qz1IEAcqN5spy6", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Auth.Credentials do | |
@moduledoc """ | |
This module represents and validates the credentials | |
""" | |
use Ecto.Schema | |
import Ecto.Changeset | |
alias Auth.Credentials | |
@primary_key false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Auth.TokenResult do | |
@moduledoc """ | |
This struct represents the result of the authentication sign-in process. | |
We get a JWT access token from Auth0 and an expires_in field explaining | |
how long the token field will be available | |
""" | |
@enforce_keys [:access_token, :expires_in] | |
defstruct access_token: "", expires_in: 0 | |
@type t :: %__MODULE__{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Auth do | |
@moduledoc """ | |
This module is responsible to authenticate client credentials against Auth0 | |
and provide access_token and expires_in as a result | |
""" | |
alias Auth.{Credentials, TokenResult} | |
import Base | |
require Logger |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule OrdersWeb.AuthController do | |
@moduledoc """ | |
This controller allows retrieving an access token from auth0 and returning it to the user | |
providing username / password based login capability | |
""" | |
use OrdersWeb, :controller | |
alias Auth | |
alias Auth.{Credentials, TokenResult} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Auth.Guardian do | |
@moduledoc """ | |
This is the main Guardian module used by the application to gain access to claims, | |
identity, token, etc. | |
Implements callback to properly integrate with Auth0. | |
""" | |
use Guardian, otp_app: :orders | |
alias Auth.Identity |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Auth.Identity do | |
@moduledoc """ | |
This struct represents the Identitiy accessible on each connection | |
""" | |
@enforce_keys [:id] | |
defstruct id: nil | |
@type t() :: [ | |
id: String.t() | |
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Setup Guardian with Auth0 | |
config :orders, Auth.Guardian, | |
allowed_algos: ["HS256"], | |
verify_module: Guardian.JWT, | |
issuer: "https://orders-sample.eu.auth0.com/", | |
verify_issuer: true, | |
secret_key: "qgXw5waJYQ8kd6LDFpqY4UuswJ4D0gGS" |
OlderNewer