From fd81e72c7468232b28ed6f0689f1338db6b4bc39 Mon Sep 17 00:00:00 2001 From: nelsonic Date: Wed, 22 Apr 2020 22:42:29 +0100 Subject: [PATCH] add auth_plug to mix.exs for #42 --- lib/auth_web/controllers/auth_controller.ex | 6 +----- mix.exs | 16 +++++++++++----- mix.lock | 1 + 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/lib/auth_web/controllers/auth_controller.ex b/lib/auth_web/controllers/auth_controller.ex index 1ca53cb8..dee32298 100644 --- a/lib/auth_web/controllers/auth_controller.ex +++ b/lib/auth_web/controllers/auth_controller.ex @@ -17,11 +17,8 @@ defmodule AuthWeb.AuthController do `google_handler/2` handles the callback from Google Auth API redirect. """ def google_handler(conn, %{"code" => code, "state" => state}) do - IO.inspect(state, label: "state") {:ok, token} = ElixirAuthGoogle.get_token(code, conn) - IO.inspect(token, label: "token") {:ok, profile} = ElixirAuthGoogle.get_user_profile(token.access_token) - IO.inspect(profile, label: "profile") # save profile to people: person = Person.create_google_person(profile) @@ -42,7 +39,7 @@ defmodule AuthWeb.AuthController do if the state is defined, redirect to it. """ def handler(conn, person, state) do - IO.inspect(person, label: "handler/3 > person") + # IO.inspect(person, label: "handler/3 > person") # Send welcome email: Auth.Email.sendemail(%{ email: person.email, @@ -75,7 +72,6 @@ defmodule AuthWeb.AuthController do } jwt = Auth.Token.generate_and_sign!(data) - # |> IO.inspect(label: "jwt") URI.decode(state) <> "?jwt=" <> jwt end end diff --git a/mix.exs b/mix.exs index 3277355d..740fb6d5 100644 --- a/mix.exs +++ b/mix.exs @@ -55,18 +55,24 @@ defmodule Auth.Mixfile do {:jason, "~> 1.2.0"}, {:plug_cowboy, "~> 2.1.3"}, - # Field Validation and Encryption: - {:fields, "~> 2.4.0"}, - # Auth: + # https://github.com/dwyl/elixir-auth-github {:elixir_auth_github, "~> 1.2.0"}, + # https://github.com/dwyl/elixir-auth-google {:elixir_auth_google, "~> 1.2.0"}, + # https://github.com/dwyl/auth_plug + {:auth_plug, "~> 0.4.0"}, + + # Field Validation and Encryption: github.com/dwyl/fields + {:fields, "~> 2.4.0"}, + + # Crete JSON Web Tokens {:joken, "~> 2.2"}, - # check test coverage + # Check test coverage {:excoveralls, "~> 0.12.3", only: :test}, - # For publishing Hex.docs: + # Create Documentation for publishing Hex.docs: {:ex_doc, "~> 0.21.3", only: :dev} ] end diff --git a/mix.lock b/mix.lock index 1864f729..a771b54a 100644 --- a/mix.lock +++ b/mix.lock @@ -1,5 +1,6 @@ %{ "argon2_elixir": {:hex, :argon2_elixir, "2.3.0", "e251bdafd69308e8c1263e111600e6d68bd44f23d2cccbe43fcb1a417a76bc8e", [:make, :mix], [{:comeonin, "~> 5.3", [hex: :comeonin, repo: "hexpm", optional: false]}, {:elixir_make, "~> 0.6", [hex: :elixir_make, repo: "hexpm", optional: false]}], "hexpm", "28ccb63bff213aecec1f7f3dde9648418b031f822499973281d8f494b9d5a3b3"}, + "auth_plug": {:hex, :auth_plug, "0.4.0", "73c460b0dce833f864726502b79b962f5fa788c5c31af5cbc85fd38a38edb3f0", [:mix], [{:joken, "~> 2.2", [hex: :joken, repo: "hexpm", optional: false]}, {:plug, "~> 1.10", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm", "79808c94e7f2e6af63222d17aff891528d3e24f7be75c5d1c4b0983c9054bd79"}, "certifi": {:hex, :certifi, "2.5.1", "867ce347f7c7d78563450a18a6a28a8090331e77fa02380b4a21962a65d36ee5", [:rebar3], [{:parse_trans, "~>3.3", [hex: :parse_trans, repo: "hexpm", optional: false]}], "hexpm", "805abd97539caf89ec6d4732c91e62ba9da0cda51ac462380bbd28ee697a8c42"}, "comeonin": {:hex, :comeonin, "5.3.1", "7fe612b739c78c9c1a75186ef2d322ce4d25032d119823269d0aa1e2f1e20025", [:mix], [], "hexpm", "d6222483060c17f0977fad1b7401ef0c5863c985a64352755f366aee3799c245"}, "connection": {:hex, :connection, "1.0.4", "a1cae72211f0eef17705aaededacac3eb30e6625b04a6117c1b2db6ace7d5976", [:mix], [], "hexpm", "4a0850c9be22a43af9920a71ab17c051f5f7d45c209e40269a1938832510e4d9"},