From e4a5a2ddf1ebe95066e5525fd05e718ac8867744 Mon Sep 17 00:00:00 2001 From: Sean Callan Date: Tue, 18 Jul 2017 00:13:15 -0600 Subject: [PATCH 01/80] Update dependencies and version --- mix.exs | 6 +++--- mix.lock | 29 +++++++++++++++-------------- 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/mix.exs b/mix.exs index 2f67625..e545a51 100644 --- a/mix.exs +++ b/mix.exs @@ -1,7 +1,7 @@ defmodule UeberauthGoogle.Mixfile do use Mix.Project - @version "0.5.0" + @version "0.6.0" @url "https://github.com/ueberauth/ueberauth_google" def project do @@ -25,10 +25,10 @@ defmodule UeberauthGoogle.Mixfile do defp deps do [ - {:oauth2, "~> 0.8"}, + {:oauth2, "~> 0.9"}, {:ueberauth, "~> 0.4"}, - {:credo, "~> 0.5", only: [:dev, :test]}, + {:credo, "~> 0.8", only: [:dev, :test]}, {:earmark, ">= 0.0.0", only: :dev}, {:ex_doc, "~> 0.3", only: :dev}, ] diff --git a/mix.lock b/mix.lock index 7b2d242..d95b51e 100644 --- a/mix.lock +++ b/mix.lock @@ -1,17 +1,18 @@ -%{"bunt": {:hex, :bunt, "0.1.6", "5d95a6882f73f3b9969fdfd1953798046664e6f77ec4e486e6fafc7caad97c6f", [:mix], []}, - "certifi": {:hex, :certifi, "0.7.0", "861a57f3808f7eb0c2d1802afeaae0fa5de813b0df0979153cbafcd853ababaf", [:rebar3], []}, - "credo": {:hex, :credo, "0.5.3", "0c405b36e7651245a8ed63c09e2d52c2e2b89b6d02b1570c4d611e0fcbecf4a2", [:mix], [{:bunt, "~> 0.1.6", [hex: :bunt, optional: false]}]}, - "earmark": {:hex, :earmark, "1.0.1", "2c2cd903bfdc3de3f189bd9a8d4569a075b88a8981ded9a0d95672f6e2b63141", [:mix], []}, - "ex_doc": {:hex, :ex_doc, "0.13.2", "1059a588d2ad3ffab25a0b85c58abf08e437d3e7a9124ac255e1d15cec68ab79", [:mix], [{:earmark, "~> 1.0", [hex: :earmark, optional: false]}]}, - "hackney": {:hex, :hackney, "1.6.3", "d489d7ca2d4323e307bedc4bfe684323a7bf773ecfd77938f3ee8074e488e140", [:mix, :rebar3], [{:certifi, "0.7.0", [hex: :certifi, optional: false]}, {:idna, "1.2.0", [hex: :idna, optional: false]}, {:metrics, "1.0.1", [hex: :metrics, optional: false]}, {:mimerl, "1.0.2", [hex: :mimerl, optional: false]}, {:ssl_verify_fun, "1.1.1", [hex: :ssl_verify_fun, optional: false]}]}, +%{"bunt": {:hex, :bunt, "0.2.0", "951c6e801e8b1d2cbe58ebbd3e616a869061ddadcc4863d0a2182541acae9a38", [:mix], [], "hexpm"}, + "certifi": {:hex, :certifi, "1.2.1", "c3904f192bd5284e5b13f20db3ceac9626e14eeacfbb492e19583cf0e37b22be", [:rebar3], [], "hexpm"}, + "credo": {:hex, :credo, "0.8.4", "4e50acac058cf6292d6066e5b0d03da5e1483702e1ccde39abba385c9f03ead4", [:mix], [{:bunt, "~> 0.2.0", [hex: :bunt, repo: "hexpm", optional: false]}], "hexpm"}, + "earmark": {:hex, :earmark, "1.0.1", "2c2cd903bfdc3de3f189bd9a8d4569a075b88a8981ded9a0d95672f6e2b63141", [], [], "hexpm"}, + "ex_doc": {:hex, :ex_doc, "0.13.2", "1059a588d2ad3ffab25a0b85c58abf08e437d3e7a9124ac255e1d15cec68ab79", [], [{:earmark, "~> 1.0", [hex: :earmark, repo: "hexpm", optional: false]}], "hexpm"}, + "hackney": {:hex, :hackney, "1.8.6", "21a725db3569b3fb11a6af17d5c5f654052ce9624219f1317e8639183de4a423", [:rebar3], [{:certifi, "1.2.1", [hex: :certifi, repo: "hexpm", optional: false]}, {:idna, "5.0.2", [hex: :idna, repo: "hexpm", optional: false]}, {:metrics, "1.0.1", [hex: :metrics, repo: "hexpm", optional: false]}, {:mimerl, "1.0.2", [hex: :mimerl, repo: "hexpm", optional: false]}, {:ssl_verify_fun, "1.1.1", [hex: :ssl_verify_fun, repo: "hexpm", optional: false]}], "hexpm"}, "httpoison": {:hex, :httpoison, "0.9.1", "6c2b4eaf2588a6f3ef29663d28c992531ca3f0bc832a97e0359bc822978e1c5d", [:mix], [{:hackney, "~> 1.6.0", [hex: :hackney, optional: false]}]}, - "idna": {:hex, :idna, "1.2.0", "ac62ee99da068f43c50dc69acf700e03a62a348360126260e87f2b54eced86b2", [:rebar3], []}, - "metrics": {:hex, :metrics, "1.0.1", "25f094dea2cda98213cecc3aeff09e940299d950904393b2a29d191c346a8486", [:rebar3], []}, - "mime": {:hex, :mime, "1.0.1", "05c393850524767d13a53627df71beeebb016205eb43bfbd92d14d24ec7a1b51", [:mix], []}, - "mimerl": {:hex, :mimerl, "1.0.2", "993f9b0e084083405ed8252b99460c4f0563e41729ab42d9074fd5e52439be88", [:rebar3], []}, + "idna": {:hex, :idna, "5.0.2", "ac203208ada855d95dc591a764b6e87259cb0e2a364218f215ad662daa8cd6b4", [:rebar3], [{:unicode_util_compat, "0.2.0", [hex: :unicode_util_compat, repo: "hexpm", optional: false]}], "hexpm"}, + "metrics": {:hex, :metrics, "1.0.1", "25f094dea2cda98213cecc3aeff09e940299d950904393b2a29d191c346a8486", [], [], "hexpm"}, + "mime": {:hex, :mime, "1.0.1", "05c393850524767d13a53627df71beeebb016205eb43bfbd92d14d24ec7a1b51", [], [], "hexpm"}, + "mimerl": {:hex, :mimerl, "1.0.2", "993f9b0e084083405ed8252b99460c4f0563e41729ab42d9074fd5e52439be88", [], [], "hexpm"}, "mimetype_parser": {:hex, :mimetype_parser, "0.1.2", "221d2d3f727e89d80de5e1610fc2ce444514aa56f873da1b8fc9c033143e5d6a", [:mix], []}, - "oauth2": {:hex, :oauth2, "0.8.0", "9650476a695a22c75fa9a0a8fed8094a135ba1972a7f421450e9b10cba3547dd", [:mix], [{:hackney, "~> 1.6", [hex: :hackney, optional: false]}]}, - "plug": {:hex, :plug, "1.2.0", "496bef96634a49d7803ab2671482f0c5ce9ce0b7b9bc25bc0ae8e09859dd2004", [:mix], [{:cowboy, "~> 1.0", [hex: :cowboy, optional: true]}, {:mime, "~> 1.0", [hex: :mime, optional: false]}]}, + "oauth2": {:hex, :oauth2, "0.9.1", "cac86d87f35ec835bfe4c791263bdb88c0d8bf1617d64f555ede4e9d913e35ef", [:mix], [{:hackney, "~> 1.7", [hex: :hackney, repo: "hexpm", optional: false]}], "hexpm"}, + "plug": {:hex, :plug, "1.2.0", "496bef96634a49d7803ab2671482f0c5ce9ce0b7b9bc25bc0ae8e09859dd2004", [], [{:cowboy, "~> 1.0", [hex: :cowboy, repo: "hexpm", optional: true]}, {:mime, "~> 1.0", [hex: :mime, repo: "hexpm", optional: false]}], "hexpm"}, "poison": {:hex, :poison, "2.2.0", "4763b69a8a77bd77d26f477d196428b741261a761257ff1cf92753a0d4d24a63", [:mix], []}, - "ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.1", "28a4d65b7f59893bc2c7de786dec1e1555bd742d336043fe644ae956c3497fbe", [:make, :rebar], []}, - "ueberauth": {:hex, :ueberauth, "0.4.0", "bc72d5e5a7bdcbfcf28a756e34630816edabc926303bdce7e171f7ac7ffa4f91", [:mix], [{:plug, "~> 1.2", [hex: :plug, optional: false]}]}} + "ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.1", "28a4d65b7f59893bc2c7de786dec1e1555bd742d336043fe644ae956c3497fbe", [:make, :rebar], [], "hexpm"}, + "ueberauth": {:hex, :ueberauth, "0.4.0", "bc72d5e5a7bdcbfcf28a756e34630816edabc926303bdce7e171f7ac7ffa4f91", [], [{:plug, "~> 1.2", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm"}, + "unicode_util_compat": {:hex, :unicode_util_compat, "0.2.0", "dbbccf6781821b1c0701845eaf966c9b6d83d7c3bfc65ca2b78b88b8678bfa35", [:rebar3], [], "hexpm"}} From 67ef990e0f6d55275fed5b7db1a7cb1cee540be9 Mon Sep 17 00:00:00 2001 From: Sean Callan Date: Tue, 18 Jul 2017 00:13:36 -0600 Subject: [PATCH 02/80] Add OSX and vim files to ignore --- .gitignore | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/.gitignore b/.gitignore index 9607671..ec63485 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,55 @@ + +# Created by https://www.gitignore.io/api/elixir,osx,vim + +### Elixir ### /_build +/cover /deps erl_crash.dump *.ez +*.beam + +### Elixir Patch ### +/doc +### OSX ### +*.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + +### Vim ### +# swap +[._]*.s[a-v][a-z] +[._]*.sw[a-p] +[._]s[a-v][a-z] +[._]sw[a-p] +# session +Session.vim +# temporary +.netrwhist +*~ +# auto-generated tag files +tags + +# End of https://www.gitignore.io/api/elixir,osx,vim From c215a149873cb0db996d39890560a2b37c011486 Mon Sep 17 00:00:00 2001 From: Evadne Wu Date: Fri, 1 Sep 2017 16:45:50 +0100 Subject: [PATCH 03/80] fixes crash on regular OAuth callback errors (#41) - for example, redeeming the code again would crash because the strategy was using OAuth2.Client.get_token!, which will attempt to illegially raise an exception using a OAuth response struct --- lib/ueberauth/strategy/google.ex | 12 ++++++------ lib/ueberauth/strategy/google/oauth.ex | 16 ++++++++++------ 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/lib/ueberauth/strategy/google.ex b/lib/ueberauth/strategy/google.ex index c0dc3c7..ad6126b 100644 --- a/lib/ueberauth/strategy/google.ex +++ b/lib/ueberauth/strategy/google.ex @@ -32,13 +32,13 @@ defmodule Ueberauth.Strategy.Google do Handles the callback from Google. """ def handle_callback!(%Plug.Conn{params: %{"code" => code}} = conn) do + params = [code: code] opts = [redirect_uri: callback_url(conn)] - token = Ueberauth.Strategy.Google.OAuth.get_token!([code: code], opts) - - if token.access_token == nil do - set_errors!(conn, [error(token.other_params["error"], token.other_params["error_description"])]) - else - fetch_user(conn, token) + case Ueberauth.Strategy.Google.OAuth.get_access_token(params, opts) do + {:ok, token} -> + fetch_user(conn, token) + {:error, {error_code, error_description}} -> + set_errors!(conn, [error(error_code, error_description)]) end end diff --git a/lib/ueberauth/strategy/google/oauth.ex b/lib/ueberauth/strategy/google/oauth.ex index 160f584..9f4b654 100644 --- a/lib/ueberauth/strategy/google/oauth.ex +++ b/lib/ueberauth/strategy/google/oauth.ex @@ -51,12 +51,16 @@ defmodule Ueberauth.Strategy.Google.OAuth do |> OAuth2.Client.get(url, headers, opts) end - def get_token!(params \\ [], opts \\ []) do - client = - opts - |> client - |> OAuth2.Client.get_token!(params) - client.token + def get_access_token(params \\ [], opts \\ []) do + case opts |> client |> OAuth2.Client.get_token(params) do + {:error, %{body: %{"error" => error, "error_description" => description}}} -> + {:error, {error, description}} + {:ok, %{token: %{access_token: nil} = token}} -> + %{"error" => error, "error_description" => description} = token.other_params + {:error, {error, description}} + {:ok, %{token: token}} -> + {:ok, token} + end end # Strategy Callbacks From 3a7949fdc5a007c2a124aa0b6a5bd808688d9a68 Mon Sep 17 00:00:00 2001 From: Dave Lucia Date: Fri, 17 Nov 2017 14:07:01 -0500 Subject: [PATCH 04/80] Fix CaseClauseError in fetch_user for {:error, Response} tuple (#43) --- lib/ueberauth/strategy/google.ex | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/ueberauth/strategy/google.ex b/lib/ueberauth/strategy/google.ex index ad6126b..389225c 100644 --- a/lib/ueberauth/strategy/google.ex +++ b/lib/ueberauth/strategy/google.ex @@ -128,6 +128,8 @@ defmodule Ueberauth.Strategy.Google do set_errors!(conn, [error("token", "unauthorized")]) {:ok, %OAuth2.Response{status_code: status_code, body: user}} when status_code in 200..399 -> put_private(conn, :google_user, user) + {:error, %OAuth2.Response{status_code: status_code}} -> + set_errors!(conn, [error("OAuth2", status_code)]) {:error, %OAuth2.Error{reason: reason}} -> set_errors!(conn, [error("OAuth2", reason)]) end From c751fb0b968a36c3b8bc6f49c91da7c32750158a Mon Sep 17 00:00:00 2001 From: Sean Callan Date: Fri, 17 Nov 2017 12:07:53 -0700 Subject: [PATCH 05/80] Release 0.7 --- README.md | 2 +- mix.exs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 1f0aece..57a8522 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ ```elixir def deps do - [{:ueberauth_google, "~> 0.5"}] + [{:ueberauth_google, "~> 0.7"}] end ``` diff --git a/mix.exs b/mix.exs index e545a51..a466037 100644 --- a/mix.exs +++ b/mix.exs @@ -1,7 +1,7 @@ defmodule UeberauthGoogle.Mixfile do use Mix.Project - @version "0.6.0" + @version "0.7.0" @url "https://github.com/ueberauth/ueberauth_google" def project do From 3f5c12609a8a0af050441cbd14648284e55fecc0 Mon Sep 17 00:00:00 2001 From: Chad Gorshing Date: Mon, 8 Jan 2018 09:50:06 -0600 Subject: [PATCH 06/80] Corrected "email" scope. (#46) See https://developers.google.com/identity/protocols/googlescopes for more information in the "Google Sign-In" section. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 57a8522..8740396 100644 --- a/README.md +++ b/README.md @@ -79,7 +79,7 @@ By default the requested scope is "email". Scope can be configured either explic ```elixir config :ueberauth, Ueberauth, providers: [ - google: {Ueberauth.Strategy.Google, [default_scope: "emails profile plus.me"]} + google: {Ueberauth.Strategy.Google, [default_scope: "email profile plus.me"]} ] ``` From 453e52a37ad90a7335e9f2c3f81d4a7543650d2f Mon Sep 17 00:00:00 2001 From: Chad Gorshing Date: Mon, 26 Feb 2018 08:57:24 -0600 Subject: [PATCH 07/80] Update README.md (#47) Corrected a minor typo in the README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 8740396..c8eddea 100644 --- a/README.md +++ b/README.md @@ -66,7 +66,7 @@ For an example implementation see the [Überauth Example](https://github.com/ueb ## Calling -Depending on the configured url you can initial the request through: +Depending on the configured url you can initiate the request through: /auth/google From 5a79321eabbd70326f8e22bf4c5541d591179333 Mon Sep 17 00:00:00 2001 From: Venkat Dinavahi Date: Wed, 25 Apr 2018 00:04:59 -0400 Subject: [PATCH 08/80] replaced deprecated approval_prompt with prompt (#51) --- README.md | 4 ++-- lib/ueberauth/strategy/google.ex | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index c8eddea..35217f9 100644 --- a/README.md +++ b/README.md @@ -83,12 +83,12 @@ config :ueberauth, Ueberauth, ] ``` -You can also pass options such as the `hd` parameter to limit sign-in to a particular Google Apps hosted domain, or `approval_prompt` and `access_type` options to request refresh_tokens and offline access. +You can also pass options such as the `hd` parameter to limit sign-in to a particular Google Apps hosted domain, or `prompt` and `access_type` options to request refresh_tokens and offline access. ```elixir config :ueberauth, Ueberauth, providers: [ - google: {Ueberauth.Strategy.Google, [hd: "example.com", approval_prompt: "force", access_type: "offline"]} + google: {Ueberauth.Strategy.Google, [hd: "example.com", prompt: "select_account", access_type: "offline"]} ] ``` diff --git a/lib/ueberauth/strategy/google.ex b/lib/ueberauth/strategy/google.ex index 389225c..408d281 100644 --- a/lib/ueberauth/strategy/google.ex +++ b/lib/ueberauth/strategy/google.ex @@ -18,7 +18,7 @@ defmodule Ueberauth.Strategy.Google do opts = [scope: scopes] |> with_optional(:hd, conn) - |> with_optional(:approval_prompt, conn) + |> with_optional(:prompt, conn) |> with_optional(:access_type, conn) |> with_param(:access_type, conn) |> with_param(:prompt, conn) From 6b88c9f66cdb73b86360744daef7fc5ac390395a Mon Sep 17 00:00:00 2001 From: henb Date: Thu, 21 Jun 2018 04:34:02 +0300 Subject: [PATCH 09/80] Fixed redirect_uri from config (#55) --- lib/ueberauth/strategy/google.ex | 7 ++++--- lib/ueberauth/strategy/google/oauth.ex | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/ueberauth/strategy/google.ex b/lib/ueberauth/strategy/google.ex index 408d281..9efa3b4 100644 --- a/lib/ueberauth/strategy/google.ex +++ b/lib/ueberauth/strategy/google.ex @@ -15,7 +15,7 @@ defmodule Ueberauth.Strategy.Google do def handle_request!(conn) do scopes = conn.params["scope"] || option(conn, :default_scope) - opts = + params = [scope: scopes] |> with_optional(:hd, conn) |> with_optional(:prompt, conn) @@ -23,9 +23,10 @@ defmodule Ueberauth.Strategy.Google do |> with_param(:access_type, conn) |> with_param(:prompt, conn) |> with_param(:state, conn) - |> Keyword.put(:redirect_uri, callback_url(conn)) - redirect!(conn, Ueberauth.Strategy.Google.OAuth.authorize_url!(opts)) + opts = [redirect_uri: callback_url(conn)] + + redirect!(conn, Ueberauth.Strategy.Google.OAuth.authorize_url!(params, opts)) end @doc """ diff --git a/lib/ueberauth/strategy/google/oauth.ex b/lib/ueberauth/strategy/google/oauth.ex index 9f4b654..02102d5 100644 --- a/lib/ueberauth/strategy/google/oauth.ex +++ b/lib/ueberauth/strategy/google/oauth.ex @@ -29,8 +29,8 @@ defmodule Ueberauth.Strategy.Google.OAuth do opts = @defaults - |> Keyword.merge(config) |> Keyword.merge(opts) + |> Keyword.merge(config) OAuth2.Client.new(opts) end From c1916865fafec10ecf2da5f305af0703de862023 Mon Sep 17 00:00:00 2001 From: Sean Callan Date: Wed, 19 Dec 2018 09:23:30 -0700 Subject: [PATCH 10/80] Release 0.8 --- mix.exs | 2 +- mix.lock | 20 +++++++++++--------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/mix.exs b/mix.exs index a466037..6f9d8fe 100644 --- a/mix.exs +++ b/mix.exs @@ -1,7 +1,7 @@ defmodule UeberauthGoogle.Mixfile do use Mix.Project - @version "0.7.0" + @version "0.8.0" @url "https://github.com/ueberauth/ueberauth_google" def project do diff --git a/mix.lock b/mix.lock index d95b51e..de80c01 100644 --- a/mix.lock +++ b/mix.lock @@ -1,18 +1,20 @@ -%{"bunt": {:hex, :bunt, "0.2.0", "951c6e801e8b1d2cbe58ebbd3e616a869061ddadcc4863d0a2182541acae9a38", [:mix], [], "hexpm"}, +%{ + "bunt": {:hex, :bunt, "0.2.0", "951c6e801e8b1d2cbe58ebbd3e616a869061ddadcc4863d0a2182541acae9a38", [:mix], [], "hexpm"}, "certifi": {:hex, :certifi, "1.2.1", "c3904f192bd5284e5b13f20db3ceac9626e14eeacfbb492e19583cf0e37b22be", [:rebar3], [], "hexpm"}, "credo": {:hex, :credo, "0.8.4", "4e50acac058cf6292d6066e5b0d03da5e1483702e1ccde39abba385c9f03ead4", [:mix], [{:bunt, "~> 0.2.0", [hex: :bunt, repo: "hexpm", optional: false]}], "hexpm"}, - "earmark": {:hex, :earmark, "1.0.1", "2c2cd903bfdc3de3f189bd9a8d4569a075b88a8981ded9a0d95672f6e2b63141", [], [], "hexpm"}, - "ex_doc": {:hex, :ex_doc, "0.13.2", "1059a588d2ad3ffab25a0b85c58abf08e437d3e7a9124ac255e1d15cec68ab79", [], [{:earmark, "~> 1.0", [hex: :earmark, repo: "hexpm", optional: false]}], "hexpm"}, + "earmark": {:hex, :earmark, "1.0.1", "2c2cd903bfdc3de3f189bd9a8d4569a075b88a8981ded9a0d95672f6e2b63141", [:mix], [], "hexpm"}, + "ex_doc": {:hex, :ex_doc, "0.13.2", "1059a588d2ad3ffab25a0b85c58abf08e437d3e7a9124ac255e1d15cec68ab79", [:mix], [{:earmark, "~> 1.0", [hex: :earmark, repo: "hexpm", optional: false]}], "hexpm"}, "hackney": {:hex, :hackney, "1.8.6", "21a725db3569b3fb11a6af17d5c5f654052ce9624219f1317e8639183de4a423", [:rebar3], [{:certifi, "1.2.1", [hex: :certifi, repo: "hexpm", optional: false]}, {:idna, "5.0.2", [hex: :idna, repo: "hexpm", optional: false]}, {:metrics, "1.0.1", [hex: :metrics, repo: "hexpm", optional: false]}, {:mimerl, "1.0.2", [hex: :mimerl, repo: "hexpm", optional: false]}, {:ssl_verify_fun, "1.1.1", [hex: :ssl_verify_fun, repo: "hexpm", optional: false]}], "hexpm"}, "httpoison": {:hex, :httpoison, "0.9.1", "6c2b4eaf2588a6f3ef29663d28c992531ca3f0bc832a97e0359bc822978e1c5d", [:mix], [{:hackney, "~> 1.6.0", [hex: :hackney, optional: false]}]}, "idna": {:hex, :idna, "5.0.2", "ac203208ada855d95dc591a764b6e87259cb0e2a364218f215ad662daa8cd6b4", [:rebar3], [{:unicode_util_compat, "0.2.0", [hex: :unicode_util_compat, repo: "hexpm", optional: false]}], "hexpm"}, - "metrics": {:hex, :metrics, "1.0.1", "25f094dea2cda98213cecc3aeff09e940299d950904393b2a29d191c346a8486", [], [], "hexpm"}, - "mime": {:hex, :mime, "1.0.1", "05c393850524767d13a53627df71beeebb016205eb43bfbd92d14d24ec7a1b51", [], [], "hexpm"}, - "mimerl": {:hex, :mimerl, "1.0.2", "993f9b0e084083405ed8252b99460c4f0563e41729ab42d9074fd5e52439be88", [], [], "hexpm"}, + "metrics": {:hex, :metrics, "1.0.1", "25f094dea2cda98213cecc3aeff09e940299d950904393b2a29d191c346a8486", [:rebar3], [], "hexpm"}, + "mime": {:hex, :mime, "1.0.1", "05c393850524767d13a53627df71beeebb016205eb43bfbd92d14d24ec7a1b51", [:mix], [], "hexpm"}, + "mimerl": {:hex, :mimerl, "1.0.2", "993f9b0e084083405ed8252b99460c4f0563e41729ab42d9074fd5e52439be88", [:rebar3], [], "hexpm"}, "mimetype_parser": {:hex, :mimetype_parser, "0.1.2", "221d2d3f727e89d80de5e1610fc2ce444514aa56f873da1b8fc9c033143e5d6a", [:mix], []}, "oauth2": {:hex, :oauth2, "0.9.1", "cac86d87f35ec835bfe4c791263bdb88c0d8bf1617d64f555ede4e9d913e35ef", [:mix], [{:hackney, "~> 1.7", [hex: :hackney, repo: "hexpm", optional: false]}], "hexpm"}, - "plug": {:hex, :plug, "1.2.0", "496bef96634a49d7803ab2671482f0c5ce9ce0b7b9bc25bc0ae8e09859dd2004", [], [{:cowboy, "~> 1.0", [hex: :cowboy, repo: "hexpm", optional: true]}, {:mime, "~> 1.0", [hex: :mime, repo: "hexpm", optional: false]}], "hexpm"}, + "plug": {:hex, :plug, "1.2.0", "496bef96634a49d7803ab2671482f0c5ce9ce0b7b9bc25bc0ae8e09859dd2004", [:mix], [{:cowboy, "~> 1.0", [hex: :cowboy, repo: "hexpm", optional: true]}, {:mime, "~> 1.0", [hex: :mime, repo: "hexpm", optional: false]}], "hexpm"}, "poison": {:hex, :poison, "2.2.0", "4763b69a8a77bd77d26f477d196428b741261a761257ff1cf92753a0d4d24a63", [:mix], []}, "ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.1", "28a4d65b7f59893bc2c7de786dec1e1555bd742d336043fe644ae956c3497fbe", [:make, :rebar], [], "hexpm"}, - "ueberauth": {:hex, :ueberauth, "0.4.0", "bc72d5e5a7bdcbfcf28a756e34630816edabc926303bdce7e171f7ac7ffa4f91", [], [{:plug, "~> 1.2", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm"}, - "unicode_util_compat": {:hex, :unicode_util_compat, "0.2.0", "dbbccf6781821b1c0701845eaf966c9b6d83d7c3bfc65ca2b78b88b8678bfa35", [:rebar3], [], "hexpm"}} + "ueberauth": {:hex, :ueberauth, "0.4.0", "bc72d5e5a7bdcbfcf28a756e34630816edabc926303bdce7e171f7ac7ffa4f91", [:mix], [{:plug, "~> 1.2", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm"}, + "unicode_util_compat": {:hex, :unicode_util_compat, "0.2.0", "dbbccf6781821b1c0701845eaf966c9b6d83d7c3bfc65ca2b78b88b8678bfa35", [:rebar3], [], "hexpm"}, +} From 26e2a44882593f47898cc17ecfa16d9a6765c471 Mon Sep 17 00:00:00 2001 From: Grant Nelson Date: Wed, 19 Dec 2018 11:25:19 -0500 Subject: [PATCH 11/80] TravisCI minimal config for Elixir projects using Elixir ~>1.3 (#54) * Create travis.yml with language: elixir * Updated .travis.yml Trying again, based on other elixir .travis.yml files and reading the TravisCI docs. * Converted elixir versions to strings in travis.yml --- .travis.yml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..2ae7c1c --- /dev/null +++ b/.travis.yml @@ -0,0 +1,16 @@ +language: elixir + +cache: + directories: + - ~/.hex + - ~/.mix + - deps + +elixir: + - '1.3' + - '1.4' + - '1.5' + - '1.6' + +script: + - mix test From b696c6d188790c5f6a848de828963bd3ff57d508 Mon Sep 17 00:00:00 2001 From: Carsten Zimmermann Date: Thu, 3 Jan 2019 17:07:16 +0100 Subject: [PATCH 12/80] Update release version in README (#57) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 35217f9..e664160 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ ```elixir def deps do - [{:ueberauth_google, "~> 0.7"}] + [{:ueberauth_google, "~> 0.8"}] end ``` From 88b9ae851ffda0d34e991ee85e84a0803f7448d0 Mon Sep 17 00:00:00 2001 From: Evadne Wu Date: Sat, 9 Mar 2019 17:21:43 +0000 Subject: [PATCH 13/80] Amended oAuth strategy to resolve m/f/a tuples (#60) * Amended oAuth strategy to resolve m/f/a tuples - this allows specifying {m, f, a} tuples for things such as Client ID / Client Secret * Moved config resolution to after all values have been merged * Amended Strategy to also derive crednetials from options - This is in addition to deriving from the Environment --- lib/ueberauth/strategy/google.ex | 20 +++++++++++++++----- lib/ueberauth/strategy/google/oauth.ex | 18 +++++++++++------- 2 files changed, 26 insertions(+), 12 deletions(-) diff --git a/lib/ueberauth/strategy/google.ex b/lib/ueberauth/strategy/google.ex index 9efa3b4..c41ebe8 100644 --- a/lib/ueberauth/strategy/google.ex +++ b/lib/ueberauth/strategy/google.ex @@ -24,17 +24,17 @@ defmodule Ueberauth.Strategy.Google do |> with_param(:prompt, conn) |> with_param(:state, conn) - opts = [redirect_uri: callback_url(conn)] - + opts = oauth_client_options_from_conn(conn) redirect!(conn, Ueberauth.Strategy.Google.OAuth.authorize_url!(params, opts)) end - + @doc """ Handles the callback from Google. """ def handle_callback!(%Plug.Conn{params: %{"code" => code}} = conn) do params = [code: code] - opts = [redirect_uri: callback_url(conn)] + opts = oauth_client_options_from_conn(conn) + case Ueberauth.Strategy.Google.OAuth.get_access_token(params, opts) do {:ok, token} -> fetch_user(conn, token) @@ -116,7 +116,6 @@ defmodule Ueberauth.Strategy.Google do } end - defp fetch_user(conn, token) do conn = put_private(conn, :google_token, token) @@ -144,6 +143,17 @@ defmodule Ueberauth.Strategy.Google do if option(conn, key), do: Keyword.put(opts, key, option(conn, key)), else: opts end + defp oauth_client_options_from_conn(conn) do + base_options = [redirect_uri: callback_url(conn)] + request_options = conn.private[:ueberauth_request_options].options + + case {request_options[:client_id], request_options[:client_secret]} do + {nil, _} -> base_options + {_, nil} -> base_options + {id, secret} -> [client_id: id, client_secret: secret] ++ base_options + end + end + defp option(conn, key) do Keyword.get(options(conn), key, Keyword.get(default_options(), key)) end diff --git a/lib/ueberauth/strategy/google/oauth.ex b/lib/ueberauth/strategy/google/oauth.ex index 02102d5..0cec195 100644 --- a/lib/ueberauth/strategy/google/oauth.ex +++ b/lib/ueberauth/strategy/google/oauth.ex @@ -25,13 +25,8 @@ defmodule Ueberauth.Strategy.Google.OAuth do These options are only useful for usage outside the normal callback phase of Ueberauth. """ def client(opts \\ []) do - config = Application.get_env(:ueberauth, Ueberauth.Strategy.Google.OAuth) - - opts = - @defaults - |> Keyword.merge(opts) - |> Keyword.merge(config) - + config = Application.get_env(:ueberauth, __MODULE__, []) + opts = @defaults |> Keyword.merge(opts) |> Keyword.merge(config) |> resolve_values() OAuth2.Client.new(opts) end @@ -75,4 +70,13 @@ defmodule Ueberauth.Strategy.Google.OAuth do |> put_header("Accept", "application/json") |> OAuth2.Strategy.AuthCode.get_token(params, headers) end + + defp resolve_values(list) do + for {key, value} <- list do + {key, resolve_value(value)} + end + end + + defp resolve_value({m, f, a}) when is_atom(m) and is_atom(f), do: apply(m, f, a) + defp resolve_value(v), do: v end From ad0a11016d8ce02726008c9eb58130a1004e50d7 Mon Sep 17 00:00:00 2001 From: Marcin Lewandowski Date: Thu, 14 Mar 2019 20:50:06 +0100 Subject: [PATCH 14/80] Added information about reading client_id/client_secret from MFA to the README --- README.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/README.md b/README.md index e664160..28e6a6a 100644 --- a/README.md +++ b/README.md @@ -33,12 +33,24 @@ 1. Update your provider configuration: + Use that if you want to read client ID/secret from the environment + variables in the compile time: + ```elixir config :ueberauth, Ueberauth.Strategy.Google.OAuth, client_id: System.get_env("GOOGLE_CLIENT_ID"), client_secret: System.get_env("GOOGLE_CLIENT_SECRET") ``` + Use that if you want to read client ID/secret from the environment + variables in the run time: + + ```elixir + config :ueberauth, Ueberauth.Strategy.Google.OAuth, + client_id: {System, :get_env, ["GOOGLE_CLIENT_ID"]}, + client_secret: {System, :get_env, ["GOOGLE_CLIENT_SECRET"]} + ``` + 1. Include the Überauth plug in your controller: ```elixir From c0ff1cb5e89bb0ec8a2964b97f3dadbf8d83034e Mon Sep 17 00:00:00 2001 From: snewcomer Date: Sat, 5 Jan 2019 13:37:18 -0800 Subject: [PATCH 15/80] Set json library on OAuth2 --- lib/ueberauth/strategy/google/oauth.ex | 5 ++++- mix.exs | 2 +- mix.lock | 11 ++++++----- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/lib/ueberauth/strategy/google/oauth.ex b/lib/ueberauth/strategy/google/oauth.ex index 0cec195..d4424cc 100644 --- a/lib/ueberauth/strategy/google/oauth.ex +++ b/lib/ueberauth/strategy/google/oauth.ex @@ -27,7 +27,10 @@ defmodule Ueberauth.Strategy.Google.OAuth do def client(opts \\ []) do config = Application.get_env(:ueberauth, __MODULE__, []) opts = @defaults |> Keyword.merge(opts) |> Keyword.merge(config) |> resolve_values() + json_library = Application.get_env(:ueberauth, :json_library) + OAuth2.Client.new(opts) + |> OAuth2.Client.put_serializer("application/json", json_library) end @doc """ @@ -76,7 +79,7 @@ defmodule Ueberauth.Strategy.Google.OAuth do {key, resolve_value(value)} end end - + defp resolve_value({m, f, a}) when is_atom(m) and is_atom(f), do: apply(m, f, a) defp resolve_value(v), do: v end diff --git a/mix.exs b/mix.exs index 6f9d8fe..a7108d1 100644 --- a/mix.exs +++ b/mix.exs @@ -25,7 +25,7 @@ defmodule UeberauthGoogle.Mixfile do defp deps do [ - {:oauth2, "~> 0.9"}, + {:oauth2, github: "scrogson/oauth2", branch: "register_serializers"}, {:ueberauth, "~> 0.4"}, {:credo, "~> 0.8", only: [:dev, :test]}, diff --git a/mix.lock b/mix.lock index de80c01..3bd8e19 100644 --- a/mix.lock +++ b/mix.lock @@ -1,20 +1,21 @@ %{ "bunt": {:hex, :bunt, "0.2.0", "951c6e801e8b1d2cbe58ebbd3e616a869061ddadcc4863d0a2182541acae9a38", [:mix], [], "hexpm"}, - "certifi": {:hex, :certifi, "1.2.1", "c3904f192bd5284e5b13f20db3ceac9626e14eeacfbb492e19583cf0e37b22be", [:rebar3], [], "hexpm"}, + "certifi": {:hex, :certifi, "2.3.1", "d0f424232390bf47d82da8478022301c561cf6445b5b5fb6a84d49a9e76d2639", [:rebar3], [{:parse_trans, "3.2.0", [hex: :parse_trans, repo: "hexpm", optional: false]}], "hexpm"}, "credo": {:hex, :credo, "0.8.4", "4e50acac058cf6292d6066e5b0d03da5e1483702e1ccde39abba385c9f03ead4", [:mix], [{:bunt, "~> 0.2.0", [hex: :bunt, repo: "hexpm", optional: false]}], "hexpm"}, "earmark": {:hex, :earmark, "1.0.1", "2c2cd903bfdc3de3f189bd9a8d4569a075b88a8981ded9a0d95672f6e2b63141", [:mix], [], "hexpm"}, "ex_doc": {:hex, :ex_doc, "0.13.2", "1059a588d2ad3ffab25a0b85c58abf08e437d3e7a9124ac255e1d15cec68ab79", [:mix], [{:earmark, "~> 1.0", [hex: :earmark, repo: "hexpm", optional: false]}], "hexpm"}, - "hackney": {:hex, :hackney, "1.8.6", "21a725db3569b3fb11a6af17d5c5f654052ce9624219f1317e8639183de4a423", [:rebar3], [{:certifi, "1.2.1", [hex: :certifi, repo: "hexpm", optional: false]}, {:idna, "5.0.2", [hex: :idna, repo: "hexpm", optional: false]}, {:metrics, "1.0.1", [hex: :metrics, repo: "hexpm", optional: false]}, {:mimerl, "1.0.2", [hex: :mimerl, repo: "hexpm", optional: false]}, {:ssl_verify_fun, "1.1.1", [hex: :ssl_verify_fun, repo: "hexpm", optional: false]}], "hexpm"}, + "hackney": {:hex, :hackney, "1.13.0", "24edc8cd2b28e1c652593833862435c80661834f6c9344e84b6a2255e7aeef03", [:rebar3], [{:certifi, "2.3.1", [hex: :certifi, repo: "hexpm", optional: false]}, {:idna, "5.1.2", [hex: :idna, repo: "hexpm", optional: false]}, {:metrics, "1.0.1", [hex: :metrics, repo: "hexpm", optional: false]}, {:mimerl, "1.0.2", [hex: :mimerl, repo: "hexpm", optional: false]}, {:ssl_verify_fun, "1.1.1", [hex: :ssl_verify_fun, repo: "hexpm", optional: false]}], "hexpm"}, "httpoison": {:hex, :httpoison, "0.9.1", "6c2b4eaf2588a6f3ef29663d28c992531ca3f0bc832a97e0359bc822978e1c5d", [:mix], [{:hackney, "~> 1.6.0", [hex: :hackney, optional: false]}]}, - "idna": {:hex, :idna, "5.0.2", "ac203208ada855d95dc591a764b6e87259cb0e2a364218f215ad662daa8cd6b4", [:rebar3], [{:unicode_util_compat, "0.2.0", [hex: :unicode_util_compat, repo: "hexpm", optional: false]}], "hexpm"}, + "idna": {:hex, :idna, "5.1.2", "e21cb58a09f0228a9e0b95eaa1217f1bcfc31a1aaa6e1fdf2f53a33f7dbd9494", [:rebar3], [{:unicode_util_compat, "0.3.1", [hex: :unicode_util_compat, repo: "hexpm", optional: false]}], "hexpm"}, "metrics": {:hex, :metrics, "1.0.1", "25f094dea2cda98213cecc3aeff09e940299d950904393b2a29d191c346a8486", [:rebar3], [], "hexpm"}, "mime": {:hex, :mime, "1.0.1", "05c393850524767d13a53627df71beeebb016205eb43bfbd92d14d24ec7a1b51", [:mix], [], "hexpm"}, "mimerl": {:hex, :mimerl, "1.0.2", "993f9b0e084083405ed8252b99460c4f0563e41729ab42d9074fd5e52439be88", [:rebar3], [], "hexpm"}, "mimetype_parser": {:hex, :mimetype_parser, "0.1.2", "221d2d3f727e89d80de5e1610fc2ce444514aa56f873da1b8fc9c033143e5d6a", [:mix], []}, - "oauth2": {:hex, :oauth2, "0.9.1", "cac86d87f35ec835bfe4c791263bdb88c0d8bf1617d64f555ede4e9d913e35ef", [:mix], [{:hackney, "~> 1.7", [hex: :hackney, repo: "hexpm", optional: false]}], "hexpm"}, + "oauth2": {:git, "https://github.com/scrogson/oauth2.git", "92aa2ea25e5df0e6c0fc89f7d918704f72b71988", [branch: "register_serializers"]}, + "parse_trans": {:hex, :parse_trans, "3.2.0", "2adfa4daf80c14dc36f522cf190eb5c4ee3e28008fc6394397c16f62a26258c2", [:rebar3], [], "hexpm"}, "plug": {:hex, :plug, "1.2.0", "496bef96634a49d7803ab2671482f0c5ce9ce0b7b9bc25bc0ae8e09859dd2004", [:mix], [{:cowboy, "~> 1.0", [hex: :cowboy, repo: "hexpm", optional: true]}, {:mime, "~> 1.0", [hex: :mime, repo: "hexpm", optional: false]}], "hexpm"}, "poison": {:hex, :poison, "2.2.0", "4763b69a8a77bd77d26f477d196428b741261a761257ff1cf92753a0d4d24a63", [:mix], []}, "ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.1", "28a4d65b7f59893bc2c7de786dec1e1555bd742d336043fe644ae956c3497fbe", [:make, :rebar], [], "hexpm"}, "ueberauth": {:hex, :ueberauth, "0.4.0", "bc72d5e5a7bdcbfcf28a756e34630816edabc926303bdce7e171f7ac7ffa4f91", [:mix], [{:plug, "~> 1.2", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm"}, - "unicode_util_compat": {:hex, :unicode_util_compat, "0.2.0", "dbbccf6781821b1c0701845eaf966c9b6d83d7c3bfc65ca2b78b88b8678bfa35", [:rebar3], [], "hexpm"}, + "unicode_util_compat": {:hex, :unicode_util_compat, "0.3.1", "a1f612a7b512638634a603c8f401892afbf99b8ce93a45041f8aaca99cadb85e", [:rebar3], [], "hexpm"}, } From 43514034a35b0de07893a7f783a7a17c67a6dc2b Mon Sep 17 00:00:00 2001 From: snewcomer Date: Sat, 5 Jan 2019 22:46:04 -0800 Subject: [PATCH 16/80] use json_library hook. Need new release of ueberauth with new hooks --- mix.exs | 2 +- mix.lock | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/mix.exs b/mix.exs index a7108d1..d2a6b0c 100644 --- a/mix.exs +++ b/mix.exs @@ -26,7 +26,7 @@ defmodule UeberauthGoogle.Mixfile do defp deps do [ {:oauth2, github: "scrogson/oauth2", branch: "register_serializers"}, - {:ueberauth, "~> 0.4"}, + {:ueberauth, github: "ueberauth/ueberauth"}, {:credo, "~> 0.8", only: [:dev, :test]}, {:earmark, ">= 0.0.0", only: :dev}, diff --git a/mix.lock b/mix.lock index 3bd8e19..c4539c0 100644 --- a/mix.lock +++ b/mix.lock @@ -8,14 +8,14 @@ "httpoison": {:hex, :httpoison, "0.9.1", "6c2b4eaf2588a6f3ef29663d28c992531ca3f0bc832a97e0359bc822978e1c5d", [:mix], [{:hackney, "~> 1.6.0", [hex: :hackney, optional: false]}]}, "idna": {:hex, :idna, "5.1.2", "e21cb58a09f0228a9e0b95eaa1217f1bcfc31a1aaa6e1fdf2f53a33f7dbd9494", [:rebar3], [{:unicode_util_compat, "0.3.1", [hex: :unicode_util_compat, repo: "hexpm", optional: false]}], "hexpm"}, "metrics": {:hex, :metrics, "1.0.1", "25f094dea2cda98213cecc3aeff09e940299d950904393b2a29d191c346a8486", [:rebar3], [], "hexpm"}, - "mime": {:hex, :mime, "1.0.1", "05c393850524767d13a53627df71beeebb016205eb43bfbd92d14d24ec7a1b51", [:mix], [], "hexpm"}, + "mime": {:hex, :mime, "1.3.1", "30ce04ab3175b6ad0bdce0035cba77bba68b813d523d1aac73d9781b4d193cf8", [:mix], [], "hexpm"}, "mimerl": {:hex, :mimerl, "1.0.2", "993f9b0e084083405ed8252b99460c4f0563e41729ab42d9074fd5e52439be88", [:rebar3], [], "hexpm"}, "mimetype_parser": {:hex, :mimetype_parser, "0.1.2", "221d2d3f727e89d80de5e1610fc2ce444514aa56f873da1b8fc9c033143e5d6a", [:mix], []}, "oauth2": {:git, "https://github.com/scrogson/oauth2.git", "92aa2ea25e5df0e6c0fc89f7d918704f72b71988", [branch: "register_serializers"]}, "parse_trans": {:hex, :parse_trans, "3.2.0", "2adfa4daf80c14dc36f522cf190eb5c4ee3e28008fc6394397c16f62a26258c2", [:rebar3], [], "hexpm"}, - "plug": {:hex, :plug, "1.2.0", "496bef96634a49d7803ab2671482f0c5ce9ce0b7b9bc25bc0ae8e09859dd2004", [:mix], [{:cowboy, "~> 1.0", [hex: :cowboy, repo: "hexpm", optional: true]}, {:mime, "~> 1.0", [hex: :mime, repo: "hexpm", optional: false]}], "hexpm"}, + "plug": {:hex, :plug, "1.5.1", "1ff35bdecfb616f1a2b1c935ab5e4c47303f866cb929d2a76f0541e553a58165", [:mix], [{:cowboy, "~> 1.0.1 or ~> 1.1 or ~> 2.3", [hex: :cowboy, repo: "hexpm", optional: true]}, {:mime, "~> 1.0", [hex: :mime, repo: "hexpm", optional: false]}], "hexpm"}, "poison": {:hex, :poison, "2.2.0", "4763b69a8a77bd77d26f477d196428b741261a761257ff1cf92753a0d4d24a63", [:mix], []}, "ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.1", "28a4d65b7f59893bc2c7de786dec1e1555bd742d336043fe644ae956c3497fbe", [:make, :rebar], [], "hexpm"}, - "ueberauth": {:hex, :ueberauth, "0.4.0", "bc72d5e5a7bdcbfcf28a756e34630816edabc926303bdce7e171f7ac7ffa4f91", [:mix], [{:plug, "~> 1.2", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm"}, + "ueberauth": {:git, "https://github.com/ueberauth/ueberauth.git", "2087e031c3ff486e0aafb4684659a3e224d2aa29", []}, "unicode_util_compat": {:hex, :unicode_util_compat, "0.3.1", "a1f612a7b512638634a603c8f401892afbf99b8ce93a45041f8aaca99cadb85e", [:rebar3], [], "hexpm"}, } From a728ae445b02c472dabf3995f5f660c28a514430 Mon Sep 17 00:00:00 2001 From: snewcomer Date: Fri, 15 Mar 2019 07:30:35 -0700 Subject: [PATCH 17/80] Update to latest ueberauth and oauth2 --- mix.exs | 4 ++-- mix.lock | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/mix.exs b/mix.exs index d2a6b0c..3e19702 100644 --- a/mix.exs +++ b/mix.exs @@ -25,8 +25,8 @@ defmodule UeberauthGoogle.Mixfile do defp deps do [ - {:oauth2, github: "scrogson/oauth2", branch: "register_serializers"}, - {:ueberauth, github: "ueberauth/ueberauth"}, + {:oauth2, "~> 1.0.0"}, + {:ueberauth, "~> 0.6.0"}, {:credo, "~> 0.8", only: [:dev, :test]}, {:earmark, ">= 0.0.0", only: :dev}, diff --git a/mix.lock b/mix.lock index c4539c0..5ff23bf 100644 --- a/mix.lock +++ b/mix.lock @@ -11,11 +11,11 @@ "mime": {:hex, :mime, "1.3.1", "30ce04ab3175b6ad0bdce0035cba77bba68b813d523d1aac73d9781b4d193cf8", [:mix], [], "hexpm"}, "mimerl": {:hex, :mimerl, "1.0.2", "993f9b0e084083405ed8252b99460c4f0563e41729ab42d9074fd5e52439be88", [:rebar3], [], "hexpm"}, "mimetype_parser": {:hex, :mimetype_parser, "0.1.2", "221d2d3f727e89d80de5e1610fc2ce444514aa56f873da1b8fc9c033143e5d6a", [:mix], []}, - "oauth2": {:git, "https://github.com/scrogson/oauth2.git", "92aa2ea25e5df0e6c0fc89f7d918704f72b71988", [branch: "register_serializers"]}, + "oauth2": {:hex, :oauth2, "1.0.0", "7ae134c369bb9f7e96ed9404d12f34e938daa14745f1601876526599be4c80f2", [:mix], [{:hackney, "~> 1.13.0", [hex: :hackney, repo: "hexpm", optional: false]}], "hexpm"}, "parse_trans": {:hex, :parse_trans, "3.2.0", "2adfa4daf80c14dc36f522cf190eb5c4ee3e28008fc6394397c16f62a26258c2", [:rebar3], [], "hexpm"}, "plug": {:hex, :plug, "1.5.1", "1ff35bdecfb616f1a2b1c935ab5e4c47303f866cb929d2a76f0541e553a58165", [:mix], [{:cowboy, "~> 1.0.1 or ~> 1.1 or ~> 2.3", [hex: :cowboy, repo: "hexpm", optional: true]}, {:mime, "~> 1.0", [hex: :mime, repo: "hexpm", optional: false]}], "hexpm"}, "poison": {:hex, :poison, "2.2.0", "4763b69a8a77bd77d26f477d196428b741261a761257ff1cf92753a0d4d24a63", [:mix], []}, "ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.1", "28a4d65b7f59893bc2c7de786dec1e1555bd742d336043fe644ae956c3497fbe", [:make, :rebar], [], "hexpm"}, - "ueberauth": {:git, "https://github.com/ueberauth/ueberauth.git", "2087e031c3ff486e0aafb4684659a3e224d2aa29", []}, + "ueberauth": {:hex, :ueberauth, "0.6.1", "9e90d3337dddf38b1ca2753aca9b1e53d8a52b890191cdc55240247c89230412", [:mix], [{:plug, "~> 1.5", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm"}, "unicode_util_compat": {:hex, :unicode_util_compat, "0.3.1", "a1f612a7b512638634a603c8f401892afbf99b8ce93a45041f8aaca99cadb85e", [:rebar3], [], "hexpm"}, } From 6c1b38332954153ba8620612a5e8dc17b308ac58 Mon Sep 17 00:00:00 2001 From: snewcomer Date: Fri, 15 Mar 2019 07:32:17 -0700 Subject: [PATCH 18/80] removed unused deps from lockfile --- mix.lock | 3 --- 1 file changed, 3 deletions(-) diff --git a/mix.lock b/mix.lock index 5ff23bf..23f98f6 100644 --- a/mix.lock +++ b/mix.lock @@ -5,16 +5,13 @@ "earmark": {:hex, :earmark, "1.0.1", "2c2cd903bfdc3de3f189bd9a8d4569a075b88a8981ded9a0d95672f6e2b63141", [:mix], [], "hexpm"}, "ex_doc": {:hex, :ex_doc, "0.13.2", "1059a588d2ad3ffab25a0b85c58abf08e437d3e7a9124ac255e1d15cec68ab79", [:mix], [{:earmark, "~> 1.0", [hex: :earmark, repo: "hexpm", optional: false]}], "hexpm"}, "hackney": {:hex, :hackney, "1.13.0", "24edc8cd2b28e1c652593833862435c80661834f6c9344e84b6a2255e7aeef03", [:rebar3], [{:certifi, "2.3.1", [hex: :certifi, repo: "hexpm", optional: false]}, {:idna, "5.1.2", [hex: :idna, repo: "hexpm", optional: false]}, {:metrics, "1.0.1", [hex: :metrics, repo: "hexpm", optional: false]}, {:mimerl, "1.0.2", [hex: :mimerl, repo: "hexpm", optional: false]}, {:ssl_verify_fun, "1.1.1", [hex: :ssl_verify_fun, repo: "hexpm", optional: false]}], "hexpm"}, - "httpoison": {:hex, :httpoison, "0.9.1", "6c2b4eaf2588a6f3ef29663d28c992531ca3f0bc832a97e0359bc822978e1c5d", [:mix], [{:hackney, "~> 1.6.0", [hex: :hackney, optional: false]}]}, "idna": {:hex, :idna, "5.1.2", "e21cb58a09f0228a9e0b95eaa1217f1bcfc31a1aaa6e1fdf2f53a33f7dbd9494", [:rebar3], [{:unicode_util_compat, "0.3.1", [hex: :unicode_util_compat, repo: "hexpm", optional: false]}], "hexpm"}, "metrics": {:hex, :metrics, "1.0.1", "25f094dea2cda98213cecc3aeff09e940299d950904393b2a29d191c346a8486", [:rebar3], [], "hexpm"}, "mime": {:hex, :mime, "1.3.1", "30ce04ab3175b6ad0bdce0035cba77bba68b813d523d1aac73d9781b4d193cf8", [:mix], [], "hexpm"}, "mimerl": {:hex, :mimerl, "1.0.2", "993f9b0e084083405ed8252b99460c4f0563e41729ab42d9074fd5e52439be88", [:rebar3], [], "hexpm"}, - "mimetype_parser": {:hex, :mimetype_parser, "0.1.2", "221d2d3f727e89d80de5e1610fc2ce444514aa56f873da1b8fc9c033143e5d6a", [:mix], []}, "oauth2": {:hex, :oauth2, "1.0.0", "7ae134c369bb9f7e96ed9404d12f34e938daa14745f1601876526599be4c80f2", [:mix], [{:hackney, "~> 1.13.0", [hex: :hackney, repo: "hexpm", optional: false]}], "hexpm"}, "parse_trans": {:hex, :parse_trans, "3.2.0", "2adfa4daf80c14dc36f522cf190eb5c4ee3e28008fc6394397c16f62a26258c2", [:rebar3], [], "hexpm"}, "plug": {:hex, :plug, "1.5.1", "1ff35bdecfb616f1a2b1c935ab5e4c47303f866cb929d2a76f0541e553a58165", [:mix], [{:cowboy, "~> 1.0.1 or ~> 1.1 or ~> 2.3", [hex: :cowboy, repo: "hexpm", optional: true]}, {:mime, "~> 1.0", [hex: :mime, repo: "hexpm", optional: false]}], "hexpm"}, - "poison": {:hex, :poison, "2.2.0", "4763b69a8a77bd77d26f477d196428b741261a761257ff1cf92753a0d4d24a63", [:mix], []}, "ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.1", "28a4d65b7f59893bc2c7de786dec1e1555bd742d336043fe644ae956c3497fbe", [:make, :rebar], [], "hexpm"}, "ueberauth": {:hex, :ueberauth, "0.6.1", "9e90d3337dddf38b1ca2753aca9b1e53d8a52b890191cdc55240247c89230412", [:mix], [{:plug, "~> 1.5", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm"}, "unicode_util_compat": {:hex, :unicode_util_compat, "0.3.1", "a1f612a7b512638634a603c8f401892afbf99b8ce93a45041f8aaca99cadb85e", [:rebar3], [], "hexpm"}, From 381bc298dd769a4f85e6d4863a325688ce440c91 Mon Sep 17 00:00:00 2001 From: snewcomer Date: Fri, 15 Mar 2019 07:35:48 -0700 Subject: [PATCH 19/80] remove space --- lib/ueberauth/strategy/google/oauth.ex | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/ueberauth/strategy/google/oauth.ex b/lib/ueberauth/strategy/google/oauth.ex index d4424cc..64bec93 100644 --- a/lib/ueberauth/strategy/google/oauth.ex +++ b/lib/ueberauth/strategy/google/oauth.ex @@ -79,7 +79,6 @@ defmodule Ueberauth.Strategy.Google.OAuth do {key, resolve_value(value)} end end - defp resolve_value({m, f, a}) when is_atom(m) and is_atom(f), do: apply(m, f, a) defp resolve_value(v), do: v end From 34fe5dc36edc0ad175aefe45185fc4ad4b56ffe2 Mon Sep 17 00:00:00 2001 From: snewcomer Date: Fri, 15 Mar 2019 07:37:18 -0700 Subject: [PATCH 20/80] Revert "remove space" This reverts commit 381bc298dd769a4f85e6d4863a325688ce440c91. --- lib/ueberauth/strategy/google/oauth.ex | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/ueberauth/strategy/google/oauth.ex b/lib/ueberauth/strategy/google/oauth.ex index 64bec93..d4424cc 100644 --- a/lib/ueberauth/strategy/google/oauth.ex +++ b/lib/ueberauth/strategy/google/oauth.ex @@ -79,6 +79,7 @@ defmodule Ueberauth.Strategy.Google.OAuth do {key, resolve_value(value)} end end + defp resolve_value({m, f, a}) when is_atom(m) and is_atom(f), do: apply(m, f, a) defp resolve_value(v), do: v end From 6525cb8f99adaccce264486923382f59be1ec14b Mon Sep 17 00:00:00 2001 From: snewcomer Date: Fri, 15 Mar 2019 10:36:00 -0700 Subject: [PATCH 21/80] actually use json_library method --- lib/ueberauth/strategy/google/oauth.ex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ueberauth/strategy/google/oauth.ex b/lib/ueberauth/strategy/google/oauth.ex index d4424cc..986ad9d 100644 --- a/lib/ueberauth/strategy/google/oauth.ex +++ b/lib/ueberauth/strategy/google/oauth.ex @@ -27,7 +27,7 @@ defmodule Ueberauth.Strategy.Google.OAuth do def client(opts \\ []) do config = Application.get_env(:ueberauth, __MODULE__, []) opts = @defaults |> Keyword.merge(opts) |> Keyword.merge(config) |> resolve_values() - json_library = Application.get_env(:ueberauth, :json_library) + json_library = Ueberauth.json_library() OAuth2.Client.new(opts) |> OAuth2.Client.put_serializer("application/json", json_library) From c2cc7036ce74cf28fab77d5f8982f66c5505b3d0 Mon Sep 17 00:00:00 2001 From: Andy Kent Date: Sun, 7 Jul 2019 22:23:15 +0100 Subject: [PATCH 22/80] Add support for optional login_hint param --- lib/ueberauth/strategy/google.ex | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/ueberauth/strategy/google.ex b/lib/ueberauth/strategy/google.ex index c41ebe8..83c4ed8 100644 --- a/lib/ueberauth/strategy/google.ex +++ b/lib/ueberauth/strategy/google.ex @@ -20,14 +20,16 @@ defmodule Ueberauth.Strategy.Google do |> with_optional(:hd, conn) |> with_optional(:prompt, conn) |> with_optional(:access_type, conn) + |> with_optional(:login_hint, conn) |> with_param(:access_type, conn) |> with_param(:prompt, conn) + |> with_param(:login_hint, conn) |> with_param(:state, conn) opts = oauth_client_options_from_conn(conn) redirect!(conn, Ueberauth.Strategy.Google.OAuth.authorize_url!(params, opts)) end - + @doc """ Handles the callback from Google. """ @@ -146,7 +148,7 @@ defmodule Ueberauth.Strategy.Google do defp oauth_client_options_from_conn(conn) do base_options = [redirect_uri: callback_url(conn)] request_options = conn.private[:ueberauth_request_options].options - + case {request_options[:client_id], request_options[:client_secret]} do {nil, _} -> base_options {_, nil} -> base_options From ecc0cf380d16455c9cc34b8eeefff82936b34aa3 Mon Sep 17 00:00:00 2001 From: foxtrod Date: Thu, 1 Aug 2019 11:48:25 +0300 Subject: [PATCH 23/80] add birthday --- lib/ueberauth/strategy/google.ex | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/ueberauth/strategy/google.ex b/lib/ueberauth/strategy/google.ex index c41ebe8..a4caa42 100644 --- a/lib/ueberauth/strategy/google.ex +++ b/lib/ueberauth/strategy/google.ex @@ -97,6 +97,7 @@ defmodule Ueberauth.Strategy.Google do image: user["picture"], last_name: user["family_name"], name: user["name"], + birthday: user["birthday"], urls: %{ profile: user["profile"], website: user["hd"] From 41ba33f53e2acea390c1bb00de5ce1c1fd71d538 Mon Sep 17 00:00:00 2001 From: foxtrod Date: Fri, 2 Aug 2019 13:38:16 +0300 Subject: [PATCH 24/80] change mix --- mix.exs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mix.exs b/mix.exs index 3e19702..a0fce25 100644 --- a/mix.exs +++ b/mix.exs @@ -26,7 +26,7 @@ defmodule UeberauthGoogle.Mixfile do defp deps do [ {:oauth2, "~> 1.0.0"}, - {:ueberauth, "~> 0.6.0"}, + {:ueberauth, "~> 0.6.0", git: "https://github.com/foxtrod/ueberauth.git"}, {:credo, "~> 0.8", only: [:dev, :test]}, {:earmark, ">= 0.0.0", only: :dev}, From dee3f5beab310eb5eed1dd2e17bc7ef054311ab5 Mon Sep 17 00:00:00 2001 From: Yordis Prieto Lazo Date: Sat, 3 Aug 2019 16:24:09 -0700 Subject: [PATCH 25/80] Fix markdown --- CHANGELOG.md | 26 ++++++++++++++------------ CONTRIBUTING.md | 1 + 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 290cbb1..b206c0d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,22 +1,24 @@ -# v 0.6.0 +# Changelog -* Add support for access_type per request using url parameter +## v0.6.0 -# v 0.5.0 +* Add support for access_type per request using url parameter. + +## v0.5.0 * Add support for new params: access_type, approval_prompt, state. -* Fix Elixir warnings +* Fix Elixir warnings. -# v 0.4.0 +## v0.4.0 -* Target Elixir 1.3 and greater -* Fix OAuth bug with 0.6.0 pin +* Target Elixir 1.3 and greater. +* Fix OAuth bug with 0.6.0 pin. -# v 0.3.0 +## v0.3.0 -* Use OpenID endpoint for profile information -* Update authorize and token URLs +* Use OpenID endpoint for profile information. +* Update authorize and token URLs. -# v 0.2.0 +## v0.2.0 -* Release 0.2.0 to follow Ueberauth +* Release 0.2.0 to follow Ueberauth. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 98fada1..b4e2d6b 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,6 +1,7 @@ # Contributing to Ueberauth Google ## Pull Requests Welcome + 1. Fork ueberauth_google 2. Create a topic branch 3. Make logically-grouped commits with clear commit messages From 3feed4b1fbac37945ffe4894ed0532d6c4f5d0f0 Mon Sep 17 00:00:00 2001 From: Yordis Prieto Lazo Date: Sat, 3 Aug 2019 16:28:57 -0700 Subject: [PATCH 26/80] Bump version and add changelog --- CHANGELOG.md | 9 +++++++++ mix.exs | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b206c0d..8eb972a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,14 @@ # Changelog +## v0.9.0 + +### Enhancement + +* Add support for optional login_hint param [#61](https://github.com/ueberauth/ueberauth_google/pull/61) +* Use json_library method from Ueberauth config [#58](https://github.com/ueberauth/ueberauth_google/pull/58) +* Allows specifying `{m, f, a}` tuples for things such as Client ID + and Client Secret [#60](https://github.com/ueberauth/ueberauth_google/pull/60) + ## v0.6.0 * Add support for access_type per request using url parameter. diff --git a/mix.exs b/mix.exs index 3e19702..c14299f 100644 --- a/mix.exs +++ b/mix.exs @@ -1,7 +1,7 @@ defmodule UeberauthGoogle.Mixfile do use Mix.Project - @version "0.8.0" + @version "0.9.0" @url "https://github.com/ueberauth/ueberauth_google" def project do From 98d3e735ca745d507d312179cd53d71245a90cd3 Mon Sep 17 00:00:00 2001 From: Yordis Prieto Lazo Date: Sun, 4 Aug 2019 21:02:02 -0700 Subject: [PATCH 27/80] Fix elixir versions --- .travis.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 2ae7c1c..523cdf0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,10 +7,8 @@ cache: - deps elixir: - - '1.3' - - '1.4' - - '1.5' - - '1.6' + - '1.8' + - '1.9' script: - mix test From 1456715985289468d2b40cc18d7e8b4edc82e741 Mon Sep 17 00:00:00 2001 From: Tobias Pfeiffer Date: Wed, 21 Aug 2019 09:10:11 +0200 Subject: [PATCH 28/80] Allow newest oauth2 client with security fixes oauth2 has a recent possibly backwards incompatible release that makes sure the spec is followed and authorization headers are respected (https://github.com/scrogson/oauth2/blob/master/CHANGELOG.md#v200-2019-07-15) This fixed scrogson/oauth2#128 hence I think it's important to include. Decided to not require 2.x as that might conflict too hard with other libraries. Also decided to allow minor version bumps as @scrogson seems to be good about semver <3 As #66 isn't merged yet I'd like it if this could get in with the release. fixes #67 --- mix.exs | 2 +- mix.lock | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/mix.exs b/mix.exs index 3e19702..4418f97 100644 --- a/mix.exs +++ b/mix.exs @@ -25,7 +25,7 @@ defmodule UeberauthGoogle.Mixfile do defp deps do [ - {:oauth2, "~> 1.0.0"}, + {:oauth2, "~> 1.0 or ~> 2.0"}, {:ueberauth, "~> 0.6.0"}, {:credo, "~> 0.8", only: [:dev, :test]}, diff --git a/mix.lock b/mix.lock index 23f98f6..757dfcf 100644 --- a/mix.lock +++ b/mix.lock @@ -1,18 +1,18 @@ %{ "bunt": {:hex, :bunt, "0.2.0", "951c6e801e8b1d2cbe58ebbd3e616a869061ddadcc4863d0a2182541acae9a38", [:mix], [], "hexpm"}, - "certifi": {:hex, :certifi, "2.3.1", "d0f424232390bf47d82da8478022301c561cf6445b5b5fb6a84d49a9e76d2639", [:rebar3], [{:parse_trans, "3.2.0", [hex: :parse_trans, repo: "hexpm", optional: false]}], "hexpm"}, + "certifi": {:hex, :certifi, "2.5.1", "867ce347f7c7d78563450a18a6a28a8090331e77fa02380b4a21962a65d36ee5", [:rebar3], [{:parse_trans, "~>3.3", [hex: :parse_trans, repo: "hexpm", optional: false]}], "hexpm"}, "credo": {:hex, :credo, "0.8.4", "4e50acac058cf6292d6066e5b0d03da5e1483702e1ccde39abba385c9f03ead4", [:mix], [{:bunt, "~> 0.2.0", [hex: :bunt, repo: "hexpm", optional: false]}], "hexpm"}, "earmark": {:hex, :earmark, "1.0.1", "2c2cd903bfdc3de3f189bd9a8d4569a075b88a8981ded9a0d95672f6e2b63141", [:mix], [], "hexpm"}, "ex_doc": {:hex, :ex_doc, "0.13.2", "1059a588d2ad3ffab25a0b85c58abf08e437d3e7a9124ac255e1d15cec68ab79", [:mix], [{:earmark, "~> 1.0", [hex: :earmark, repo: "hexpm", optional: false]}], "hexpm"}, - "hackney": {:hex, :hackney, "1.13.0", "24edc8cd2b28e1c652593833862435c80661834f6c9344e84b6a2255e7aeef03", [:rebar3], [{:certifi, "2.3.1", [hex: :certifi, repo: "hexpm", optional: false]}, {:idna, "5.1.2", [hex: :idna, repo: "hexpm", optional: false]}, {:metrics, "1.0.1", [hex: :metrics, repo: "hexpm", optional: false]}, {:mimerl, "1.0.2", [hex: :mimerl, repo: "hexpm", optional: false]}, {:ssl_verify_fun, "1.1.1", [hex: :ssl_verify_fun, repo: "hexpm", optional: false]}], "hexpm"}, - "idna": {:hex, :idna, "5.1.2", "e21cb58a09f0228a9e0b95eaa1217f1bcfc31a1aaa6e1fdf2f53a33f7dbd9494", [:rebar3], [{:unicode_util_compat, "0.3.1", [hex: :unicode_util_compat, repo: "hexpm", optional: false]}], "hexpm"}, + "hackney": {:hex, :hackney, "1.15.1", "9f8f471c844b8ce395f7b6d8398139e26ddca9ebc171a8b91342ee15a19963f4", [:rebar3], [{:certifi, "2.5.1", [hex: :certifi, repo: "hexpm", optional: false]}, {:idna, "6.0.0", [hex: :idna, repo: "hexpm", optional: false]}, {:metrics, "1.0.1", [hex: :metrics, repo: "hexpm", optional: false]}, {:mimerl, "~>1.1", [hex: :mimerl, repo: "hexpm", optional: false]}, {:ssl_verify_fun, "1.1.4", [hex: :ssl_verify_fun, repo: "hexpm", optional: false]}], "hexpm"}, + "idna": {:hex, :idna, "6.0.0", "689c46cbcdf3524c44d5f3dde8001f364cd7608a99556d8fbd8239a5798d4c10", [:rebar3], [{:unicode_util_compat, "0.4.1", [hex: :unicode_util_compat, repo: "hexpm", optional: false]}], "hexpm"}, "metrics": {:hex, :metrics, "1.0.1", "25f094dea2cda98213cecc3aeff09e940299d950904393b2a29d191c346a8486", [:rebar3], [], "hexpm"}, "mime": {:hex, :mime, "1.3.1", "30ce04ab3175b6ad0bdce0035cba77bba68b813d523d1aac73d9781b4d193cf8", [:mix], [], "hexpm"}, - "mimerl": {:hex, :mimerl, "1.0.2", "993f9b0e084083405ed8252b99460c4f0563e41729ab42d9074fd5e52439be88", [:rebar3], [], "hexpm"}, - "oauth2": {:hex, :oauth2, "1.0.0", "7ae134c369bb9f7e96ed9404d12f34e938daa14745f1601876526599be4c80f2", [:mix], [{:hackney, "~> 1.13.0", [hex: :hackney, repo: "hexpm", optional: false]}], "hexpm"}, - "parse_trans": {:hex, :parse_trans, "3.2.0", "2adfa4daf80c14dc36f522cf190eb5c4ee3e28008fc6394397c16f62a26258c2", [:rebar3], [], "hexpm"}, + "mimerl": {:hex, :mimerl, "1.2.0", "67e2d3f571088d5cfd3e550c383094b47159f3eee8ffa08e64106cdf5e981be3", [:rebar3], [], "hexpm"}, + "oauth2": {:hex, :oauth2, "2.0.0", "338382079fe16c514420fa218b0903f8ad2d4bfc0ad0c9f988867dfa246731b0", [:mix], [{:hackney, "~> 1.13", [hex: :hackney, repo: "hexpm", optional: false]}], "hexpm"}, + "parse_trans": {:hex, :parse_trans, "3.3.0", "09765507a3c7590a784615cfd421d101aec25098d50b89d7aa1d66646bc571c1", [:rebar3], [], "hexpm"}, "plug": {:hex, :plug, "1.5.1", "1ff35bdecfb616f1a2b1c935ab5e4c47303f866cb929d2a76f0541e553a58165", [:mix], [{:cowboy, "~> 1.0.1 or ~> 1.1 or ~> 2.3", [hex: :cowboy, repo: "hexpm", optional: true]}, {:mime, "~> 1.0", [hex: :mime, repo: "hexpm", optional: false]}], "hexpm"}, - "ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.1", "28a4d65b7f59893bc2c7de786dec1e1555bd742d336043fe644ae956c3497fbe", [:make, :rebar], [], "hexpm"}, + "ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.4", "f0eafff810d2041e93f915ef59899c923f4568f4585904d010387ed74988e77b", [:make, :mix, :rebar3], [], "hexpm"}, "ueberauth": {:hex, :ueberauth, "0.6.1", "9e90d3337dddf38b1ca2753aca9b1e53d8a52b890191cdc55240247c89230412", [:mix], [{:plug, "~> 1.5", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm"}, - "unicode_util_compat": {:hex, :unicode_util_compat, "0.3.1", "a1f612a7b512638634a603c8f401892afbf99b8ce93a45041f8aaca99cadb85e", [:rebar3], [], "hexpm"}, + "unicode_util_compat": {:hex, :unicode_util_compat, "0.4.1", "d869e4c68901dd9531385bb0c8c40444ebf624e60b6962d95952775cac5e90cd", [:rebar3], [], "hexpm"}, } From 92007249ce0bac7b26dcf94b708435356f147afd Mon Sep 17 00:00:00 2001 From: Tobias Pfeiffer Date: Wed, 21 Aug 2019 09:32:57 +0200 Subject: [PATCH 29/80] travis please? From dcf016e4078c020a854e4d578345e5d1e5615af7 Mon Sep 17 00:00:00 2001 From: Tobias Pfeiffer Date: Wed, 21 Aug 2019 09:37:14 +0200 Subject: [PATCH 30/80] newer elixir versions so travis doesnt fail --- .travis.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 2ae7c1c..378fd5e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,10 +7,10 @@ cache: - deps elixir: - - '1.3' - - '1.4' - - '1.5' - - '1.6' + - 1.6 + - 1.7 + - 1.8 + - 1.9 script: - mix test From e7d8e2c9a1f40895a81e76764c4ab3cb6aae252d Mon Sep 17 00:00:00 2001 From: Yordis Prieto Lazo Date: Wed, 21 Aug 2019 06:48:18 -0700 Subject: [PATCH 31/80] Fix deps --- mix.exs | 5 ++--- mix.lock | 10 +++++++--- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/mix.exs b/mix.exs index 783a436..c2b648f 100644 --- a/mix.exs +++ b/mix.exs @@ -28,9 +28,8 @@ defmodule UeberauthGoogle.Mixfile do {:oauth2, "~> 1.0 or ~> 2.0"}, {:ueberauth, "~> 0.6.0"}, - {:credo, "~> 0.8", only: [:dev, :test]}, - {:earmark, ">= 0.0.0", only: :dev}, - {:ex_doc, "~> 0.3", only: :dev}, + {:credo, ">= 0.0.0", only: [:dev, :test], runtime: false}, + {:ex_doc, ">= 0.0.0", only: [:dev], runtime: false}, ] end diff --git a/mix.lock b/mix.lock index 757dfcf..2f540f8 100644 --- a/mix.lock +++ b/mix.lock @@ -1,14 +1,18 @@ %{ "bunt": {:hex, :bunt, "0.2.0", "951c6e801e8b1d2cbe58ebbd3e616a869061ddadcc4863d0a2182541acae9a38", [:mix], [], "hexpm"}, "certifi": {:hex, :certifi, "2.5.1", "867ce347f7c7d78563450a18a6a28a8090331e77fa02380b4a21962a65d36ee5", [:rebar3], [{:parse_trans, "~>3.3", [hex: :parse_trans, repo: "hexpm", optional: false]}], "hexpm"}, - "credo": {:hex, :credo, "0.8.4", "4e50acac058cf6292d6066e5b0d03da5e1483702e1ccde39abba385c9f03ead4", [:mix], [{:bunt, "~> 0.2.0", [hex: :bunt, repo: "hexpm", optional: false]}], "hexpm"}, - "earmark": {:hex, :earmark, "1.0.1", "2c2cd903bfdc3de3f189bd9a8d4569a075b88a8981ded9a0d95672f6e2b63141", [:mix], [], "hexpm"}, - "ex_doc": {:hex, :ex_doc, "0.13.2", "1059a588d2ad3ffab25a0b85c58abf08e437d3e7a9124ac255e1d15cec68ab79", [:mix], [{:earmark, "~> 1.0", [hex: :earmark, repo: "hexpm", optional: false]}], "hexpm"}, + "credo": {:hex, :credo, "1.1.3", "bf31887b8914a4b7e1810ae2b5aab7c657698abbf4cca6a2335a094d57995168", [:mix], [{:bunt, "~> 0.2.0", [hex: :bunt, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm"}, + "earmark": {:hex, :earmark, "1.3.5", "0db71c8290b5bc81cb0101a2a507a76dca659513984d683119ee722828b424f6", [:mix], [], "hexpm"}, + "ex_doc": {:hex, :ex_doc, "0.21.1", "5ac36660846967cd869255f4426467a11672fec3d8db602c429425ce5b613b90", [:mix], [{:earmark, "~> 1.3", [hex: :earmark, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}], "hexpm"}, "hackney": {:hex, :hackney, "1.15.1", "9f8f471c844b8ce395f7b6d8398139e26ddca9ebc171a8b91342ee15a19963f4", [:rebar3], [{:certifi, "2.5.1", [hex: :certifi, repo: "hexpm", optional: false]}, {:idna, "6.0.0", [hex: :idna, repo: "hexpm", optional: false]}, {:metrics, "1.0.1", [hex: :metrics, repo: "hexpm", optional: false]}, {:mimerl, "~>1.1", [hex: :mimerl, repo: "hexpm", optional: false]}, {:ssl_verify_fun, "1.1.4", [hex: :ssl_verify_fun, repo: "hexpm", optional: false]}], "hexpm"}, "idna": {:hex, :idna, "6.0.0", "689c46cbcdf3524c44d5f3dde8001f364cd7608a99556d8fbd8239a5798d4c10", [:rebar3], [{:unicode_util_compat, "0.4.1", [hex: :unicode_util_compat, repo: "hexpm", optional: false]}], "hexpm"}, + "jason": {:hex, :jason, "1.1.2", "b03dedea67a99223a2eaf9f1264ce37154564de899fd3d8b9a21b1a6fd64afe7", [:mix], [{:decimal, "~> 1.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm"}, + "makeup": {:hex, :makeup, "1.0.0", "671df94cf5a594b739ce03b0d0316aa64312cee2574b6a44becb83cd90fb05dc", [:mix], [{:nimble_parsec, "~> 0.5.0", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm"}, + "makeup_elixir": {:hex, :makeup_elixir, "0.14.0", "cf8b7c66ad1cff4c14679698d532f0b5d45a3968ffbcbfd590339cb57742f1ae", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm"}, "metrics": {:hex, :metrics, "1.0.1", "25f094dea2cda98213cecc3aeff09e940299d950904393b2a29d191c346a8486", [:rebar3], [], "hexpm"}, "mime": {:hex, :mime, "1.3.1", "30ce04ab3175b6ad0bdce0035cba77bba68b813d523d1aac73d9781b4d193cf8", [:mix], [], "hexpm"}, "mimerl": {:hex, :mimerl, "1.2.0", "67e2d3f571088d5cfd3e550c383094b47159f3eee8ffa08e64106cdf5e981be3", [:rebar3], [], "hexpm"}, + "nimble_parsec": {:hex, :nimble_parsec, "0.5.1", "c90796ecee0289dbb5ad16d3ad06f957b0cd1199769641c961cfe0b97db190e0", [:mix], [], "hexpm"}, "oauth2": {:hex, :oauth2, "2.0.0", "338382079fe16c514420fa218b0903f8ad2d4bfc0ad0c9f988867dfa246731b0", [:mix], [{:hackney, "~> 1.13", [hex: :hackney, repo: "hexpm", optional: false]}], "hexpm"}, "parse_trans": {:hex, :parse_trans, "3.3.0", "09765507a3c7590a784615cfd421d101aec25098d50b89d7aa1d66646bc571c1", [:rebar3], [], "hexpm"}, "plug": {:hex, :plug, "1.5.1", "1ff35bdecfb616f1a2b1c935ab5e4c47303f866cb929d2a76f0541e553a58165", [:mix], [{:cowboy, "~> 1.0.1 or ~> 1.1 or ~> 2.3", [hex: :cowboy, repo: "hexpm", optional: true]}, {:mime, "~> 1.0", [hex: :mime, repo: "hexpm", optional: false]}], "hexpm"}, From 997375a58844878a0127a3b0ca6ec248ba57910a Mon Sep 17 00:00:00 2001 From: Tobias Pfeiffer Date: Wed, 21 Aug 2019 21:20:15 +0200 Subject: [PATCH 32/80] Include version badge in README I find it to be extremely useful if I quickly want to check what the latest version to install is. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 28e6a6a..d336970 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Überauth Google +# Überauth Google [![Hex Version](https://img.shields.io/hexpm/v/ueberauth_google.svg)](https://hex.pm/packages/ueberauth_google) > Google OAuth2 strategy for Überauth. From bec7fa7e137a6ae34a1a0aa424a9c10907c7fb64 Mon Sep 17 00:00:00 2001 From: Tobias Pfeiffer Date: Fri, 23 Aug 2019 10:23:58 +0200 Subject: [PATCH 33/80] `hd:` doesn't limit login to a domain but only suggests it The previous wording was misleading as it could be interpreted as a security mechanism which it definitely isn't. --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index d336970..e7c6b63 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ 1. Update your provider configuration: - Use that if you want to read client ID/secret from the environment + Use that if you want to read client ID/secret from the environment variables in the compile time: ```elixir @@ -42,7 +42,7 @@ client_secret: System.get_env("GOOGLE_CLIENT_SECRET") ``` - Use that if you want to read client ID/secret from the environment + Use that if you want to read client ID/secret from the environment variables in the run time: ```elixir @@ -95,7 +95,7 @@ config :ueberauth, Ueberauth, ] ``` -You can also pass options such as the `hd` parameter to limit sign-in to a particular Google Apps hosted domain, or `prompt` and `access_type` options to request refresh_tokens and offline access. +You can also pass options such as the `hd` parameter to suggest a particular Google Apps hosted domain (caution, can still be overridden by the user), or `prompt` and `access_type` options to request refresh_tokens and offline access. ```elixir config :ueberauth, Ueberauth, From fd69ba66324908b48c9dc920121b72aeecc3153b Mon Sep 17 00:00:00 2001 From: Tobias Pfeiffer Date: Sat, 24 Aug 2019 14:04:35 +0200 Subject: [PATCH 34/80] Added OAuth version relaxation to Changelog It was important for me and I think it might be important for others :tada: --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8eb972a..0703f4d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ * Use json_library method from Ueberauth config [#58](https://github.com/ueberauth/ueberauth_google/pull/58) * Allows specifying `{m, f, a}` tuples for things such as Client ID and Client Secret [#60](https://github.com/ueberauth/ueberauth_google/pull/60) +* Allows the newest oauth2 package versions with potential security fixes [#68](https://github.com/ueberauth/ueberauth_google/pull/68) ## v0.6.0 From be8de6f69dbab9e786ab3806c367a97c0060c983 Mon Sep 17 00:00:00 2001 From: foxtrod Date: Wed, 23 Oct 2019 22:10:47 +0300 Subject: [PATCH 35/80] change mix --- mix.exs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mix.exs b/mix.exs index a0fce25..3e19702 100644 --- a/mix.exs +++ b/mix.exs @@ -26,7 +26,7 @@ defmodule UeberauthGoogle.Mixfile do defp deps do [ {:oauth2, "~> 1.0.0"}, - {:ueberauth, "~> 0.6.0", git: "https://github.com/foxtrod/ueberauth.git"}, + {:ueberauth, "~> 0.6.0"}, {:credo, "~> 0.8", only: [:dev, :test]}, {:earmark, ">= 0.0.0", only: :dev}, From 0e8da6e868c61f6905b224a908c6d20374926f32 Mon Sep 17 00:00:00 2001 From: Matt Pinkston Date: Fri, 28 Feb 2020 19:02:09 +0900 Subject: [PATCH 36/80] Allow the userinfo endpoint to be configured via options. This is useful for environments where the url is different such as China --- README.md | 21 +++++++++++++++++++++ lib/ueberauth/strategy/google.ex | 18 ++++++++++++++++-- 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index e7c6b63..312da0a 100644 --- a/README.md +++ b/README.md @@ -104,6 +104,27 @@ config :ueberauth, Ueberauth, ] ``` +In some cases, it may be necessary to update the user info endpoint, such as when deploying to countries that block access to the default endpoint. + +```elixir +config :ueberauth, Ueberauth, + providers: [ + google: {Ueberauth.Strategy.Google, [userinfo_endpoint: "https://www.googleapis.cn/oauth2/v3/userinfo"]} + ] +``` + +This may also be set via runtime configuration by passing a 2 or 3 argument tuple. To use this feature, the first argument must be the atom `:system`, and the second argument must represent the environment variable containing the endpoint url. +A third argument may be passed representing a default value if the environment variable is not found, otherwise the library default will be used. + +```elixir +config :ueberauth, Ueberauth, + providers: [ + google: {Ueberauth.Strategy.Google, [ + userinfo_endpoint: {:system, "GOOGLE_USERINFO_ENDPOINT", "https://www.googleapis.cn/oauth2/v3/userinfo"} + ]} + ] +``` + To guard against client-side request modification, it's important to still check the domain in `info.urls[:website]` within the `Ueberauth.Auth` struct if you want to limit sign-in to a specific domain. ## License diff --git a/lib/ueberauth/strategy/google.ex b/lib/ueberauth/strategy/google.ex index 83c4ed8..fd75ccf 100644 --- a/lib/ueberauth/strategy/google.ex +++ b/lib/ueberauth/strategy/google.ex @@ -3,7 +3,11 @@ defmodule Ueberauth.Strategy.Google do Google Strategy for Überauth. """ - use Ueberauth.Strategy, uid_field: :sub, default_scope: "email", hd: nil + use Ueberauth.Strategy, + uid_field: :sub, + default_scope: "email", + hd: nil, + userinfo_endpoint: "https://www.googleapis.com/oauth2/v3/userinfo" alias Ueberauth.Auth.Info alias Ueberauth.Auth.Credentials @@ -122,7 +126,17 @@ defmodule Ueberauth.Strategy.Google do conn = put_private(conn, :google_token, token) # userinfo_endpoint from https://accounts.google.com/.well-known/openid-configuration - path = "https://www.googleapis.com/oauth2/v3/userinfo" + # the userinfo_endpoint may be overridden in options when necessary. + path = + case option(conn, :userinfo_endpoint) do + {:system, varname, default} -> + System.get_env(varname, default) + {:system, varname} -> + System.get_env(varname, Keyword.get(default_options(), :userinfo_endpoint)) + other -> + other + end + resp = Ueberauth.Strategy.Google.OAuth.get(token, path) case resp do From 174cba04ca61bb257fddd0ac5a3255ef73150504 Mon Sep 17 00:00:00 2001 From: Matt Pinkston Date: Thu, 5 Mar 2020 18:44:14 +0900 Subject: [PATCH 37/80] added tests --- .formatter.exs | 4 ++ config/config.exs | 10 +++ mix.exs | 1 + mix.lock | 47 +++++++------ test/strategy/google_test.exs | 121 +++++++++++++++++++++++++++++++++ test/ueber_google_test.exs | 8 --- test/ueberauth_google_test.exs | 4 ++ 7 files changed, 167 insertions(+), 28 deletions(-) create mode 100644 .formatter.exs create mode 100644 test/strategy/google_test.exs delete mode 100644 test/ueber_google_test.exs create mode 100644 test/ueberauth_google_test.exs diff --git a/.formatter.exs b/.formatter.exs new file mode 100644 index 0000000..bb09258 --- /dev/null +++ b/.formatter.exs @@ -0,0 +1,4 @@ +[ + inputs: ["{mix,.formatter}.exs", "{config,lib,test}/**/*.{ex,exs}"], + line_length: 120 +] diff --git a/config/config.exs b/config/config.exs index d2d855e..795f918 100644 --- a/config/config.exs +++ b/config/config.exs @@ -1 +1,11 @@ use Mix.Config + +config :ueberauth, Ueberauth, + providers: [ + google: {Ueberauth.Strategy.Google, []} + ] + +config :ueberauth, Ueberauth.Strategy.Google.OAuth, + client_id: "client_id", + client_secret: "client_secret", + token_url: "token_url" diff --git a/mix.exs b/mix.exs index c2b648f..e19c74a 100644 --- a/mix.exs +++ b/mix.exs @@ -30,6 +30,7 @@ defmodule UeberauthGoogle.Mixfile do {:credo, ">= 0.0.0", only: [:dev, :test], runtime: false}, {:ex_doc, ">= 0.0.0", only: [:dev], runtime: false}, + {:mock, "~> 0.3", only: :test} ] end diff --git a/mix.lock b/mix.lock index 2f540f8..2004852 100644 --- a/mix.lock +++ b/mix.lock @@ -1,22 +1,29 @@ %{ - "bunt": {:hex, :bunt, "0.2.0", "951c6e801e8b1d2cbe58ebbd3e616a869061ddadcc4863d0a2182541acae9a38", [:mix], [], "hexpm"}, - "certifi": {:hex, :certifi, "2.5.1", "867ce347f7c7d78563450a18a6a28a8090331e77fa02380b4a21962a65d36ee5", [:rebar3], [{:parse_trans, "~>3.3", [hex: :parse_trans, repo: "hexpm", optional: false]}], "hexpm"}, - "credo": {:hex, :credo, "1.1.3", "bf31887b8914a4b7e1810ae2b5aab7c657698abbf4cca6a2335a094d57995168", [:mix], [{:bunt, "~> 0.2.0", [hex: :bunt, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm"}, - "earmark": {:hex, :earmark, "1.3.5", "0db71c8290b5bc81cb0101a2a507a76dca659513984d683119ee722828b424f6", [:mix], [], "hexpm"}, - "ex_doc": {:hex, :ex_doc, "0.21.1", "5ac36660846967cd869255f4426467a11672fec3d8db602c429425ce5b613b90", [:mix], [{:earmark, "~> 1.3", [hex: :earmark, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}], "hexpm"}, - "hackney": {:hex, :hackney, "1.15.1", "9f8f471c844b8ce395f7b6d8398139e26ddca9ebc171a8b91342ee15a19963f4", [:rebar3], [{:certifi, "2.5.1", [hex: :certifi, repo: "hexpm", optional: false]}, {:idna, "6.0.0", [hex: :idna, repo: "hexpm", optional: false]}, {:metrics, "1.0.1", [hex: :metrics, repo: "hexpm", optional: false]}, {:mimerl, "~>1.1", [hex: :mimerl, repo: "hexpm", optional: false]}, {:ssl_verify_fun, "1.1.4", [hex: :ssl_verify_fun, repo: "hexpm", optional: false]}], "hexpm"}, - "idna": {:hex, :idna, "6.0.0", "689c46cbcdf3524c44d5f3dde8001f364cd7608a99556d8fbd8239a5798d4c10", [:rebar3], [{:unicode_util_compat, "0.4.1", [hex: :unicode_util_compat, repo: "hexpm", optional: false]}], "hexpm"}, - "jason": {:hex, :jason, "1.1.2", "b03dedea67a99223a2eaf9f1264ce37154564de899fd3d8b9a21b1a6fd64afe7", [:mix], [{:decimal, "~> 1.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm"}, - "makeup": {:hex, :makeup, "1.0.0", "671df94cf5a594b739ce03b0d0316aa64312cee2574b6a44becb83cd90fb05dc", [:mix], [{:nimble_parsec, "~> 0.5.0", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm"}, - "makeup_elixir": {:hex, :makeup_elixir, "0.14.0", "cf8b7c66ad1cff4c14679698d532f0b5d45a3968ffbcbfd590339cb57742f1ae", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm"}, - "metrics": {:hex, :metrics, "1.0.1", "25f094dea2cda98213cecc3aeff09e940299d950904393b2a29d191c346a8486", [:rebar3], [], "hexpm"}, - "mime": {:hex, :mime, "1.3.1", "30ce04ab3175b6ad0bdce0035cba77bba68b813d523d1aac73d9781b4d193cf8", [:mix], [], "hexpm"}, - "mimerl": {:hex, :mimerl, "1.2.0", "67e2d3f571088d5cfd3e550c383094b47159f3eee8ffa08e64106cdf5e981be3", [:rebar3], [], "hexpm"}, - "nimble_parsec": {:hex, :nimble_parsec, "0.5.1", "c90796ecee0289dbb5ad16d3ad06f957b0cd1199769641c961cfe0b97db190e0", [:mix], [], "hexpm"}, - "oauth2": {:hex, :oauth2, "2.0.0", "338382079fe16c514420fa218b0903f8ad2d4bfc0ad0c9f988867dfa246731b0", [:mix], [{:hackney, "~> 1.13", [hex: :hackney, repo: "hexpm", optional: false]}], "hexpm"}, - "parse_trans": {:hex, :parse_trans, "3.3.0", "09765507a3c7590a784615cfd421d101aec25098d50b89d7aa1d66646bc571c1", [:rebar3], [], "hexpm"}, - "plug": {:hex, :plug, "1.5.1", "1ff35bdecfb616f1a2b1c935ab5e4c47303f866cb929d2a76f0541e553a58165", [:mix], [{:cowboy, "~> 1.0.1 or ~> 1.1 or ~> 2.3", [hex: :cowboy, repo: "hexpm", optional: true]}, {:mime, "~> 1.0", [hex: :mime, repo: "hexpm", optional: false]}], "hexpm"}, - "ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.4", "f0eafff810d2041e93f915ef59899c923f4568f4585904d010387ed74988e77b", [:make, :mix, :rebar3], [], "hexpm"}, - "ueberauth": {:hex, :ueberauth, "0.6.1", "9e90d3337dddf38b1ca2753aca9b1e53d8a52b890191cdc55240247c89230412", [:mix], [{:plug, "~> 1.5", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm"}, - "unicode_util_compat": {:hex, :unicode_util_compat, "0.4.1", "d869e4c68901dd9531385bb0c8c40444ebf624e60b6962d95952775cac5e90cd", [:rebar3], [], "hexpm"}, + "bunt": {:hex, :bunt, "0.2.0", "951c6e801e8b1d2cbe58ebbd3e616a869061ddadcc4863d0a2182541acae9a38", [:mix], [], "hexpm", "7af5c7e09fe1d40f76c8e4f9dd2be7cebd83909f31fee7cd0e9eadc567da8353"}, + "certifi": {:hex, :certifi, "2.5.1", "867ce347f7c7d78563450a18a6a28a8090331e77fa02380b4a21962a65d36ee5", [:rebar3], [{:parse_trans, "~>3.3", [hex: :parse_trans, repo: "hexpm", optional: false]}], "hexpm", "805abd97539caf89ec6d4732c91e62ba9da0cda51ac462380bbd28ee697a8c42"}, + "credo": {:hex, :credo, "1.1.3", "bf31887b8914a4b7e1810ae2b5aab7c657698abbf4cca6a2335a094d57995168", [:mix], [{:bunt, "~> 0.2.0", [hex: :bunt, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "95ef6f8105e9b9d61c567204d8df9c382bb9ae5dff7c11c25b69d7c022e1183e"}, + "earmark": {:hex, :earmark, "1.3.5", "0db71c8290b5bc81cb0101a2a507a76dca659513984d683119ee722828b424f6", [:mix], [], "hexpm", "762b999fd414fb41e297944228aa1de2cd4a3876a07f968c8b11d1e9a2190d07"}, + "ex_doc": {:hex, :ex_doc, "0.21.1", "5ac36660846967cd869255f4426467a11672fec3d8db602c429425ce5b613b90", [:mix], [{:earmark, "~> 1.3", [hex: :earmark, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}], "hexpm", "93d2fee94d2f88abf507628378371ea5fab08ed03fa59a6daa3d4469d9159ddd"}, + "exactor": {:hex, :exactor, "2.2.4", "5efb4ddeb2c48d9a1d7c9b465a6fffdd82300eb9618ece5d34c3334d5d7245b1", [:mix], [], "hexpm", "1222419f706e01bfa1095aec9acf6421367dcfab798a6f67c54cf784733cd6b5"}, + "exjsx": {:hex, :exjsx, "4.0.0", "60548841e0212df401e38e63c0078ec57b33e7ea49b032c796ccad8cde794b5c", [:mix], [{:jsx, "~> 2.8.0", [hex: :jsx, repo: "hexpm", optional: false]}], "hexpm", "32e95820a97cffea67830e91514a2ad53b888850442d6d395f53a1ac60c82e07"}, + "exvcr": {:hex, :exvcr, "0.11.1", "a5e5f57a67538e032e16cfea6cfb1232314fb146e3ceedf1cde4a11f12fb7a58", [:mix], [{:exactor, "~> 2.2", [hex: :exactor, repo: "hexpm", optional: false]}, {:exjsx, "~> 4.0", [hex: :exjsx, repo: "hexpm", optional: false]}, {:httpoison, "~> 1.0", [hex: :httpoison, repo: "hexpm", optional: true]}, {:httpotion, "~> 3.1", [hex: :httpotion, repo: "hexpm", optional: true]}, {:ibrowse, "~> 4.4", [hex: :ibrowse, repo: "hexpm", optional: true]}, {:meck, "~> 0.8", [hex: :meck, repo: "hexpm", optional: false]}], "hexpm", "984a4d52d9e01d5f0e28d45718565a41dffab3ac18e029ae45d42f16a2a58a1d"}, + "hackney": {:hex, :hackney, "1.15.1", "9f8f471c844b8ce395f7b6d8398139e26ddca9ebc171a8b91342ee15a19963f4", [:rebar3], [{:certifi, "2.5.1", [hex: :certifi, repo: "hexpm", optional: false]}, {:idna, "6.0.0", [hex: :idna, repo: "hexpm", optional: false]}, {:metrics, "1.0.1", [hex: :metrics, repo: "hexpm", optional: false]}, {:mimerl, "~>1.1", [hex: :mimerl, repo: "hexpm", optional: false]}, {:ssl_verify_fun, "1.1.4", [hex: :ssl_verify_fun, repo: "hexpm", optional: false]}], "hexpm", "c2790c9f0f7205f4a362512192dee8179097394400e745e4d20bab7226a8eaad"}, + "idna": {:hex, :idna, "6.0.0", "689c46cbcdf3524c44d5f3dde8001f364cd7608a99556d8fbd8239a5798d4c10", [:rebar3], [{:unicode_util_compat, "0.4.1", [hex: :unicode_util_compat, repo: "hexpm", optional: false]}], "hexpm", "4bdd305eb64e18b0273864920695cb18d7a2021f31a11b9c5fbcd9a253f936e2"}, + "jason": {:hex, :jason, "1.1.2", "b03dedea67a99223a2eaf9f1264ce37154564de899fd3d8b9a21b1a6fd64afe7", [:mix], [{:decimal, "~> 1.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "fdf843bca858203ae1de16da2ee206f53416bbda5dc8c9e78f43243de4bc3afe"}, + "jsx": {:hex, :jsx, "2.8.3", "a05252d381885240744d955fbe3cf810504eb2567164824e19303ea59eef62cf", [:mix, :rebar3], [], "hexpm", "fc3499fed7a726995aa659143a248534adc754ebd16ccd437cd93b649a95091f"}, + "makeup": {:hex, :makeup, "1.0.0", "671df94cf5a594b739ce03b0d0316aa64312cee2574b6a44becb83cd90fb05dc", [:mix], [{:nimble_parsec, "~> 0.5.0", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "a10c6eb62cca416019663129699769f0c2ccf39428b3bb3c0cb38c718a0c186d"}, + "makeup_elixir": {:hex, :makeup_elixir, "0.14.0", "cf8b7c66ad1cff4c14679698d532f0b5d45a3968ffbcbfd590339cb57742f1ae", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "d4b316c7222a85bbaa2fd7c6e90e37e953257ad196dc229505137c5e505e9eff"}, + "meck": {:hex, :meck, "0.8.13", "ffedb39f99b0b99703b8601c6f17c7f76313ee12de6b646e671e3188401f7866", [:rebar3], [], "hexpm", "d34f013c156db51ad57cc556891b9720e6a1c1df5fe2e15af999c84d6cebeb1a"}, + "metrics": {:hex, :metrics, "1.0.1", "25f094dea2cda98213cecc3aeff09e940299d950904393b2a29d191c346a8486", [:rebar3], [], "hexpm", "69b09adddc4f74a40716ae54d140f93beb0fb8978d8636eaded0c31b6f099f16"}, + "mime": {:hex, :mime, "1.3.1", "30ce04ab3175b6ad0bdce0035cba77bba68b813d523d1aac73d9781b4d193cf8", [:mix], [], "hexpm", "6cbe761d6a0ca5a31a0931bf4c63204bceb64538e664a8ecf784a9a6f3b875f1"}, + "mimerl": {:hex, :mimerl, "1.2.0", "67e2d3f571088d5cfd3e550c383094b47159f3eee8ffa08e64106cdf5e981be3", [:rebar3], [], "hexpm", "f278585650aa581986264638ebf698f8bb19df297f66ad91b18910dfc6e19323"}, + "mock": {:hex, :mock, "0.3.4", "c5862eb3b8c64237f45f586cf00c9d892ba07bb48305a43319d428ce3c2897dd", [:mix], [{:meck, "~> 0.8.13", [hex: :meck, repo: "hexpm", optional: false]}], "hexpm", "e6d886252f1a41f4ba06ecf2b4c8d38760b34b1c08a11c28f7397b2e03995964"}, + "nimble_parsec": {:hex, :nimble_parsec, "0.5.1", "c90796ecee0289dbb5ad16d3ad06f957b0cd1199769641c961cfe0b97db190e0", [:mix], [], "hexpm", "00e3ebdc821fb3a36957320d49e8f4bfa310d73ea31c90e5f925dc75e030da8f"}, + "oauth2": {:hex, :oauth2, "2.0.0", "338382079fe16c514420fa218b0903f8ad2d4bfc0ad0c9f988867dfa246731b0", [:mix], [{:hackney, "~> 1.13", [hex: :hackney, repo: "hexpm", optional: false]}], "hexpm", "881b8364ac7385f9fddc7949379cbe3f7081da37233a1aa7aab844670a91e7e7"}, + "parse_trans": {:hex, :parse_trans, "3.3.0", "09765507a3c7590a784615cfd421d101aec25098d50b89d7aa1d66646bc571c1", [:rebar3], [], "hexpm", "17ef63abde837ad30680ea7f857dd9e7ced9476cdd7b0394432af4bfc241b960"}, + "plug": {:hex, :plug, "1.9.0", "8d7c4e26962283ff9f8f3347bd73838e2413fbc38b7bb5467d5924f68f3a5a4a", [:mix], [{:mime, "~> 1.0", [hex: :mime, repo: "hexpm", optional: false]}, {:plug_crypto, "~> 1.0", [hex: :plug_crypto, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4", [hex: :telemetry, repo: "hexpm", optional: true]}], "hexpm", "9902eda2c52ada2a096434682e99a2493f5d06a94d6ac6bcfff9805f952350f1"}, + "plug_crypto": {:hex, :plug_crypto, "1.1.2", "bdd187572cc26dbd95b87136290425f2b580a116d3fb1f564216918c9730d227", [:mix], [], "hexpm", "6b8b608f895b6ffcfad49c37c7883e8df98ae19c6a28113b02aa1e9c5b22d6b5"}, + "ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.4", "f0eafff810d2041e93f915ef59899c923f4568f4585904d010387ed74988e77b", [:make, :mix, :rebar3], [], "hexpm", "603561dc0fd62f4f2ea9b890f4e20e1a0d388746d6e20557cafb1b16950de88c"}, + "ueberauth": {:hex, :ueberauth, "0.6.1", "9e90d3337dddf38b1ca2753aca9b1e53d8a52b890191cdc55240247c89230412", [:mix], [{:plug, "~> 1.5", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm", "81ea8303ef676a7b8e6e308584e9b9232d2b6fb02110d00dba351edd823a7d96"}, + "unicode_util_compat": {:hex, :unicode_util_compat, "0.4.1", "d869e4c68901dd9531385bb0c8c40444ebf624e60b6962d95952775cac5e90cd", [:rebar3], [], "hexpm", "1d1848c40487cdb0b30e8ed975e34e025860c02e419cb615d255849f3427439d"}, } diff --git a/test/strategy/google_test.exs b/test/strategy/google_test.exs new file mode 100644 index 0000000..d5f0b93 --- /dev/null +++ b/test/strategy/google_test.exs @@ -0,0 +1,121 @@ +defmodule Ueberauth.Strategy.GoogleTest do + use ExUnit.Case, async: true + use Plug.Test + + import Mock + import Plug.Conn + + setup_with_mocks([ + {OAuth2.Client, [:passthrough], + [ + get_token: &oauth2_get_token/2, + get: &oauth2_get/4 + ]} + ]) do + :ok + end + + def set_options(routes, conn, opt) do + case Enum.find_index(routes, &(elem(&1, 0) == {conn.request_path, conn.method})) do + nil -> + routes + + idx -> + update_in(routes, [Access.at(idx), Access.elem(1), Access.elem(2)], &%{&1 | options: opt}) + end + end + + defp token(client, opts), do: {:ok, %{client | token: OAuth2.AccessToken.new(opts)}} + defp response(body, code \\ 200), do: {:ok, %OAuth2.Response{status_code: code, body: body}} + + def oauth2_get_token(client, code: "success_code"), do: token(client, "success_token") + def oauth2_get_token(client, code: "uid_code"), do: token(client, "uid_token") + def oauth2_get_token(client, code: "userinfo_code"), do: token(client, "userinfo_token") + + def oauth2_get(%{token: %{access_token: "success_token"}}, _url, _, _), + do: response(%{"sub" => "1234_fred", "name" => "Fred Jones", "email" => "fred_jones@example.com"}) + + def oauth2_get(%{token: %{access_token: "uid_token"}}, _url, _, _), + do: response(%{"uid_field" => "1234_daphne", "name" => "Daphne Blake"}) + + def oauth2_get(%{token: %{access_token: "userinfo_token"}}, "https://www.googleapis.com/oauth2/v3/userinfo", _, _), + do: response(%{"sub" => "1234_velma", "name" => "Velma Dinkley"}) + + def oauth2_get(%{token: %{access_token: "userinfo_token"}}, "example.com/shaggy", _, _), + do: response(%{"sub" => "1234_shaggy", "name" => "Norville Rogers"}) + + def oauth2_get(%{token: %{access_token: "userinfo_token"}}, "example.com/scooby", _, _), + do: response(%{"sub" => "1234_scooby", "name" => "Scooby Doo"}) + + test "handle_request! redirects to appropriate auth uri" do + conn = conn(:get, "/auth/google", %{}) + # Make sure the hd and scope params are included for good measure + routes = Ueberauth.init() |> set_options(conn, hd: "example.com", default_scope: "email openid") + + resp = Ueberauth.call(conn, routes) + + assert resp.status == 302 + assert [location] = get_resp_header(resp, "location") + + redirect_uri = URI.parse(location) + assert redirect_uri.host == "accounts.google.com" + assert redirect_uri.path == "/o/oauth2/v2/auth" + + assert %{ + "client_id" => "client_id", + "redirect_uri" => "http://www.example.com/auth/google/callback", + "response_type" => "code", + "scope" => "email openid", + "hd" => "example.com" + } = Plug.Conn.Query.decode(redirect_uri.query) + end + + test "handle_callback! assigns required fields on successful auth" do + conn = conn(:get, "/auth/google/callback", %{code: "success_code"}) + routes = Ueberauth.init([]) + assert %Plug.Conn{assigns: %{ueberauth_auth: auth}} = Ueberauth.call(conn, routes) + assert auth.credentials.token == "success_token" + assert auth.info.name == "Fred Jones" + assert auth.info.email == "fred_jones@example.com" + assert auth.uid == "1234_fred" + end + + test "uid_field is picked according to the specified option" do + conn = conn(:get, "/auth/google/callback", %{code: "uid_code"}) + routes = Ueberauth.init() |> set_options(conn, uid_field: "uid_field") + assert %Plug.Conn{assigns: %{ueberauth_auth: auth}} = Ueberauth.call(conn, routes) + assert auth.info.name == "Daphne Blake" + assert auth.uid == "1234_daphne" + end + + test "userinfo is fetched according to userinfo_endpoint" do + conn = conn(:get, "/auth/google/callback", %{code: "userinfo_code"}) + routes = Ueberauth.init() |> set_options(conn, userinfo_endpoint: "example.com/shaggy") + assert %Plug.Conn{assigns: %{ueberauth_auth: auth}} = Ueberauth.call(conn, routes) + assert auth.info.name == "Norville Rogers" + end + + test "userinfo can be set via runtime config with default" do + conn = conn(:get, "/auth/google/callback", %{code: "userinfo_code"}) + routes = Ueberauth.init() |> set_options(conn, userinfo_endpoint: {:system, "NOT_SET", "example.com/shaggy"}) + assert %Plug.Conn{assigns: %{ueberauth_auth: auth}} = Ueberauth.call(conn, routes) + assert auth.info.name == "Norville Rogers" + end + + test "userinfo uses default library value if runtime env not found" do + conn = conn(:get, "/auth/google/callback", %{code: "userinfo_code"}) + routes = Ueberauth.init() |> set_options(conn, userinfo_endpoint: {:system, "NOT_SET"}) + assert %Plug.Conn{assigns: %{ueberauth_auth: auth}} = Ueberauth.call(conn, routes) + assert auth.info.name == "Velma Dinkley" + end + + test "userinfo can be set via runtime config" do + conn = conn(:get, "/auth/google/callback", %{code: "userinfo_code"}) + routes = Ueberauth.init() |> set_options(conn, userinfo_endpoint: {:system, "UEBERAUTH_SCOOBY_DOO"}) + + System.put_env("UEBERAUTH_SCOOBY_DOO", "example.com/scooby") + assert %Plug.Conn{assigns: %{ueberauth_auth: auth}} = Ueberauth.call(conn, routes) + assert auth.info.name == "Scooby Doo" + System.delete_env("UEBERAUTH_SCOOBY_DOO") + end +end diff --git a/test/ueber_google_test.exs b/test/ueber_google_test.exs deleted file mode 100644 index 377d513..0000000 --- a/test/ueber_google_test.exs +++ /dev/null @@ -1,8 +0,0 @@ -defmodule UeberauthGoogleTest do - use ExUnit.Case - doctest UeberauthGoogle - - test "the truth" do - assert 1 + 1 == 2 - end -end diff --git a/test/ueberauth_google_test.exs b/test/ueberauth_google_test.exs new file mode 100644 index 0000000..d43bb38 --- /dev/null +++ b/test/ueberauth_google_test.exs @@ -0,0 +1,4 @@ +defmodule UeberauthGoogleTest do + use ExUnit.Case, async: true + doctest UeberauthGoogle +end From 50956cc50d20526795af0b3238194907f7506108 Mon Sep 17 00:00:00 2001 From: Matt Pinkston Date: Thu, 5 Mar 2020 18:50:07 +0900 Subject: [PATCH 38/80] tweak for elixir < 1.9 compatibility --- lib/ueberauth/strategy/google.ex | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/ueberauth/strategy/google.ex b/lib/ueberauth/strategy/google.ex index fd75ccf..820102f 100644 --- a/lib/ueberauth/strategy/google.ex +++ b/lib/ueberauth/strategy/google.ex @@ -130,9 +130,9 @@ defmodule Ueberauth.Strategy.Google do path = case option(conn, :userinfo_endpoint) do {:system, varname, default} -> - System.get_env(varname, default) + System.get_env(varname) || default {:system, varname} -> - System.get_env(varname, Keyword.get(default_options(), :userinfo_endpoint)) + System.get_env(varname) || Keyword.get(default_options(), :userinfo_endpoint) other -> other end From b3c95fa85d661f2dc7d9cdd7aa93dc11f446883f Mon Sep 17 00:00:00 2001 From: Hans Pagh Date: Thu, 5 Mar 2020 13:15:45 +0100 Subject: [PATCH 39/80] update ueberauth dep --- mix.exs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mix.exs b/mix.exs index 3e19702..5c98f7c 100644 --- a/mix.exs +++ b/mix.exs @@ -25,8 +25,8 @@ defmodule UeberauthGoogle.Mixfile do defp deps do [ - {:oauth2, "~> 1.0.0"}, - {:ueberauth, "~> 0.6.0"}, + {:oauth2, "~> 1.0 or ~> 2.0"}, + {:ueberauth, "~> 0.6.1"}, {:credo, "~> 0.8", only: [:dev, :test]}, {:earmark, ">= 0.0.0", only: :dev}, From c9ef7910d4decdab66023cbdc9d90ad714a2f4ce Mon Sep 17 00:00:00 2001 From: Hans Pagh Date: Thu, 5 Mar 2020 13:40:51 +0100 Subject: [PATCH 40/80] use version 0.6.3 --- mix.exs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mix.exs b/mix.exs index a56172b..cddbcb3 100644 --- a/mix.exs +++ b/mix.exs @@ -26,7 +26,7 @@ defmodule UeberauthGoogle.Mixfile do defp deps do [ {:oauth2, "~> 1.0 or ~> 2.0"}, - {:ueberauth, "~> 0.6.1"}, + {:ueberauth, "~> 0.6.3"}, {:credo, ">= 0.0.0", only: [:dev, :test], runtime: false}, {:ex_doc, ">= 0.0.0", only: [:dev], runtime: false}, From b6686fb0c54df1c898cd5be7c75e87613d9d01bf Mon Sep 17 00:00:00 2001 From: Ruben Amortegui Date: Wed, 15 Apr 2020 18:02:32 -0600 Subject: [PATCH 41/80] Update lock version of plug and ueberauth --- mix.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mix.lock b/mix.lock index 2004852..11b60d1 100644 --- a/mix.lock +++ b/mix.lock @@ -21,9 +21,9 @@ "nimble_parsec": {:hex, :nimble_parsec, "0.5.1", "c90796ecee0289dbb5ad16d3ad06f957b0cd1199769641c961cfe0b97db190e0", [:mix], [], "hexpm", "00e3ebdc821fb3a36957320d49e8f4bfa310d73ea31c90e5f925dc75e030da8f"}, "oauth2": {:hex, :oauth2, "2.0.0", "338382079fe16c514420fa218b0903f8ad2d4bfc0ad0c9f988867dfa246731b0", [:mix], [{:hackney, "~> 1.13", [hex: :hackney, repo: "hexpm", optional: false]}], "hexpm", "881b8364ac7385f9fddc7949379cbe3f7081da37233a1aa7aab844670a91e7e7"}, "parse_trans": {:hex, :parse_trans, "3.3.0", "09765507a3c7590a784615cfd421d101aec25098d50b89d7aa1d66646bc571c1", [:rebar3], [], "hexpm", "17ef63abde837ad30680ea7f857dd9e7ced9476cdd7b0394432af4bfc241b960"}, - "plug": {:hex, :plug, "1.9.0", "8d7c4e26962283ff9f8f3347bd73838e2413fbc38b7bb5467d5924f68f3a5a4a", [:mix], [{:mime, "~> 1.0", [hex: :mime, repo: "hexpm", optional: false]}, {:plug_crypto, "~> 1.0", [hex: :plug_crypto, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4", [hex: :telemetry, repo: "hexpm", optional: true]}], "hexpm", "9902eda2c52ada2a096434682e99a2493f5d06a94d6ac6bcfff9805f952350f1"}, + "plug": {:hex, :plug, "1.10.0", "6508295cbeb4c654860845fb95260737e4a8838d34d115ad76cd487584e2fc4d", [:mix], [{:mime, "~> 1.0", [hex: :mime, repo: "hexpm", optional: false]}, {:plug_crypto, "~> 1.1.1 or ~> 1.2", [hex: :plug_crypto, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4", [hex: :telemetry, repo: "hexpm", optional: true]}], "hexpm", "422a9727e667be1bf5ab1de03be6fa0ad67b775b2d84ed908f3264415ef29d4a"}, "plug_crypto": {:hex, :plug_crypto, "1.1.2", "bdd187572cc26dbd95b87136290425f2b580a116d3fb1f564216918c9730d227", [:mix], [], "hexpm", "6b8b608f895b6ffcfad49c37c7883e8df98ae19c6a28113b02aa1e9c5b22d6b5"}, "ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.4", "f0eafff810d2041e93f915ef59899c923f4568f4585904d010387ed74988e77b", [:make, :mix, :rebar3], [], "hexpm", "603561dc0fd62f4f2ea9b890f4e20e1a0d388746d6e20557cafb1b16950de88c"}, - "ueberauth": {:hex, :ueberauth, "0.6.1", "9e90d3337dddf38b1ca2753aca9b1e53d8a52b890191cdc55240247c89230412", [:mix], [{:plug, "~> 1.5", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm", "81ea8303ef676a7b8e6e308584e9b9232d2b6fb02110d00dba351edd823a7d96"}, + "ueberauth": {:hex, :ueberauth, "0.6.3", "d42ace28b870e8072cf30e32e385579c57b9cc96ec74fa1f30f30da9c14f3cc0", [:mix], [{:plug, "~> 1.5", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm", "afc293d8a1140d6591b53e3eaf415ca92842cb1d32fad3c450c6f045f7f91b60"}, "unicode_util_compat": {:hex, :unicode_util_compat, "0.4.1", "d869e4c68901dd9531385bb0c8c40444ebf624e60b6962d95952775cac5e90cd", [:rebar3], [], "hexpm", "1d1848c40487cdb0b30e8ed975e34e025860c02e419cb615d255849f3427439d"}, } From 194a34bfab03c96058715cc44f967a05d3df569e Mon Sep 17 00:00:00 2001 From: Ruben Amortegui Date: Wed, 15 Apr 2020 18:02:48 -0600 Subject: [PATCH 42/80] Update docs to match current version of the app --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 312da0a..65b2def 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ ```elixir def deps do - [{:ueberauth_google, "~> 0.8"}] + [{:ueberauth_google, "~> 0.9"}] end ``` From 9abed05302d7dfaa2998a5fd0c9b83d04679fde2 Mon Sep 17 00:00:00 2001 From: Max Strother Date: Fri, 21 Aug 2020 14:08:16 +0200 Subject: [PATCH 43/80] Add support for optional include_granted_scopes param --- README.md | 4 ++-- lib/ueberauth/strategy/google.ex | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 65b2def..1dca876 100644 --- a/README.md +++ b/README.md @@ -95,12 +95,12 @@ config :ueberauth, Ueberauth, ] ``` -You can also pass options such as the `hd` parameter to suggest a particular Google Apps hosted domain (caution, can still be overridden by the user), or `prompt` and `access_type` options to request refresh_tokens and offline access. +You can also pass options such as the `hd` parameter to suggest a particular Google Apps hosted domain (caution, can still be overridden by the user), `prompt` and `access_type` options to request refresh_tokens and offline access (both have to be present), or `include_granted_scopes` parameter to allow [incremental authorization](https://developers.google.com/identity/protocols/oauth2/web-server#incrementalAuth). ```elixir config :ueberauth, Ueberauth, providers: [ - google: {Ueberauth.Strategy.Google, [hd: "example.com", prompt: "select_account", access_type: "offline"]} + google: {Ueberauth.Strategy.Google, [hd: "example.com", prompt: "select_account", access_type: "offline", include_granted_scopes: true]} ] ``` diff --git a/lib/ueberauth/strategy/google.ex b/lib/ueberauth/strategy/google.ex index 5cb249c..bda2847 100644 --- a/lib/ueberauth/strategy/google.ex +++ b/lib/ueberauth/strategy/google.ex @@ -25,6 +25,7 @@ defmodule Ueberauth.Strategy.Google do |> with_optional(:prompt, conn) |> with_optional(:access_type, conn) |> with_optional(:login_hint, conn) + |> with_optional(:include_granted_scopes, conn) |> with_param(:access_type, conn) |> with_param(:prompt, conn) |> with_param(:login_hint, conn) From 2e5df9d83a3cf86a56d2a3fa8e8b93823a8ace19 Mon Sep 17 00:00:00 2001 From: Hans Pagh Date: Tue, 20 Oct 2020 10:42:26 +0200 Subject: [PATCH 44/80] release 0.10.0 --- CHANGELOG.md | 14 ++++++++++++++ README.md | 2 +- mix.exs | 2 +- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0703f4d..64eddfa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,19 @@ # Changelog +## v0.11.0 (Unreleased) + + +## v0.10.0 + +### Enhancement + +* Updated docs [#69](https://github.com/ueberauth/ueberauth_google/pull/69) [#70](https://github.com/ueberauth/ueberauth_google/pull/70) +* Support for birthday [#73](https://github.com/ueberauth/ueberauth_google/pull/73) +* Allow for userinfo endpoint to be configured [#75](https://github.com/ueberauth/ueberauth_google/pull/75) +* Updated plug and ueberauth packages [#76](https://github.com/ueberauth/ueberauth_google/pull/76) + +Thanks goes to all the contributes + ## v0.9.0 ### Enhancement diff --git a/README.md b/README.md index 1dca876..dcf1b2a 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ ```elixir def deps do - [{:ueberauth_google, "~> 0.9"}] + [{:ueberauth_google, "~> 0.10"}] end ``` diff --git a/mix.exs b/mix.exs index cddbcb3..a05fa8d 100644 --- a/mix.exs +++ b/mix.exs @@ -1,7 +1,7 @@ defmodule UeberauthGoogle.Mixfile do use Mix.Project - @version "0.9.0" + @version "0.10.0" @url "https://github.com/ueberauth/ueberauth_google" def project do From b2088d1ac657136d848d2f51bd99625fa5415cc9 Mon Sep 17 00:00:00 2001 From: Kian-Meng Ang Date: Thu, 1 Apr 2021 20:25:20 +0800 Subject: [PATCH 45/80] Misc doc changes Besides other documentation changes, this commit ensures the generated HTML doc for HexDocs.pm will become the main source doc for this Elixir library which leverage on latest ExDoc features. --- .formatter.exs | 1 + .gitignore | 3 ++ CHANGELOG.md | 20 ++++---- CONTRIBUTING.md | 2 +- LICENSE | 3 +- README.md | 44 +++++++++++------ lib/ueberauth/strategy/google/oauth.ex | 7 +-- mix.exs | 65 ++++++++++++++------------ mix.lock | 10 ++-- 9 files changed, 91 insertions(+), 64 deletions(-) diff --git a/.formatter.exs b/.formatter.exs index bb09258..0a70dc0 100644 --- a/.formatter.exs +++ b/.formatter.exs @@ -1,3 +1,4 @@ +# Used by "mix format" [ inputs: ["{mix,.formatter}.exs", "{config,lib,test}/**/*.{ex,exs}"], line_length: 120 diff --git a/.gitignore b/.gitignore index ec63485..e746ad7 100644 --- a/.gitignore +++ b/.gitignore @@ -5,7 +5,10 @@ /_build /cover /deps +/tmp +/.fetch erl_crash.dump +ueberauth_google-*.tar *.ez *.beam diff --git a/CHANGELOG.md b/CHANGELOG.md index 64eddfa..b877ce4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,7 @@ ## v0.11.0 (Unreleased) -## v0.10.0 +## v0.10.0 - 2020-10-20 ### Enhancement @@ -14,35 +14,35 @@ Thanks goes to all the contributes -## v0.9.0 +## v0.9.0 - 2019-08-21 ### Enhancement * Add support for optional login_hint param [#61](https://github.com/ueberauth/ueberauth_google/pull/61) -* Use json_library method from Ueberauth config [#58](https://github.com/ueberauth/ueberauth_google/pull/58) +* Use `json_library` method from Ueberauth config [#58](https://github.com/ueberauth/ueberauth_google/pull/58) * Allows specifying `{m, f, a}` tuples for things such as Client ID and Client Secret [#60](https://github.com/ueberauth/ueberauth_google/pull/60) * Allows the newest oauth2 package versions with potential security fixes [#68](https://github.com/ueberauth/ueberauth_google/pull/68) -## v0.6.0 +## v0.6.0 - 2017-07-18 -* Add support for access_type per request using url parameter. +* Add support for `access_type` per request using `url` parameter. -## v0.5.0 +## v0.5.0 - 2016-12-27 -* Add support for new params: access_type, approval_prompt, state. +* Add support for new params: `access_type`, `approval_prompt`, `state`. * Fix Elixir warnings. -## v0.4.0 +## v0.4.0 - 2016-09-21 * Target Elixir 1.3 and greater. * Fix OAuth bug with 0.6.0 pin. -## v0.3.0 +## v0.3.0 - 2016-08-15 * Use OpenID endpoint for profile information. * Update authorize and token URLs. -## v0.2.0 +## v0.2.0 - 2016-12-10 * Release 0.2.0 to follow Ueberauth. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index b4e2d6b..c748f44 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,4 +1,4 @@ -# Contributing to Ueberauth Google +# Contributing ## Pull Requests Welcome diff --git a/LICENSE b/LICENSE index 473a36e..4f1532b 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2015 Sean +Copyright (c) 2015 Sean Callan Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -19,4 +19,3 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - diff --git a/README.md b/README.md index dcf1b2a..9885737 100644 --- a/README.md +++ b/README.md @@ -1,28 +1,40 @@ -# Überauth Google [![Hex Version](https://img.shields.io/hexpm/v/ueberauth_google.svg)](https://hex.pm/packages/ueberauth_google) +# Überauth Google + +[![Build Status](https://travis-ci.org/ueberauth/ueberauth_google.svg?branch=master)](https://travis-ci.org/ueberauth/ueberauth_google) +[![Module Version](https://img.shields.io/hexpm/v/ueberauth_google.svg)](https://hex.pm/packages/ueberauth_google) +[![Hex Docs](https://img.shields.io/badge/hex-docs-lightgreen.svg)](https://hexdocs.pm/ueberauth_google/) +[![Total Download](https://img.shields.io/hexpm/dt/ueberauth_google.svg)](https://hex.pm/packages/ueberauth_google) +[![License](https://img.shields.io/hexpm/l/ueberauth_google.svg)](https://github.com/ueberauth/ueberauth_google/blob/master/LICENSE) +[![Last Updated](https://img.shields.io/github/last-commit/ueberauth/ueberauth_google.svg)](https://github.com/ueberauth/ueberauth_google/commits/master) + > Google OAuth2 strategy for Überauth. ## Installation -1. Setup your application at [Google Developer Console](https://console.developers.google.com/home). +1. Setup your application at [Google Developer Console](https://console.developers.google.com/home). -1. Add `:ueberauth_google` to your list of dependencies in `mix.exs`: +2. Add `:ueberauth_google` to your list of dependencies in `mix.exs`: ```elixir def deps do - [{:ueberauth_google, "~> 0.10"}] + [ + {:ueberauth_google, "~> 0.10"} + ] end ``` -1. Add the strategy to your applications: +3. Add the strategy to your applications: ```elixir def application do - [applications: [:ueberauth_google]] + [ + applications: [:ueberauth_google] + ] end ``` -1. Add Google to your Überauth configuration: +4. Add Google to your Überauth configuration: ```elixir config :ueberauth, Ueberauth, @@ -31,7 +43,7 @@ ] ``` -1. Update your provider configuration: +5. Update your provider configuration: Use that if you want to read client ID/secret from the environment variables in the compile time: @@ -51,7 +63,7 @@ client_secret: {System, :get_env, ["GOOGLE_CLIENT_SECRET"]} ``` -1. Include the Überauth plug in your controller: +6. Include the Überauth plug in your controller: ```elixir defmodule MyApp.AuthController do @@ -61,7 +73,7 @@ end ``` -1. Create the request and callback routes if you haven't already: +7. Create the request and callback routes if you haven't already: ```elixir scope "/auth", MyApp do @@ -72,7 +84,7 @@ end ``` -1. Your controller needs to implement callbacks to deal with `Ueberauth.Auth` and `Ueberauth.Failure` responses. +8. Your controller needs to implement callbacks to deal with `Ueberauth.Auth` and `Ueberauth.Failure` responses. For an example implementation see the [Überauth Example](https://github.com/ueberauth/ueberauth_example) application. @@ -113,8 +125,8 @@ config :ueberauth, Ueberauth, ] ``` -This may also be set via runtime configuration by passing a 2 or 3 argument tuple. To use this feature, the first argument must be the atom `:system`, and the second argument must represent the environment variable containing the endpoint url. -A third argument may be passed representing a default value if the environment variable is not found, otherwise the library default will be used. +This may also be set via runtime configuration by passing a 2 or 3 argument tuple. To use this feature, the first argument must be the atom `:system`, and the second argument must represent the environment variable containing the endpoint url. +A third argument may be passed representing a default value if the environment variable is not found, otherwise the library default will be used. ```elixir config :ueberauth, Ueberauth, @@ -127,6 +139,8 @@ config :ueberauth, Ueberauth, To guard against client-side request modification, it's important to still check the domain in `info.urls[:website]` within the `Ueberauth.Auth` struct if you want to limit sign-in to a specific domain. -## License +## Copyright and License + +Copyright (c) 2015 Sean Callan -Please see [LICENSE](https://github.com/ueberauth/ueberauth_google/blob/master/LICENSE) for licensing details. +Released under the MIT License, which can be found in the repository in [LICENSE](https://github.com/ueberauth/ueberauth_google/blob/master/LICENSE). diff --git a/lib/ueberauth/strategy/google/oauth.ex b/lib/ueberauth/strategy/google/oauth.ex index 986ad9d..930769c 100644 --- a/lib/ueberauth/strategy/google/oauth.ex +++ b/lib/ueberauth/strategy/google/oauth.ex @@ -4,9 +4,10 @@ defmodule Ueberauth.Strategy.Google.OAuth do Add `client_id` and `client_secret` to your configuration: - config :ueberauth, Ueberauth.Strategy.Google.OAuth, - client_id: System.get_env("GOOGLE_APP_ID"), - client_secret: System.get_env("GOOGLE_APP_SECRET") + config :ueberauth, Ueberauth.Strategy.Google.OAuth, + client_id: System.get_env("GOOGLE_APP_ID"), + client_secret: System.get_env("GOOGLE_APP_SECRET") + """ use OAuth2.Strategy diff --git a/mix.exs b/mix.exs index a05fa8d..6449335 100644 --- a/mix.exs +++ b/mix.exs @@ -1,51 +1,58 @@ defmodule UeberauthGoogle.Mixfile do use Mix.Project + @source_url "https://github.com/ueberauth/ueberauth_google" @version "0.10.0" - @url "https://github.com/ueberauth/ueberauth_google" def project do - [app: :ueberauth_google, - version: @version, - name: "Ueberauth Google Strategy", - package: package(), - elixir: "~> 1.3", - build_embedded: Mix.env == :prod, - start_permanent: Mix.env == :prod, - source_url: @url, - homepage_url: @url, - description: description(), - deps: deps(), - docs: docs()] + [ + app: :ueberauth_google, + version: @version, + name: "Üeberauth Google", + elixir: "~> 1.8", + start_permanent: Mix.env() == :prod, + package: package(), + deps: deps(), + docs: docs() + ] end def application do - [applications: [:logger, :oauth2, :ueberauth]] + [ + extra_applications: [:logger, :oauth2, :ueberauth] + ] end defp deps do [ - {:oauth2, "~> 1.0 or ~> 2.0"}, - {:ueberauth, "~> 0.6.3"}, - - {:credo, ">= 0.0.0", only: [:dev, :test], runtime: false}, - {:ex_doc, ">= 0.0.0", only: [:dev], runtime: false}, - {:mock, "~> 0.3", only: :test} + {:oauth2, "~> 1.0 or ~> 2.0"}, + {:ueberauth, "~> 0.6.3"}, + {:credo, ">= 0.0.0", only: [:dev, :test], runtime: false}, + {:ex_doc, ">= 0.0.0", only: [:dev], runtime: false}, + {:mock, "~> 0.3", only: :test} ] end defp docs do - [extras: ["README.md", "CONTRIBUTING.md"]] - end - - defp description do - "An Uberauth strategy for Google authentication." + [ + extras: ["CHANGELOG.md", "CONTRIBUTING.md", "README.md"], + main: "readme", + source_url: @source_url, + homepage_url: @source_url, + formatters: ["html"] + ] end defp package do - [files: ["lib", "mix.exs", "README.md", "LICENSE"], - maintainers: ["Sean Callan"], - licenses: ["MIT"], - links: %{"GitHub": @url}] + [ + description: "An Uberauth strategy for Google authentication.", + files: ["lib", "mix.exs", "README.md", "CHANGELOG.md", "CONTRIBUTING.md", "LICENSE"], + maintainers: ["Sean Callan"], + licenses: ["MIT"], + links: %{ + Changelog: "https://hexdocs.pm/ueberauth_google/changelog.html", + GitHub: @source_url + } + ] end end diff --git a/mix.lock b/mix.lock index 11b60d1..e97382e 100644 --- a/mix.lock +++ b/mix.lock @@ -3,7 +3,8 @@ "certifi": {:hex, :certifi, "2.5.1", "867ce347f7c7d78563450a18a6a28a8090331e77fa02380b4a21962a65d36ee5", [:rebar3], [{:parse_trans, "~>3.3", [hex: :parse_trans, repo: "hexpm", optional: false]}], "hexpm", "805abd97539caf89ec6d4732c91e62ba9da0cda51ac462380bbd28ee697a8c42"}, "credo": {:hex, :credo, "1.1.3", "bf31887b8914a4b7e1810ae2b5aab7c657698abbf4cca6a2335a094d57995168", [:mix], [{:bunt, "~> 0.2.0", [hex: :bunt, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "95ef6f8105e9b9d61c567204d8df9c382bb9ae5dff7c11c25b69d7c022e1183e"}, "earmark": {:hex, :earmark, "1.3.5", "0db71c8290b5bc81cb0101a2a507a76dca659513984d683119ee722828b424f6", [:mix], [], "hexpm", "762b999fd414fb41e297944228aa1de2cd4a3876a07f968c8b11d1e9a2190d07"}, - "ex_doc": {:hex, :ex_doc, "0.21.1", "5ac36660846967cd869255f4426467a11672fec3d8db602c429425ce5b613b90", [:mix], [{:earmark, "~> 1.3", [hex: :earmark, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}], "hexpm", "93d2fee94d2f88abf507628378371ea5fab08ed03fa59a6daa3d4469d9159ddd"}, + "earmark_parser": {:hex, :earmark_parser, "1.4.12", "b245e875ec0a311a342320da0551da407d9d2b65d98f7a9597ae078615af3449", [:mix], [], "hexpm", "711e2cc4d64abb7d566d43f54b78f7dc129308a63bc103fbd88550d2174b3160"}, + "ex_doc": {:hex, :ex_doc, "0.24.1", "15673de99154f93ca7f05900e4e4155ced1ee0cd34e0caeee567900a616871a4", [:mix], [{:earmark_parser, "~> 1.4.0", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1", [hex: :makeup_erlang, repo: "hexpm", optional: false]}], "hexpm", "07972f17bdf7dc7b5bd76ec97b556b26178ed3f056e7ec9288eb7cea7f91cce2"}, "exactor": {:hex, :exactor, "2.2.4", "5efb4ddeb2c48d9a1d7c9b465a6fffdd82300eb9618ece5d34c3334d5d7245b1", [:mix], [], "hexpm", "1222419f706e01bfa1095aec9acf6421367dcfab798a6f67c54cf784733cd6b5"}, "exjsx": {:hex, :exjsx, "4.0.0", "60548841e0212df401e38e63c0078ec57b33e7ea49b032c796ccad8cde794b5c", [:mix], [{:jsx, "~> 2.8.0", [hex: :jsx, repo: "hexpm", optional: false]}], "hexpm", "32e95820a97cffea67830e91514a2ad53b888850442d6d395f53a1ac60c82e07"}, "exvcr": {:hex, :exvcr, "0.11.1", "a5e5f57a67538e032e16cfea6cfb1232314fb146e3ceedf1cde4a11f12fb7a58", [:mix], [{:exactor, "~> 2.2", [hex: :exactor, repo: "hexpm", optional: false]}, {:exjsx, "~> 4.0", [hex: :exjsx, repo: "hexpm", optional: false]}, {:httpoison, "~> 1.0", [hex: :httpoison, repo: "hexpm", optional: true]}, {:httpotion, "~> 3.1", [hex: :httpotion, repo: "hexpm", optional: true]}, {:ibrowse, "~> 4.4", [hex: :ibrowse, repo: "hexpm", optional: true]}, {:meck, "~> 0.8", [hex: :meck, repo: "hexpm", optional: false]}], "hexpm", "984a4d52d9e01d5f0e28d45718565a41dffab3ac18e029ae45d42f16a2a58a1d"}, @@ -11,14 +12,15 @@ "idna": {:hex, :idna, "6.0.0", "689c46cbcdf3524c44d5f3dde8001f364cd7608a99556d8fbd8239a5798d4c10", [:rebar3], [{:unicode_util_compat, "0.4.1", [hex: :unicode_util_compat, repo: "hexpm", optional: false]}], "hexpm", "4bdd305eb64e18b0273864920695cb18d7a2021f31a11b9c5fbcd9a253f936e2"}, "jason": {:hex, :jason, "1.1.2", "b03dedea67a99223a2eaf9f1264ce37154564de899fd3d8b9a21b1a6fd64afe7", [:mix], [{:decimal, "~> 1.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "fdf843bca858203ae1de16da2ee206f53416bbda5dc8c9e78f43243de4bc3afe"}, "jsx": {:hex, :jsx, "2.8.3", "a05252d381885240744d955fbe3cf810504eb2567164824e19303ea59eef62cf", [:mix, :rebar3], [], "hexpm", "fc3499fed7a726995aa659143a248534adc754ebd16ccd437cd93b649a95091f"}, - "makeup": {:hex, :makeup, "1.0.0", "671df94cf5a594b739ce03b0d0316aa64312cee2574b6a44becb83cd90fb05dc", [:mix], [{:nimble_parsec, "~> 0.5.0", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "a10c6eb62cca416019663129699769f0c2ccf39428b3bb3c0cb38c718a0c186d"}, - "makeup_elixir": {:hex, :makeup_elixir, "0.14.0", "cf8b7c66ad1cff4c14679698d532f0b5d45a3968ffbcbfd590339cb57742f1ae", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "d4b316c7222a85bbaa2fd7c6e90e37e953257ad196dc229505137c5e505e9eff"}, + "makeup": {:hex, :makeup, "1.0.5", "d5a830bc42c9800ce07dd97fa94669dfb93d3bf5fcf6ea7a0c67b2e0e4a7f26c", [:mix], [{:nimble_parsec, "~> 0.5 or ~> 1.0", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "cfa158c02d3f5c0c665d0af11512fed3fba0144cf1aadee0f2ce17747fba2ca9"}, + "makeup_elixir": {:hex, :makeup_elixir, "0.15.1", "b5888c880d17d1cc3e598f05cdb5b5a91b7b17ac4eaf5f297cb697663a1094dd", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.1", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "db68c173234b07ab2a07f645a5acdc117b9f99d69ebf521821d89690ae6c6ec8"}, + "makeup_erlang": {:hex, :makeup_erlang, "0.1.1", "3fcb7f09eb9d98dc4d208f49cc955a34218fc41ff6b84df7c75b3e6e533cc65f", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "174d0809e98a4ef0b3309256cbf97101c6ec01c4ab0b23e926a9e17df2077cbb"}, "meck": {:hex, :meck, "0.8.13", "ffedb39f99b0b99703b8601c6f17c7f76313ee12de6b646e671e3188401f7866", [:rebar3], [], "hexpm", "d34f013c156db51ad57cc556891b9720e6a1c1df5fe2e15af999c84d6cebeb1a"}, "metrics": {:hex, :metrics, "1.0.1", "25f094dea2cda98213cecc3aeff09e940299d950904393b2a29d191c346a8486", [:rebar3], [], "hexpm", "69b09adddc4f74a40716ae54d140f93beb0fb8978d8636eaded0c31b6f099f16"}, "mime": {:hex, :mime, "1.3.1", "30ce04ab3175b6ad0bdce0035cba77bba68b813d523d1aac73d9781b4d193cf8", [:mix], [], "hexpm", "6cbe761d6a0ca5a31a0931bf4c63204bceb64538e664a8ecf784a9a6f3b875f1"}, "mimerl": {:hex, :mimerl, "1.2.0", "67e2d3f571088d5cfd3e550c383094b47159f3eee8ffa08e64106cdf5e981be3", [:rebar3], [], "hexpm", "f278585650aa581986264638ebf698f8bb19df297f66ad91b18910dfc6e19323"}, "mock": {:hex, :mock, "0.3.4", "c5862eb3b8c64237f45f586cf00c9d892ba07bb48305a43319d428ce3c2897dd", [:mix], [{:meck, "~> 0.8.13", [hex: :meck, repo: "hexpm", optional: false]}], "hexpm", "e6d886252f1a41f4ba06ecf2b4c8d38760b34b1c08a11c28f7397b2e03995964"}, - "nimble_parsec": {:hex, :nimble_parsec, "0.5.1", "c90796ecee0289dbb5ad16d3ad06f957b0cd1199769641c961cfe0b97db190e0", [:mix], [], "hexpm", "00e3ebdc821fb3a36957320d49e8f4bfa310d73ea31c90e5f925dc75e030da8f"}, + "nimble_parsec": {:hex, :nimble_parsec, "1.1.0", "3a6fca1550363552e54c216debb6a9e95bd8d32348938e13de5eda962c0d7f89", [:mix], [], "hexpm", "08eb32d66b706e913ff748f11694b17981c0b04a33ef470e33e11b3d3ac8f54b"}, "oauth2": {:hex, :oauth2, "2.0.0", "338382079fe16c514420fa218b0903f8ad2d4bfc0ad0c9f988867dfa246731b0", [:mix], [{:hackney, "~> 1.13", [hex: :hackney, repo: "hexpm", optional: false]}], "hexpm", "881b8364ac7385f9fddc7949379cbe3f7081da37233a1aa7aab844670a91e7e7"}, "parse_trans": {:hex, :parse_trans, "3.3.0", "09765507a3c7590a784615cfd421d101aec25098d50b89d7aa1d66646bc571c1", [:rebar3], [], "hexpm", "17ef63abde837ad30680ea7f857dd9e7ced9476cdd7b0394432af4bfc241b960"}, "plug": {:hex, :plug, "1.10.0", "6508295cbeb4c654860845fb95260737e4a8838d34d115ad76cd487584e2fc4d", [:mix], [{:mime, "~> 1.0", [hex: :mime, repo: "hexpm", optional: false]}, {:plug_crypto, "~> 1.1.1 or ~> 1.2", [hex: :plug_crypto, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4", [hex: :telemetry, repo: "hexpm", optional: true]}], "hexpm", "422a9727e667be1bf5ab1de03be6fa0ad67b775b2d84ed908f3264415ef29d4a"}, From abeb9075891c4b24da95752415a3924f6ac5d191 Mon Sep 17 00:00:00 2001 From: Greg Rychlewski Date: Thu, 15 Jul 2021 19:17:56 -0400 Subject: [PATCH 46/80] upgrade ueberauth to 0.7.0 + refactor state param logic so it's compatible --- lib/ueberauth/strategy/google.ex | 2 +- mix.exs | 2 +- mix.lock | 9 +++--- test/strategy/google_test.exs | 53 +++++++++++++++++++++++--------- 4 files changed, 46 insertions(+), 20 deletions(-) diff --git a/lib/ueberauth/strategy/google.ex b/lib/ueberauth/strategy/google.ex index bda2847..1acbbd4 100644 --- a/lib/ueberauth/strategy/google.ex +++ b/lib/ueberauth/strategy/google.ex @@ -29,7 +29,7 @@ defmodule Ueberauth.Strategy.Google do |> with_param(:access_type, conn) |> with_param(:prompt, conn) |> with_param(:login_hint, conn) - |> with_param(:state, conn) + |> with_state_param(conn) opts = oauth_client_options_from_conn(conn) redirect!(conn, Ueberauth.Strategy.Google.OAuth.authorize_url!(params, opts)) diff --git a/mix.exs b/mix.exs index 6449335..c999730 100644 --- a/mix.exs +++ b/mix.exs @@ -26,7 +26,7 @@ defmodule UeberauthGoogle.Mixfile do defp deps do [ {:oauth2, "~> 1.0 or ~> 2.0"}, - {:ueberauth, "~> 0.6.3"}, + {:ueberauth, "~> 0.7.0"}, {:credo, ">= 0.0.0", only: [:dev, :test], runtime: false}, {:ex_doc, ">= 0.0.0", only: [:dev], runtime: false}, {:mock, "~> 0.3", only: :test} diff --git a/mix.lock b/mix.lock index e97382e..1c43d1f 100644 --- a/mix.lock +++ b/mix.lock @@ -17,15 +17,16 @@ "makeup_erlang": {:hex, :makeup_erlang, "0.1.1", "3fcb7f09eb9d98dc4d208f49cc955a34218fc41ff6b84df7c75b3e6e533cc65f", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "174d0809e98a4ef0b3309256cbf97101c6ec01c4ab0b23e926a9e17df2077cbb"}, "meck": {:hex, :meck, "0.8.13", "ffedb39f99b0b99703b8601c6f17c7f76313ee12de6b646e671e3188401f7866", [:rebar3], [], "hexpm", "d34f013c156db51ad57cc556891b9720e6a1c1df5fe2e15af999c84d6cebeb1a"}, "metrics": {:hex, :metrics, "1.0.1", "25f094dea2cda98213cecc3aeff09e940299d950904393b2a29d191c346a8486", [:rebar3], [], "hexpm", "69b09adddc4f74a40716ae54d140f93beb0fb8978d8636eaded0c31b6f099f16"}, - "mime": {:hex, :mime, "1.3.1", "30ce04ab3175b6ad0bdce0035cba77bba68b813d523d1aac73d9781b4d193cf8", [:mix], [], "hexpm", "6cbe761d6a0ca5a31a0931bf4c63204bceb64538e664a8ecf784a9a6f3b875f1"}, + "mime": {:hex, :mime, "1.6.0", "dabde576a497cef4bbdd60aceee8160e02a6c89250d6c0b29e56c0dfb00db3d2", [:mix], [], "hexpm", "31a1a8613f8321143dde1dafc36006a17d28d02bdfecb9e95a880fa7aabd19a7"}, "mimerl": {:hex, :mimerl, "1.2.0", "67e2d3f571088d5cfd3e550c383094b47159f3eee8ffa08e64106cdf5e981be3", [:rebar3], [], "hexpm", "f278585650aa581986264638ebf698f8bb19df297f66ad91b18910dfc6e19323"}, "mock": {:hex, :mock, "0.3.4", "c5862eb3b8c64237f45f586cf00c9d892ba07bb48305a43319d428ce3c2897dd", [:mix], [{:meck, "~> 0.8.13", [hex: :meck, repo: "hexpm", optional: false]}], "hexpm", "e6d886252f1a41f4ba06ecf2b4c8d38760b34b1c08a11c28f7397b2e03995964"}, "nimble_parsec": {:hex, :nimble_parsec, "1.1.0", "3a6fca1550363552e54c216debb6a9e95bd8d32348938e13de5eda962c0d7f89", [:mix], [], "hexpm", "08eb32d66b706e913ff748f11694b17981c0b04a33ef470e33e11b3d3ac8f54b"}, "oauth2": {:hex, :oauth2, "2.0.0", "338382079fe16c514420fa218b0903f8ad2d4bfc0ad0c9f988867dfa246731b0", [:mix], [{:hackney, "~> 1.13", [hex: :hackney, repo: "hexpm", optional: false]}], "hexpm", "881b8364ac7385f9fddc7949379cbe3f7081da37233a1aa7aab844670a91e7e7"}, "parse_trans": {:hex, :parse_trans, "3.3.0", "09765507a3c7590a784615cfd421d101aec25098d50b89d7aa1d66646bc571c1", [:rebar3], [], "hexpm", "17ef63abde837ad30680ea7f857dd9e7ced9476cdd7b0394432af4bfc241b960"}, - "plug": {:hex, :plug, "1.10.0", "6508295cbeb4c654860845fb95260737e4a8838d34d115ad76cd487584e2fc4d", [:mix], [{:mime, "~> 1.0", [hex: :mime, repo: "hexpm", optional: false]}, {:plug_crypto, "~> 1.1.1 or ~> 1.2", [hex: :plug_crypto, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4", [hex: :telemetry, repo: "hexpm", optional: true]}], "hexpm", "422a9727e667be1bf5ab1de03be6fa0ad67b775b2d84ed908f3264415ef29d4a"}, - "plug_crypto": {:hex, :plug_crypto, "1.1.2", "bdd187572cc26dbd95b87136290425f2b580a116d3fb1f564216918c9730d227", [:mix], [], "hexpm", "6b8b608f895b6ffcfad49c37c7883e8df98ae19c6a28113b02aa1e9c5b22d6b5"}, + "plug": {:hex, :plug, "1.11.1", "f2992bac66fdae679453c9e86134a4201f6f43a687d8ff1cd1b2862d53c80259", [:mix], [{:mime, "~> 1.0", [hex: :mime, repo: "hexpm", optional: false]}, {:plug_crypto, "~> 1.1.1 or ~> 1.2", [hex: :plug_crypto, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "23524e4fefbb587c11f0833b3910bfb414bf2e2534d61928e920f54e3a1b881f"}, + "plug_crypto": {:hex, :plug_crypto, "1.2.2", "05654514ac717ff3a1843204b424477d9e60c143406aa94daf2274fdd280794d", [:mix], [], "hexpm", "87631c7ad914a5a445f0a3809f99b079113ae4ed4b867348dd9eec288cecb6db"}, "ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.4", "f0eafff810d2041e93f915ef59899c923f4568f4585904d010387ed74988e77b", [:make, :mix, :rebar3], [], "hexpm", "603561dc0fd62f4f2ea9b890f4e20e1a0d388746d6e20557cafb1b16950de88c"}, - "ueberauth": {:hex, :ueberauth, "0.6.3", "d42ace28b870e8072cf30e32e385579c57b9cc96ec74fa1f30f30da9c14f3cc0", [:mix], [{:plug, "~> 1.5", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm", "afc293d8a1140d6591b53e3eaf415ca92842cb1d32fad3c450c6f045f7f91b60"}, + "telemetry": {:hex, :telemetry, "0.4.3", "a06428a514bdbc63293cd9a6263aad00ddeb66f608163bdec7c8995784080818", [:rebar3], [], "hexpm", "eb72b8365ffda5bed68a620d1da88525e326cb82a75ee61354fc24b844768041"}, + "ueberauth": {:hex, :ueberauth, "0.7.0", "9c44f41798b5fa27f872561b6f7d2bb0f10f03fdd22b90f454232d7b087f4b75", [:mix], [{:plug, "~> 1.5", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm", "2efad9022e949834f16cc52cd935165049d81fa9e925690f91035c2e4b58d905"}, "unicode_util_compat": {:hex, :unicode_util_compat, "0.4.1", "d869e4c68901dd9531385bb0c8c40444ebf624e60b6962d95952775cac5e90cd", [:rebar3], [], "hexpm", "1d1848c40487cdb0b30e8ed975e34e025860c02e419cb615d255849f3427439d"}, } diff --git a/test/strategy/google_test.exs b/test/strategy/google_test.exs index d5f0b93..bb4d642 100644 --- a/test/strategy/google_test.exs +++ b/test/strategy/google_test.exs @@ -4,6 +4,7 @@ defmodule Ueberauth.Strategy.GoogleTest do import Mock import Plug.Conn + import Ueberauth.Strategy.Helpers setup_with_mocks([ {OAuth2.Client, [:passthrough], @@ -12,7 +13,12 @@ defmodule Ueberauth.Strategy.GoogleTest do get: &oauth2_get/4 ]} ]) do - :ok + # Create a connection with Ueberauth's CSRF cookies so they can be recycled during tests + routes = Ueberauth.init([]) + csrf_conn = conn(:get, "/auth/google", %{}) |> Ueberauth.call(routes) + csrf_state = with_state_param([], csrf_conn) |> Keyword.get(:state) + + {:ok, csrf_conn: csrf_conn, csrf_state: csrf_state} end def set_options(routes, conn, opt) do @@ -47,6 +53,13 @@ defmodule Ueberauth.Strategy.GoogleTest do def oauth2_get(%{token: %{access_token: "userinfo_token"}}, "example.com/scooby", _, _), do: response(%{"sub" => "1234_scooby", "name" => "Scooby Doo"}) + defp set_csrf_cookies(conn, csrf_conn) do + conn + |> init_test_session(%{}) + |> recycle_cookies(csrf_conn) + |> fetch_cookies() + end + test "handle_request! redirects to appropriate auth uri" do conn = conn(:get, "/auth/google", %{}) # Make sure the hd and scope params are included for good measure @@ -70,8 +83,8 @@ defmodule Ueberauth.Strategy.GoogleTest do } = Plug.Conn.Query.decode(redirect_uri.query) end - test "handle_callback! assigns required fields on successful auth" do - conn = conn(:get, "/auth/google/callback", %{code: "success_code"}) + test "handle_callback! assigns required fields on successful auth", %{csrf_state: csrf_state, csrf_conn: csrf_conn} do + conn = conn(:get, "/auth/google/callback", %{code: "success_code", state: csrf_state}) |> set_csrf_cookies(csrf_conn) routes = Ueberauth.init([]) assert %Plug.Conn{assigns: %{ueberauth_auth: auth}} = Ueberauth.call(conn, routes) assert auth.credentials.token == "success_token" @@ -80,42 +93,54 @@ defmodule Ueberauth.Strategy.GoogleTest do assert auth.uid == "1234_fred" end - test "uid_field is picked according to the specified option" do - conn = conn(:get, "/auth/google/callback", %{code: "uid_code"}) + test "uid_field is picked according to the specified option", %{csrf_state: csrf_state, csrf_conn: csrf_conn} do + conn = conn(:get, "/auth/google/callback", %{code: "uid_code", state: csrf_state}) |> set_csrf_cookies(csrf_conn) routes = Ueberauth.init() |> set_options(conn, uid_field: "uid_field") assert %Plug.Conn{assigns: %{ueberauth_auth: auth}} = Ueberauth.call(conn, routes) assert auth.info.name == "Daphne Blake" assert auth.uid == "1234_daphne" end - test "userinfo is fetched according to userinfo_endpoint" do - conn = conn(:get, "/auth/google/callback", %{code: "userinfo_code"}) + test "userinfo is fetched according to userinfo_endpoint", %{csrf_state: csrf_state, csrf_conn: csrf_conn} do + conn = conn(:get, "/auth/google/callback", %{code: "userinfo_code", state: csrf_state}) |> set_csrf_cookies(csrf_conn) routes = Ueberauth.init() |> set_options(conn, userinfo_endpoint: "example.com/shaggy") assert %Plug.Conn{assigns: %{ueberauth_auth: auth}} = Ueberauth.call(conn, routes) assert auth.info.name == "Norville Rogers" end - test "userinfo can be set via runtime config with default" do - conn = conn(:get, "/auth/google/callback", %{code: "userinfo_code"}) + test "userinfo can be set via runtime config with default", %{csrf_state: csrf_state, csrf_conn: csrf_conn} do + conn = conn(:get, "/auth/google/callback", %{code: "userinfo_code", state: csrf_state}) |> set_csrf_cookies(csrf_conn) routes = Ueberauth.init() |> set_options(conn, userinfo_endpoint: {:system, "NOT_SET", "example.com/shaggy"}) assert %Plug.Conn{assigns: %{ueberauth_auth: auth}} = Ueberauth.call(conn, routes) assert auth.info.name == "Norville Rogers" end - test "userinfo uses default library value if runtime env not found" do - conn = conn(:get, "/auth/google/callback", %{code: "userinfo_code"}) + test "userinfo uses default library value if runtime env not found", %{csrf_state: csrf_state, csrf_conn: csrf_conn} do + conn = conn(:get, "/auth/google/callback", %{code: "userinfo_code", state: csrf_state}) |> set_csrf_cookies(csrf_conn) routes = Ueberauth.init() |> set_options(conn, userinfo_endpoint: {:system, "NOT_SET"}) assert %Plug.Conn{assigns: %{ueberauth_auth: auth}} = Ueberauth.call(conn, routes) assert auth.info.name == "Velma Dinkley" end - test "userinfo can be set via runtime config" do - conn = conn(:get, "/auth/google/callback", %{code: "userinfo_code"}) + test "userinfo can be set via runtime config", %{csrf_state: csrf_state, csrf_conn: csrf_conn} do + conn = conn(:get, "/auth/google/callback", %{code: "userinfo_code", state: csrf_state}) |> set_csrf_cookies(csrf_conn) routes = Ueberauth.init() |> set_options(conn, userinfo_endpoint: {:system, "UEBERAUTH_SCOOBY_DOO"}) - System.put_env("UEBERAUTH_SCOOBY_DOO", "example.com/scooby") assert %Plug.Conn{assigns: %{ueberauth_auth: auth}} = Ueberauth.call(conn, routes) assert auth.info.name == "Scooby Doo" System.delete_env("UEBERAUTH_SCOOBY_DOO") end + + test "state param is present in the redirect uri" do + conn = conn(:get, "/auth/google", %{}) + + routes = Ueberauth.init() + resp = Ueberauth.call(conn, routes) + + assert [location] = get_resp_header(resp, "location") + + redirect_uri = URI.parse(location) + + assert redirect_uri.query =~ "state=" + end end From 79090d2d98db10409e2d679c70249db7569cf50e Mon Sep 17 00:00:00 2001 From: Greg Rychlewski Date: Thu, 15 Jul 2021 19:18:29 -0400 Subject: [PATCH 47/80] mix format --- test/strategy/google_test.exs | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/test/strategy/google_test.exs b/test/strategy/google_test.exs index bb4d642..48743ab 100644 --- a/test/strategy/google_test.exs +++ b/test/strategy/google_test.exs @@ -84,7 +84,9 @@ defmodule Ueberauth.Strategy.GoogleTest do end test "handle_callback! assigns required fields on successful auth", %{csrf_state: csrf_state, csrf_conn: csrf_conn} do - conn = conn(:get, "/auth/google/callback", %{code: "success_code", state: csrf_state}) |> set_csrf_cookies(csrf_conn) + conn = + conn(:get, "/auth/google/callback", %{code: "success_code", state: csrf_state}) |> set_csrf_cookies(csrf_conn) + routes = Ueberauth.init([]) assert %Plug.Conn{assigns: %{ueberauth_auth: auth}} = Ueberauth.call(conn, routes) assert auth.credentials.token == "success_token" @@ -102,28 +104,36 @@ defmodule Ueberauth.Strategy.GoogleTest do end test "userinfo is fetched according to userinfo_endpoint", %{csrf_state: csrf_state, csrf_conn: csrf_conn} do - conn = conn(:get, "/auth/google/callback", %{code: "userinfo_code", state: csrf_state}) |> set_csrf_cookies(csrf_conn) + conn = + conn(:get, "/auth/google/callback", %{code: "userinfo_code", state: csrf_state}) |> set_csrf_cookies(csrf_conn) + routes = Ueberauth.init() |> set_options(conn, userinfo_endpoint: "example.com/shaggy") assert %Plug.Conn{assigns: %{ueberauth_auth: auth}} = Ueberauth.call(conn, routes) assert auth.info.name == "Norville Rogers" end test "userinfo can be set via runtime config with default", %{csrf_state: csrf_state, csrf_conn: csrf_conn} do - conn = conn(:get, "/auth/google/callback", %{code: "userinfo_code", state: csrf_state}) |> set_csrf_cookies(csrf_conn) + conn = + conn(:get, "/auth/google/callback", %{code: "userinfo_code", state: csrf_state}) |> set_csrf_cookies(csrf_conn) + routes = Ueberauth.init() |> set_options(conn, userinfo_endpoint: {:system, "NOT_SET", "example.com/shaggy"}) assert %Plug.Conn{assigns: %{ueberauth_auth: auth}} = Ueberauth.call(conn, routes) assert auth.info.name == "Norville Rogers" end test "userinfo uses default library value if runtime env not found", %{csrf_state: csrf_state, csrf_conn: csrf_conn} do - conn = conn(:get, "/auth/google/callback", %{code: "userinfo_code", state: csrf_state}) |> set_csrf_cookies(csrf_conn) + conn = + conn(:get, "/auth/google/callback", %{code: "userinfo_code", state: csrf_state}) |> set_csrf_cookies(csrf_conn) + routes = Ueberauth.init() |> set_options(conn, userinfo_endpoint: {:system, "NOT_SET"}) assert %Plug.Conn{assigns: %{ueberauth_auth: auth}} = Ueberauth.call(conn, routes) assert auth.info.name == "Velma Dinkley" end test "userinfo can be set via runtime config", %{csrf_state: csrf_state, csrf_conn: csrf_conn} do - conn = conn(:get, "/auth/google/callback", %{code: "userinfo_code", state: csrf_state}) |> set_csrf_cookies(csrf_conn) + conn = + conn(:get, "/auth/google/callback", %{code: "userinfo_code", state: csrf_state}) |> set_csrf_cookies(csrf_conn) + routes = Ueberauth.init() |> set_options(conn, userinfo_endpoint: {:system, "UEBERAUTH_SCOOBY_DOO"}) System.put_env("UEBERAUTH_SCOOBY_DOO", "example.com/scooby") assert %Plug.Conn{assigns: %{ueberauth_auth: auth}} = Ueberauth.call(conn, routes) From 1b830f6116e9b5f48bf004172d07634b5030cc33 Mon Sep 17 00:00:00 2001 From: Yordis Prieto Lazo Date: Thu, 15 Jul 2021 19:52:17 -0400 Subject: [PATCH 48/80] Versioning --- CHANGELOG.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b877ce4..b6db4bd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,11 @@ # Changelog -## v0.11.0 (Unreleased) +## (Unreleased) +## v0.10.1 + +* Misc doc changes [81](https://github.com/ueberauth/ueberauth_google/pull/81) +* Upgrade Ueberauth and Refactor CSRF State Logic [82](https://github.com/ueberauth/ueberauth_google/pull/82) ## v0.10.0 - 2020-10-20 From ee6f9ddff059a0b8eb2cddaf64d3eefcc2202450 Mon Sep 17 00:00:00 2001 From: Yordis Prieto Lazo Date: Thu, 15 Jul 2021 20:07:17 -0400 Subject: [PATCH 49/80] Update version --- mix.exs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mix.exs b/mix.exs index c999730..6d3d0be 100644 --- a/mix.exs +++ b/mix.exs @@ -2,7 +2,7 @@ defmodule UeberauthGoogle.Mixfile do use Mix.Project @source_url "https://github.com/ueberauth/ueberauth_google" - @version "0.10.0" + @version "0.10.1" def project do [ From e38f39b8e0d6ecc0fdf5ba0d6e1cd2546ac41397 Mon Sep 17 00:00:00 2001 From: Jason Axelson Date: Wed, 8 Sep 2021 14:00:35 -0700 Subject: [PATCH 50/80] Remove :applications instructions from readme Elixir 1.4 (released in 2016) add application inference, so now in almost all situations it is not necessary to add a dependency to `:applications`. And if you set just a single application in `:applications` then you will break your release. Since ueberauth_google only support Elixir 1.8 and up, we don't need to mention :applications anymore --- README.md | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 9885737..6ed15b0 100644 --- a/README.md +++ b/README.md @@ -24,17 +24,7 @@ end ``` -3. Add the strategy to your applications: - - ```elixir - def application do - [ - applications: [:ueberauth_google] - ] - end - ``` - -4. Add Google to your Überauth configuration: +3. Add Google to your Überauth configuration: ```elixir config :ueberauth, Ueberauth, @@ -43,7 +33,7 @@ ] ``` -5. Update your provider configuration: +4. Update your provider configuration: Use that if you want to read client ID/secret from the environment variables in the compile time: @@ -63,7 +53,7 @@ client_secret: {System, :get_env, ["GOOGLE_CLIENT_SECRET"]} ``` -6. Include the Überauth plug in your controller: +5. Include the Überauth plug in your controller: ```elixir defmodule MyApp.AuthController do @@ -73,7 +63,7 @@ end ``` -7. Create the request and callback routes if you haven't already: +6. Create the request and callback routes if you haven't already: ```elixir scope "/auth", MyApp do @@ -84,7 +74,7 @@ end ``` -8. Your controller needs to implement callbacks to deal with `Ueberauth.Auth` and `Ueberauth.Failure` responses. +7. Your controller needs to implement callbacks to deal with `Ueberauth.Auth` and `Ueberauth.Failure` responses. For an example implementation see the [Überauth Example](https://github.com/ueberauth/ueberauth_example) application. From facf8b7bb95b52ae3ae0c1479109525b065bab32 Mon Sep 17 00:00:00 2001 From: Yordis Prieto Lazo Date: Sun, 17 Oct 2021 14:14:51 -0400 Subject: [PATCH 51/80] chore: add workflows --- .github/CODEOWNERS | 3 +++ .github/workflows/ci.yml | 51 +++++++++++++++++++++++++++++++++++ .github/workflows/release.yml | 32 ++++++++++++++++++++++ 3 files changed, 86 insertions(+) create mode 100644 .github/CODEOWNERS create mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/release.yml diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 0000000..09f3be6 --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1,3 @@ +# Order is important. The last matching pattern takes the most precedence. +# Default owners for everything in the repo. +* @ueberauth/developers diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..d57516b --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,51 @@ +name: Continuous Integration + +on: + pull_request: + types: [opened, reopened, synchronize] + push: + branches: + - 'master' +jobs: + Test: + runs-on: ubuntu-latest + steps: + - name: Checkout Code + uses: actions/checkout@v1 + + - name: Set up Elixir + uses: erlef/setup-elixir@v1 + with: + elixir-version: '1.11' + otp-version: '22.3' + + - name: Install Dependencies + run: | + mix local.rebar --force + mix local.hex --force + mix deps.get + - name: Run Tests + run: mix test + + Linting: + runs-on: ubuntu-latest + steps: + - name: Checkout Code + uses: actions/checkout@v1 + + - name: Set up Elixir + uses: erlef/setup-elixir@v1 + with: + elixir-version: '1.11' + otp-version: '22.3' + + - name: Install Dependencies + run: | + mix local.rebar --force + mix local.hex --force + mix deps.get + - name: Run Formatter + run: mix format --check-formatted + + - name: Run Credo + run: mix credo diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..61d5739 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,32 @@ +name: Hexpm Release + +on: + release: + types: [published] + +jobs: + publish: + name: Publish + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Set up Elixir + uses: erlef/setup-elixir@v1 + with: + elixir-version: '1.11' + otp-version: '22.3' + - name: Restore dependencies cache + uses: actions/cache@v2 + with: + path: deps + key: ${{ runner.os }}-mix-${{ hashFiles('**/mix.lock') }} + restore-keys: ${{ runner.os }}-mix- + - name: Install dependencies + run: | + mix local.rebar --force + mix local.hex --force + mix deps.get + - name: Run Hex Publish + run: mix hex.publish --yes + env: + HEX_API_KEY: ${{ secrets.HEX_API_KEY }} From 65e506b2f6765181a55efc7050d7ceb315cd5c56 Mon Sep 17 00:00:00 2001 From: Yordis Prieto Lazo Date: Sun, 17 Oct 2021 14:39:54 -0400 Subject: [PATCH 52/80] chore: fix ci --- lib/ueberauth/strategy/google.ex | 12 +++++++++--- lib/ueberauth/strategy/google/oauth.ex | 12 +++++++----- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/lib/ueberauth/strategy/google.ex b/lib/ueberauth/strategy/google.ex index 1acbbd4..e209777 100644 --- a/lib/ueberauth/strategy/google.ex +++ b/lib/ueberauth/strategy/google.ex @@ -45,6 +45,7 @@ defmodule Ueberauth.Strategy.Google do case Ueberauth.Strategy.Google.OAuth.get_access_token(params, opts) do {:ok, token} -> fetch_user(conn, token) + {:error, {error_code, error_description}} -> set_errors!(conn, [error(error_code, error_description)]) end @@ -78,9 +79,9 @@ defmodule Ueberauth.Strategy.Google do Includes the credentials from the google response. """ def credentials(conn) do - token = conn.private.google_token - scope_string = (token.other_params["scope"] || "") - scopes = String.split(scope_string, ",") + token = conn.private.google_token + scope_string = token.other_params["scope"] || "" + scopes = String.split(scope_string, ",") %Credentials{ expires: !!token.expires_at, @@ -133,8 +134,10 @@ defmodule Ueberauth.Strategy.Google do case option(conn, :userinfo_endpoint) do {:system, varname, default} -> System.get_env(varname) || default + {:system, varname} -> System.get_env(varname) || Keyword.get(default_options(), :userinfo_endpoint) + other -> other end @@ -144,10 +147,13 @@ defmodule Ueberauth.Strategy.Google do case resp do {:ok, %OAuth2.Response{status_code: 401, body: _body}} -> set_errors!(conn, [error("token", "unauthorized")]) + {:ok, %OAuth2.Response{status_code: status_code, body: user}} when status_code in 200..399 -> put_private(conn, :google_user, user) + {:error, %OAuth2.Response{status_code: status_code}} -> set_errors!(conn, [error("OAuth2", status_code)]) + {:error, %OAuth2.Error{reason: reason}} -> set_errors!(conn, [error("OAuth2", reason)]) end diff --git a/lib/ueberauth/strategy/google/oauth.ex b/lib/ueberauth/strategy/google/oauth.ex index 930769c..a8b1d19 100644 --- a/lib/ueberauth/strategy/google/oauth.ex +++ b/lib/ueberauth/strategy/google/oauth.ex @@ -12,11 +12,11 @@ defmodule Ueberauth.Strategy.Google.OAuth do use OAuth2.Strategy @defaults [ - strategy: __MODULE__, - site: "https://accounts.google.com", - authorize_url: "/o/oauth2/v2/auth", - token_url: "https://www.googleapis.com/oauth2/v4/token" - ] + strategy: __MODULE__, + site: "https://accounts.google.com", + authorize_url: "/o/oauth2/v2/auth", + token_url: "https://www.googleapis.com/oauth2/v4/token" + ] @doc """ Construct a client for requests to Google. @@ -54,9 +54,11 @@ defmodule Ueberauth.Strategy.Google.OAuth do case opts |> client |> OAuth2.Client.get_token(params) do {:error, %{body: %{"error" => error, "error_description" => description}}} -> {:error, {error, description}} + {:ok, %{token: %{access_token: nil} = token}} -> %{"error" => error, "error_description" => description} = token.other_params {:error, {error, description}} + {:ok, %{token: token}} -> {:ok, token} end From becc95360ea5e2a9ffc6bc1481d2514440b5194b Mon Sep 17 00:00:00 2001 From: Yordis Prieto Lazo Date: Sun, 17 Oct 2021 14:50:39 -0400 Subject: [PATCH 53/80] chore: fix credo --- lib/ueberauth/strategy/google.ex | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/lib/ueberauth/strategy/google.ex b/lib/ueberauth/strategy/google.ex index e209777..765fdbf 100644 --- a/lib/ueberauth/strategy/google.ex +++ b/lib/ueberauth/strategy/google.ex @@ -130,25 +130,14 @@ defmodule Ueberauth.Strategy.Google do # userinfo_endpoint from https://accounts.google.com/.well-known/openid-configuration # the userinfo_endpoint may be overridden in options when necessary. - path = - case option(conn, :userinfo_endpoint) do - {:system, varname, default} -> - System.get_env(varname) || default - - {:system, varname} -> - System.get_env(varname) || Keyword.get(default_options(), :userinfo_endpoint) - - other -> - other - end - - resp = Ueberauth.Strategy.Google.OAuth.get(token, path) + resp = Ueberauth.Strategy.Google.OAuth.get(token, get_userinfo_endpoint(conn)) case resp do {:ok, %OAuth2.Response{status_code: 401, body: _body}} -> set_errors!(conn, [error("token", "unauthorized")]) - {:ok, %OAuth2.Response{status_code: status_code, body: user}} when status_code in 200..399 -> + {:ok, %OAuth2.Response{status_code: status_code, body: user}} + when status_code in 200..399 -> put_private(conn, :google_user, user) {:error, %OAuth2.Response{status_code: status_code}} -> @@ -159,6 +148,19 @@ defmodule Ueberauth.Strategy.Google do end end + defp get_userinfo_endpoint(conn) do + case option(conn, :userinfo_endpoint) do + {:system, varname, default} -> + System.get_env(varname) || default + + {:system, varname} -> + System.get_env(varname) || Keyword.get(default_options(), :userinfo_endpoint) + + other -> + other + end + end + defp with_param(opts, key, conn) do if value = conn.params[to_string(key)], do: Keyword.put(opts, key, value), else: opts end From adf59076474f819f7bbae7ac09cb80632dfe7198 Mon Sep 17 00:00:00 2001 From: Lukasz Samson Date: Wed, 29 Dec 2021 13:46:31 +0100 Subject: [PATCH 54/80] fix crash on not handled Oauth2.Error --- lib/ueberauth/strategy/google/oauth.ex | 9 ++++++--- test/strategy/google_test.exs | 22 ++++++++++++++++++++++ 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/lib/ueberauth/strategy/google/oauth.ex b/lib/ueberauth/strategy/google/oauth.ex index a8b1d19..f04a8d3 100644 --- a/lib/ueberauth/strategy/google/oauth.ex +++ b/lib/ueberauth/strategy/google/oauth.ex @@ -52,14 +52,17 @@ defmodule Ueberauth.Strategy.Google.OAuth do def get_access_token(params \\ [], opts \\ []) do case opts |> client |> OAuth2.Client.get_token(params) do - {:error, %{body: %{"error" => error, "error_description" => description}}} -> + {:error, %OAuth2.Response{body: %{"error" => error, "error_description" => description}}} -> {:error, {error, description}} - {:ok, %{token: %{access_token: nil} = token}} -> + {:error, %OAuth2.Error{reason: reason}} -> + {:error, {"error", to_string(reason)}} + + {:ok, %OAuth2.Client{token: %{access_token: nil} = token}} -> %{"error" => error, "error_description" => description} = token.other_params {:error, {error, description}} - {:ok, %{token: token}} -> + {:ok, %OAuth2.Client{token: token}} -> {:ok, token} end end diff --git a/test/strategy/google_test.exs b/test/strategy/google_test.exs index 48743ab..f6756b4 100644 --- a/test/strategy/google_test.exs +++ b/test/strategy/google_test.exs @@ -37,6 +37,8 @@ defmodule Ueberauth.Strategy.GoogleTest do def oauth2_get_token(client, code: "success_code"), do: token(client, "success_token") def oauth2_get_token(client, code: "uid_code"), do: token(client, "uid_token") def oauth2_get_token(client, code: "userinfo_code"), do: token(client, "userinfo_token") + def oauth2_get_token(_client, code: "oauth2_error"), do: {:error, %OAuth2.Error{reason: :timeout}} + def oauth2_get_token(_client, code: "error_response"), do: {:error, %OAuth2.Response{body: %{"error" => "some error", "error_description" => "something went wrong"}}} def oauth2_get(%{token: %{access_token: "success_token"}}, _url, _, _), do: response(%{"sub" => "1234_fred", "name" => "Fred Jones", "email" => "fred_jones@example.com"}) @@ -153,4 +155,24 @@ defmodule Ueberauth.Strategy.GoogleTest do assert redirect_uri.query =~ "state=" end + + describe "error handling" do + test "handle_callback! handles Oauth2.Error", %{csrf_state: csrf_state, csrf_conn: csrf_conn} do + conn = + conn(:get, "/auth/google/callback", %{code: "oauth2_error", state: csrf_state}) |> set_csrf_cookies(csrf_conn) + + routes = Ueberauth.init([]) + assert %Plug.Conn{assigns: %{ueberauth_failure: failure}} = Ueberauth.call(conn, routes) + assert %Ueberauth.Failure{errors: [%Ueberauth.Failure.Error{message: "timeout", message_key: "error"}]} = failure + end + + test "handle_callback! handles error response", %{csrf_state: csrf_state, csrf_conn: csrf_conn} do + conn = + conn(:get, "/auth/google/callback", %{code: "error_response", state: csrf_state}) |> set_csrf_cookies(csrf_conn) + + routes = Ueberauth.init([]) + assert %Plug.Conn{assigns: %{ueberauth_failure: failure}} = Ueberauth.call(conn, routes) + assert %Ueberauth.Failure{errors: [%Ueberauth.Failure.Error{message: "something went wrong", message_key: "some error"}]} = failure + end + end end From 3b8ee407794b5401c2593465e90a386a3a1e238d Mon Sep 17 00:00:00 2001 From: Wilhelm Hugo Kirschbaum Date: Sat, 21 May 2022 11:01:20 +0200 Subject: [PATCH 55/80] import Config to fix warning --- config/config.exs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/config.exs b/config/config.exs index 795f918..fc261c2 100644 --- a/config/config.exs +++ b/config/config.exs @@ -1,4 +1,4 @@ -use Mix.Config +import Config config :ueberauth, Ueberauth, providers: [ From c2b86b949bc4032b47db63a54259148a10e0d601 Mon Sep 17 00:00:00 2001 From: Wilhelm Hugo Kirschbaum Date: Sat, 21 May 2022 11:02:12 +0200 Subject: [PATCH 56/80] Allow ueberauth 0.9 Ueberauth 0.9 does not seem to introduce any compatibility issues with ueberauth_google --- mix.exs | 2 +- mix.lock | 39 ++++++++++++++++++++------------------- 2 files changed, 21 insertions(+), 20 deletions(-) diff --git a/mix.exs b/mix.exs index 6d3d0be..2367fe3 100644 --- a/mix.exs +++ b/mix.exs @@ -26,7 +26,7 @@ defmodule UeberauthGoogle.Mixfile do defp deps do [ {:oauth2, "~> 1.0 or ~> 2.0"}, - {:ueberauth, "~> 0.7.0"}, + {:ueberauth, "~> 0.7.0 or ~> 0.9.0"}, {:credo, ">= 0.0.0", only: [:dev, :test], runtime: false}, {:ex_doc, ">= 0.0.0", only: [:dev], runtime: false}, {:mock, "~> 0.3", only: :test} diff --git a/mix.lock b/mix.lock index 1c43d1f..72792e9 100644 --- a/mix.lock +++ b/mix.lock @@ -1,32 +1,33 @@ %{ "bunt": {:hex, :bunt, "0.2.0", "951c6e801e8b1d2cbe58ebbd3e616a869061ddadcc4863d0a2182541acae9a38", [:mix], [], "hexpm", "7af5c7e09fe1d40f76c8e4f9dd2be7cebd83909f31fee7cd0e9eadc567da8353"}, - "certifi": {:hex, :certifi, "2.5.1", "867ce347f7c7d78563450a18a6a28a8090331e77fa02380b4a21962a65d36ee5", [:rebar3], [{:parse_trans, "~>3.3", [hex: :parse_trans, repo: "hexpm", optional: false]}], "hexpm", "805abd97539caf89ec6d4732c91e62ba9da0cda51ac462380bbd28ee697a8c42"}, - "credo": {:hex, :credo, "1.1.3", "bf31887b8914a4b7e1810ae2b5aab7c657698abbf4cca6a2335a094d57995168", [:mix], [{:bunt, "~> 0.2.0", [hex: :bunt, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "95ef6f8105e9b9d61c567204d8df9c382bb9ae5dff7c11c25b69d7c022e1183e"}, + "certifi": {:hex, :certifi, "2.9.0", "6f2a475689dd47f19fb74334859d460a2dc4e3252a3324bd2111b8f0429e7e21", [:rebar3], [], "hexpm", "266da46bdb06d6c6d35fde799bcb28d36d985d424ad7c08b5bb48f5b5cdd4641"}, + "credo": {:hex, :credo, "1.6.4", "ddd474afb6e8c240313f3a7b0d025cc3213f0d171879429bf8535d7021d9ad78", [:mix], [{:bunt, "~> 0.2.0", [hex: :bunt, repo: "hexpm", optional: false]}, {:file_system, "~> 0.2.8", [hex: :file_system, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "c28f910b61e1ff829bffa056ef7293a8db50e87f2c57a9b5c3f57eee124536b7"}, "earmark": {:hex, :earmark, "1.3.5", "0db71c8290b5bc81cb0101a2a507a76dca659513984d683119ee722828b424f6", [:mix], [], "hexpm", "762b999fd414fb41e297944228aa1de2cd4a3876a07f968c8b11d1e9a2190d07"}, - "earmark_parser": {:hex, :earmark_parser, "1.4.12", "b245e875ec0a311a342320da0551da407d9d2b65d98f7a9597ae078615af3449", [:mix], [], "hexpm", "711e2cc4d64abb7d566d43f54b78f7dc129308a63bc103fbd88550d2174b3160"}, - "ex_doc": {:hex, :ex_doc, "0.24.1", "15673de99154f93ca7f05900e4e4155ced1ee0cd34e0caeee567900a616871a4", [:mix], [{:earmark_parser, "~> 1.4.0", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1", [hex: :makeup_erlang, repo: "hexpm", optional: false]}], "hexpm", "07972f17bdf7dc7b5bd76ec97b556b26178ed3f056e7ec9288eb7cea7f91cce2"}, + "earmark_parser": {:hex, :earmark_parser, "1.4.25", "2024618731c55ebfcc5439d756852ec4e85978a39d0d58593763924d9a15916f", [:mix], [], "hexpm", "56749c5e1c59447f7b7a23ddb235e4b3defe276afc220a6227237f3efe83f51e"}, + "ex_doc": {:hex, :ex_doc, "0.28.4", "001a0ea6beac2f810f1abc3dbf4b123e9593eaa5f00dd13ded024eae7c523298", [:mix], [{:earmark_parser, "~> 1.4.19", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1", [hex: :makeup_erlang, repo: "hexpm", optional: false]}], "hexpm", "bf85d003dd34911d89c8ddb8bda1a958af3471a274a4c2150a9c01c78ac3f8ed"}, "exactor": {:hex, :exactor, "2.2.4", "5efb4ddeb2c48d9a1d7c9b465a6fffdd82300eb9618ece5d34c3334d5d7245b1", [:mix], [], "hexpm", "1222419f706e01bfa1095aec9acf6421367dcfab798a6f67c54cf784733cd6b5"}, "exjsx": {:hex, :exjsx, "4.0.0", "60548841e0212df401e38e63c0078ec57b33e7ea49b032c796ccad8cde794b5c", [:mix], [{:jsx, "~> 2.8.0", [hex: :jsx, repo: "hexpm", optional: false]}], "hexpm", "32e95820a97cffea67830e91514a2ad53b888850442d6d395f53a1ac60c82e07"}, "exvcr": {:hex, :exvcr, "0.11.1", "a5e5f57a67538e032e16cfea6cfb1232314fb146e3ceedf1cde4a11f12fb7a58", [:mix], [{:exactor, "~> 2.2", [hex: :exactor, repo: "hexpm", optional: false]}, {:exjsx, "~> 4.0", [hex: :exjsx, repo: "hexpm", optional: false]}, {:httpoison, "~> 1.0", [hex: :httpoison, repo: "hexpm", optional: true]}, {:httpotion, "~> 3.1", [hex: :httpotion, repo: "hexpm", optional: true]}, {:ibrowse, "~> 4.4", [hex: :ibrowse, repo: "hexpm", optional: true]}, {:meck, "~> 0.8", [hex: :meck, repo: "hexpm", optional: false]}], "hexpm", "984a4d52d9e01d5f0e28d45718565a41dffab3ac18e029ae45d42f16a2a58a1d"}, - "hackney": {:hex, :hackney, "1.15.1", "9f8f471c844b8ce395f7b6d8398139e26ddca9ebc171a8b91342ee15a19963f4", [:rebar3], [{:certifi, "2.5.1", [hex: :certifi, repo: "hexpm", optional: false]}, {:idna, "6.0.0", [hex: :idna, repo: "hexpm", optional: false]}, {:metrics, "1.0.1", [hex: :metrics, repo: "hexpm", optional: false]}, {:mimerl, "~>1.1", [hex: :mimerl, repo: "hexpm", optional: false]}, {:ssl_verify_fun, "1.1.4", [hex: :ssl_verify_fun, repo: "hexpm", optional: false]}], "hexpm", "c2790c9f0f7205f4a362512192dee8179097394400e745e4d20bab7226a8eaad"}, - "idna": {:hex, :idna, "6.0.0", "689c46cbcdf3524c44d5f3dde8001f364cd7608a99556d8fbd8239a5798d4c10", [:rebar3], [{:unicode_util_compat, "0.4.1", [hex: :unicode_util_compat, repo: "hexpm", optional: false]}], "hexpm", "4bdd305eb64e18b0273864920695cb18d7a2021f31a11b9c5fbcd9a253f936e2"}, - "jason": {:hex, :jason, "1.1.2", "b03dedea67a99223a2eaf9f1264ce37154564de899fd3d8b9a21b1a6fd64afe7", [:mix], [{:decimal, "~> 1.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "fdf843bca858203ae1de16da2ee206f53416bbda5dc8c9e78f43243de4bc3afe"}, + "file_system": {:hex, :file_system, "0.2.10", "fb082005a9cd1711c05b5248710f8826b02d7d1784e7c3451f9c1231d4fc162d", [:mix], [], "hexpm", "41195edbfb562a593726eda3b3e8b103a309b733ad25f3d642ba49696bf715dc"}, + "hackney": {:hex, :hackney, "1.18.1", "f48bf88f521f2a229fc7bae88cf4f85adc9cd9bcf23b5dc8eb6a1788c662c4f6", [:rebar3], [{:certifi, "~>2.9.0", [hex: :certifi, repo: "hexpm", optional: false]}, {:idna, "~>6.1.0", [hex: :idna, repo: "hexpm", optional: false]}, {:metrics, "~>1.0.0", [hex: :metrics, repo: "hexpm", optional: false]}, {:mimerl, "~>1.1", [hex: :mimerl, repo: "hexpm", optional: false]}, {:parse_trans, "3.3.1", [hex: :parse_trans, repo: "hexpm", optional: false]}, {:ssl_verify_fun, "~>1.1.0", [hex: :ssl_verify_fun, repo: "hexpm", optional: false]}, {:unicode_util_compat, "~>0.7.0", [hex: :unicode_util_compat, repo: "hexpm", optional: false]}], "hexpm", "a4ecdaff44297e9b5894ae499e9a070ea1888c84afdd1fd9b7b2bc384950128e"}, + "idna": {:hex, :idna, "6.1.1", "8a63070e9f7d0c62eb9d9fcb360a7de382448200fbbd1b106cc96d3d8099df8d", [:rebar3], [{:unicode_util_compat, "~>0.7.0", [hex: :unicode_util_compat, repo: "hexpm", optional: false]}], "hexpm", "92376eb7894412ed19ac475e4a86f7b413c1b9fbb5bd16dccd57934157944cea"}, + "jason": {:hex, :jason, "1.3.0", "fa6b82a934feb176263ad2df0dbd91bf633d4a46ebfdffea0c8ae82953714946", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "53fc1f51255390e0ec7e50f9cb41e751c260d065dcba2bf0d08dc51a4002c2ac"}, "jsx": {:hex, :jsx, "2.8.3", "a05252d381885240744d955fbe3cf810504eb2567164824e19303ea59eef62cf", [:mix, :rebar3], [], "hexpm", "fc3499fed7a726995aa659143a248534adc754ebd16ccd437cd93b649a95091f"}, - "makeup": {:hex, :makeup, "1.0.5", "d5a830bc42c9800ce07dd97fa94669dfb93d3bf5fcf6ea7a0c67b2e0e4a7f26c", [:mix], [{:nimble_parsec, "~> 0.5 or ~> 1.0", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "cfa158c02d3f5c0c665d0af11512fed3fba0144cf1aadee0f2ce17747fba2ca9"}, - "makeup_elixir": {:hex, :makeup_elixir, "0.15.1", "b5888c880d17d1cc3e598f05cdb5b5a91b7b17ac4eaf5f297cb697663a1094dd", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.1", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "db68c173234b07ab2a07f645a5acdc117b9f99d69ebf521821d89690ae6c6ec8"}, + "makeup": {:hex, :makeup, "1.1.0", "6b67c8bc2882a6b6a445859952a602afc1a41c2e08379ca057c0f525366fc3ca", [:mix], [{:nimble_parsec, "~> 1.2.2 or ~> 1.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "0a45ed501f4a8897f580eabf99a2e5234ea3e75a4373c8a52824f6e873be57a6"}, + "makeup_elixir": {:hex, :makeup_elixir, "0.16.0", "f8c570a0d33f8039513fbccaf7108c5d750f47d8defd44088371191b76492b0b", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.2.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "28b2cbdc13960a46ae9a8858c4bebdec3c9a6d7b4b9e7f4ed1502f8159f338e7"}, "makeup_erlang": {:hex, :makeup_erlang, "0.1.1", "3fcb7f09eb9d98dc4d208f49cc955a34218fc41ff6b84df7c75b3e6e533cc65f", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "174d0809e98a4ef0b3309256cbf97101c6ec01c4ab0b23e926a9e17df2077cbb"}, - "meck": {:hex, :meck, "0.8.13", "ffedb39f99b0b99703b8601c6f17c7f76313ee12de6b646e671e3188401f7866", [:rebar3], [], "hexpm", "d34f013c156db51ad57cc556891b9720e6a1c1df5fe2e15af999c84d6cebeb1a"}, + "meck": {:hex, :meck, "0.9.2", "85ccbab053f1db86c7ca240e9fc718170ee5bda03810a6292b5306bf31bae5f5", [:rebar3], [], "hexpm", "81344f561357dc40a8344afa53767c32669153355b626ea9fcbc8da6b3045826"}, "metrics": {:hex, :metrics, "1.0.1", "25f094dea2cda98213cecc3aeff09e940299d950904393b2a29d191c346a8486", [:rebar3], [], "hexpm", "69b09adddc4f74a40716ae54d140f93beb0fb8978d8636eaded0c31b6f099f16"}, - "mime": {:hex, :mime, "1.6.0", "dabde576a497cef4bbdd60aceee8160e02a6c89250d6c0b29e56c0dfb00db3d2", [:mix], [], "hexpm", "31a1a8613f8321143dde1dafc36006a17d28d02bdfecb9e95a880fa7aabd19a7"}, + "mime": {:hex, :mime, "2.0.2", "0b9e1a4c840eafb68d820b0e2158ef5c49385d17fb36855ac6e7e087d4b1dcc5", [:mix], [], "hexpm", "e6a3f76b4c277739e36c2e21a2c640778ba4c3846189d5ab19f97f126df5f9b7"}, "mimerl": {:hex, :mimerl, "1.2.0", "67e2d3f571088d5cfd3e550c383094b47159f3eee8ffa08e64106cdf5e981be3", [:rebar3], [], "hexpm", "f278585650aa581986264638ebf698f8bb19df297f66ad91b18910dfc6e19323"}, - "mock": {:hex, :mock, "0.3.4", "c5862eb3b8c64237f45f586cf00c9d892ba07bb48305a43319d428ce3c2897dd", [:mix], [{:meck, "~> 0.8.13", [hex: :meck, repo: "hexpm", optional: false]}], "hexpm", "e6d886252f1a41f4ba06ecf2b4c8d38760b34b1c08a11c28f7397b2e03995964"}, - "nimble_parsec": {:hex, :nimble_parsec, "1.1.0", "3a6fca1550363552e54c216debb6a9e95bd8d32348938e13de5eda962c0d7f89", [:mix], [], "hexpm", "08eb32d66b706e913ff748f11694b17981c0b04a33ef470e33e11b3d3ac8f54b"}, + "mock": {:hex, :mock, "0.3.7", "75b3bbf1466d7e486ea2052a73c6e062c6256fb429d6797999ab02fa32f29e03", [:mix], [{:meck, "~> 0.9.2", [hex: :meck, repo: "hexpm", optional: false]}], "hexpm", "4da49a4609e41fd99b7836945c26f373623ea968cfb6282742bcb94440cf7e5c"}, + "nimble_parsec": {:hex, :nimble_parsec, "1.2.3", "244836e6e3f1200c7f30cb56733fd808744eca61fd182f731eac4af635cc6d0b", [:mix], [], "hexpm", "c8d789e39b9131acf7b99291e93dae60ab48ef14a7ee9d58c6964f59efb570b0"}, "oauth2": {:hex, :oauth2, "2.0.0", "338382079fe16c514420fa218b0903f8ad2d4bfc0ad0c9f988867dfa246731b0", [:mix], [{:hackney, "~> 1.13", [hex: :hackney, repo: "hexpm", optional: false]}], "hexpm", "881b8364ac7385f9fddc7949379cbe3f7081da37233a1aa7aab844670a91e7e7"}, - "parse_trans": {:hex, :parse_trans, "3.3.0", "09765507a3c7590a784615cfd421d101aec25098d50b89d7aa1d66646bc571c1", [:rebar3], [], "hexpm", "17ef63abde837ad30680ea7f857dd9e7ced9476cdd7b0394432af4bfc241b960"}, - "plug": {:hex, :plug, "1.11.1", "f2992bac66fdae679453c9e86134a4201f6f43a687d8ff1cd1b2862d53c80259", [:mix], [{:mime, "~> 1.0", [hex: :mime, repo: "hexpm", optional: false]}, {:plug_crypto, "~> 1.1.1 or ~> 1.2", [hex: :plug_crypto, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "23524e4fefbb587c11f0833b3910bfb414bf2e2534d61928e920f54e3a1b881f"}, + "parse_trans": {:hex, :parse_trans, "3.3.1", "16328ab840cc09919bd10dab29e431da3af9e9e7e7e6f0089dd5a2d2820011d8", [:rebar3], [], "hexpm", "07cd9577885f56362d414e8c4c4e6bdf10d43a8767abb92d24cbe8b24c54888b"}, + "plug": {:hex, :plug, "1.13.6", "187beb6b67c6cec50503e940f0434ea4692b19384d47e5fdfd701e93cadb4cc2", [:mix], [{:mime, "~> 1.0 or ~> 2.0", [hex: :mime, repo: "hexpm", optional: false]}, {:plug_crypto, "~> 1.1.1 or ~> 1.2", [hex: :plug_crypto, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4.3 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "02b9c6b9955bce92c829f31d6284bf53c591ca63c4fb9ff81dfd0418667a34ff"}, "plug_crypto": {:hex, :plug_crypto, "1.2.2", "05654514ac717ff3a1843204b424477d9e60c143406aa94daf2274fdd280794d", [:mix], [], "hexpm", "87631c7ad914a5a445f0a3809f99b079113ae4ed4b867348dd9eec288cecb6db"}, - "ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.4", "f0eafff810d2041e93f915ef59899c923f4568f4585904d010387ed74988e77b", [:make, :mix, :rebar3], [], "hexpm", "603561dc0fd62f4f2ea9b890f4e20e1a0d388746d6e20557cafb1b16950de88c"}, - "telemetry": {:hex, :telemetry, "0.4.3", "a06428a514bdbc63293cd9a6263aad00ddeb66f608163bdec7c8995784080818", [:rebar3], [], "hexpm", "eb72b8365ffda5bed68a620d1da88525e326cb82a75ee61354fc24b844768041"}, - "ueberauth": {:hex, :ueberauth, "0.7.0", "9c44f41798b5fa27f872561b6f7d2bb0f10f03fdd22b90f454232d7b087f4b75", [:mix], [{:plug, "~> 1.5", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm", "2efad9022e949834f16cc52cd935165049d81fa9e925690f91035c2e4b58d905"}, - "unicode_util_compat": {:hex, :unicode_util_compat, "0.4.1", "d869e4c68901dd9531385bb0c8c40444ebf624e60b6962d95952775cac5e90cd", [:rebar3], [], "hexpm", "1d1848c40487cdb0b30e8ed975e34e025860c02e419cb615d255849f3427439d"}, + "ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.6", "cf344f5692c82d2cd7554f5ec8fd961548d4fd09e7d22f5b62482e5aeaebd4b0", [:make, :mix, :rebar3], [], "hexpm", "bdb0d2471f453c88ff3908e7686f86f9be327d065cc1ec16fa4540197ea04680"}, + "telemetry": {:hex, :telemetry, "1.1.0", "a589817034a27eab11144ad24d5c0f9fab1f58173274b1e9bae7074af9cbee51", [:rebar3], [], "hexpm", "b727b2a1f75614774cff2d7565b64d0dfa5bd52ba517f16543e6fc7efcc0df48"}, + "ueberauth": {:hex, :ueberauth, "0.9.0", "9f2dc8f6158fc09d048da0c1a548a4b2f9326bf01a35acdcaa94f4bc5b936c9a", [:mix], [{:plug, "~> 1.5", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm", "6d6e0c6f7191b8d25153ae3596b3d98b5c06f9bb887d1e2d7b98b74eff3d189b"}, + "unicode_util_compat": {:hex, :unicode_util_compat, "0.7.0", "bc84380c9ab48177092f43ac89e4dfa2c6d62b40b8bd132b1059ecc7232f9a78", [:rebar3], [], "hexpm", "25eee6d67df61960cf6a794239566599b09e17e668d3700247bc498638152521"}, } From 720d9a4710f664c0fe46e11dbb06577b0808cdea Mon Sep 17 00:00:00 2001 From: Wilhelm Hugo Kirschbaum Date: Tue, 24 May 2022 08:32:59 +0200 Subject: [PATCH 57/80] Run mix format --- test/strategy/google_test.exs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/test/strategy/google_test.exs b/test/strategy/google_test.exs index f6756b4..9144f3b 100644 --- a/test/strategy/google_test.exs +++ b/test/strategy/google_test.exs @@ -38,7 +38,9 @@ defmodule Ueberauth.Strategy.GoogleTest do def oauth2_get_token(client, code: "uid_code"), do: token(client, "uid_token") def oauth2_get_token(client, code: "userinfo_code"), do: token(client, "userinfo_token") def oauth2_get_token(_client, code: "oauth2_error"), do: {:error, %OAuth2.Error{reason: :timeout}} - def oauth2_get_token(_client, code: "error_response"), do: {:error, %OAuth2.Response{body: %{"error" => "some error", "error_description" => "something went wrong"}}} + + def oauth2_get_token(_client, code: "error_response"), + do: {:error, %OAuth2.Response{body: %{"error" => "some error", "error_description" => "something went wrong"}}} def oauth2_get(%{token: %{access_token: "success_token"}}, _url, _, _), do: response(%{"sub" => "1234_fred", "name" => "Fred Jones", "email" => "fred_jones@example.com"}) @@ -172,7 +174,10 @@ defmodule Ueberauth.Strategy.GoogleTest do routes = Ueberauth.init([]) assert %Plug.Conn{assigns: %{ueberauth_failure: failure}} = Ueberauth.call(conn, routes) - assert %Ueberauth.Failure{errors: [%Ueberauth.Failure.Error{message: "something went wrong", message_key: "some error"}]} = failure + + assert %Ueberauth.Failure{ + errors: [%Ueberauth.Failure.Error{message: "something went wrong", message_key: "some error"}] + } = failure end end end From b0cff0a93c318a544f55e71523345ee1a757558c Mon Sep 17 00:00:00 2001 From: Andreas Sliwka Date: Fri, 8 Jul 2022 11:58:36 +0200 Subject: [PATCH 58/80] Updated ueberauth to 0.10 --- mix.exs | 2 +- mix.lock | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mix.exs b/mix.exs index 2367fe3..bbf9475 100644 --- a/mix.exs +++ b/mix.exs @@ -26,7 +26,7 @@ defmodule UeberauthGoogle.Mixfile do defp deps do [ {:oauth2, "~> 1.0 or ~> 2.0"}, - {:ueberauth, "~> 0.7.0 or ~> 0.9.0"}, + {:ueberauth, "~> 0.10.0"}, {:credo, ">= 0.0.0", only: [:dev, :test], runtime: false}, {:ex_doc, ">= 0.0.0", only: [:dev], runtime: false}, {:mock, "~> 0.3", only: :test} diff --git a/mix.lock b/mix.lock index 72792e9..0c8eaaa 100644 --- a/mix.lock +++ b/mix.lock @@ -28,6 +28,6 @@ "plug_crypto": {:hex, :plug_crypto, "1.2.2", "05654514ac717ff3a1843204b424477d9e60c143406aa94daf2274fdd280794d", [:mix], [], "hexpm", "87631c7ad914a5a445f0a3809f99b079113ae4ed4b867348dd9eec288cecb6db"}, "ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.6", "cf344f5692c82d2cd7554f5ec8fd961548d4fd09e7d22f5b62482e5aeaebd4b0", [:make, :mix, :rebar3], [], "hexpm", "bdb0d2471f453c88ff3908e7686f86f9be327d065cc1ec16fa4540197ea04680"}, "telemetry": {:hex, :telemetry, "1.1.0", "a589817034a27eab11144ad24d5c0f9fab1f58173274b1e9bae7074af9cbee51", [:rebar3], [], "hexpm", "b727b2a1f75614774cff2d7565b64d0dfa5bd52ba517f16543e6fc7efcc0df48"}, - "ueberauth": {:hex, :ueberauth, "0.9.0", "9f2dc8f6158fc09d048da0c1a548a4b2f9326bf01a35acdcaa94f4bc5b936c9a", [:mix], [{:plug, "~> 1.5", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm", "6d6e0c6f7191b8d25153ae3596b3d98b5c06f9bb887d1e2d7b98b74eff3d189b"}, + "ueberauth": {:hex, :ueberauth, "0.10.1", "6706b410ee6bd9d67eac983ed9dc7fdc1f06b18677d7b8ba71d5725e07cc8826", [:mix], [{:plug, "~> 1.5", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm", "bb715b562395c4cc26b2d8e637c6bb0eb8c67d50c0ea543c0f78f06b7e8efdb1"}, "unicode_util_compat": {:hex, :unicode_util_compat, "0.7.0", "bc84380c9ab48177092f43ac89e4dfa2c6d62b40b8bd132b1059ecc7232f9a78", [:rebar3], [], "hexpm", "25eee6d67df61960cf6a794239566599b09e17e668d3700247bc498638152521"}, } From 0d264f0abb5fe48eea79e7cc8e17bf56bfa35b56 Mon Sep 17 00:00:00 2001 From: AJ Foster Date: Thu, 8 Sep 2022 00:20:08 +0000 Subject: [PATCH 59/80] Prefer local configuration over global configuration --- lib/ueberauth/strategy/google/oauth.ex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ueberauth/strategy/google/oauth.ex b/lib/ueberauth/strategy/google/oauth.ex index f04a8d3..d4a9f82 100644 --- a/lib/ueberauth/strategy/google/oauth.ex +++ b/lib/ueberauth/strategy/google/oauth.ex @@ -27,7 +27,7 @@ defmodule Ueberauth.Strategy.Google.OAuth do """ def client(opts \\ []) do config = Application.get_env(:ueberauth, __MODULE__, []) - opts = @defaults |> Keyword.merge(opts) |> Keyword.merge(config) |> resolve_values() + opts = @defaults |> Keyword.merge(config) |> Keyword.merge(opts) |> resolve_values() json_library = Ueberauth.json_library() OAuth2.Client.new(opts) From f69d03d8a9be6bb6e2b45114cdf222fcc2108306 Mon Sep 17 00:00:00 2001 From: Yordis Prieto Lazo Date: Fri, 23 Sep 2022 12:27:32 -0400 Subject: [PATCH 60/80] chore: add changelog --- CHANGELOG.md | 4 ++++ mix.exs | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b6db4bd..602866f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ## (Unreleased) +## v0.10.2 + +* Prefer Local Over Global Configuration [95](https://github.com/ueberauth/ueberauth_google/pull/95) + ## v0.10.1 * Misc doc changes [81](https://github.com/ueberauth/ueberauth_google/pull/81) diff --git a/mix.exs b/mix.exs index bbf9475..fde3cfe 100644 --- a/mix.exs +++ b/mix.exs @@ -2,7 +2,7 @@ defmodule UeberauthGoogle.Mixfile do use Mix.Project @source_url "https://github.com/ueberauth/ueberauth_google" - @version "0.10.1" + @version "0.10.2" def project do [ From e083a8d3c3bf900ba4fa0349c222805bc745747b Mon Sep 17 00:00:00 2001 From: Kian-Meng Ang Date: Mon, 14 Nov 2022 09:08:40 +0800 Subject: [PATCH 61/80] Use erlef/setup-beam and bump GHA versions Remove extra redirection. See https://github.com/erlef/setup-beam/issues/20. Also added GHA badge to readme. --- .github/workflows/ci.yml | 6 +++--- .github/workflows/release.yml | 6 +++--- README.md | 1 + 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d57516b..7d79afd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,10 +11,10 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout Code - uses: actions/checkout@v1 + uses: actions/checkout@v3 - name: Set up Elixir - uses: erlef/setup-elixir@v1 + uses: erlef/setup-beam@v1 with: elixir-version: '1.11' otp-version: '22.3' @@ -31,7 +31,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout Code - uses: actions/checkout@v1 + uses: actions/checkout@v3 - name: Set up Elixir uses: erlef/setup-elixir@v1 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 61d5739..f191748 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -9,14 +9,14 @@ jobs: name: Publish runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Set up Elixir - uses: erlef/setup-elixir@v1 + uses: erlef/setup-beam@v1 with: elixir-version: '1.11' otp-version: '22.3' - name: Restore dependencies cache - uses: actions/cache@v2 + uses: actions/cache@v3 with: path: deps key: ${{ runner.os }}-mix-${{ hashFiles('**/mix.lock') }} diff --git a/README.md b/README.md index 6ed15b0..1a88519 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,6 @@ # Überauth Google +[![Continuous Integration](https://github.com/ueberauth/ueberauth_google/actions/workflows/ci.yml/badge.svg)](https://github.com/ueberauth/ueberauth_google/actions/workflows/ci.yml) [![Build Status](https://travis-ci.org/ueberauth/ueberauth_google.svg?branch=master)](https://travis-ci.org/ueberauth/ueberauth_google) [![Module Version](https://img.shields.io/hexpm/v/ueberauth_google.svg)](https://hex.pm/packages/ueberauth_google) [![Hex Docs](https://img.shields.io/badge/hex-docs-lightgreen.svg)](https://hexdocs.pm/ueberauth_google/) From ca133dd1360a31316b5f2a5a29603be75b676669 Mon Sep 17 00:00:00 2001 From: Angelika Tyborska Date: Thu, 3 Aug 2023 00:38:20 +0200 Subject: [PATCH 62/80] Handle 503 response with no error_description --- lib/ueberauth/strategy/google/oauth.ex | 3 ++- test/strategy/google_test.exs | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/lib/ueberauth/strategy/google/oauth.ex b/lib/ueberauth/strategy/google/oauth.ex index d4a9f82..c818cca 100644 --- a/lib/ueberauth/strategy/google/oauth.ex +++ b/lib/ueberauth/strategy/google/oauth.ex @@ -52,7 +52,8 @@ defmodule Ueberauth.Strategy.Google.OAuth do def get_access_token(params \\ [], opts \\ []) do case opts |> client |> OAuth2.Client.get_token(params) do - {:error, %OAuth2.Response{body: %{"error" => error, "error_description" => description}}} -> + {:error, %OAuth2.Response{body: %{"error" => error}} = response} -> + description = Map.get(response.body, "error_description", "") {:error, {error, description}} {:error, %OAuth2.Error{reason: reason}} -> diff --git a/test/strategy/google_test.exs b/test/strategy/google_test.exs index 9144f3b..f431d5c 100644 --- a/test/strategy/google_test.exs +++ b/test/strategy/google_test.exs @@ -42,6 +42,9 @@ defmodule Ueberauth.Strategy.GoogleTest do def oauth2_get_token(_client, code: "error_response"), do: {:error, %OAuth2.Response{body: %{"error" => "some error", "error_description" => "something went wrong"}}} + def oauth2_get_token(_client, code: "error_response_no_description"), + do: {:error, %OAuth2.Response{body: %{"error" => "some error"}}} + def oauth2_get(%{token: %{access_token: "success_token"}}, _url, _, _), do: response(%{"sub" => "1234_fred", "name" => "Fred Jones", "email" => "fred_jones@example.com"}) @@ -179,5 +182,21 @@ defmodule Ueberauth.Strategy.GoogleTest do errors: [%Ueberauth.Failure.Error{message: "something went wrong", message_key: "some error"}] } = failure end + + test "handle_callback! handles error response without error_description", %{ + csrf_state: csrf_state, + csrf_conn: csrf_conn + } do + conn = + conn(:get, "/auth/google/callback", %{code: "error_response_no_description", state: csrf_state}) + |> set_csrf_cookies(csrf_conn) + + routes = Ueberauth.init([]) + assert %Plug.Conn{assigns: %{ueberauth_failure: failure}} = Ueberauth.call(conn, routes) + + assert %Ueberauth.Failure{ + errors: [%Ueberauth.Failure.Error{message: "", message_key: "some error"}] + } = failure + end end end From 195c6e509d8f443479cc444bffde64bfa21005e5 Mon Sep 17 00:00:00 2001 From: Angelika Tyborska Date: Thu, 3 Aug 2023 08:14:02 +0200 Subject: [PATCH 63/80] Use the real life error code in test --- test/strategy/google_test.exs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/strategy/google_test.exs b/test/strategy/google_test.exs index f431d5c..0105c94 100644 --- a/test/strategy/google_test.exs +++ b/test/strategy/google_test.exs @@ -43,7 +43,7 @@ defmodule Ueberauth.Strategy.GoogleTest do do: {:error, %OAuth2.Response{body: %{"error" => "some error", "error_description" => "something went wrong"}}} def oauth2_get_token(_client, code: "error_response_no_description"), - do: {:error, %OAuth2.Response{body: %{"error" => "some error"}}} + do: {:error, %OAuth2.Response{body: %{"error" => "internal_failure"}}} def oauth2_get(%{token: %{access_token: "success_token"}}, _url, _, _), do: response(%{"sub" => "1234_fred", "name" => "Fred Jones", "email" => "fred_jones@example.com"}) @@ -195,7 +195,7 @@ defmodule Ueberauth.Strategy.GoogleTest do assert %Plug.Conn{assigns: %{ueberauth_failure: failure}} = Ueberauth.call(conn, routes) assert %Ueberauth.Failure{ - errors: [%Ueberauth.Failure.Error{message: "", message_key: "some error"}] + errors: [%Ueberauth.Failure.Error{message: "", message_key: "internal_failure"}] } = failure end end From f7b9328f505ecb86152dd35fd626fc94ceda8ff6 Mon Sep 17 00:00:00 2001 From: Angelika Tyborska Date: Thu, 3 Aug 2023 08:21:29 +0200 Subject: [PATCH 64/80] Fix erlang version not found in version list on CI --- .github/workflows/ci.yml | 6 +++--- .github/workflows/release.yml | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7d79afd..5d9d95c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,7 +8,7 @@ on: - 'master' jobs: Test: - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 steps: - name: Checkout Code uses: actions/checkout@v3 @@ -28,13 +28,13 @@ jobs: run: mix test Linting: - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 steps: - name: Checkout Code uses: actions/checkout@v3 - name: Set up Elixir - uses: erlef/setup-elixir@v1 + uses: erlef/setup-beam@v1 with: elixir-version: '1.11' otp-version: '22.3' diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f191748..198cf3e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -7,7 +7,7 @@ on: jobs: publish: name: Publish - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 steps: - uses: actions/checkout@v3 - name: Set up Elixir From 829ea972b11db3e16cafb47c12b8a5b4a5523378 Mon Sep 17 00:00:00 2001 From: Angelika Tyborska Date: Thu, 3 Aug 2023 08:27:34 +0200 Subject: [PATCH 65/80] Add entry to CHANGELOG --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 602866f..2ab2444 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## (Unreleased) +- Handle `%OAuth2.Response{status_code: 503}` with no `error_description` in `get_access_token` [99](https://github.com/ueberauth/ueberauth_google/pull/99) + ## v0.10.2 * Prefer Local Over Global Configuration [95](https://github.com/ueberauth/ueberauth_google/pull/95) From a430ec7231bb0fff73f5ce9c931f9c02b88ed6c2 Mon Sep 17 00:00:00 2001 From: Yordis Prieto Lazo Date: Thu, 3 Aug 2023 13:05:53 -0400 Subject: [PATCH 66/80] versioning --- CHANGELOG.md | 2 ++ mix.exs | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2ab2444..fcc6d94 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## (Unreleased) +## v0.10.3 + - Handle `%OAuth2.Response{status_code: 503}` with no `error_description` in `get_access_token` [99](https://github.com/ueberauth/ueberauth_google/pull/99) ## v0.10.2 diff --git a/mix.exs b/mix.exs index fde3cfe..5012ee4 100644 --- a/mix.exs +++ b/mix.exs @@ -2,7 +2,7 @@ defmodule UeberauthGoogle.Mixfile do use Mix.Project @source_url "https://github.com/ueberauth/ueberauth_google" - @version "0.10.2" + @version "0.10.3" def project do [ From 14d368296c64e7946694d31052d589a0104fe599 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20Guti=C3=A9rrez?= Date: Tue, 19 Sep 2023 13:47:41 -0600 Subject: [PATCH 67/80] Add the option to get the client secret dynamically --- lib/ueberauth/strategy/google/oauth.ex | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/lib/ueberauth/strategy/google/oauth.ex b/lib/ueberauth/strategy/google/oauth.ex index c818cca..e85d9c8 100644 --- a/lib/ueberauth/strategy/google/oauth.ex +++ b/lib/ueberauth/strategy/google/oauth.ex @@ -27,7 +27,14 @@ defmodule Ueberauth.Strategy.Google.OAuth do """ def client(opts \\ []) do config = Application.get_env(:ueberauth, __MODULE__, []) - opts = @defaults |> Keyword.merge(config) |> Keyword.merge(opts) |> resolve_values() + + opts = + @defaults + |> Keyword.merge(config) + |> Keyword.merge(opts) + |> resolve_values() + |> generate_secret() + json_library = Ueberauth.json_library() OAuth2.Client.new(opts) @@ -89,4 +96,14 @@ defmodule Ueberauth.Strategy.Google.OAuth do defp resolve_value({m, f, a}) when is_atom(m) and is_atom(f), do: apply(m, f, a) defp resolve_value(v), do: v + + defp generate_secret(opts) do + if is_tuple(opts[:client_secret]) do + {module, fun} = opts[:client_secret] + secret = apply(module, fun, [opts]) + Keyword.put(opts, :client_secret, secret) + else + opts + end + end end From a4c9875f71ff59e00138fb20c7b27de6ee59a246 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20Guti=C3=A9rrez?= Date: Wed, 20 Sep 2023 11:55:29 -0600 Subject: [PATCH 68/80] Add unit tests for dynamic client secret generation --- test/strategy/google/oauth_test.exs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 test/strategy/google/oauth_test.exs diff --git a/test/strategy/google/oauth_test.exs b/test/strategy/google/oauth_test.exs new file mode 100644 index 0000000..83832b4 --- /dev/null +++ b/test/strategy/google/oauth_test.exs @@ -0,0 +1,20 @@ +defmodule Ueberauth.Strategy.Google.OAuthTest do + use ExUnit.Case + + alias Ueberauth.Strategy.Google.OAuth + + defmodule MyApp.Google do + def client_secret(_opts), do: "custom_client_secret" + end + + describe "client/1" do + test "uses client secret in the config when it is not a tuple" do + assert %OAuth2.Client{client_secret: "client_secret"} = OAuth.client() + end + + test "generates client secret when it is using a tuple config" do + options = [client_secret: {MyApp.Google, :client_secret}] + assert %OAuth2.Client{client_secret: "custom_client_secret"} = OAuth.client(options) + end + end +end From be040edd9af975fae79d4ef6aa4f53e0845f3af6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20Guti=C3=A9rrez?= Date: Wed, 20 Sep 2023 11:56:37 -0600 Subject: [PATCH 69/80] Add sync true in tests for OAuth module --- test/strategy/google/oauth_test.exs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/strategy/google/oauth_test.exs b/test/strategy/google/oauth_test.exs index 83832b4..1039d76 100644 --- a/test/strategy/google/oauth_test.exs +++ b/test/strategy/google/oauth_test.exs @@ -1,5 +1,5 @@ defmodule Ueberauth.Strategy.Google.OAuthTest do - use ExUnit.Case + use ExUnit.Case, async: true alias Ueberauth.Strategy.Google.OAuth From 78e5db0e1910987af940ab5ab16e51c94cc437c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20Guti=C3=A9rrez?= Date: Wed, 20 Sep 2023 12:28:18 -0600 Subject: [PATCH 70/80] Update CHANGELOG and bumping package version --- CHANGELOG.md | 6 +++++- mix.exs | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fcc6d94..c83f7d2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,9 +2,13 @@ ## (Unreleased) +## v0.11.0 + +* Allow using a function to generate the client secret [101](https://github.com/ueberauth/ueberauth_google/pull/101) + ## v0.10.3 -- Handle `%OAuth2.Response{status_code: 503}` with no `error_description` in `get_access_token` [99](https://github.com/ueberauth/ueberauth_google/pull/99) +* Handle `%OAuth2.Response{status_code: 503}` with no `error_description` in `get_access_token` [99](https://github.com/ueberauth/ueberauth_google/pull/99) ## v0.10.2 diff --git a/mix.exs b/mix.exs index 5012ee4..369f18b 100644 --- a/mix.exs +++ b/mix.exs @@ -2,7 +2,7 @@ defmodule UeberauthGoogle.Mixfile do use Mix.Project @source_url "https://github.com/ueberauth/ueberauth_google" - @version "0.10.3" + @version "0.11.0" def project do [ From 34a66525f65aae7af35f3876b7bcb85a2e58719a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20Guti=C3=A9rrez?= Date: Wed, 20 Sep 2023 12:35:34 -0600 Subject: [PATCH 71/80] Improve a little bit the codebase --- lib/ueberauth/strategy/google/oauth.ex | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/lib/ueberauth/strategy/google/oauth.ex b/lib/ueberauth/strategy/google/oauth.ex index e85d9c8..1f299bd 100644 --- a/lib/ueberauth/strategy/google/oauth.ex +++ b/lib/ueberauth/strategy/google/oauth.ex @@ -27,17 +27,14 @@ defmodule Ueberauth.Strategy.Google.OAuth do """ def client(opts \\ []) do config = Application.get_env(:ueberauth, __MODULE__, []) - - opts = - @defaults - |> Keyword.merge(config) - |> Keyword.merge(opts) - |> resolve_values() - |> generate_secret() - json_library = Ueberauth.json_library() - OAuth2.Client.new(opts) + @defaults + |> Keyword.merge(config) + |> Keyword.merge(opts) + |> resolve_values() + |> generate_secret() + |> OAuth2.Client.new() |> OAuth2.Client.put_serializer("application/json", json_library) end From 6981399aa59c4e0209bf81e1680f80651387097d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20Guti=C3=A9rrez?= Date: Mon, 25 Sep 2023 11:11:18 -0600 Subject: [PATCH 72/80] Add support to hl param in handle_request --- lib/ueberauth/strategy/google.ex | 1 + test/strategy/google_test.exs | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/ueberauth/strategy/google.ex b/lib/ueberauth/strategy/google.ex index 765fdbf..d185d4c 100644 --- a/lib/ueberauth/strategy/google.ex +++ b/lib/ueberauth/strategy/google.ex @@ -29,6 +29,7 @@ defmodule Ueberauth.Strategy.Google do |> with_param(:access_type, conn) |> with_param(:prompt, conn) |> with_param(:login_hint, conn) + |> with_param(:hl, conn) |> with_state_param(conn) opts = oauth_client_options_from_conn(conn) diff --git a/test/strategy/google_test.exs b/test/strategy/google_test.exs index 0105c94..234a880 100644 --- a/test/strategy/google_test.exs +++ b/test/strategy/google_test.exs @@ -68,7 +68,7 @@ defmodule Ueberauth.Strategy.GoogleTest do end test "handle_request! redirects to appropriate auth uri" do - conn = conn(:get, "/auth/google", %{}) + conn = conn(:get, "/auth/google", %{hl: "es"}) # Make sure the hd and scope params are included for good measure routes = Ueberauth.init() |> set_options(conn, hd: "example.com", default_scope: "email openid") @@ -86,7 +86,8 @@ defmodule Ueberauth.Strategy.GoogleTest do "redirect_uri" => "http://www.example.com/auth/google/callback", "response_type" => "code", "scope" => "email openid", - "hd" => "example.com" + "hd" => "example.com", + "hl" => "es" } = Plug.Conn.Query.decode(redirect_uri.query) end From 91784d80e7f9cf8607043db71508afe4c371084d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20Guti=C3=A9rrez?= Date: Mon, 25 Sep 2023 11:13:15 -0600 Subject: [PATCH 73/80] Bump application version and add entry in the changelog --- CHANGELOG.md | 4 ++++ mix.exs | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c83f7d2..16676a3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ## (Unreleased) +## v0.12.0 + +* Add support to hl param in handle_request! [102](https://github.com/ueberauth/ueberauth_google/pull/102) + ## v0.11.0 * Allow using a function to generate the client secret [101](https://github.com/ueberauth/ueberauth_google/pull/101) diff --git a/mix.exs b/mix.exs index 369f18b..671993e 100644 --- a/mix.exs +++ b/mix.exs @@ -2,7 +2,7 @@ defmodule UeberauthGoogle.Mixfile do use Mix.Project @source_url "https://github.com/ueberauth/ueberauth_google" - @version "0.11.0" + @version "0.12.0" def project do [ From 9302f16537955155c963395e480983520b609182 Mon Sep 17 00:00:00 2001 From: Anton Medvedev Date: Thu, 18 May 2017 20:23:16 +0700 Subject: [PATCH 74/80] Add support for access_token callback Add access_token check --- lib/ueberauth/strategy/google.ex | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/lib/ueberauth/strategy/google.ex b/lib/ueberauth/strategy/google.ex index d185d4c..0fa2433 100644 --- a/lib/ueberauth/strategy/google.ex +++ b/lib/ueberauth/strategy/google.ex @@ -52,6 +52,20 @@ defmodule Ueberauth.Strategy.Google do end end + @doc """ + Handles the callback from app. + """ + def handle_callback!(%Plug.Conn{params: %{"access_token" => access_token}} = conn) do + client = Ueberauth.Strategy.Google.OAuth.client + token = OAuth2.AccessToken.new(access_token) + + if check_access_token(conn, client, token) do + fetch_user(conn, token) + else + set_errors!(conn, [error("token", "Token verification failed")]) + end + end + @doc false def handle_callback!(conn) do set_errors!(conn, [error("missing_code", "No code received")]) @@ -184,4 +198,20 @@ defmodule Ueberauth.Strategy.Google do defp option(conn, key) do Keyword.get(options(conn), key, Keyword.get(default_options(), key)) end + + def check_access_token(conn, client, token) do + client_id = client.client_id + params = %{ + "access_token" => token.access_token + } + url = "https://www.googleapis.com/oauth2/v3/tokeninfo" + case OAuth2.Client.get(client, url, [], params: params) do + {:ok, %OAuth2.Response{ + status_code: 200, + body: %{"aud" => ^client_id} + }} -> true + _ -> false + + end + end end From dda067f32c5cea08e3eab7aa186b6a3c1dfcc06d Mon Sep 17 00:00:00 2001 From: Anton Medvedev Date: Tue, 13 Jun 2017 15:26:26 +0700 Subject: [PATCH 75/80] Add google verification for apps id_token --- lib/ueberauth/strategy/google.ex | 44 +++++++++++++++++++------------- 1 file changed, 26 insertions(+), 18 deletions(-) diff --git a/lib/ueberauth/strategy/google.ex b/lib/ueberauth/strategy/google.ex index 0fa2433..8610769 100644 --- a/lib/ueberauth/strategy/google.ex +++ b/lib/ueberauth/strategy/google.ex @@ -13,6 +13,8 @@ defmodule Ueberauth.Strategy.Google do alias Ueberauth.Auth.Credentials alias Ueberauth.Auth.Extra + @allowed_client_ids Application.get_env(:ueberauth, Ueberauth.Strategy.Google.OAuth)[:allowed_client_ids] + @doc """ Handles initial request for Google authentication. """ @@ -55,14 +57,13 @@ defmodule Ueberauth.Strategy.Google do @doc """ Handles the callback from app. """ - def handle_callback!(%Plug.Conn{params: %{"access_token" => access_token}} = conn) do + def handle_callback!(%Plug.Conn{params: %{"id_token" => id_token}} = conn) do client = Ueberauth.Strategy.Google.OAuth.client - token = OAuth2.AccessToken.new(access_token) - - if check_access_token(conn, client, token) do - fetch_user(conn, token) - else - set_errors!(conn, [error("token", "Token verification failed")]) + case verify_token(conn, client, id_token) do + {:ok, user} -> + put_user(conn, user) + {:error, reason} -> + set_errors!(conn, [error("token", reason)]) end end @@ -175,6 +176,10 @@ defmodule Ueberauth.Strategy.Google do other end end + + defp put_user(conn, user) do + put_private(conn, :google_user, user) + end defp with_param(opts, key, conn) do if value = conn.params[to_string(key)], do: Keyword.put(opts, key, value), else: opts @@ -199,19 +204,22 @@ defmodule Ueberauth.Strategy.Google do Keyword.get(options(conn), key, Keyword.get(default_options(), key)) end - def check_access_token(conn, client, token) do - client_id = client.client_id - params = %{ - "access_token" => token.access_token - } + def verify_token(conn, client, id_token) do url = "https://www.googleapis.com/oauth2/v3/tokeninfo" - case OAuth2.Client.get(client, url, [], params: params) do - {:ok, %OAuth2.Response{ - status_code: 200, - body: %{"aud" => ^client_id} - }} -> true - _ -> false + params = %{"id_token" => id_token} + resp = OAuth2.Client.get(client, url, [], params: params) + case resp do + {:ok, %OAuth2.Response{status_code: 200, + body: %{"aud" => aud} = body + }} -> + if Enum.member?(@allowed_client_ids, aud) do + {:ok, body} + else + {:error, "Passed client id is disallowed"} + end + _ -> + {:error, "Token verification failed"} end end end From 080ebe4e8538266faaa1ce0fc158586e3f616a19 Mon Sep 17 00:00:00 2001 From: Anton Medvedev Date: Tue, 13 Jun 2017 16:02:16 +0700 Subject: [PATCH 76/80] Add empty access token --- lib/ueberauth/strategy/google.ex | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/ueberauth/strategy/google.ex b/lib/ueberauth/strategy/google.ex index 8610769..5d839df 100644 --- a/lib/ueberauth/strategy/google.ex +++ b/lib/ueberauth/strategy/google.ex @@ -178,6 +178,8 @@ defmodule Ueberauth.Strategy.Google do end defp put_user(conn, user) do + token = %OAuth2.AccessToken{} + conn = put_private(conn, :google_token, token) put_private(conn, :google_user, user) end From f0340b0400d4ea368ba0ce9f6fc0c285abaebbfb Mon Sep 17 00:00:00 2001 From: Anton Medvedev Date: Tue, 13 Jun 2017 19:17:38 +0700 Subject: [PATCH 77/80] Fix typo --- lib/ueberauth/strategy/google.ex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ueberauth/strategy/google.ex b/lib/ueberauth/strategy/google.ex index 5d839df..6fecb07 100644 --- a/lib/ueberauth/strategy/google.ex +++ b/lib/ueberauth/strategy/google.ex @@ -218,7 +218,7 @@ defmodule Ueberauth.Strategy.Google do if Enum.member?(@allowed_client_ids, aud) do {:ok, body} else - {:error, "Passed client id is disallowed"} + {:error, "Unknown client id"} end _ -> {:error, "Token verification failed"} From f049df9381b4f8fbb59ab6a4fefb762bf0e5079a Mon Sep 17 00:00:00 2001 From: Nikita Bulatov Date: Mon, 27 Aug 2018 18:21:27 +0700 Subject: [PATCH 78/80] dev(): wrong aud error message added --- lib/ueberauth/strategy/google.ex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ueberauth/strategy/google.ex b/lib/ueberauth/strategy/google.ex index 6fecb07..dcdff78 100644 --- a/lib/ueberauth/strategy/google.ex +++ b/lib/ueberauth/strategy/google.ex @@ -218,7 +218,7 @@ defmodule Ueberauth.Strategy.Google do if Enum.member?(@allowed_client_ids, aud) do {:ok, body} else - {:error, "Unknown client id"} + {:error, "Unknown client id #{aud}"} end _ -> {:error, "Token verification failed"} From b0d0a6c5e4f8aac328df63e99f0c4fe8631c688a Mon Sep 17 00:00:00 2001 From: Aleksandr Basov Date: Wed, 6 May 2020 23:14:02 +0500 Subject: [PATCH 79/80] Use dynamic env and remove unused deps --- lib/ueberauth/strategy/google.ex | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/ueberauth/strategy/google.ex b/lib/ueberauth/strategy/google.ex index dcdff78..43c5253 100644 --- a/lib/ueberauth/strategy/google.ex +++ b/lib/ueberauth/strategy/google.ex @@ -13,8 +13,6 @@ defmodule Ueberauth.Strategy.Google do alias Ueberauth.Auth.Credentials alias Ueberauth.Auth.Extra - @allowed_client_ids Application.get_env(:ueberauth, Ueberauth.Strategy.Google.OAuth)[:allowed_client_ids] - @doc """ Handles initial request for Google authentication. """ @@ -206,7 +204,7 @@ defmodule Ueberauth.Strategy.Google do Keyword.get(options(conn), key, Keyword.get(default_options(), key)) end - def verify_token(conn, client, id_token) do + def verify_token(_conn, client, id_token) do url = "https://www.googleapis.com/oauth2/v3/tokeninfo" params = %{"id_token" => id_token} resp = OAuth2.Client.get(client, url, [], params: params) @@ -215,7 +213,7 @@ defmodule Ueberauth.Strategy.Google do {:ok, %OAuth2.Response{status_code: 200, body: %{"aud" => aud} = body }} -> - if Enum.member?(@allowed_client_ids, aud) do + if Enum.member?(allowed_client_ids(), aud) do {:ok, body} else {:error, "Unknown client id #{aud}"} @@ -224,4 +222,8 @@ defmodule Ueberauth.Strategy.Google do {:error, "Token verification failed"} end end + + defp allowed_client_ids() do + Application.get_env(:ueberauth, Ueberauth.Strategy.Google.OAuth)[:allowed_client_ids] + end end From 9c01cf9332fed3950ca0d7f38c2ac9f53c68e8e6 Mon Sep 17 00:00:00 2001 From: Julie Date: Wed, 13 Apr 2022 15:53:28 +0700 Subject: [PATCH 80/80] Add webview param to auth url --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index e746ad7..f28fecd 100644 --- a/.gitignore +++ b/.gitignore @@ -20,7 +20,7 @@ ueberauth_google-*.tar .LSOverride # Icon must end with two \r -Icon +Icon # Thumbnails ._*