From b74053d848f724517348699e8cf8604a1ed993ca Mon Sep 17 00:00:00 2001 From: Duy Trinh Duc Date: Thu, 12 Jul 2018 15:17:58 +0700 Subject: [PATCH 1/4] Upgrade omniauth-oauth2 --- omniauth-kakao.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/omniauth-kakao.gemspec b/omniauth-kakao.gemspec index c0d6b1f..10f4fd9 100644 --- a/omniauth-kakao.gemspec +++ b/omniauth-kakao.gemspec @@ -21,7 +21,7 @@ Gem::Specification.new do |s| s.require_paths = ["lib"] s.add_dependency 'omniauth', '~> 1.0' - s.add_dependency 'omniauth-oauth2', '~> 1.3.1' + s.add_dependency 'omniauth-oauth2', '~> 1.5.0' s.add_development_dependency 'rspec', '~> 2.14', '>= 2.14.1' s.add_development_dependency 'guard-rspec', '~> 4.2', '>= 4.2.8' From e90ce30bb9bb4f764aafb0dd80d2512622201d56 Mon Sep 17 00:00:00 2001 From: Duy Trinh Duc Date: Mon, 16 Jul 2018 16:23:42 +0700 Subject: [PATCH 2/4] Fix redirect_uri mismatch issue --- Gemfile.lock | 30 +++++++++++++++--------------- lib/omniauth/strategies/kakao.rb | 12 ++---------- 2 files changed, 17 insertions(+), 25 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 84e5516..d4a791e 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -3,7 +3,7 @@ PATH specs: omniauth-kakao (0.2.0) omniauth (~> 1.0) - omniauth-oauth2 (~> 1.3.1) + omniauth-oauth2 (~> 1.5.0) GEM remote: http://rubygems.org/ @@ -11,7 +11,7 @@ GEM coderay (1.1.1) diff-lcs (1.2.5) fakeweb (1.3.0) - faraday (0.9.2) + faraday (0.12.2) multipart-post (>= 1.2, < 3) ffi (1.9.14) formatador (0.2.5) @@ -29,38 +29,38 @@ GEM guard (~> 2.1) guard-compat (~> 1.1) rspec (>= 2.99.0, < 4.0) - hashie (3.4.4) - jwt (1.5.4) + hashie (3.5.7) + jwt (1.5.6) listen (3.1.5) rb-fsevent (~> 0.9, >= 0.9.4) rb-inotify (~> 0.9, >= 0.9.7) ruby_dep (~> 1.2) lumberjack (1.0.10) method_source (0.8.2) - multi_json (1.12.1) - multi_xml (0.5.5) + multi_json (1.13.1) + multi_xml (0.6.0) multipart-post (2.0.0) nenv (0.3.0) notiffany (0.1.1) nenv (~> 0.1) shellany (~> 0.0) - oauth2 (1.2.0) - faraday (>= 0.8, < 0.10) + oauth2 (1.4.0) + faraday (>= 0.8, < 0.13) jwt (~> 1.0) multi_json (~> 1.3) multi_xml (~> 0.5) rack (>= 1.2, < 3) - omniauth (1.3.1) - hashie (>= 1.2, < 4) - rack (>= 1.0, < 3) - omniauth-oauth2 (1.3.1) - oauth2 (~> 1.0) + omniauth (1.8.1) + hashie (>= 3.4.6, < 3.6.0) + rack (>= 1.6.2, < 3) + omniauth-oauth2 (1.5.0) + oauth2 (~> 1.1) omniauth (~> 1.2) pry (0.10.4) coderay (~> 1.1.0) method_source (~> 0.8.1) slop (~> 3.4) - rack (2.0.1) + rack (2.0.5) rb-fsevent (0.9.7) rb-inotify (0.9.7) ffi (>= 0.5.0) @@ -87,4 +87,4 @@ DEPENDENCIES rspec (~> 2.14, >= 2.14.1) BUNDLED WITH - 1.12.3 + 1.12.5 diff --git a/lib/omniauth/strategies/kakao.rb b/lib/omniauth/strategies/kakao.rb index c0cbf04..228f7ed 100644 --- a/lib/omniauth/strategies/kakao.rb +++ b/lib/omniauth/strategies/kakao.rb @@ -31,16 +31,8 @@ def initialize(app, *args, &block) options[:callback_path] = options[:redirect_path] || DEFAULT_REDIRECT_PATH end - def callback_phase - previous_callback_path = options.delete(:callback_path) - @env["PATH_INFO"] = "/auth/kakao/callback" - options[:callback_path] = previous_callback_path - super - end - - def mock_call!(*) - options.delete(:callback_path) - super + def callback_url + options[:callback_url] || (full_host + script_name + callback_path) end private From b11665992fde5c5538e3d0517a23b31f26a8197d Mon Sep 17 00:00:00 2001 From: Duy Trinh Duc Date: Tue, 17 Jul 2018 13:46:18 +0700 Subject: [PATCH 3/4] Update spec --- spec/omniauth/strategies/kakao_spec.rb | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/spec/omniauth/strategies/kakao_spec.rb b/spec/omniauth/strategies/kakao_spec.rb index 5eb0b21..36b2ee6 100644 --- a/spec/omniauth/strategies/kakao_spec.rb +++ b/spec/omniauth/strategies/kakao_spec.rb @@ -154,19 +154,6 @@ def make_request(url, opts={}) }) end - describe "GET /auth/kakao" do - it "should redirect to callback url (/auth/kakao/callback)" do - request = make_request("/auth/kakao") - middleware = make_middleware(CLIENT_ID) - code, env = middleware.call(request) - - code.should == 302 - - actual_path = URI(env["Location"]).path - actual_path.should == "/auth/kakao/callback" - end - end - describe "GET /oauth" do it "should request registered mock" do request = make_request("/oauth") From 3a05b91d682490ff96220565eb34129f088dec3d Mon Sep 17 00:00:00 2001 From: Duy Trinh Duc Date: Fri, 20 Jul 2018 14:21:44 +0700 Subject: [PATCH 4/4] Add email to info --- lib/omniauth/strategies/kakao.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/omniauth/strategies/kakao.rb b/lib/omniauth/strategies/kakao.rb index 228f7ed..0597ec8 100644 --- a/lib/omniauth/strategies/kakao.rb +++ b/lib/omniauth/strategies/kakao.rb @@ -19,6 +19,7 @@ class Kakao < OmniAuth::Strategies::OAuth2 { 'name' => raw_properties['nickname'], 'image' => raw_properties['thumbnail_image'], + 'email' => raw_info['kaccount_email'], } end