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

Extract client_id from HTTP referer #55

Closed
9 tasks done
nelsonic opened this issue Apr 28, 2020 · 3 comments
Closed
9 tasks done

Extract client_id from HTTP referer #55

nelsonic opened this issue Apr 28, 2020 · 3 comments
Assignees
Labels
enhancement New feature or enhancement of existing functionality priority-2 Second highest priority, should be worked on as soon as the Priority-1 issues are finished T4h Time Estimate 4 Hours technical A technical issue that requires understanding of the code, infrastructure or dependencies
Projects

Comments

@nelsonic
Copy link
Member

nelsonic commented Apr 28, 2020

auth_plug sends the client_id to the auth_url when no valid JWT is found: lib/auth_plug.ex#L167
We need to verify the client_id (decode_decrypt/1 followed by lookup in apikeys)
and if the client_id is valid, use the client_secret to sign the JWT on successful authentication.

Todo

  • Extract the client_id from the HTTP referer
    • Check if the client_id is valid before displaying the "login buttons" page
      • If client_id not valid, return a friendly Error: 401: AUTH_API_KEY not valid
  • Include the client_id in the state prop that gets sent to GitHub/Google
    I checked and it's RFC3986 compliant to have multiple question marks in a URL Query:
    https://stackoverflow.com/questions/2924160/is-it-valid-more-than-one-question-mark-in-a-url
  • Extract the the client_id from the state (returned by Auth Provider)
  • Confirm that it's still valid (not altered by the Auth Provider > decode_decrypt/1)
  • Lookup the client_id in apikeys
  • Use corresponding client_secret to sign JWT
  • Redirect back to original HTTP referer with JWT

With the completion of this issue Auth dwyl/app#268 will be fully functional!
Let's get it done!

@nelsonic nelsonic added enhancement New feature or enhancement of existing functionality priority-2 Second highest priority, should be worked on as soon as the Priority-1 issues are finished T4h Time Estimate 4 Hours technical A technical issue that requires understanding of the code, infrastructure or dependencies labels Apr 28, 2020
@nelsonic nelsonic self-assigned this Apr 28, 2020
@nelsonic nelsonic added this to To do in dwyl app Apr 28, 2020
@nelsonic nelsonic moved this from To do to In progress in dwyl app Apr 28, 2020
@nelsonic
Copy link
Member Author

true

@nelsonic
Copy link
Member Author

Extracting the client_id from the URL query params works:
image

@nelsonic
Copy link
Member Author

This is working. ✅
See: #43

dwyl app automation moved this from In progress to Done Apr 29, 2020
@nelsonic nelsonic mentioned this issue Apr 29, 2020
12 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or enhancement of existing functionality priority-2 Second highest priority, should be worked on as soon as the Priority-1 issues are finished T4h Time Estimate 4 Hours technical A technical issue that requires understanding of the code, infrastructure or dependencies
Projects
dwyl app
  
Done
Development

No branches or pull requests

1 participant