-
Notifications
You must be signed in to change notification settings - Fork 23
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
Google OAuth Authentication #247
Comments
Recap on how "Sign in with Google" worksGoogle provide OAuth protocol to allow user to signin with an application. The Google documentation ( Using OAuth 2.0 to Access Google APIs) contains the following schemas which describe in a bit more details the steps of authorization: So once a Google token is created for a user, the application will create a session for the user with put_session function (note that the Because the signin process will create a google token and a client session we need to remember to verify that both of this items are still valid and especially checking that they have not expired. |
I'm currently testing the defp deps do
[
{:phoenix, "~> 1.4.10"},
{:phoenix_pubsub, "~> 1.1"},
{:phoenix_ecto, "~> 4.0"},
{:ecto_sql, "~> 3.1"},
{:postgrex, ">= 0.0.0"},
{:phoenix_html, "~> 2.11"},
{:phoenix_live_reload, "~> 1.2", only: :dev},
{:gettext, "~> 0.11"},
{:jason, "~> 1.0"},
{:plug_cowboy, "~> 2.0"},
{:elixir_auth_google, git: "https://github.com/dwyl/elixir-auth-google.git", branch: "initialise-app" }
]
end
|
@SimonLab indeed because the git dependency doesn't have a version/hash updates are manual. 😞 (hopefully not too tedious until we are able to publish it to Hex.pm...) 👍 |
Now that we have a working elixir package to get a Google token with OAuth we can create a session with Phoenix for the user.
|
How to save the token in the Google database? |
@SimonLab sounds like we need a new schema for storing this data.
|
Agree for having the see also the |
Preparing the application for Fields
|
Find an example on the Fields repo for the encryption keys: So it looks like we can create multiple keys by seperating them with comma and it looks like they are created with :base64:
|
@SimonLab progress looking good. 👍 |
sounds good @nelsonic
Other notes |
@SimonLab we may also need a |
According to branding guidelines: https://developers.google.com/identity/branding-guidelines#color Which color of button do we prefer? |
@nelsonic Exactly that. Let's go with blue for now so it's a quick spot? |
We can force the use of a specific version of a dependency using the {:poison, "~> 2.2", override: true}, will make sure the application uses poison 2.2 |
Working on the following logic when google returns the user profile:
I need to simplify the flow and then add the details step by step as it becomes difficult to test all the cases |
@SimonLab thanks for sharing your plan. 👍 Remember that the Using Ecto Associations in Phoenix Elixir Casts video is from Jan 2017 which includes "models" which are no longer part of latest Phoenix. The ecto association is still relevant. |
@SimonLab any objection to me changing the Google Auth callback url I agree that this is semantic. But if we have some reasoning behind our URL patterns, LMK your thoughts. 👍 |
The profile: %{
"email" => "[email protected]",
"email_verified" => true,
"family_name" => "Correia",
"given_name" => "Nelson",
"locale" => "en",
"name" => "Nelson Correia",
"picture" => "https://lh3.googleusercontent.com/a-/AAuE7mApnYb260YC1JY7aPUBxwk8iNzVKB5Q3x_8d3-ThA",
"sub" => "940732358705212133793"
} We need to store all of this data in the
We will use the |
Going to add the two missing fields
defmodule App.Repo.Migrations.AddPictureLocaleToPeople do
use Ecto.Migration
def change do
alter table(:people) do
add :picture, :binary # Field.Url
add :locale, :string, default: "en"
end
end
end |
@nelsonic , yes the name of the callback endpoint is a bit more flexible with On the In fact I'm not sure we can hard code the url of the callback endpoint. I was thinking to call a function to get the current hostname (eg |
@SimonLab exactly. I feel that having it "standardised" will help people move faster. As for the getting the hostname. See: dwyl/elixir-auth-google#17 and PR: dwyl/elixir-auth-google#18 |
@SimonLab what do you feel is still required to consider this issue/feature "done"? 💭 |
I'm currently adding dwyl/mvp#36 which redirect the user to her info page if already loggedin. I'd like to add a |
@SimonLab makes sense to do dwyl/app-mvp-phoenix#36 given your time associated |
The last point to finish for this PR is to define the status for the email (verified or not).
The seeding-data Phoenix article |
This comment has been minimized.
This comment has been minimized.
With Google authentication we are saving in the |
@SimonLab this sounds like a question for the #237 issue. 😉 |
This is now working on https://dwylapp.herokuapp.com Closing. ✅ |
As a person who has a Google Account (for personal or work reasons),
I want the ability sign into the @dwyl App using my Google Account
so that I don't have to waste time registering or remembering another password.
Todo
#4285F4
button to our App as a CTA to Auth with Google Google Auth Button Appearance > Blue #249email
address encrypted in theperson.email
field. (so that we can email the person to remind them of their progress on a task, sending email will be in Sprint 3)email
hashed inemail_hash
so that the address can be looked up.To see why this is needed, GOTO: BUG: New Person inserted each time I authenticate with Google mvp#29
picture
- so we can display the person's avatar in the App.givenName
- So we can address the person "Welcome Simon!"familyName
- Useful when differentiating people with the samegivenName
in a team/org.status=1
- the email address has been verified.locale
- the language to display in the UI. (translations to follow in future)We have implemented this before: https://github.com/dwyl/hapi-auth-google this can be used as a reference.
The text was updated successfully, but these errors were encountered: