omniauth-kakao 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bb5a75b470abb1ff60e97711d9d7d092ea9090b6
4
- data.tar.gz: f81819bcad8d02a12042af027c9c8ea2ed5bb854
3
+ metadata.gz: d408aa8b09df76d9027300b309cc1d72fe2d7099
4
+ data.tar.gz: df858be392f2b9910f478073da3965e004be0a4d
5
5
  SHA512:
6
- metadata.gz: d4bafbc60cbbb7b280a1050326ba73c7b4bec0cbfc9e2783403c78c095454806783f85acf54a99a1c490053afec8733b2bca0ffa710195ea564549f87009d6c6
7
- data.tar.gz: 10ef7e0e3bcc4e050aaff082506451d447848e152502722a8ae5092ae369da81eed28d9517ba154d30f028e4db09150290f1d1a7c5a06c741f99a0e4c440a669
6
+ metadata.gz: afa6411ff7e30b91d58f43d20993062fbf15d94b657968127f212cd4378266e899d237fa83909a852a912333086cddb3a15c2b0b0afdd334229a54871fcc0ee1
7
+ data.tar.gz: f46f477f9de2d92ff48090b7c17b6c23a67ffceca63d68174f1e23498cfcde6baa6a5f3ffd05fc51a28d48d12d0727f607d2ca749f1322b43006d36f47758a11
data/.gitignore ADDED
@@ -0,0 +1 @@
1
+ *.gem
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format progress
data/CHANGELOG CHANGED
@@ -1,3 +1,7 @@
1
+ ## v0.0.2
2
+
3
+ * 개발 완료
4
+
1
5
  ## v0.0.1
2
6
 
3
7
  * 릴리즈 준비
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'http://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in omniauth-github.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,87 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ omniauth-kakao (0.0.1)
5
+ omniauth (~> 1.0)
6
+ omniauth-oauth2 (~> 1.1)
7
+
8
+ GEM
9
+ remote: http://rubygems.org/
10
+ specs:
11
+ celluloid (0.15.2)
12
+ timers (~> 1.1.0)
13
+ celluloid-io (0.15.0)
14
+ celluloid (>= 0.15.0)
15
+ nio4r (>= 0.5.0)
16
+ coderay (1.1.0)
17
+ diff-lcs (1.2.5)
18
+ fakeweb (1.3.0)
19
+ faraday (0.9.0)
20
+ multipart-post (>= 1.2, < 3)
21
+ ffi (1.9.3)
22
+ formatador (0.2.4)
23
+ guard (2.6.0)
24
+ formatador (>= 0.2.4)
25
+ listen (~> 2.7)
26
+ lumberjack (~> 1.0)
27
+ pry (>= 0.9.12)
28
+ thor (>= 0.18.1)
29
+ guard-rspec (4.2.8)
30
+ guard (~> 2.1)
31
+ rspec (>= 2.14, < 4.0)
32
+ hashie (2.1.1)
33
+ jwt (0.1.11)
34
+ multi_json (>= 1.5)
35
+ listen (2.7.4)
36
+ celluloid (>= 0.15.2)
37
+ celluloid-io (>= 0.15.0)
38
+ rb-fsevent (>= 0.9.3)
39
+ rb-inotify (>= 0.9)
40
+ lumberjack (1.0.5)
41
+ method_source (0.8.2)
42
+ multi_json (1.9.3)
43
+ multi_xml (0.5.5)
44
+ multipart-post (2.0.0)
45
+ nio4r (1.0.0)
46
+ oauth2 (0.9.3)
47
+ faraday (>= 0.8, < 0.10)
48
+ jwt (~> 0.1.8)
49
+ multi_json (~> 1.3)
50
+ multi_xml (~> 0.5)
51
+ rack (~> 1.2)
52
+ omniauth (1.2.1)
53
+ hashie (>= 1.2, < 3)
54
+ rack (~> 1.0)
55
+ omniauth-oauth2 (1.1.2)
56
+ faraday (>= 0.8, < 0.10)
57
+ multi_json (~> 1.3)
58
+ oauth2 (~> 0.9.3)
59
+ omniauth (~> 1.2)
60
+ pry (0.9.12.6)
61
+ coderay (~> 1.0)
62
+ method_source (~> 0.8)
63
+ slop (~> 3.4)
64
+ rack (1.5.2)
65
+ rb-fsevent (0.9.4)
66
+ rb-inotify (0.9.4)
67
+ ffi (>= 0.5.0)
68
+ rspec (2.14.1)
69
+ rspec-core (~> 2.14.0)
70
+ rspec-expectations (~> 2.14.0)
71
+ rspec-mocks (~> 2.14.0)
72
+ rspec-core (2.14.8)
73
+ rspec-expectations (2.14.5)
74
+ diff-lcs (>= 1.1.3, < 2.0)
75
+ rspec-mocks (2.14.6)
76
+ slop (3.5.0)
77
+ thor (0.19.1)
78
+ timers (1.1.0)
79
+
80
+ PLATFORMS
81
+ ruby
82
+
83
+ DEPENDENCIES
84
+ fakeweb (~> 1.3.0)
85
+ guard-rspec (~> 4.2.8)
86
+ omniauth-kakao!
87
+ rspec (~> 2.14.1)
data/Guardfile ADDED
@@ -0,0 +1,8 @@
1
+ # A sample Guardfile
2
+ # More info at https://github.com/guard/guard#readme
3
+
4
+ guard :rspec, :cmd => "bundle exec rspec spec" do
5
+ watch(%r{^spec/.+_spec\.rb$})
6
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
7
+ watch('spec/spec_helper.rb') { "spec" }
8
+ end
data/README.md CHANGED
@@ -1,4 +1,74 @@
1
- omniauth-kakao
2
- ==============
1
+ # OmniAuth Kakao
3
2
 
4
- OmniAuth strategy for Kakao(under construction)
3
+ This is the OmniAuth strategy for authenticating to [Kakao](http://www.kakao.com/). To
4
+ use it, you'll need to sign up for an REST API Key on the [Kakao Developers Page](http://developers.kakao.com). For more information, please refer to [Create New Application](https://developers.kakao.com/docs/restapi#시작하기-앱-생성) page.
5
+
6
+ [카카오](http://www.kakao.com/) 인증을 위한 OmniAuth strategy 입니다.
7
+ [카카오 개발자 페이지](http://developers.kakao.com) 에서 REST API 키를 생성한 뒤 이용할 수 있습니다. 자세한 사항은 [앱 생성](https://developers.kakao.com/docs/restapi#시작하기-앱-생성) 페이지를 참조해 주세요.
8
+
9
+ ## Installing
10
+
11
+ Add to your `Gemfile`:
12
+
13
+ ```ruby
14
+ gem 'omniauth-kakao'
15
+ ```
16
+
17
+ Then `bundle install`.
18
+
19
+ ## Usage
20
+
21
+ Here's a quick example, adding the middleware to a Rails app in `config/initializers/omniauth.rb`:
22
+
23
+ ```ruby
24
+ Rails.application.config.middleware.use OmniAuth::Builder do
25
+ provider :kakao, ENV['KAKAO_CLIENT_ID']
26
+ end
27
+ ```
28
+
29
+ For more information, please read the [OmniAuth](https://github.com/intridea/omniauth) docs for detailed instructions.
30
+
31
+ ## Auth Hash
32
+
33
+ Here's an example *Auth Hash* available in `request.env['omniauth.auth']`:
34
+
35
+ ```ruby
36
+ {
37
+ :provider => 'kakao',
38
+ :uid => '123456789',
39
+ :info => {
40
+ :name => 'Hong Gil-Dong',
41
+ :image => 'http://xxx.kakao.com/.../aaa.jpg',
42
+ },
43
+ :credentials => {
44
+ :token => 'ABCDEF...', # OAuth 2.0 access_token, which you may wish to store.
45
+ :refresh_token => 'OPQRST...', # OAuth 2.0 refresh_token.
46
+ :expires_at => 1321747205, # when the access token expires (it always will)
47
+ :expires => true # this will always be true
48
+ },
49
+ :extra => {
50
+ :properties => {
51
+ :nickname => 'Hong Gil-Dong',
52
+ :thumbnail_image => 'http://xxx.kakao.com/.../aaa.jpg'
53
+ :profile_image => 'http://xxx.kakao.com/.../bbb.jpg'
54
+ }
55
+ }
56
+ }
57
+ ```
58
+
59
+ ## Contribute
60
+
61
+ 1. Fork the repository.
62
+ 1. Create a new branch for each feature or improvement.
63
+ 1. Add tests for it. This is important!
64
+ 1. Send a pull request from each feature branch.
65
+
66
+ ## License
67
+
68
+ Copyright (c) 2014 [Shayne Sung-Hee Kang](http://medium.com/@shaynekang).
69
+
70
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
71
+
72
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
73
+
74
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,2 @@
1
+ require "omniauth-kakao/version"
2
+ require 'omniauth/strategies/kakao'
@@ -1,5 +1,5 @@
1
1
  module Omniauth
2
2
  module Kakao
3
- VERSION = "0.0.1"
3
+ VERSION = "0.0.2"
4
4
  end
5
5
  end
@@ -0,0 +1,49 @@
1
+ require 'omniauth-oauth2'
2
+
3
+ module OmniAuth
4
+ module Strategies
5
+ class Kakao < OmniAuth::Strategies::OAuth2
6
+ option :name, 'kakao'
7
+
8
+ option :client_options, {
9
+ :site => 'https://kauth.kakao.com',
10
+ :authorize_path => '/oauth/authorize',
11
+ :token_url => '/oauth/token',
12
+ }
13
+
14
+ uid { raw_info['id'].to_s }
15
+
16
+ info do
17
+ {
18
+ 'name' => raw_properties['nickname'],
19
+ 'image' => raw_properties['thumbnail_image'],
20
+ }
21
+ end
22
+
23
+ extra do
24
+ {'properties' => raw_properties}
25
+ end
26
+
27
+ def initialize(app, *args, &block)
28
+ super
29
+ options[:callback_path] = "/oauth"
30
+ end
31
+
32
+ def callback_phase
33
+ @env["PATH_INFO"] = "/auth/kakao/callback"
34
+ super
35
+ end
36
+
37
+ private
38
+ def raw_info
39
+ @raw_info ||= access_token.get('https://kapi.kakao.com/v1/user/me', {}).parsed || {}
40
+ end
41
+
42
+ def raw_properties
43
+ @raw_properties ||= raw_info['properties']
44
+ end
45
+ end
46
+ end
47
+ end
48
+
49
+ OmniAuth.config.add_camelization 'kakao', 'Kakao'
@@ -0,0 +1,29 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "omniauth-kakao/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "omniauth-kakao"
7
+ s.version = Omniauth::Kakao::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ["Shayne Sung-Hee Kang"]
10
+ s.email = ["shayne.kang@gmail.com"]
11
+ s.homepage = "http://medium.com/@shaynekang"
12
+ s.summary = %q{OmniAuth strategy for Kakao}
13
+ s.description = %q{OmniAuth strategy for Kakao(http://developers.kakao.com/)}
14
+ s.license = "MIT"
15
+
16
+ s.rubyforge_project = "omniauth-kakao"
17
+
18
+ s.files = `git ls-files`.split("\n")
19
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
20
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
21
+ s.require_paths = ["lib"]
22
+
23
+ s.add_dependency 'omniauth', '~> 1.0'
24
+ s.add_dependency 'omniauth-oauth2', '~> 1.1'
25
+
26
+ s.add_development_dependency 'rspec', '~> 2.14.1'
27
+ s.add_development_dependency 'guard-rspec', '~> 4.2.8'
28
+ s.add_development_dependency 'fakeweb', '~> 1.3.0'
29
+ end
@@ -0,0 +1,116 @@
1
+ require 'spec_helper'
2
+ require 'omniauth'
3
+ require 'omniauth-kakao'
4
+
5
+ describe OmniAuth::Strategies::Kakao do
6
+ CLIENT_ID = '<<your-client-id>>'
7
+ SERVER_NAME = 'www.example.com'
8
+
9
+ before do
10
+ OmniAuth.config.logger.level = 5
11
+ end
12
+
13
+ let(:middleware) do
14
+ app = ->(env) { [200, env, "app"] }
15
+
16
+ middleware = OmniAuth::Strategies::Kakao.new(app)
17
+ middleware.tap do |middleware|
18
+ middleware.options.client_id = CLIENT_ID
19
+ end
20
+ end
21
+
22
+ def generate_request(url, opts={})
23
+ Rack::MockRequest.env_for(url, {
24
+ 'rack.session' => {},
25
+ 'SERVER_NAME' => SERVER_NAME,
26
+ }.merge(opts))
27
+ end
28
+
29
+ describe "GET /auth/kakao" do
30
+ it "should redirect to authorize page" do
31
+ request = generate_request('/auth/kakao')
32
+
33
+ code, env = middleware.call(request)
34
+ code.should == 302
35
+
36
+ expect_url = <<-EXPECT
37
+ https://kauth.kakao.com/oauth/authorize
38
+ ?client_id=#{CLIENT_ID}
39
+ &redirect_uri=http://#{SERVER_NAME}/oauth
40
+ &response_type=code
41
+ EXPECT
42
+ expect_url = expect_url.gsub(/(\n|\t|\s)/, '')
43
+
44
+ actual_url = URI.decode(env['Location'])
45
+ actual_url = actual_url.split("&state")[0]
46
+
47
+ actual_url.should == expect_url
48
+ end
49
+ end
50
+
51
+ describe "GET /oauth" do
52
+ CODE = "dummy-code"
53
+ STATE = "dummy-state"
54
+ ACCESS_TOKEN = "dummy-access-token"
55
+ REFRESH_TOKEN = "dummy-refresh-token"
56
+
57
+ it "should request access token and user information" do
58
+ FakeWeb.register_uri(:post, "https://kauth.kakao.com/oauth/token",
59
+ :content_type => "application/json;charset=UTF-8",
60
+ :parameters => {
61
+ :grant_type => 'authorization_code',
62
+ :client_id => CLIENT_ID,
63
+ :redirect_uri => URI.encode("http://#{SERVER_NAME}/oauth"),
64
+ :code => CODE
65
+ },
66
+ :body => {
67
+ :access_token => ACCESS_TOKEN,
68
+ :token_type => "bearer",
69
+ :refresh_token => REFRESH_TOKEN,
70
+ :expires_in => 99999,
71
+ :scope => "Basic_Profile"
72
+ }.to_json
73
+ )
74
+
75
+ FakeWeb.register_uri(:get, "https://kapi.kakao.com/v1/user/me",
76
+ :content_type => "application/json;charset=UTF-8",
77
+ :"Authorization" => "Bearer #{ACCESS_TOKEN}",
78
+ :body => {
79
+ :id => 123456789,
80
+ :properties => {
81
+ :nickname => "John Doe",
82
+ :thumbnail_image => "http://xxx.kakao.com/.../aaa.jpg",
83
+ :profile_image => "http://xxx.kakao.com/.../bbb.jpg",
84
+ }
85
+ }.to_json
86
+ )
87
+
88
+ request = generate_request("/oauth?code=#{CODE}&state=#{STATE}", {
89
+ 'rack.session' => {
90
+ 'omniauth.state' => STATE
91
+ },
92
+ })
93
+
94
+ code, env = middleware.call(request)
95
+ code.should == 200
96
+
97
+ result = env['omniauth.auth']
98
+
99
+ result.provider.should == "kakao"
100
+ result.uid.should == "123456789"
101
+
102
+ information = result.info
103
+ information.name.should == "John Doe"
104
+ information.image.should == "http://xxx.kakao.com/.../aaa.jpg"
105
+
106
+ credentials = result.credentials
107
+ credentials.token.should == ACCESS_TOKEN
108
+ credentials.refresh_token.should == REFRESH_TOKEN
109
+
110
+ properties = result.extra.properties
111
+ properties.nickname.should == "John Doe"
112
+ properties.thumbnail_image.should == "http://xxx.kakao.com/.../aaa.jpg"
113
+ properties.profile_image.should == "http://xxx.kakao.com/.../bbb.jpg"
114
+ end
115
+ end
116
+ end
@@ -0,0 +1,22 @@
1
+ # This file was generated by the `rspec --init` command. Conventionally, all
2
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3
+ # Require this file using `require "spec_helper"` to ensure that it is only
4
+ # loaded once.
5
+ #
6
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
7
+ require 'fakeweb'
8
+
9
+ $:.unshift File.expand_path('..', __FILE__)
10
+ $:.unshift File.expand_path('../../lib', __FILE__)
11
+
12
+ RSpec.configure do |config|
13
+ config.treat_symbols_as_metadata_keys_with_true_values = true
14
+ config.run_all_when_everything_filtered = true
15
+ config.filter_run :focus
16
+
17
+ # Run specs in random order to surface order dependencies. If you find an
18
+ # order dependency and want to debug it, you can fix the order by providing
19
+ # the seed, which is printed after each run.
20
+ # --seed 1234
21
+ config.order = 'random'
22
+ end
metadata CHANGED
@@ -1,26 +1,106 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omniauth-kakao
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shayne Sung-Hee Kang
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-04 00:00:00.000000000 Z
12
- dependencies: []
13
- description: OmniAuth strategy for Kakao(under construction)
11
+ date: 2014-05-05 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: omniauth
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: omniauth-oauth2
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '1.1'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '1.1'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: 2.14.1
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: 2.14.1
55
+ - !ruby/object:Gem::Dependency
56
+ name: guard-rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: 4.2.8
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: 4.2.8
69
+ - !ruby/object:Gem::Dependency
70
+ name: fakeweb
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ~>
74
+ - !ruby/object:Gem::Version
75
+ version: 1.3.0
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ~>
81
+ - !ruby/object:Gem::Version
82
+ version: 1.3.0
83
+ description: OmniAuth strategy for Kakao(http://developers.kakao.com/)
14
84
  email:
15
85
  - shayne.kang@gmail.com
16
86
  executables: []
17
87
  extensions: []
18
88
  extra_rdoc_files: []
19
89
  files:
90
+ - .gitignore
91
+ - .rspec
20
92
  - CHANGELOG
93
+ - Gemfile
94
+ - Gemfile.lock
95
+ - Guardfile
21
96
  - README.md
97
+ - lib/omniauth-kakao.rb
22
98
  - lib/omniauth-kakao/version.rb
23
- homepage: http://www.medium.com/shaynekang
99
+ - lib/omniauth/strategies/kakao.rb
100
+ - omniauth-kakao.gemspec
101
+ - spec/omniauth/strategies/kakao_spec.rb
102
+ - spec/spec_helper.rb
103
+ homepage: http://medium.com/@shaynekang
24
104
  licenses:
25
105
  - MIT
26
106
  metadata: {}
@@ -44,4 +124,6 @@ rubygems_version: 2.0.14
44
124
  signing_key:
45
125
  specification_version: 4
46
126
  summary: OmniAuth strategy for Kakao
47
- test_files: []
127
+ test_files:
128
+ - spec/omniauth/strategies/kakao_spec.rb
129
+ - spec/spec_helper.rb