From 54029c8ba5bf5ca40b0a0743b3eef468ca1ae10a Mon Sep 17 00:00:00 2001 From: Gerard de Brieder Date: Fri, 7 Jul 2017 20:32:14 +0200 Subject: [PATCH 01/28] The new facebook api requires to pass along profile_fields. If this is empty you will not get the email back, even if that is defined in the scope. An other change is that you also need to pass along public_profile along with email in the scope for this to work. (#37) --- lib/ueberauth/strategy/facebook.ex | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/ueberauth/strategy/facebook.ex b/lib/ueberauth/strategy/facebook.ex index e367e5c..0f5978a 100644 --- a/lib/ueberauth/strategy/facebook.ex +++ b/lib/ueberauth/strategy/facebook.ex @@ -3,8 +3,8 @@ defmodule Ueberauth.Strategy.Facebook do Facebook Strategy for Überauth. """ - use Ueberauth.Strategy, default_scope: "email", - profile_fields: "", + use Ueberauth.Strategy, default_scope: "email,public_profile", + profile_fields: "id,email,gender,link,locale,name,timezone,updated_time,verified", uid_field: :id, allowed_request_params: [ :auth_type, From 1aea81a5253cd5bc8d999e60e22e527c163cf717 Mon Sep 17 00:00:00 2001 From: Sean Callan Date: Tue, 18 Jul 2017 00:19:03 -0600 Subject: [PATCH 02/28] Update dependencies and add Credo --- mix.exs | 14 ++++++-------- mix.lock | 34 +++++++++++++++------------------- 2 files changed, 21 insertions(+), 27 deletions(-) diff --git a/mix.exs b/mix.exs index 1357e4a..0128b02 100644 --- a/mix.exs +++ b/mix.exs @@ -24,14 +24,12 @@ defmodule UeberauthFacebook.Mixfile do end defp deps do - [ - {:ueberauth, "~> 0.4"}, - {:oauth2, "~> 0.8.0"}, - - {:ex_doc, "~> 0.2", only: :dev}, - {:earmark, ">= 0.0.0", only: :dev}, - {:credo, "~> 0.5", only: [:dev, :test]}, - ] + [{:ueberauth, "~> 0.4"}, + {:oauth2, "~> 0.9"}, + + {:credo, "~> 0.8", only: [:dev, :test]}, + {:ex_doc, "~> 0.16", only: :dev}, + {:earmark, ">= 0.0.0", only: :dev}] end defp docs do diff --git a/mix.lock b/mix.lock index ca35554..d2831c7 100644 --- a/mix.lock +++ b/mix.lock @@ -1,19 +1,15 @@ -%{"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]}]}, - "dogma": {:hex, :dogma, "0.0.11", "1396bfe10a962b5c5b0468eba6eb3be85d693d55f2d698fda29660a059eb2180", [:mix], [{:poison, "~> 1.0", [hex: :poison, optional: false]}]}, - "earmark": {:hex, :earmark, "0.1.19", "ffec54f520a11b711532c23d8a52b75a74c09697062d10613fa2dbdf8a9db36e", [:mix], []}, - "ex_doc": {:hex, :ex_doc, "0.10.0", "f49c237250b829df986486b38f043e6f8e19d19b41101987f7214543f75947ec", [:mix], [{:earmark, "~> 0.1.17 or ~> 0.2", [hex: :earmark, optional: true]}]}, - "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]}]}, - "httpoison": {:hex, :httpoison, "0.9.0", "68187a2daddfabbe7ca8f7d75ef227f89f0e1507f7eecb67e4536b3c516faddb", [: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], []}, - "mimetype_parser": {:hex, :mimetype_parser, "0.1.2", "221d2d3f727e89d80de5e1610fc2ce444514aa56f873da1b8fc9c033143e5d6a", [:mix], []}, - "oauth2": {:hex, :oauth2, "0.8.2", "3f3c9fef0ceb5ba80b6ed097ec98acc0d13f5869dce0ebbbbc521caa56077c12", [: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]}]}, - "poison": {:hex, :poison, "1.5.2", "560bdfb7449e3ddd23a096929fb9fc2122f709bcc758b2d5d5a5c7d0ea848910", [:mix], []}, - "ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.1", "28a4d65b7f59893bc2c7de786dec1e1555bd742d336043fe644ae956c3497fbe", [:make, :rebar], []}, - "ssl_verify_hostname": {:hex, :ssl_verify_hostname, "1.0.5", "2e73e068cd6393526f9fa6d399353d7c9477d6886ba005f323b592d389fb47be", [:make], []}, - "ueberauth": {:hex, :ueberauth, "0.4.0", "bc72d5e5a7bdcbfcf28a756e34630816edabc926303bdce7e171f7ac7ffa4f91", [:mix], [{:plug, "~> 1.2", [hex: :plug, 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.2.2", "f718159d6b65068e8daeef709ccddae5f7fdc770707d82e7d126f584cd925b74", [:mix], [], "hexpm"}, + "ex_doc": {:hex, :ex_doc, "0.16.2", "3b3e210ebcd85a7c76b4e73f85c5640c011d2a0b2f06dcdf5acdb2ae904e5084", [:mix], [{:earmark, "~> 1.1", [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"}, + "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.1.0", "01c1d6f4083d8aa5c7b8c246ade95139620ef8effb009edde934e0ec3b28090a", [:mix], [], "hexpm"}, + "mimerl": {:hex, :mimerl, "1.0.2", "993f9b0e084083405ed8252b99460c4f0563e41729ab42d9074fd5e52439be88", [], [], "hexpm"}, + "oauth2": {:hex, :oauth2, "0.9.1", "cac86d87f35ec835bfe4c791263bdb88c0d8bf1617d64f555ede4e9d913e35ef", [:mix], [{:hackney, "~> 1.7", [hex: :hackney, repo: "hexpm", optional: false]}], "hexpm"}, + "plug": {:hex, :plug, "1.3.5", "7503bfcd7091df2a9761ef8cecea666d1f2cc454cbbaf0afa0b6e259203b7031", [:mix], [{:cowboy, "~> 1.0.1 or ~> 1.1", [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"}, + "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 54b03ff4ee7d4aad55b9cc0d2d1c18a9afdda6bb Mon Sep 17 00:00:00 2001 From: Sean Callan Date: Tue, 18 Jul 2017 00:19:12 -0600 Subject: [PATCH 03/28] Correct Credo complaints --- lib/ueberauth/strategy/facebook.ex | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/ueberauth/strategy/facebook.ex b/lib/ueberauth/strategy/facebook.ex index 0f5978a..ce88938 100644 --- a/lib/ueberauth/strategy/facebook.ex +++ b/lib/ueberauth/strategy/facebook.ex @@ -32,8 +32,8 @@ defmodule Ueberauth.Strategy.Facebook do |> maybe_replace_param(conn, "scope", :default_scope) |> maybe_replace_param(conn, "state", :state) |> maybe_replace_param(conn, "display", :display) - |> Enum.filter(fn {k,_v} -> Enum.member?(allowed_params, k) end) - |> Enum.map(fn {k,v} -> {String.to_existing_atom(k), v} end) + |> Enum.filter(fn {k, _v} -> Enum.member?(allowed_params, k) end) + |> Enum.map(fn {k, v} -> {String.to_existing_atom(k), v} end) |> Keyword.put(:redirect_uri, callback_url(conn)) |> Ueberauth.Strategy.Facebook.OAuth.authorize_url! From 9df852d94ae7adccf9260fa1b99d1a4279ac89af Mon Sep 17 00:00:00 2001 From: Sean Callan Date: Tue, 18 Jul 2017 00:23:25 -0600 Subject: [PATCH 04/28] Update Travis matrix --- .travis.yml | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index eb03ffa..5d8b44c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,10 +1,15 @@ language: elixir +elixir: + - 1.4 + - 1.3 +otp_release: + - 20.0 + - 19.3 + - 18.3 matrix: - include: - - otp_release: 18.3 - elixir: 1.3.2 - - otp_release: 19.0 - elixir: 1.3.2 -sudo: false + exclude: + - elixir: 1.3 + otp_release: 20.0 script: - mix test + - mix credo From d2583e28edbc0cc0c818e2d3f6e34c02a68c4dc1 Mon Sep 17 00:00:00 2001 From: Sean Callan Date: Tue, 18 Jul 2017 00:23:35 -0600 Subject: [PATCH 05/28] Release 0.7.0 --- mix.exs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mix.exs b/mix.exs index 0128b02..90f0c06 100644 --- a/mix.exs +++ b/mix.exs @@ -1,7 +1,7 @@ -defmodule UeberauthFacebook.Mixfile do +defmodule Ueberauth.Facebook.Mixfile do use Mix.Project - @version "0.6.0" + @version "0.7.0" @url "https://github.com/ueberauth/ueberauth_facebook" def project do From 3fa42abb3b09e54e606c402944c798ea7f83e669 Mon Sep 17 00:00:00 2001 From: Nikita Sobolev Date: Sat, 26 Aug 2017 21:12:31 +0300 Subject: [PATCH 06/28] Updates README.md with svg badge and new package version (#38) --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index cf4fcd3..396807f 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # Überauth Facebook [![Build Status][travis-img]][travis] [![Hex Version][hex-img]][hex] [![License][license-img]][license] -[travis-img]: https://travis-ci.org/ueberauth/ueberauth_facebook.png?branch=master +[travis-img]: https://travis-ci.org/ueberauth/ueberauth_facebook.svg?branch=master [travis]: https://travis-ci.org/ueberauth/ueberauth_facebook [hex-img]: https://img.shields.io/hexpm/v/ueberauth_facebook.svg [hex]: https://hex.pm/packages/ueberauth_facebook @@ -18,7 +18,7 @@ ```elixir def deps do - [{:ueberauth_facebook, "~> 0.6"}] + [{:ueberauth_facebook, "~> 0.7"}] end ``` From 925ec34cfbbdf908ca1c0db6635f883bb1f8d6b9 Mon Sep 17 00:00:00 2001 From: jabberfest Date: Thu, 1 Mar 2018 11:42:00 -0500 Subject: [PATCH 07/28] Allow option to specify scheme for usar avatar url. Defaults to http (#40) * Allow option to specify scheme for usar avatar url. Defaults to http * Revert "Allow option to specify scheme for usar avatar url. Defaults to http" This reverts commit 2a7a453d01b2c0f47c4a2a96fa66d6feca45c3d3. * Change http to https scheme in URL returned by fetch_image * Bump credo dep to fix code analysis bug and make travis green * Update travis config to include versions of elixir up to 1.6 * Update exclude option in travis config * Exclude Elixir 1.6 with OTP 18.3 * Eclude Elixir 1.3 with OTP 20.2 --- .travis.yml | 8 ++++++-- lib/ueberauth/strategy/facebook.ex | 2 +- mix.exs | 2 +- mix.lock | 14 ++++++++------ 4 files changed, 16 insertions(+), 10 deletions(-) diff --git a/.travis.yml b/.travis.yml index 5d8b44c..ae69db4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,15 +1,19 @@ language: elixir elixir: + - 1.6 + - 1.5 - 1.4 - 1.3 otp_release: - - 20.0 + - 20.2 - 19.3 - 18.3 matrix: exclude: + - elixir: 1.6 + otp_release: 18.3 - elixir: 1.3 - otp_release: 20.0 + otp_release: 20.2 script: - mix test - mix credo diff --git a/lib/ueberauth/strategy/facebook.ex b/lib/ueberauth/strategy/facebook.ex index ce88938..1a995a1 100644 --- a/lib/ueberauth/strategy/facebook.ex +++ b/lib/ueberauth/strategy/facebook.ex @@ -132,7 +132,7 @@ defmodule Ueberauth.Strategy.Facebook do end defp fetch_image(uid) do - "http://graph.facebook.com/#{uid}/picture?type=square" + "https://graph.facebook.com/#{uid}/picture?type=square" end defp fetch_user(conn, client) do diff --git a/mix.exs b/mix.exs index 90f0c06..f9d3d7c 100644 --- a/mix.exs +++ b/mix.exs @@ -27,7 +27,7 @@ defmodule Ueberauth.Facebook.Mixfile do [{:ueberauth, "~> 0.4"}, {:oauth2, "~> 0.9"}, - {:credo, "~> 0.8", only: [:dev, :test]}, + {:credo, "~> 0.8.10", only: [:dev, :test]}, {:ex_doc, "~> 0.16", only: :dev}, {:earmark, ">= 0.0.0", only: :dev}] end diff --git a/mix.lock b/mix.lock index d2831c7..9cee785 100644 --- a/mix.lock +++ b/mix.lock @@ -1,15 +1,17 @@ -%{"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"}, + "credo": {:hex, :credo, "0.8.10", "261862bb7363247762e1063713bb85df2bbd84af8d8610d1272cd9c1943bba63", [:mix], [{:bunt, "~> 0.2.0", [hex: :bunt, repo: "hexpm", optional: false]}], "hexpm"}, "earmark": {:hex, :earmark, "1.2.2", "f718159d6b65068e8daeef709ccddae5f7fdc770707d82e7d126f584cd925b74", [:mix], [], "hexpm"}, "ex_doc": {:hex, :ex_doc, "0.16.2", "3b3e210ebcd85a7c76b4e73f85c5640c011d2a0b2f06dcdf5acdb2ae904e5084", [:mix], [{:earmark, "~> 1.1", [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"}, "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"}, + "metrics": {:hex, :metrics, "1.0.1", "25f094dea2cda98213cecc3aeff09e940299d950904393b2a29d191c346a8486", [:rebar3], [], "hexpm"}, "mime": {:hex, :mime, "1.1.0", "01c1d6f4083d8aa5c7b8c246ade95139620ef8effb009edde934e0ec3b28090a", [:mix], [], "hexpm"}, - "mimerl": {:hex, :mimerl, "1.0.2", "993f9b0e084083405ed8252b99460c4f0563e41729ab42d9074fd5e52439be88", [], [], "hexpm"}, + "mimerl": {:hex, :mimerl, "1.0.2", "993f9b0e084083405ed8252b99460c4f0563e41729ab42d9074fd5e52439be88", [:rebar3], [], "hexpm"}, "oauth2": {:hex, :oauth2, "0.9.1", "cac86d87f35ec835bfe4c791263bdb88c0d8bf1617d64f555ede4e9d913e35ef", [:mix], [{:hackney, "~> 1.7", [hex: :hackney, repo: "hexpm", optional: false]}], "hexpm"}, "plug": {:hex, :plug, "1.3.5", "7503bfcd7091df2a9761ef8cecea666d1f2cc454cbbaf0afa0b6e259203b7031", [:mix], [{:cowboy, "~> 1.0.1 or ~> 1.1", [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"}, - "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 2b31d99c35852327aa5b509128f0f9f7f689c774 Mon Sep 17 00:00:00 2001 From: Jeff Browning Date: Sat, 9 Mar 2019 10:52:38 -0500 Subject: [PATCH 08/28] Stop ending empty params to the FB auth dialog (#46) Fixes #45 --- lib/ueberauth/strategy/facebook.ex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ueberauth/strategy/facebook.ex b/lib/ueberauth/strategy/facebook.ex index 1a995a1..0a3380c 100644 --- a/lib/ueberauth/strategy/facebook.ex +++ b/lib/ueberauth/strategy/facebook.ex @@ -191,7 +191,7 @@ defmodule Ueberauth.Strategy.Facebook do defp option(value, _conn, _key), do: value defp maybe_replace_param(params, conn, name, config_key) do - if params[name] do + if params[name] || is_nil(option(params[name], conn, config_key)) do params else Map.put( From e766e1f0609065d768b9b05adfdfb9bfc2a86d05 Mon Sep 17 00:00:00 2001 From: Sean Callan Date: Sat, 9 Mar 2019 12:50:01 -0700 Subject: [PATCH 09/28] Release 0.8 --- README.md | 2 +- mix.exs | 4 ++-- mix.lock | 7 +++++-- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 396807f..79d38ad 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ ```elixir def deps do - [{:ueberauth_facebook, "~> 0.7"}] + [{:ueberauth_facebook, "~> 0.8"}] end ``` diff --git a/mix.exs b/mix.exs index f9d3d7c..3ee792d 100644 --- a/mix.exs +++ b/mix.exs @@ -1,7 +1,7 @@ defmodule Ueberauth.Facebook.Mixfile do use Mix.Project - @version "0.7.0" + @version "0.8.0" @url "https://github.com/ueberauth/ueberauth_facebook" def project do @@ -28,7 +28,7 @@ defmodule Ueberauth.Facebook.Mixfile do {:oauth2, "~> 0.9"}, {:credo, "~> 0.8.10", only: [:dev, :test]}, - {:ex_doc, "~> 0.16", only: :dev}, + {:ex_doc, "~> 0.19", only: :dev}, {:earmark, ">= 0.0.0", only: :dev}] end diff --git a/mix.lock b/mix.lock index 9cee785..d0efae1 100644 --- a/mix.lock +++ b/mix.lock @@ -2,13 +2,16 @@ "bunt": {:hex, :bunt, "0.2.0", "951c6e801e8b1d2cbe58ebbd3e616a869061ddadcc4863d0a2182541acae9a38", [:mix], [], "hexpm"}, "certifi": {:hex, :certifi, "1.2.1", "c3904f192bd5284e5b13f20db3ceac9626e14eeacfbb492e19583cf0e37b22be", [:rebar3], [], "hexpm"}, "credo": {:hex, :credo, "0.8.10", "261862bb7363247762e1063713bb85df2bbd84af8d8610d1272cd9c1943bba63", [:mix], [{:bunt, "~> 0.2.0", [hex: :bunt, repo: "hexpm", optional: false]}], "hexpm"}, - "earmark": {:hex, :earmark, "1.2.2", "f718159d6b65068e8daeef709ccddae5f7fdc770707d82e7d126f584cd925b74", [:mix], [], "hexpm"}, - "ex_doc": {:hex, :ex_doc, "0.16.2", "3b3e210ebcd85a7c76b4e73f85c5640c011d2a0b2f06dcdf5acdb2ae904e5084", [:mix], [{:earmark, "~> 1.1", [hex: :earmark, repo: "hexpm", optional: false]}], "hexpm"}, + "earmark": {:hex, :earmark, "1.3.1", "73812f447f7a42358d3ba79283cfa3075a7580a3a2ed457616d6517ac3738cb9", [:mix], [], "hexpm"}, + "ex_doc": {:hex, :ex_doc, "0.19.3", "3c7b0f02851f5fc13b040e8e925051452e41248f685e40250d7e40b07b9f8c10", [:mix], [{:earmark, "~> 1.2", [hex: :earmark, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.10", [hex: :makeup_elixir, 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"}, "idna": {:hex, :idna, "5.0.2", "ac203208ada855d95dc591a764b6e87259cb0e2a364218f215ad662daa8cd6b4", [:rebar3], [{:unicode_util_compat, "0.2.0", [hex: :unicode_util_compat, repo: "hexpm", optional: false]}], "hexpm"}, + "makeup": {:hex, :makeup, "0.8.0", "9cf32aea71c7fe0a4b2e9246c2c4978f9070257e5c9ce6d4a28ec450a839b55f", [:mix], [{:nimble_parsec, "~> 0.5.0", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm"}, + "makeup_elixir": {:hex, :makeup_elixir, "0.13.0", "be7a477997dcac2e48a9d695ec730b2d22418292675c75aa2d34ba0909dcdeda", [:mix], [{:makeup, "~> 0.8", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm"}, "metrics": {:hex, :metrics, "1.0.1", "25f094dea2cda98213cecc3aeff09e940299d950904393b2a29d191c346a8486", [:rebar3], [], "hexpm"}, "mime": {:hex, :mime, "1.1.0", "01c1d6f4083d8aa5c7b8c246ade95139620ef8effb009edde934e0ec3b28090a", [:mix], [], "hexpm"}, "mimerl": {:hex, :mimerl, "1.0.2", "993f9b0e084083405ed8252b99460c4f0563e41729ab42d9074fd5e52439be88", [:rebar3], [], "hexpm"}, + "nimble_parsec": {:hex, :nimble_parsec, "0.5.0", "90e2eca3d0266e5c53f8fbe0079694740b9c91b6747f2b7e3c5d21966bba8300", [:mix], [], "hexpm"}, "oauth2": {:hex, :oauth2, "0.9.1", "cac86d87f35ec835bfe4c791263bdb88c0d8bf1617d64f555ede4e9d913e35ef", [:mix], [{:hackney, "~> 1.7", [hex: :hackney, repo: "hexpm", optional: false]}], "hexpm"}, "plug": {:hex, :plug, "1.3.5", "7503bfcd7091df2a9761ef8cecea666d1f2cc454cbbaf0afa0b6e259203b7031", [:mix], [{:cowboy, "~> 1.0.1 or ~> 1.1", [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"}, From 842888874e24bebb0216c4be5311656c0d96a985 Mon Sep 17 00:00:00 2001 From: Tajinder Chumber Date: Mon, 5 Aug 2019 19:43:41 +0100 Subject: [PATCH 10/28] set oauth2 json library based on ueberauth's json library --- .gitignore | 3 +++ lib/ueberauth/strategy/facebook/oauth.ex | 3 +++ mix.exs | 4 ++-- mix.lock | 22 ++++++++++++---------- 4 files changed, 20 insertions(+), 12 deletions(-) diff --git a/.gitignore b/.gitignore index 9607671..fdeb96d 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,6 @@ /deps erl_crash.dump *.ez + + ### VS Code ### +.elixir_ls diff --git a/lib/ueberauth/strategy/facebook/oauth.ex b/lib/ueberauth/strategy/facebook/oauth.ex index 4da7087..26400a6 100644 --- a/lib/ueberauth/strategy/facebook/oauth.ex +++ b/lib/ueberauth/strategy/facebook/oauth.ex @@ -33,7 +33,10 @@ defmodule Ueberauth.Strategy.Facebook.OAuth do |> Keyword.merge(config) |> Keyword.merge(opts) + json_library = Ueberauth.json_library() + OAuth2.Client.new(opts) + |> OAuth2.Client.put_serializer("application/json", json_library) end @doc """ diff --git a/mix.exs b/mix.exs index 3ee792d..0c76303 100644 --- a/mix.exs +++ b/mix.exs @@ -24,8 +24,8 @@ defmodule Ueberauth.Facebook.Mixfile do end defp deps do - [{:ueberauth, "~> 0.4"}, - {:oauth2, "~> 0.9"}, + [{:ueberauth, "~> 0.6.0"}, + {:oauth2, "~> 1.0.0"}, {:credo, "~> 0.8.10", only: [:dev, :test]}, {:ex_doc, "~> 0.19", only: :dev}, diff --git a/mix.lock b/mix.lock index d0efae1..d6074d6 100644 --- a/mix.lock +++ b/mix.lock @@ -1,20 +1,22 @@ %{ "bunt": {:hex, :bunt, "0.2.0", "951c6e801e8b1d2cbe58ebbd3e616a869061ddadcc4863d0a2182541acae9a38", [:mix], [], "hexpm"}, - "certifi": {:hex, :certifi, "1.2.1", "c3904f192bd5284e5b13f20db3ceac9626e14eeacfbb492e19583cf0e37b22be", [:rebar3], [], "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.10", "261862bb7363247762e1063713bb85df2bbd84af8d8610d1272cd9c1943bba63", [:mix], [{:bunt, "~> 0.2.0", [hex: :bunt, repo: "hexpm", optional: false]}], "hexpm"}, "earmark": {:hex, :earmark, "1.3.1", "73812f447f7a42358d3ba79283cfa3075a7580a3a2ed457616d6517ac3738cb9", [:mix], [], "hexpm"}, "ex_doc": {:hex, :ex_doc, "0.19.3", "3c7b0f02851f5fc13b040e8e925051452e41248f685e40250d7e40b07b9f8c10", [:mix], [{:earmark, "~> 1.2", [hex: :earmark, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.10", [hex: :makeup_elixir, 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"}, - "idna": {:hex, :idna, "5.0.2", "ac203208ada855d95dc591a764b6e87259cb0e2a364218f215ad662daa8cd6b4", [:rebar3], [{:unicode_util_compat, "0.2.0", [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"}, "makeup": {:hex, :makeup, "0.8.0", "9cf32aea71c7fe0a4b2e9246c2c4978f9070257e5c9ce6d4a28ec450a839b55f", [:mix], [{:nimble_parsec, "~> 0.5.0", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm"}, "makeup_elixir": {:hex, :makeup_elixir, "0.13.0", "be7a477997dcac2e48a9d695ec730b2d22418292675c75aa2d34ba0909dcdeda", [:mix], [{:makeup, "~> 0.8", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm"}, "metrics": {:hex, :metrics, "1.0.1", "25f094dea2cda98213cecc3aeff09e940299d950904393b2a29d191c346a8486", [:rebar3], [], "hexpm"}, - "mime": {:hex, :mime, "1.1.0", "01c1d6f4083d8aa5c7b8c246ade95139620ef8effb009edde934e0ec3b28090a", [:mix], [], "hexpm"}, - "mimerl": {:hex, :mimerl, "1.0.2", "993f9b0e084083405ed8252b99460c4f0563e41729ab42d9074fd5e52439be88", [: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.0", "90e2eca3d0266e5c53f8fbe0079694740b9c91b6747f2b7e3c5d21966bba8300", [:mix], [], "hexpm"}, - "oauth2": {:hex, :oauth2, "0.9.1", "cac86d87f35ec835bfe4c791263bdb88c0d8bf1617d64f555ede4e9d913e35ef", [:mix], [{:hackney, "~> 1.7", [hex: :hackney, repo: "hexpm", optional: false]}], "hexpm"}, - "plug": {:hex, :plug, "1.3.5", "7503bfcd7091df2a9761ef8cecea666d1f2cc454cbbaf0afa0b6e259203b7031", [:mix], [{:cowboy, "~> 1.0.1 or ~> 1.1", [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"}, - "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"}, + "oauth2": {:hex, :oauth2, "1.0.1", "2a116de7863d4b5a8a265d77e62b17a6f54e0c01a5bbbf02210783cb861e49ac", [: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.8.3", "12d5f9796dc72e8ac9614e94bda5e51c4c028d0d428e9297650d09e15a684478", [: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"}, + "plug_crypto": {:hex, :plug_crypto, "1.0.0", "18e49317d3fa343f24620ed22795ec29d4a5e602d52d1513ccea0b07d8ea7d4d", [:mix], [], "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"}, } From ea5da0fb77dcf647680ff917b45a6cbcc95aa442 Mon Sep 17 00:00:00 2001 From: Arjan Scherpenisse Date: Fri, 23 Aug 2019 13:54:00 +0200 Subject: [PATCH 11/28] Allow oauth2 library version 2.x --- mix.exs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mix.exs b/mix.exs index 0c76303..d7ab64e 100644 --- a/mix.exs +++ b/mix.exs @@ -25,7 +25,7 @@ defmodule Ueberauth.Facebook.Mixfile do defp deps do [{:ueberauth, "~> 0.6.0"}, - {:oauth2, "~> 1.0.0"}, + {:oauth2, "~> 1.0 or ~> 2.0"}, {:credo, "~> 0.8.10", only: [:dev, :test]}, {:ex_doc, "~> 0.19", only: :dev}, From ee28811a6a8f25ab3e1291f48ad128390bf6da46 Mon Sep 17 00:00:00 2001 From: Steve Date: Fri, 7 Feb 2020 16:33:12 -0500 Subject: [PATCH 12/28] allow oauth options to be configured from the conn --- lib/ueberauth/strategy/facebook.ex | 56 ++++++++++++++++-------- lib/ueberauth/strategy/facebook/oauth.ex | 2 +- 2 files changed, 39 insertions(+), 19 deletions(-) diff --git a/lib/ueberauth/strategy/facebook.ex b/lib/ueberauth/strategy/facebook.ex index 0a3380c..c401486 100644 --- a/lib/ueberauth/strategy/facebook.ex +++ b/lib/ueberauth/strategy/facebook.ex @@ -3,17 +3,17 @@ defmodule Ueberauth.Strategy.Facebook do Facebook Strategy for Überauth. """ - use Ueberauth.Strategy, default_scope: "email,public_profile", - profile_fields: "id,email,gender,link,locale,name,timezone,updated_time,verified", - uid_field: :id, - allowed_request_params: [ - :auth_type, - :scope, - :locale, - :state, - :display - ] - + use Ueberauth.Strategy, + default_scope: "email,public_profile", + profile_fields: "id,email,gender,link,locale,name,timezone,updated_time,verified", + uid_field: :id, + allowed_request_params: [ + :auth_type, + :scope, + :locale, + :state, + :display + ] alias Ueberauth.Auth.Info alias Ueberauth.Auth.Credentials @@ -23,11 +23,15 @@ defmodule Ueberauth.Strategy.Facebook do Handles initial request for Facebook authentication. """ def handle_request!(conn) do - allowed_params = conn - |> option(:allowed_request_params) - |> Enum.map(&to_string/1) + allowed_params = + conn + |> option(:allowed_request_params) + |> Enum.map(&to_string/1) + + opts = oauth_client_options_from_conn(conn) - authorize_url = conn.params + authorize_url = + conn.params |> maybe_replace_param(conn, "auth_type", :auth_type) |> maybe_replace_param(conn, "scope", :default_scope) |> maybe_replace_param(conn, "state", :state) @@ -35,7 +39,7 @@ defmodule Ueberauth.Strategy.Facebook do |> Enum.filter(fn {k, _v} -> Enum.member?(allowed_params, k) end) |> Enum.map(fn {k, v} -> {String.to_existing_atom(k), v} end) |> Keyword.put(:redirect_uri, callback_url(conn)) - |> Ueberauth.Strategy.Facebook.OAuth.authorize_url! + |> Ueberauth.Strategy.Facebook.OAuth.authorize_url!(opts) redirect!(conn, authorize_url) end @@ -139,12 +143,15 @@ defmodule Ueberauth.Strategy.Facebook do conn = put_private(conn, :facebook_token, client.token) query = user_query(conn, client.token) path = "/me?#{query}" + case OAuth2.Client.get(client, path) 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 -> + when status_code in 200..399 -> put_private(conn, :facebook_user, user) + {:error, %OAuth2.Error{reason: reason}} -> set_errors!(conn, [error("OAuth2", reason)]) end @@ -154,7 +161,7 @@ defmodule Ueberauth.Strategy.Facebook do %{"appsecret_proof" => appsecret_proof(token)} |> Map.merge(query_params(conn, :locale)) |> Map.merge(query_params(conn, :profile)) - |> URI.encode_query + |> URI.encode_query() end defp appsecret_proof(token) do @@ -173,6 +180,7 @@ defmodule Ueberauth.Strategy.Facebook do defp query_params(conn, :profile) do %{"fields" => option(conn, :profile_fields)} end + defp query_params(conn, :locale) do case option(conn, :locale) do nil -> %{} @@ -187,6 +195,7 @@ defmodule Ueberauth.Strategy.Facebook do |> options |> Keyword.get(key, default) end + defp option(nil, conn, key), do: option(conn, key) defp option(value, _conn, _key), do: value @@ -201,4 +210,15 @@ defmodule Ueberauth.Strategy.Facebook do ) end 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 end diff --git a/lib/ueberauth/strategy/facebook/oauth.ex b/lib/ueberauth/strategy/facebook/oauth.ex index 26400a6..4c2ece9 100644 --- a/lib/ueberauth/strategy/facebook/oauth.ex +++ b/lib/ueberauth/strategy/facebook/oauth.ex @@ -26,7 +26,7 @@ defmodule Ueberauth.Strategy.Facebook.OAuth do of Ueberauth. """ def client(opts \\ []) do - config = Application.get_env(:ueberauth, Ueberauth.Strategy.Facebook.OAuth) + config = Application.get_env(:ueberauth, Ueberauth.Strategy.Facebook.OAuth, []) opts = @defaults From a351a25fa6f175116f8dd3b075bbe622604db5be Mon Sep 17 00:00:00 2001 From: Jeff Browning Date: Wed, 12 Feb 2020 08:39:43 -0500 Subject: [PATCH 13/28] Handle errors from fetching the access token with an invalid/expired code (#52) Fixes #51 --- lib/ueberauth/strategy/facebook.ex | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/lib/ueberauth/strategy/facebook.ex b/lib/ueberauth/strategy/facebook.ex index 0a3380c..9a97e6b 100644 --- a/lib/ueberauth/strategy/facebook.ex +++ b/lib/ueberauth/strategy/facebook.ex @@ -45,15 +45,20 @@ defmodule Ueberauth.Strategy.Facebook do """ def handle_callback!(%Plug.Conn{params: %{"code" => code}} = conn) do opts = [redirect_uri: callback_url(conn)] - client = Ueberauth.Strategy.Facebook.OAuth.get_token!([code: code], opts) - token = client.token - - if token.access_token == nil do - err = token.other_params["error"] - desc = token.other_params["error_description"] - set_errors!(conn, [error(err, desc)]) - else - fetch_user(conn, client) + try do + client = Ueberauth.Strategy.Facebook.OAuth.get_token!([code: code], opts) + token = client.token + + if token.access_token == nil do + err = token.other_params["error"] + desc = token.other_params["error_description"] + set_errors!(conn, [error(err, desc)]) + else + fetch_user(conn, client) + end + rescue + OAuth2.Error -> + set_errors!(conn, [error("invalid_code", "The code has been used or has expired")]) end end From 8824db789a75d3ddf45b437abffa12923ec6aad7 Mon Sep 17 00:00:00 2001 From: Steve Date: Fri, 14 Feb 2020 13:15:49 -0500 Subject: [PATCH 14/28] also get options from conn here --- lib/ueberauth/strategy/facebook.ex | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/lib/ueberauth/strategy/facebook.ex b/lib/ueberauth/strategy/facebook.ex index c401486..8909ddb 100644 --- a/lib/ueberauth/strategy/facebook.ex +++ b/lib/ueberauth/strategy/facebook.ex @@ -48,7 +48,13 @@ defmodule Ueberauth.Strategy.Facebook do Handles the callback from Facebook. """ def handle_callback!(%Plug.Conn{params: %{"code" => code}} = conn) do - opts = [redirect_uri: callback_url(conn)] + opts = oauth_client_options_from_conn(conn) + + config = + :ueberauth + |> Application.get_env(Ueberauth.Strategy.Facebook.OAuth, []) + |> Keyword.merge(opts) + client = Ueberauth.Strategy.Facebook.OAuth.get_token!([code: code], opts) token = client.token @@ -57,7 +63,7 @@ defmodule Ueberauth.Strategy.Facebook do desc = token.other_params["error_description"] set_errors!(conn, [error(err, desc)]) else - fetch_user(conn, client) + fetch_user(conn, client, config) end end @@ -139,9 +145,9 @@ defmodule Ueberauth.Strategy.Facebook do "https://graph.facebook.com/#{uid}/picture?type=square" end - defp fetch_user(conn, client) do + defp fetch_user(conn, client, config) do conn = put_private(conn, :facebook_token, client.token) - query = user_query(conn, client.token) + query = user_query(conn, client.token, config) path = "/me?#{query}" case OAuth2.Client.get(client, path) do @@ -157,15 +163,14 @@ defmodule Ueberauth.Strategy.Facebook do end end - defp user_query(conn, token) do - %{"appsecret_proof" => appsecret_proof(token)} + defp user_query(conn, token, config) do + %{"appsecret_proof" => appsecret_proof(token, config)} |> Map.merge(query_params(conn, :locale)) |> Map.merge(query_params(conn, :profile)) |> URI.encode_query() end - defp appsecret_proof(token) do - config = Application.get_env(:ueberauth, Ueberauth.Strategy.Facebook.OAuth) + defp appsecret_proof(token, config) do client_secret = Keyword.get(config, :client_secret) token.access_token From 1835c0b53d015c302bf864b301f3a35772acf6fb Mon Sep 17 00:00:00 2001 From: Hans Pagh Date: Mon, 2 Mar 2020 17:53:42 +0100 Subject: [PATCH 15/28] Release 0.8.1 --- mix.exs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mix.exs b/mix.exs index d7ab64e..0c684e1 100644 --- a/mix.exs +++ b/mix.exs @@ -1,7 +1,7 @@ defmodule Ueberauth.Facebook.Mixfile do use Mix.Project - @version "0.8.0" + @version "0.8.1" @url "https://github.com/ueberauth/ueberauth_facebook" def project do From 9af663399bb7f73423d3d1de3abb8287bf5b8f7b Mon Sep 17 00:00:00 2001 From: Berni Date: Sun, 17 May 2020 15:24:35 +0200 Subject: [PATCH 16/28] fix(*): Use type large for profile image (#54) --- lib/ueberauth/strategy/facebook.ex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ueberauth/strategy/facebook.ex b/lib/ueberauth/strategy/facebook.ex index 9a97e6b..03ea0ea 100644 --- a/lib/ueberauth/strategy/facebook.ex +++ b/lib/ueberauth/strategy/facebook.ex @@ -137,7 +137,7 @@ defmodule Ueberauth.Strategy.Facebook do end defp fetch_image(uid) do - "https://graph.facebook.com/#{uid}/picture?type=square" + "https://graph.facebook.com/#{uid}/picture?type=large" end defp fetch_user(conn, client) do From 015edf90c8c9ca0707bbe0f5d1203f340fe6ca3c Mon Sep 17 00:00:00 2001 From: Nathan Willson Date: Mon, 12 Apr 2021 22:28:35 +0900 Subject: [PATCH 17/28] Add documenation for state 1. Mention call 'options' explicitly in README 2. Add documentation about state 3. Linter removed a few extra spaces in the README --- README.md | 85 +++++++++++++++++++++++++++++-------------------------- 1 file changed, 45 insertions(+), 40 deletions(-) diff --git a/README.md b/README.md index 79d38ad..8450a76 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ # Überauth Facebook + [![Build Status][travis-img]][travis] [![Hex Version][hex-img]][hex] [![License][license-img]][license] [travis-img]: https://travis-ci.org/ueberauth/ueberauth_facebook.svg?branch=master @@ -16,57 +17,57 @@ 1. Add `:ueberauth_facebook` to your list of dependencies in `mix.exs`: - ```elixir - def deps do - [{:ueberauth_facebook, "~> 0.8"}] - end - ``` + ```elixir + def deps do + [{:ueberauth_facebook, "~> 0.8"}] + end + ``` 1. Add the strategy to your applications: - ```elixir - def application do - [applications: [:ueberauth_facebook]] - end - ``` + ```elixir + def application do + [applications: [:ueberauth_facebook]] + end + ``` 1. Add Facebook to your Überauth configuration: - ```elixir - config :ueberauth, Ueberauth, - providers: [ - facebook: {Ueberauth.Strategy.Facebook, []} - ] - ``` + ```elixir + config :ueberauth, Ueberauth, + providers: [ + facebook: {Ueberauth.Strategy.Facebook, []} + ] + ``` -1. Update your provider configuration: +1. Update your provider configuration: - ```elixir - config :ueberauth, Ueberauth.Strategy.Facebook.OAuth, - client_id: System.get_env("FACEBOOK_CLIENT_ID"), - client_secret: System.get_env("FACEBOOK_CLIENT_SECRET") - ``` + ```elixir + config :ueberauth, Ueberauth.Strategy.Facebook.OAuth, + client_id: System.get_env("FACEBOOK_CLIENT_ID"), + client_secret: System.get_env("FACEBOOK_CLIENT_SECRET") + ``` -1. Include the Überauth plug in your controller: +1. Include the Überauth plug in your controller: - ```elixir - defmodule MyApp.AuthController do - use MyApp.Web, :controller - plug Ueberauth - ... - end - ``` + ```elixir + defmodule MyApp.AuthController do + use MyApp.Web, :controller + plug Ueberauth + ... + end + ``` -1. Create the request and callback routes if you haven't already: +1. Create the request and callback routes if you haven't already: - ```elixir - scope "/auth", MyApp do - pipe_through :browser + ```elixir + scope "/auth", MyApp do + pipe_through :browser - get "/:provider", AuthController, :request - get "/:provider/callback", AuthController, :callback - end - ``` + get "/:provider", AuthController, :request + get "/:provider/callback", AuthController, :callback + end + ``` 1. Your controller needs to implement callbacks to deal with `Ueberauth.Auth` and `Ueberauth.Failure` responses. @@ -78,7 +79,7 @@ Depending on the configured URL you can initialize the request through: /auth/facebook -Or with options: +Or with options (`state`, `auth_type`, `scope`, `locale`, `display`): /auth/facebook?scope=email,public_profile @@ -117,8 +118,12 @@ config :ueberauth, Ueberauth, See [Graph API Reference > User](https://developers.facebook.com/docs/graph-api/reference/user) for full list of fields. +### Passing dynamic state + +A [state](https://developers.facebook.com/docs/facebook-login/security/#stateparam) parameter can be [passed with a call](https://developers.facebook.com/docs/facebook-login/manually-build-a-login-flow#login) and is returned in the redirect URI as a URL parameter. + + /auth/facebook?scope=email,public_profile&state={"id":1,"field":"value"} ## License Please see [LICENSE](https://github.com/ueberauth/ueberauth_facebook/blob/master/LICENSE) for licensing details. - From b36429f42666d631a5b1da0fbcdf3379f179e0c7 Mon Sep 17 00:00:00 2001 From: Nathan Willson Date: Mon, 12 Apr 2021 22:34:26 +0900 Subject: [PATCH 18/28] Update ex_doc In order to compile docs an update of ex_doc was necessary. Also ran 'mix format mix.exs' --- mix.exs | 45 +++++++++++++++++++++++++-------------------- mix.lock | 42 ++++++++++++++++++++++-------------------- 2 files changed, 47 insertions(+), 40 deletions(-) diff --git a/mix.exs b/mix.exs index 0c684e1..5f8bb0a 100644 --- a/mix.exs +++ b/mix.exs @@ -5,18 +5,20 @@ defmodule Ueberauth.Facebook.Mixfile do @url "https://github.com/ueberauth/ueberauth_facebook" def project do - [app: :ueberauth_facebook, - version: @version, - name: "Ueberauth Facebook 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_facebook, + version: @version, + name: "Ueberauth Facebook 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() + ] end def application do @@ -24,12 +26,13 @@ defmodule Ueberauth.Facebook.Mixfile do end defp deps do - [{:ueberauth, "~> 0.6.0"}, - {:oauth2, "~> 1.0 or ~> 2.0"}, - - {:credo, "~> 0.8.10", only: [:dev, :test]}, - {:ex_doc, "~> 0.19", only: :dev}, - {:earmark, ">= 0.0.0", only: :dev}] + [ + {:ueberauth, "~> 0.6.0"}, + {:oauth2, "~> 1.0 or ~> 2.0"}, + {:credo, "~> 0.8.10", only: [:dev, :test]}, + {:ex_doc, "~> 0.24", only: :dev, runtime: false}, + {:earmark, ">= 0.0.0", only: :dev} + ] end defp docs do @@ -41,9 +44,11 @@ defmodule Ueberauth.Facebook.Mixfile do end defp package do - [files: ["lib", "mix.exs", "README.md", "LICENSE"], + [ + files: ["lib", "mix.exs", "README.md", "LICENSE"], maintainers: ["Sean Callan"], licenses: ["MIT"], - links: %{"GitHub": @url}] + links: %{GitHub: @url} + ] end end diff --git a/mix.lock b/mix.lock index d6074d6..1909ddc 100644 --- a/mix.lock +++ b/mix.lock @@ -1,22 +1,24 @@ %{ - "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.10", "261862bb7363247762e1063713bb85df2bbd84af8d8610d1272cd9c1943bba63", [:mix], [{:bunt, "~> 0.2.0", [hex: :bunt, repo: "hexpm", optional: false]}], "hexpm"}, - "earmark": {:hex, :earmark, "1.3.1", "73812f447f7a42358d3ba79283cfa3075a7580a3a2ed457616d6517ac3738cb9", [:mix], [], "hexpm"}, - "ex_doc": {:hex, :ex_doc, "0.19.3", "3c7b0f02851f5fc13b040e8e925051452e41248f685e40250d7e40b07b9f8c10", [:mix], [{:earmark, "~> 1.2", [hex: :earmark, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.10", [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"}, - "makeup": {:hex, :makeup, "0.8.0", "9cf32aea71c7fe0a4b2e9246c2c4978f9070257e5c9ce6d4a28ec450a839b55f", [:mix], [{:nimble_parsec, "~> 0.5.0", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm"}, - "makeup_elixir": {:hex, :makeup_elixir, "0.13.0", "be7a477997dcac2e48a9d695ec730b2d22418292675c75aa2d34ba0909dcdeda", [:mix], [{:makeup, "~> 0.8", [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.0", "90e2eca3d0266e5c53f8fbe0079694740b9c91b6747f2b7e3c5d21966bba8300", [:mix], [], "hexpm"}, - "oauth2": {:hex, :oauth2, "1.0.1", "2a116de7863d4b5a8a265d77e62b17a6f54e0c01a5bbbf02210783cb861e49ac", [: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.8.3", "12d5f9796dc72e8ac9614e94bda5e51c4c028d0d428e9297650d09e15a684478", [: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"}, - "plug_crypto": {:hex, :plug_crypto, "1.0.0", "18e49317d3fa343f24620ed22795ec29d4a5e602d52d1513ccea0b07d8ea7d4d", [:mix], [], "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, "0.8.10", "261862bb7363247762e1063713bb85df2bbd84af8d8610d1272cd9c1943bba63", [:mix], [{:bunt, "~> 0.2.0", [hex: :bunt, repo: "hexpm", optional: false]}], "hexpm", "f3fe29f8de6be431c7736a933a3897fe9aa45533b1d1358b3691ac8ec4371e8f"}, + "earmark": {:hex, :earmark, "1.4.14", "d04572cef64dd92726a97d92d714e38d6e130b024ea1b3f8a56e7de66ec04e50", [:mix], [{:earmark_parser, ">= 1.4.12", [hex: :earmark_parser, repo: "hexpm", optional: false]}], "hexpm", "df338b8b1852ee425180b276c56c6941cb12220e04fe8718fe4acbdd35fd699f"}, + "earmark_parser": {:hex, :earmark_parser, "1.4.12", "b245e875ec0a311a342320da0551da407d9d2b65d98f7a9597ae078615af3449", [:mix], [], "hexpm", "711e2cc4d64abb7d566d43f54b78f7dc129308a63bc103fbd88550d2174b3160"}, + "ex_doc": {:hex, :ex_doc, "0.24.2", "e4c26603830c1a2286dae45f4412a4d1980e1e89dc779fcd0181ed1d5a05c8d9", [: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", "e134e1d9e821b8d9e4244687fb2ace58d479b67b282de5158333b0d57c6fb7da"}, + "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"}, + "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"}, + "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"}, + "nimble_parsec": {:hex, :nimble_parsec, "1.1.0", "3a6fca1550363552e54c216debb6a9e95bd8d32348938e13de5eda962c0d7f89", [:mix], [], "hexpm", "08eb32d66b706e913ff748f11694b17981c0b04a33ef470e33e11b3d3ac8f54b"}, + "oauth2": {:hex, :oauth2, "1.0.1", "2a116de7863d4b5a8a265d77e62b17a6f54e0c01a5bbbf02210783cb861e49ac", [:mix], [{:hackney, "~> 1.13", [hex: :hackney, repo: "hexpm", optional: false]}], "hexpm", "0417bd37101ac27cdfe33003266c15da31cf9d59f1778994624a77febd0d8e07"}, + "parse_trans": {:hex, :parse_trans, "3.3.0", "09765507a3c7590a784615cfd421d101aec25098d50b89d7aa1d66646bc571c1", [:rebar3], [], "hexpm", "17ef63abde837ad30680ea7f857dd9e7ced9476cdd7b0394432af4bfc241b960"}, + "plug": {:hex, :plug, "1.8.3", "12d5f9796dc72e8ac9614e94bda5e51c4c028d0d428e9297650d09e15a684478", [: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", "164baaeb382d19beee0ec484492aa82a9c8685770aee33b24ec727a0971b34d0"}, + "plug_crypto": {:hex, :plug_crypto, "1.0.0", "18e49317d3fa343f24620ed22795ec29d4a5e602d52d1513ccea0b07d8ea7d4d", [:mix], [], "hexpm", "73c1682f0e414cfb5d9b95c8e8cd6ffcfdae699e3b05e1db744e58b7be857759"}, + "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"}, } From e4426d3b7307ae2fee457b0210de063c5ce4fdca Mon Sep 17 00:00:00 2001 From: Kian-Meng Ang Date: Sat, 1 May 2021 04:08:47 +0800 Subject: [PATCH 19/28] Misc doc changes Besides other documentation changes, this commit ensures the generated HTML doc for HexDocs.pm will become the main reference doc for this Elixir library which leverage on latest features of ExDoc. --- .formatter.exs | 4 ++ .gitignore | 27 ++++++++-- CHANGELOG.md | 50 +++++++++++++---- CONTRIBUTING.md | 2 +- README.md | 27 +++++----- lib/ueberauth/strategy/facebook/oauth.ex | 9 ++-- mix.exs | 69 ++++++++++++++---------- mix.lock | 42 ++++++++------- 8 files changed, 151 insertions(+), 79 deletions(-) create mode 100644 .formatter.exs diff --git a/.formatter.exs b/.formatter.exs new file mode 100644 index 0000000..d2cda26 --- /dev/null +++ b/.formatter.exs @@ -0,0 +1,4 @@ +# Used by "mix format" +[ + inputs: ["{mix,.formatter}.exs", "{config,lib,test}/**/*.{ex,exs}"] +] diff --git a/.gitignore b/.gitignore index fdeb96d..7ee0d01 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,26 @@ -/_build -/deps +# The directory Mix will write compiled artifacts to. +/_build/ + +# If you run "mix test --cover", coverage assets end up here. +/cover/ + +# The directory Mix downloads your dependencies sources to. +/deps/ + +# Where third-party dependencies like ExDoc output generated docs. +/doc/ + +# Ignore .fetch files in case you like to edit your project deps locally. +/.fetch + +# If the VM crashes, it generates a dump, let's ignore it too. erl_crash.dump + +# Also ignore archive artifacts (built via "mix archive.build"). *.ez - ### VS Code ### -.elixir_ls +# Ignore package tarball (built via "mix hex.build"). +ueberauth_facebook-*.tar + +# Temporary files for e.g. tests. +/tmp diff --git a/CHANGELOG.md b/CHANGELOG.md index c505f56..e8b4e8e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,45 +1,73 @@ -# v 0.6.0 +# Changelog + +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [Unreleased] + +* Allow OAuth options to be configured from the connection +* Set default profile image to large + +## v0.8.1 - 2020-03-02 + +* Handle errors from fetching the access token with an invalid/expired code +* Support OAuth2 version 2.0 library +* Set OAuth2 JSON library based on Ueberauth's JSON libray + +## v0.8.0 - 2019-03-09 + +* Add option to specify scheme for user avatar URL +* Stop sending empty params to the Facebook auth dialog + +## v0.7.0 - 2017-07-18 + +* Support `:appsecret_proof` parameter +* Set the required `:profile_fields` to get the email back + +## v0.6.0 - 2016-12-27 * Support `:display` parameter * Use OAuth2 0.8 -# v 0.5.0 +## v0.5.0 - 2016-09-21 * Pin OAuth2 to 0.6 to avoid errors -# v 0.4 +## v0.4.0 - 2016-07-19 * Allow `:state` param to be configured -# v 0.3.2 +## v0.3.2 - 2016-02-15 * Fix support for auth_type -# v 0.3.1 +## v0.3.1 - 2016-02-10 * Add support for missing Locale parameter -# v 0.3.0 +## v0.3.0 - 2016-02-04 * Add support for auth_type * Support for additional request variables -# v 0.2.1 +## v0.2.1 - 2015-12-11 * Add missing `profile_fields` parameter -# v 0.2.0 +## v0.2.0 - 2015-11-28 * Release to follow the Ueberauth 0.2.0 release -# v 0.1.4 +## v0.1.4 - 2015-11-18 * Added oauth2 and ueberauth to applications list -# v 0.1.1 +## v0.1.1 - 2015-11-16 * Fixed character encoding errors in Hex package -# v 0.1.0 +## v0.1.0 - 2015-11-16 * Initial strategy diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 3669a7e..c94ad84 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,4 +1,4 @@ -# Contributing to Ueberauth Facebook +# Contributing ## Pull Requests Welcome 1. Fork ueberauth_facebook diff --git a/README.md b/README.md index 79d38ad..a185427 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,11 @@ # Überauth Facebook -[![Build Status][travis-img]][travis] [![Hex Version][hex-img]][hex] [![License][license-img]][license] -[travis-img]: https://travis-ci.org/ueberauth/ueberauth_facebook.svg?branch=master -[travis]: https://travis-ci.org/ueberauth/ueberauth_facebook -[hex-img]: https://img.shields.io/hexpm/v/ueberauth_facebook.svg -[hex]: https://hex.pm/packages/ueberauth_facebook -[license-img]: http://img.shields.io/badge/license-MIT-brightgreen.svg -[license]: http://opensource.org/licenses/MIT +[![Build Status](https://travis-ci.org/ueberauth/ueberauth_facebook.svg?branch=master)](https://travis-ci.org/ueberauth/ueberauth_facebook) +[![Module Version](https://img.shields.io/hexpm/v/ueberauth_facebook.svg)](https://hex.pm/packages/ueberauth_facebook) +[![Hex Docs](https://img.shields.io/badge/hex-docs-lightgreen.svg)](https://hexdocs.pm/ueberauth_facebook/) +[![Total Download](https://img.shields.io/hexpm/dt/ueberauth_facebook.svg)](https://hex.pm/packages/ueberauth_facebook) +[![License](https://img.shields.io/hexpm/l/ueberauth_facebook.svg)](https://github.com/ueberauth/ueberauth_facebook/blob/master/LICENSE) +[![Last Updated](https://img.shields.io/github/last-commit/ueberauth/ueberauth_facebook.svg)](https://github.com/ueberauth/ueberauth_facebook/commits/master) > Facebook OAuth2 strategy for Überauth. @@ -18,7 +17,9 @@ ```elixir def deps do - [{:ueberauth_facebook, "~> 0.8"}] + [ + {:ueberauth_facebook, "~> 0.8"} + ] end ``` @@ -26,7 +27,9 @@ ```elixir def application do - [applications: [:ueberauth_facebook]] + [ + applications: [:ueberauth_facebook] + ] end ``` @@ -117,8 +120,8 @@ config :ueberauth, Ueberauth, See [Graph API Reference > User](https://developers.facebook.com/docs/graph-api/reference/user) for full list of fields. +## Copyright and License -## License - -Please see [LICENSE](https://github.com/ueberauth/ueberauth_facebook/blob/master/LICENSE) for licensing details. +Copyright (c) 2015 Sean Callan +Released under the MIT License, which can be found in the repository in [LICENSE](./LICENSE). diff --git a/lib/ueberauth/strategy/facebook/oauth.ex b/lib/ueberauth/strategy/facebook/oauth.ex index 4c2ece9..bf9c05c 100644 --- a/lib/ueberauth/strategy/facebook/oauth.ex +++ b/lib/ueberauth/strategy/facebook/oauth.ex @@ -2,11 +2,12 @@ defmodule Ueberauth.Strategy.Facebook.OAuth do @moduledoc """ OAuth2 for Facebook. - Add `client_id` and `client_secret` to your configuration: + Add `:client_id` and `:client_secret` to your configuration: + + config :ueberauth, Ueberauth.Strategy.Facebook.OAuth, + client_id: System.get_env("FACEBOOK_APP_ID"), + client_secret: System.get_env("FACEBOOK_APP_SECRET") - config :ueberauth, Ueberauth.Strategy.Facebook.OAuth, - client_id: System.get_env("FACEBOOK_APP_ID"), - client_secret: System.get_env("FACEBOOK_APP_SECRET") """ use OAuth2.Strategy diff --git a/mix.exs b/mix.exs index 0c684e1..77668a3 100644 --- a/mix.exs +++ b/mix.exs @@ -1,49 +1,64 @@ defmodule Ueberauth.Facebook.Mixfile do use Mix.Project + @source_url "https://github.com/ueberauth/ueberauth_facebook" @version "0.8.1" - @url "https://github.com/ueberauth/ueberauth_facebook" def project do - [app: :ueberauth_facebook, - version: @version, - name: "Ueberauth Facebook 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_facebook, + version: @version, + name: "Überauth Facebook", + elixir: "~> 1.3", + build_embedded: Mix.env() == :prod, + start_permanent: Mix.env() == :prod, + package: package(), + deps: deps(), + docs: docs() + ] end def application do - [applications: [:logger, :oauth2, :ueberauth]] + [ + applications: [:logger, :oauth2, :ueberauth] + ] end defp deps do - [{:ueberauth, "~> 0.6.0"}, - {:oauth2, "~> 1.0 or ~> 2.0"}, - - {:credo, "~> 0.8.10", only: [:dev, :test]}, - {:ex_doc, "~> 0.19", only: :dev}, - {:earmark, ">= 0.0.0", only: :dev}] + [ + {:ueberauth, "~> 0.6.0"}, + {:oauth2, "~> 1.0 or ~> 2.0"}, + {:credo, "~> 0.8.10", only: [:dev, :test]}, + {:ex_doc, ">= 0.0.0", only: :dev, runtime: false} + ] end defp docs do - [extras: ["README.md", "CONTRIBUTING.md"]] - end - - defp description do - "An Uberauth strategy for Facebook authentication." + [ + extras: [ + "CHANGELOG.md", + "CONTRIBUTING.md", + {:"LICENSE", [title: "License"]}, + "README.md" + ], + main: "readme", + source_url: @source_url, + source_ref: "v#{@version}", + homepage_url: @source_url, + formatters: ["html"] + ] end defp package do - [files: ["lib", "mix.exs", "README.md", "LICENSE"], + [ + description: "An Überauth strategy for Facebook authentication.", + files: ["lib", "mix.exs", "README.md", "CHANGELOG.md", "CONTRIBUTING.md", "LICENSE"], maintainers: ["Sean Callan"], licenses: ["MIT"], - links: %{"GitHub": @url}] + links: %{ + Changelog: "https://hexdocs.pm/ueberauth_facebook/changelog.html", + GitHub: @source_url + } + ] end end diff --git a/mix.lock b/mix.lock index d6074d6..ecc8e2f 100644 --- a/mix.lock +++ b/mix.lock @@ -1,22 +1,24 @@ %{ - "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.10", "261862bb7363247762e1063713bb85df2bbd84af8d8610d1272cd9c1943bba63", [:mix], [{:bunt, "~> 0.2.0", [hex: :bunt, repo: "hexpm", optional: false]}], "hexpm"}, - "earmark": {:hex, :earmark, "1.3.1", "73812f447f7a42358d3ba79283cfa3075a7580a3a2ed457616d6517ac3738cb9", [:mix], [], "hexpm"}, - "ex_doc": {:hex, :ex_doc, "0.19.3", "3c7b0f02851f5fc13b040e8e925051452e41248f685e40250d7e40b07b9f8c10", [:mix], [{:earmark, "~> 1.2", [hex: :earmark, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.10", [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"}, - "makeup": {:hex, :makeup, "0.8.0", "9cf32aea71c7fe0a4b2e9246c2c4978f9070257e5c9ce6d4a28ec450a839b55f", [:mix], [{:nimble_parsec, "~> 0.5.0", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm"}, - "makeup_elixir": {:hex, :makeup_elixir, "0.13.0", "be7a477997dcac2e48a9d695ec730b2d22418292675c75aa2d34ba0909dcdeda", [:mix], [{:makeup, "~> 0.8", [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.0", "90e2eca3d0266e5c53f8fbe0079694740b9c91b6747f2b7e3c5d21966bba8300", [:mix], [], "hexpm"}, - "oauth2": {:hex, :oauth2, "1.0.1", "2a116de7863d4b5a8a265d77e62b17a6f54e0c01a5bbbf02210783cb861e49ac", [: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.8.3", "12d5f9796dc72e8ac9614e94bda5e51c4c028d0d428e9297650d09e15a684478", [: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"}, - "plug_crypto": {:hex, :plug_crypto, "1.0.0", "18e49317d3fa343f24620ed22795ec29d4a5e602d52d1513ccea0b07d8ea7d4d", [:mix], [], "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, "0.8.10", "261862bb7363247762e1063713bb85df2bbd84af8d8610d1272cd9c1943bba63", [:mix], [{:bunt, "~> 0.2.0", [hex: :bunt, repo: "hexpm", optional: false]}], "hexpm", "f3fe29f8de6be431c7736a933a3897fe9aa45533b1d1358b3691ac8ec4371e8f"}, + "earmark": {:hex, :earmark, "1.3.1", "73812f447f7a42358d3ba79283cfa3075a7580a3a2ed457616d6517ac3738cb9", [:mix], [], "hexpm", "000aaeff08919e95e7aea13e4af7b2b9734577b3e6a7c50ee31ee88cab6ec4fb"}, + "earmark_parser": {:hex, :earmark_parser, "1.4.13", "0c98163e7d04a15feb62000e1a891489feb29f3d10cb57d4f845c405852bbef8", [:mix], [], "hexpm", "d602c26af3a0af43d2f2645613f65841657ad6efc9f0e361c3b6c06b578214ba"}, + "ex_doc": {:hex, :ex_doc, "0.24.2", "e4c26603830c1a2286dae45f4412a4d1980e1e89dc779fcd0181ed1d5a05c8d9", [: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", "e134e1d9e821b8d9e4244687fb2ace58d479b67b282de5158333b0d57c6fb7da"}, + "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"}, + "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"}, + "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"}, + "nimble_parsec": {:hex, :nimble_parsec, "1.1.0", "3a6fca1550363552e54c216debb6a9e95bd8d32348938e13de5eda962c0d7f89", [:mix], [], "hexpm", "08eb32d66b706e913ff748f11694b17981c0b04a33ef470e33e11b3d3ac8f54b"}, + "oauth2": {:hex, :oauth2, "1.0.1", "2a116de7863d4b5a8a265d77e62b17a6f54e0c01a5bbbf02210783cb861e49ac", [:mix], [{:hackney, "~> 1.13", [hex: :hackney, repo: "hexpm", optional: false]}], "hexpm", "0417bd37101ac27cdfe33003266c15da31cf9d59f1778994624a77febd0d8e07"}, + "parse_trans": {:hex, :parse_trans, "3.3.0", "09765507a3c7590a784615cfd421d101aec25098d50b89d7aa1d66646bc571c1", [:rebar3], [], "hexpm", "17ef63abde837ad30680ea7f857dd9e7ced9476cdd7b0394432af4bfc241b960"}, + "plug": {:hex, :plug, "1.8.3", "12d5f9796dc72e8ac9614e94bda5e51c4c028d0d428e9297650d09e15a684478", [: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", "164baaeb382d19beee0ec484492aa82a9c8685770aee33b24ec727a0971b34d0"}, + "plug_crypto": {:hex, :plug_crypto, "1.0.0", "18e49317d3fa343f24620ed22795ec29d4a5e602d52d1513ccea0b07d8ea7d4d", [:mix], [], "hexpm", "73c1682f0e414cfb5d9b95c8e8cd6ffcfdae699e3b05e1db744e58b7be857759"}, + "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"}, } From 24971a5a6f673ee95533258e5fa7dc758ed40619 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mihai=20T=C3=A2rnovan?= Date: Thu, 27 May 2021 19:26:18 +0300 Subject: [PATCH 20/28] Fix crypto mac signature change in OTP/24 ref #60 --- lib/ueberauth/strategy/facebook.ex | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/ueberauth/strategy/facebook.ex b/lib/ueberauth/strategy/facebook.ex index 4fb18f4..6b89449 100644 --- a/lib/ueberauth/strategy/facebook.ex +++ b/lib/ueberauth/strategy/facebook.ex @@ -183,8 +183,14 @@ defmodule Ueberauth.Strategy.Facebook do |> Base.encode16(case: :lower) end + @compile {:no_warn_undefined, {:crypto, :mac, 4}} + @compile {:no_warn_undefined, {:crypto, :hmac, 3}} defp hmac(data, type, key) do - :crypto.hmac(type, key, data) + if function_exported?(:crypto, :mac, 4) do + :crypto.mac(:hmac, type, key, data) + else + :crypto.hmac(type, key, data) + end end defp query_params(conn, :profile) do From 61361cd39849784bb1bb5aec48ddf77723ed6264 Mon Sep 17 00:00:00 2001 From: Hans Pagh Date: Thu, 17 Jun 2021 09:53:03 +0200 Subject: [PATCH 21/28] undo deps update --- mix.exs | 5 ++--- mix.lock | 25 ++++++++++++------------- 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/mix.exs b/mix.exs index 212d030..5298d3c 100644 --- a/mix.exs +++ b/mix.exs @@ -29,8 +29,7 @@ defmodule Ueberauth.Facebook.Mixfile do {:ueberauth, "~> 0.6.0"}, {:oauth2, "~> 1.0 or ~> 2.0"}, {:credo, "~> 0.8.10", only: [:dev, :test]}, - {:ex_doc, "~> 0.24", only: :dev, runtime: false}, - {:earmark, ">= 0.0.0", only: :dev} + {:ex_doc, ">= 0.24.2", only: :dev, runtime: false} ] end @@ -39,7 +38,7 @@ defmodule Ueberauth.Facebook.Mixfile do extras: [ "CHANGELOG.md", "CONTRIBUTING.md", - {:"LICENSE", [title: "License"]}, + {:LICENSE, [title: "License"]}, "README.md" ], main: "readme", diff --git a/mix.lock b/mix.lock index d6bb83c..ecc8e2f 100644 --- a/mix.lock +++ b/mix.lock @@ -1,25 +1,24 @@ %{ "bunt": {:hex, :bunt, "0.2.0", "951c6e801e8b1d2cbe58ebbd3e616a869061ddadcc4863d0a2182541acae9a38", [:mix], [], "hexpm", "7af5c7e09fe1d40f76c8e4f9dd2be7cebd83909f31fee7cd0e9eadc567da8353"}, - "certifi": {:hex, :certifi, "2.6.1", "dbab8e5e155a0763eea978c913ca280a6b544bfa115633fa20249c3d396d9493", [:rebar3], [], "hexpm", "524c97b4991b3849dd5c17a631223896272c6b0af446778ba4675a1dff53bb7e"}, + "certifi": {:hex, :certifi, "2.5.1", "867ce347f7c7d78563450a18a6a28a8090331e77fa02380b4a21962a65d36ee5", [:rebar3], [{:parse_trans, "~>3.3", [hex: :parse_trans, repo: "hexpm", optional: false]}], "hexpm", "805abd97539caf89ec6d4732c91e62ba9da0cda51ac462380bbd28ee697a8c42"}, "credo": {:hex, :credo, "0.8.10", "261862bb7363247762e1063713bb85df2bbd84af8d8610d1272cd9c1943bba63", [:mix], [{:bunt, "~> 0.2.0", [hex: :bunt, repo: "hexpm", optional: false]}], "hexpm", "f3fe29f8de6be431c7736a933a3897fe9aa45533b1d1358b3691ac8ec4371e8f"}, - "earmark": {:hex, :earmark, "1.4.15", "2c7f924bf495ec1f65bd144b355d0949a05a254d0ec561740308a54946a67888", [:mix], [{:earmark_parser, ">= 1.4.13", [hex: :earmark_parser, repo: "hexpm", optional: false]}], "hexpm", "3b1209b85bc9f3586f370f7c363f6533788fb4e51db23aa79565875e7f9999ee"}, + "earmark": {:hex, :earmark, "1.3.1", "73812f447f7a42358d3ba79283cfa3075a7580a3a2ed457616d6517ac3738cb9", [:mix], [], "hexpm", "000aaeff08919e95e7aea13e4af7b2b9734577b3e6a7c50ee31ee88cab6ec4fb"}, "earmark_parser": {:hex, :earmark_parser, "1.4.13", "0c98163e7d04a15feb62000e1a891489feb29f3d10cb57d4f845c405852bbef8", [:mix], [], "hexpm", "d602c26af3a0af43d2f2645613f65841657ad6efc9f0e361c3b6c06b578214ba"}, "ex_doc": {:hex, :ex_doc, "0.24.2", "e4c26603830c1a2286dae45f4412a4d1980e1e89dc779fcd0181ed1d5a05c8d9", [: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", "e134e1d9e821b8d9e4244687fb2ace58d479b67b282de5158333b0d57c6fb7da"}, - "hackney": {:hex, :hackney, "1.17.4", "99da4674592504d3fb0cfef0db84c3ba02b4508bae2dff8c0108baa0d6e0977c", [:rebar3], [{:certifi, "~>2.6.1", [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", "de16ff4996556c8548d512f4dbe22dd58a587bf3332e7fd362430a7ef3986b16"}, - "idna": {:hex, :idna, "6.1.1", "8a63070e9f7d0c62eb9d9fcb360a7de382448200fbbd1b106cc96d3d8099df8d", [:rebar3], [{:unicode_util_compat, "~>0.7.0", [hex: :unicode_util_compat, repo: "hexpm", optional: false]}], "hexpm", "92376eb7894412ed19ac475e4a86f7b413c1b9fbb5bd16dccd57934157944cea"}, + "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"}, "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"}, "metrics": {:hex, :metrics, "1.0.1", "25f094dea2cda98213cecc3aeff09e940299d950904393b2a29d191c346a8486", [:rebar3], [], "hexpm", "69b09adddc4f74a40716ae54d140f93beb0fb8978d8636eaded0c31b6f099f16"}, - "mime": {:hex, :mime, "1.6.0", "dabde576a497cef4bbdd60aceee8160e02a6c89250d6c0b29e56c0dfb00db3d2", [:mix], [], "hexpm", "31a1a8613f8321143dde1dafc36006a17d28d02bdfecb9e95a880fa7aabd19a7"}, + "mime": {:hex, :mime, "1.3.1", "30ce04ab3175b6ad0bdce0035cba77bba68b813d523d1aac73d9781b4d193cf8", [:mix], [], "hexpm", "6cbe761d6a0ca5a31a0931bf4c63204bceb64538e664a8ecf784a9a6f3b875f1"}, "mimerl": {:hex, :mimerl, "1.2.0", "67e2d3f571088d5cfd3e550c383094b47159f3eee8ffa08e64106cdf5e981be3", [:rebar3], [], "hexpm", "f278585650aa581986264638ebf698f8bb19df297f66ad91b18910dfc6e19323"}, "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.1", "16328ab840cc09919bd10dab29e431da3af9e9e7e7e6f0089dd5a2d2820011d8", [:rebar3], [], "hexpm", "07cd9577885f56362d414e8c4c4e6bdf10d43a8767abb92d24cbe8b24c54888b"}, - "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.6", "cf344f5692c82d2cd7554f5ec8fd961548d4fd09e7d22f5b62482e5aeaebd4b0", [:make, :mix, :rebar3], [], "hexpm", "bdb0d2471f453c88ff3908e7686f86f9be327d065cc1ec16fa4540197ea04680"}, - "telemetry": {:hex, :telemetry, "0.4.3", "a06428a514bdbc63293cd9a6263aad00ddeb66f608163bdec7c8995784080818", [:rebar3], [], "hexpm", "eb72b8365ffda5bed68a620d1da88525e326cb82a75ee61354fc24b844768041"}, - "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.7.0", "bc84380c9ab48177092f43ac89e4dfa2c6d62b40b8bd132b1059ecc7232f9a78", [:rebar3], [], "hexpm", "25eee6d67df61960cf6a794239566599b09e17e668d3700247bc498638152521"}, + "oauth2": {:hex, :oauth2, "1.0.1", "2a116de7863d4b5a8a265d77e62b17a6f54e0c01a5bbbf02210783cb861e49ac", [:mix], [{:hackney, "~> 1.13", [hex: :hackney, repo: "hexpm", optional: false]}], "hexpm", "0417bd37101ac27cdfe33003266c15da31cf9d59f1778994624a77febd0d8e07"}, + "parse_trans": {:hex, :parse_trans, "3.3.0", "09765507a3c7590a784615cfd421d101aec25098d50b89d7aa1d66646bc571c1", [:rebar3], [], "hexpm", "17ef63abde837ad30680ea7f857dd9e7ced9476cdd7b0394432af4bfc241b960"}, + "plug": {:hex, :plug, "1.8.3", "12d5f9796dc72e8ac9614e94bda5e51c4c028d0d428e9297650d09e15a684478", [: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", "164baaeb382d19beee0ec484492aa82a9c8685770aee33b24ec727a0971b34d0"}, + "plug_crypto": {:hex, :plug_crypto, "1.0.0", "18e49317d3fa343f24620ed22795ec29d4a5e602d52d1513ccea0b07d8ea7d4d", [:mix], [], "hexpm", "73c1682f0e414cfb5d9b95c8e8cd6ffcfdae699e3b05e1db744e58b7be857759"}, + "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"}, } From ff5fd6624188536d09c78118edf26307a2ba542e Mon Sep 17 00:00:00 2001 From: Yordis Prieto Lazo Date: Thu, 15 Jul 2021 03:54:23 -0400 Subject: [PATCH 22/28] Update version --- CHANGELOG.md | 2 ++ mix.exs | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e8b4e8e..c66228e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## v0.8.2 - 2021-07-15 + * Allow OAuth options to be configured from the connection * Set default profile image to large diff --git a/mix.exs b/mix.exs index 5298d3c..6dcd3c9 100644 --- a/mix.exs +++ b/mix.exs @@ -2,7 +2,7 @@ defmodule Ueberauth.Facebook.Mixfile do use Mix.Project @source_url "https://github.com/ueberauth/ueberauth_facebook" - @version "0.8.1" + @version "0.8.2" def project do [ From 53223240ec1545e2b2d9d49485f055a7884a8ac4 Mon Sep 17 00:00:00 2001 From: Arjan Scherpenisse Date: Fri, 1 Oct 2021 10:21:31 +0200 Subject: [PATCH 23/28] Require Ueberauth 0.7 and implement its CSRF protection --- CHANGELOG.md | 2 ++ README.md | 36 +++++++++++++----------------- lib/ueberauth/strategy/facebook.ex | 8 +++---- mix.exs | 2 +- mix.lock | 9 ++++---- 5 files changed, 26 insertions(+), 31 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c66228e..ff5d753 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +* Require at least Ueberauth 0.7 due to changed builtin CSRF protection + ## v0.8.2 - 2021-07-15 * Allow OAuth options to be configured from the connection diff --git a/README.md b/README.md index 881cc29..81db272 100644 --- a/README.md +++ b/README.md @@ -15,23 +15,23 @@ 1. Add `:ueberauth_facebook` to your list of dependencies in `mix.exs`: - ```elixir - def deps do - [ - {:ueberauth_facebook, "~> 0.8"} - ] - end - ``` + ```elixir + def deps do + [ + {:ueberauth_facebook, "~> 0.8"} + ] + end + ``` 1. Add the strategy to your applications: - ```elixir - def application do - [ - applications: [:ueberauth_facebook] - ] - end - ``` + ```elixir + def application do + [ + applications: [:ueberauth_facebook] + ] + end + ``` 1. Add Facebook to your Überauth configuration: @@ -81,7 +81,7 @@ Depending on the configured URL you can initialize the request through: /auth/facebook -Or with options (`state`, `auth_type`, `scope`, `locale`, `display`): +Or with options (`auth_type`, `scope`, `locale`, `display`): /auth/facebook?scope=email,public_profile @@ -120,12 +120,6 @@ config :ueberauth, Ueberauth, See [Graph API Reference > User](https://developers.facebook.com/docs/graph-api/reference/user) for full list of fields. -### Passing dynamic state - -A [state](https://developers.facebook.com/docs/facebook-login/security/#stateparam) parameter can be [passed with a call](https://developers.facebook.com/docs/facebook-login/manually-build-a-login-flow#login) and is returned in the redirect URI as a URL parameter. - - /auth/facebook?scope=email,public_profile&state={"id":1,"field":"value"} - ## Copyright and License Copyright (c) 2015 Sean Callan diff --git a/lib/ueberauth/strategy/facebook.ex b/lib/ueberauth/strategy/facebook.ex index 6b89449..462a5ad 100644 --- a/lib/ueberauth/strategy/facebook.ex +++ b/lib/ueberauth/strategy/facebook.ex @@ -11,7 +11,6 @@ defmodule Ueberauth.Strategy.Facebook do :auth_type, :scope, :locale, - :state, :display ] @@ -30,18 +29,17 @@ defmodule Ueberauth.Strategy.Facebook do opts = oauth_client_options_from_conn(conn) - authorize_url = + params = conn.params |> maybe_replace_param(conn, "auth_type", :auth_type) |> maybe_replace_param(conn, "scope", :default_scope) - |> maybe_replace_param(conn, "state", :state) |> maybe_replace_param(conn, "display", :display) |> Enum.filter(fn {k, _v} -> Enum.member?(allowed_params, k) end) |> Enum.map(fn {k, v} -> {String.to_existing_atom(k), v} end) |> Keyword.put(:redirect_uri, callback_url(conn)) - |> Ueberauth.Strategy.Facebook.OAuth.authorize_url!(opts) + |> with_state_param(conn) - redirect!(conn, authorize_url) + redirect!(conn, Ueberauth.Strategy.Facebook.OAuth.authorize_url!(params, opts)) end @doc """ diff --git a/mix.exs b/mix.exs index 6dcd3c9..54b95a2 100644 --- a/mix.exs +++ b/mix.exs @@ -26,7 +26,7 @@ defmodule Ueberauth.Facebook.Mixfile do defp deps do [ - {:ueberauth, "~> 0.6.0"}, + {:ueberauth, "~> 0.7"}, {:oauth2, "~> 1.0 or ~> 2.0"}, {:credo, "~> 0.8.10", only: [:dev, :test]}, {:ex_doc, ">= 0.24.2", only: :dev, runtime: false} diff --git a/mix.lock b/mix.lock index ecc8e2f..d4f9c17 100644 --- a/mix.lock +++ b/mix.lock @@ -11,14 +11,15 @@ "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"}, "metrics": {:hex, :metrics, "1.0.1", "25f094dea2cda98213cecc3aeff09e940299d950904393b2a29d191c346a8486", [:rebar3], [], "hexpm", "69b09adddc4f74a40716ae54d140f93beb0fb8978d8636eaded0c31b6f099f16"}, - "mime": {:hex, :mime, "1.3.1", "30ce04ab3175b6ad0bdce0035cba77bba68b813d523d1aac73d9781b4d193cf8", [:mix], [], "hexpm", "6cbe761d6a0ca5a31a0931bf4c63204bceb64538e664a8ecf784a9a6f3b875f1"}, + "mime": {:hex, :mime, "2.0.1", "0de4c81303fe07806ebc2494d5321ce8fb4df106e34dd5f9d787b637ebadc256", [:mix], [], "hexpm", "7a86b920d2aedce5fb6280ac8261ac1a739ae6c1a1ad38f5eadf910063008942"}, "mimerl": {:hex, :mimerl, "1.2.0", "67e2d3f571088d5cfd3e550c383094b47159f3eee8ffa08e64106cdf5e981be3", [:rebar3], [], "hexpm", "f278585650aa581986264638ebf698f8bb19df297f66ad91b18910dfc6e19323"}, "nimble_parsec": {:hex, :nimble_parsec, "1.1.0", "3a6fca1550363552e54c216debb6a9e95bd8d32348938e13de5eda962c0d7f89", [:mix], [], "hexpm", "08eb32d66b706e913ff748f11694b17981c0b04a33ef470e33e11b3d3ac8f54b"}, "oauth2": {:hex, :oauth2, "1.0.1", "2a116de7863d4b5a8a265d77e62b17a6f54e0c01a5bbbf02210783cb861e49ac", [:mix], [{:hackney, "~> 1.13", [hex: :hackney, repo: "hexpm", optional: false]}], "hexpm", "0417bd37101ac27cdfe33003266c15da31cf9d59f1778994624a77febd0d8e07"}, "parse_trans": {:hex, :parse_trans, "3.3.0", "09765507a3c7590a784615cfd421d101aec25098d50b89d7aa1d66646bc571c1", [:rebar3], [], "hexpm", "17ef63abde837ad30680ea7f857dd9e7ced9476cdd7b0394432af4bfc241b960"}, - "plug": {:hex, :plug, "1.8.3", "12d5f9796dc72e8ac9614e94bda5e51c4c028d0d428e9297650d09e15a684478", [: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", "164baaeb382d19beee0ec484492aa82a9c8685770aee33b24ec727a0971b34d0"}, - "plug_crypto": {:hex, :plug_crypto, "1.0.0", "18e49317d3fa343f24620ed22795ec29d4a5e602d52d1513ccea0b07d8ea7d4d", [:mix], [], "hexpm", "73c1682f0e414cfb5d9b95c8e8cd6ffcfdae699e3b05e1db744e58b7be857759"}, + "plug": {:hex, :plug, "1.12.1", "645678c800601d8d9f27ad1aebba1fdb9ce5b2623ddb961a074da0b96c35187d", [: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", "d57e799a777bc20494b784966dc5fbda91eb4a09f571f76545b72a634ce0d30b"}, + "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.1", "9e90d3337dddf38b1ca2753aca9b1e53d8a52b890191cdc55240247c89230412", [:mix], [{:plug, "~> 1.5", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm", "81ea8303ef676a7b8e6e308584e9b9232d2b6fb02110d00dba351edd823a7d96"}, + "telemetry": {:hex, :telemetry, "1.0.0", "0f453a102cdf13d506b7c0ab158324c337c41f1cc7548f0bc0e130bbf0ae9452", [:rebar3], [], "hexpm", "73bc09fa59b4a0284efb4624335583c528e07ec9ae76aca96ea0673850aec57a"}, + "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"}, } From d654575bc7de31c4b3bae2162657103a25bcc9c4 Mon Sep 17 00:00:00 2001 From: Yordis Prieto Lazo Date: Sat, 2 Oct 2021 16:40:19 -0400 Subject: [PATCH 24/28] chore: versioning and adding github actions --- .github/CODEOWNERS | 3 +++ .github/workflows/ci.yml | 49 +++++++++++++++++++++++++++++++++++ .github/workflows/release.yml | 32 +++++++++++++++++++++++ CHANGELOG.md | 2 ++ mix.exs | 2 +- 5 files changed, 87 insertions(+), 1 deletion(-) 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..ebc332e --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,49 @@ +name: Continuous Integration + +on: + pull_request: + types: [opened, reopened, synchronize] + push: + branches: + - 'master' +jobs: + Test: + runs-on: ubuntu-latest + + container: + image: elixir:1.9-alpine + + steps: + - name: Checkout Code + uses: actions/checkout@v1 + + - 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 + + container: + image: elixir:1.9-alpine + + steps: + - name: Checkout Code + uses: actions/checkout@v1 + + - 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..6e6e038 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,32 @@ +name: 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 }} diff --git a/CHANGELOG.md b/CHANGELOG.md index ff5d753..1c174ad 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## v0.9.0 - 2021-09-23 + * Require at least Ueberauth 0.7 due to changed builtin CSRF protection ## v0.8.2 - 2021-07-15 diff --git a/mix.exs b/mix.exs index 54b95a2..dc6616d 100644 --- a/mix.exs +++ b/mix.exs @@ -2,7 +2,7 @@ defmodule Ueberauth.Facebook.Mixfile do use Mix.Project @source_url "https://github.com/ueberauth/ueberauth_facebook" - @version "0.8.2" + @version "0.9.0" def project do [ From 3d5dab23cc85e5c1fdbe6626f8bb5364b564946c Mon Sep 17 00:00:00 2001 From: Yordis Prieto Lazo Date: Sat, 2 Oct 2021 16:46:56 -0400 Subject: [PATCH 25/28] chore: fix credo --- lib/ueberauth/strategy/facebook/oauth.ex | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/ueberauth/strategy/facebook/oauth.ex b/lib/ueberauth/strategy/facebook/oauth.ex index bf9c05c..f914414 100644 --- a/lib/ueberauth/strategy/facebook/oauth.ex +++ b/lib/ueberauth/strategy/facebook/oauth.ex @@ -36,7 +36,8 @@ defmodule Ueberauth.Strategy.Facebook.OAuth do json_library = Ueberauth.json_library() - OAuth2.Client.new(opts) + opts + |> OAuth2.Client.new() |> OAuth2.Client.put_serializer("application/json", json_library) end From ccacb4bbd54f3abecdef4eff87fd3dccb2c70c4f Mon Sep 17 00:00:00 2001 From: Yordis Prieto Lazo Date: Sat, 2 Oct 2021 16:48:53 -0400 Subject: [PATCH 26/28] chore: fix ci --- .github/workflows/ci.yml | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ebc332e..d57516b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,39 +9,41 @@ on: jobs: Test: runs-on: ubuntu-latest - - container: - image: elixir:1.9-alpine - 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 - - container: - image: elixir:1.9-alpine - 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 From fb44fb61322019a5a24020b276e773d5711e5e51 Mon Sep 17 00:00:00 2001 From: Yordis Prieto Lazo Date: Sun, 17 Oct 2021 14:12:46 -0400 Subject: [PATCH 27/28] chore: fix name --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 6e6e038..61d5739 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,4 +1,4 @@ -name: Release +name: Hexpm Release on: release: From 1b21547941f7528be53bdfea9b660d0cb31c24ad Mon Sep 17 00:00:00 2001 From: Mrinal Saurabh Date: Fri, 22 Apr 2022 13:58:05 +0530 Subject: [PATCH 28/28] Logging in detail Different people are facing different issue but we are not able to identify the issue since the error from the client (facebook) is not being thrown back to the user. This change will provide correct message from the client. --- CHANGELOG.md | 4 ++++ lib/ueberauth/strategy/facebook.ex | 3 +-- mix.exs | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1c174ad..40dc272 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## v0.10.0 - 2021-09-23 + +* Allows errors from the provider to be thrown back to the user. + ## v0.9.0 - 2021-09-23 * Require at least Ueberauth 0.7 due to changed builtin CSRF protection diff --git a/lib/ueberauth/strategy/facebook.ex b/lib/ueberauth/strategy/facebook.ex index 462a5ad..f708bfe 100644 --- a/lib/ueberauth/strategy/facebook.ex +++ b/lib/ueberauth/strategy/facebook.ex @@ -65,8 +65,7 @@ defmodule Ueberauth.Strategy.Facebook do fetch_user(conn, client, config) end rescue - OAuth2.Error -> - set_errors!(conn, [error("invalid_code", "The code has been used or has expired")]) + e -> set_errors!(conn, [error("get_token_error", e)]) end end diff --git a/mix.exs b/mix.exs index dc6616d..5c66bdd 100644 --- a/mix.exs +++ b/mix.exs @@ -2,7 +2,7 @@ defmodule Ueberauth.Facebook.Mixfile do use Mix.Project @source_url "https://github.com/ueberauth/ueberauth_facebook" - @version "0.9.0" + @version "0.10.0" def project do [