Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exporting env variable appears erronous #75

Closed
LuchoTurtle opened this issue Oct 13, 2022 · 5 comments
Closed

Exporting env variable appears erronous #75

LuchoTurtle opened this issue Oct 13, 2022 · 5 comments

Comments

@LuchoTurtle
Copy link
Member

I'm following through using this plug and it appears to work correctly, thank you very much!

However, during my implementation, I only seemed to get it working when I was using https://auth.dwyl.com/ instead of the deployed Heroku app, as written in README.

Additionally, after creating my own app inside auth.dwyl.com, this plug only worked when I exported the variable WITHOUT the /auth.dwyl.com portion of the text for it to work.

Screenshot 2022-10-13 at 15 44 03

Otherwise, I got a :signature_error from this plug every time I tried to sign in with GitHub.

I can make a PR to fix the README file with these changes if you want to, just give me a heads-up if my walkthrough is a valid one.

@nelsonic
Copy link
Member

@LuchoTurtle can you please confirm which version of auth_plug you were attempting this with?
The domain in this case auth.dwyl.com at the end of the API Key should be required ...

auth_plug/lib/token.ex

Lines 54 to 60 in f285612

@doc """
`auth_url/0` returns the `auth_url` (the last part of the AUTH_API_KEY)
"""
def auth_url do
[_all, _id, _secret, auth_url] = split_env()
"https://" <> auth_url
end

Used in:

auth_plug/lib/auth_plug.ex

Lines 152 to 165 in f285612

def get_auth_url(conn, redirect_to \\ nil) do
auth_url = AuthPlug.Token.auth_url()
request_path = redirect_to || conn.request_path
referer =
conn
|> AuthPlug.Helpers.get_baseurl_from_conn()
|> Kernel.<>(request_path)
|> URI.encode()
client_id = AuthPlug.Token.client_id()
"#{auth_url}?referer=#{referer}&auth_client_id=#{client_id}"
end

Invoked by:

# redirect to auth_url with referer to resume once authenticated:
defp redirect_to_auth(conn) do
to = get_auth_url(conn)
# gotta tell the browser to temporarily redirect to the auth_url with 302
status = 302
conn
# redirect to auth_url
|> put_resp_header("location", to)
# only our tests see this.
|> resp(status, "unauthorized")
# halt the conn so no further processing is done.
|> halt()
end

@LuchoTurtle
Copy link
Member Author

Forgot to also comment here. I was using a previous version but while I was attempting to use the latest, it broke. This is related to #76

@nelsonic
Copy link
Member

Please try: https://authdemo.fly.dev/

@LuchoTurtle
Copy link
Member Author

Gonna have a look at this after the dwyl/product-roadmap#40 Flutter preliminary repos and Edit Timers are properly merged 👍

@LuchoTurtle
Copy link
Member Author

The work done in dwyl/phoenix-liveview-realtime-cursor-tracking-tutorial#12 shows that this issue is now resolved.

Closing it. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants