Skip to content

Commit

Permalink
use AuthPlug.Token.client_id in redirect_to_auth/2 #14
Browse files Browse the repository at this point in the history
  • Loading branch information
nelsonic committed Apr 27, 2020
1 parent aea0a83 commit dd7975c
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions lib/auth_plug.ex
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ defmodule AuthPlug do
import Plug.Conn
# https://hexdocs.pm/logger/Logger.html
require Logger
@secret System.get_env("SECRET_KEY_BASE")

@doc """
`init/1` initialises the options passed in and makes them
Expand Down Expand Up @@ -70,16 +69,16 @@ defmodule AuthPlug do
[
store: :cookie,
key: "_auth_key",
secret_key_base: @secret,
signing_salt: @secret
secret_key_base: System.get_env("SECRET_KEY_BASE"),
signing_salt: AuthPlug.Token.client_secret
]
end

@doc """
`setup_session/1` configures the Phoenix/Plug Session.
"""
def setup_session(conn) do
conn = put_in(conn.secret_key_base, @secret)
conn = put_in(conn.secret_key_base, System.get_env("SECRET_KEY_BASE"))

opts = session_options() |> Plug.Session.init()

Expand Down Expand Up @@ -165,7 +164,7 @@ defmodule AuthPlug do
opts.auth_url <>
"?referer=" <>
URI.encode(baseurl <> conn.request_path) <>
"&DWYL_API_KEY=" <> @secret
"&client_id=" <> AuthPlug.Token.client_id

# gotta tell the browser to temporarily redirect to the auth_url with 302
status = 302
Expand Down

0 comments on commit dd7975c

Please sign in to comment.