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

Initialise Phoenix application #1

Closed
13 tasks done
SimonLab opened this issue Feb 17, 2020 · 3 comments
Closed
13 tasks done

Initialise Phoenix application #1

SimonLab opened this issue Feb 17, 2020 · 3 comments

Comments

@SimonLab
Copy link
Member

SimonLab commented Feb 17, 2020

linked to dwyl/auth#40 (comment)

  • Create a new Phoenix application with mix phx.new auth-mvp --app auth_mvp . We might need to render some html from the auth application so I'm not adding the --no-webpack and --no-html option

  • Use elixir-auth-google and elixir-auth-github

    • Add the packages as dependencies
    • Create /auth/urls endpoint using the api scope and returns the list of the oauth urls
    • Create callback endpoints. These endpoints are were the Google and Github application will send the token once the user authenticate. /auth/google/callback and `/auth/github/callback
  • Allow Cross Origin Resource Sharing to allow requests to access the auth api endpoints

    • Add the cors_plug dependency
    • Update the endpoint.ex file to add the line plug CORSPlug, origin: ["*"]
  • Deploy the application on Heroku

    • Define the callback url to match the heroku name of the application. This allow the /api/auth/github/callback (and the google one) to be available for the Oauth apps
    • Generate a new secret key and add it to the environment variables on Heroku, mix phx.gen.secret
    • Add Postgres resource on Heroku
    • Follow the heroku deployment guide to make sure the application is ready: https://hexdocs.pm/phoenix/heroku.html
@SimonLab
Copy link
Member Author

elixir_auth_google has just been updated: dwyl/elixir-auth-google#34 (comment)

Updating the dependency and the code now

@SimonLab
Copy link
Member Author

SimonLab commented Feb 18, 2020

Focusing now on adding tests for the 3 endpoints:

scope "/", AuthMvpWeb do
pipe_through :api
get "/auth/google/callback", GoogleAuthController, :index
get "/auth/github/callback", GithubAuthController, :index
get "/auth/urls", AuthUrlController, :index
end

The packages elixir_auth_google and elixir_auth_github are sending request to the Oauth apps, however as these packages are already tested and the tests for auth should focus on the logic of the controller, I'm thinking to mock the functions linked to these two packages.

see http://blog.plataformatec.com.br/2015/10/mocks-and-explicit-contracts/

@nelsonic
Copy link
Member

This is done. 👍

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