omniauth-kakao 0.0.2 → 0.0.3

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: d408aa8b09df76d9027300b309cc1d72fe2d7099
4
- data.tar.gz: df858be392f2b9910f478073da3965e004be0a4d
3
+ metadata.gz: 7c204a8a6c343b6b8115eae40980433176e2e899
4
+ data.tar.gz: ed3208ce20e5ec41eaffaaabe6175f40ab3d26e2
5
5
  SHA512:
6
- metadata.gz: afa6411ff7e30b91d58f43d20993062fbf15d94b657968127f212cd4378266e899d237fa83909a852a912333086cddb3a15c2b0b0afdd334229a54871fcc0ee1
7
- data.tar.gz: f46f477f9de2d92ff48090b7c17b6c23a67ffceca63d68174f1e23498cfcde6baa6a5f3ffd05fc51a28d48d12d0727f607d2ca749f1322b43006d36f47758a11
6
+ metadata.gz: 55f45f5dd0469c6c0544c232d3a96ff5a31fd720a5d1ad1dd86d23df02402dc0754c648d8c5fc87aec1441783302951c52b3def30e219b9b1c35f730696759fa
7
+ data.tar.gz: e485c7959f343ef18d723b4cfa0e116f8a554ce57c84f809edca9cb298274cdef94bafc36d9498a8c5492d6f158d5cb08efaa2974f193b9dd7a2cdc77738bdb3
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- omniauth-kakao (0.0.1)
4
+ omniauth-kakao (0.0.2)
5
5
  omniauth (~> 1.0)
6
6
  omniauth-oauth2 (~> 1.1)
7
7
 
data/README.md CHANGED
@@ -3,35 +3,71 @@
3
3
  This is the OmniAuth strategy for authenticating to [Kakao](http://www.kakao.com/). To
4
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
5
 
6
- [카카오](http://www.kakao.com/) 인증을 위한 OmniAuth strategy 입니다.
7
- [카카오 개발자 페이지](http://developers.kakao.com) 에서 REST API 키를 생성한 뒤 이용할 수 있습니다. 자세한 사항은 [앱 생성](https://developers.kakao.com/docs/restapi#시작하기-앱-생성) 페이지를 참조해 주세요.
6
+ [카카오](http://www.kakao.com/) 인증을 위한 OmniAuth strategy 입니다. [카카오 개발자 페이지](http://developers.kakao.com)에서 REST API 키를 생성한 뒤 이용해 주세요. 자세한 사항은 [시작하기 - 앱 생성](https://developers.kakao.com/docs/restapi#시작하기-앱-생성) 페이지를 참조하시기 바랍니다.
8
7
 
9
8
  ## Installing
10
9
 
11
10
  Add to your `Gemfile`:
12
11
 
12
+ `Gemfile`에 다음의 코드를 넣어주세요.
13
+
13
14
  ```ruby
14
15
  gem 'omniauth-kakao'
15
16
  ```
16
17
 
17
18
  Then `bundle install`.
18
19
 
20
+ 이후 `bundle install` 을 실행해 주세요.
21
+
19
22
  ## Usage
20
23
 
21
24
  Here's a quick example, adding the middleware to a Rails app in `config/initializers/omniauth.rb`:
22
25
 
26
+ 다음은 간단한 예제입니다. `config/initializers/omniauth.rb`에서 미들웨어를 레일즈 어플리케이션에 넣어주세요.
27
+
28
+
23
29
  ```ruby
24
30
  Rails.application.config.middleware.use OmniAuth::Builder do
25
31
  provider :kakao, ENV['KAKAO_CLIENT_ID']
26
32
  end
27
33
  ```
28
34
 
35
+ Then go to [My Application](https://developers.kakao.com/apps) page, select your current application and add your domain address(ex: http://localhost:3000/) to 'Setting - Platform - Web - Site Domain'.
36
+
37
+ 그리고 [내 어플리케이션](https://developers.kakao.com/apps)에서 현재 어플리케이션을 선택하고, '설정 - 플랫폼 - 웹 - 사이트 도메인'에 도메인 주소(예: http://localhost:3000/)를 넣어주세요.
38
+
39
+ ![이미지](https://developers.kakao.com/assets/images/dashboard/dev_011.png)
40
+
29
41
  For more information, please read the [OmniAuth](https://github.com/intridea/omniauth) docs for detailed instructions.
30
42
 
43
+ 자세한 사항은 [OmniAuth](https://github.com/intridea/omniauth)의 문서를 참고해 주세요.
44
+
45
+ ## Example
46
+
47
+ You can test omniauth-kakao in the `example/` folder.
48
+
49
+ `example/` 폴더에 있는 예제를 통해 omniauth-kakao를 테스트해볼 수 있습니다.
50
+
51
+ ```
52
+ cd example/
53
+ bundle install
54
+ KAKAO_CLIENT_ID='<your-kakako-client-id>' ruby app.rb
55
+ ```
56
+
57
+ Then open `http://localhost:4567/` in your browser.
58
+
59
+ 이후 `http://localhost:4567/`로 접속하시면 됩니다.
60
+
61
+ Warning: Do not forgot to add `http://localhost:4567/` in your [Application Setting](https://developers.kakao.com/apps).
62
+
63
+ 주의: [어플리케이션 설정](https://developers.kakao.com/apps) 의 '설정된 플랫폼 - 웹 - 사이트 도메인'에 `http://localhost:4567/`을 넣는 걸 잊지 마세요.
64
+
31
65
  ## Auth Hash
32
66
 
33
67
  Here's an example *Auth Hash* available in `request.env['omniauth.auth']`:
34
68
 
69
+ `request.env['omniauth.auth']` 안에 들어있는 *Auth Hash* 는 다음과 같습니다.
70
+
35
71
  ```ruby
36
72
  {
37
73
  :provider => 'kakao',
@@ -63,6 +99,14 @@ Here's an example *Auth Hash* available in `request.env['omniauth.auth']`:
63
99
  1. Add tests for it. This is important!
64
100
  1. Send a pull request from each feature branch.
65
101
 
102
+ ***
103
+
104
+ 1. 저장소를 Fork해 주세요.
105
+ 1. 새로운 기능(또는 개선할 부분)마다 브랜치를 만들어 주세요.
106
+ 1. 테스트를 작성해주세요. 이는 매우 중요합니다!
107
+ 1. 브랜치를 pull request로 보내주세요.
108
+
109
+
66
110
  ## License
67
111
 
68
112
  Copyright (c) 2014 [Shayne Sung-Hee Kang](http://medium.com/@shaynekang).
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'sinatra', '~> 1.4.5'
4
+ gem 'omniauth-kakao', :path => '../'
@@ -0,0 +1,46 @@
1
+ PATH
2
+ remote: ../
3
+ specs:
4
+ omniauth-kakao (0.0.2)
5
+ omniauth (~> 1.0)
6
+ omniauth-oauth2 (~> 1.1)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ faraday (0.9.0)
12
+ multipart-post (>= 1.2, < 3)
13
+ hashie (2.1.1)
14
+ jwt (0.1.12)
15
+ multi_json (1.10.0)
16
+ multi_xml (0.5.5)
17
+ multipart-post (2.0.0)
18
+ oauth2 (0.9.3)
19
+ faraday (>= 0.8, < 0.10)
20
+ jwt (~> 0.1.8)
21
+ multi_json (~> 1.3)
22
+ multi_xml (~> 0.5)
23
+ rack (~> 1.2)
24
+ omniauth (1.2.1)
25
+ hashie (>= 1.2, < 3)
26
+ rack (~> 1.0)
27
+ omniauth-oauth2 (1.1.2)
28
+ faraday (>= 0.8, < 0.10)
29
+ multi_json (~> 1.3)
30
+ oauth2 (~> 0.9.3)
31
+ omniauth (~> 1.2)
32
+ rack (1.5.2)
33
+ rack-protection (1.5.3)
34
+ rack
35
+ sinatra (1.4.5)
36
+ rack (~> 1.4)
37
+ rack-protection (~> 1.4)
38
+ tilt (~> 1.3, >= 1.3.4)
39
+ tilt (1.4.1)
40
+
41
+ PLATFORMS
42
+ ruby
43
+
44
+ DEPENDENCIES
45
+ omniauth-kakao!
46
+ sinatra (~> 1.4.5)
@@ -0,0 +1,135 @@
1
+ require 'bundler/setup'
2
+ require 'sinatra'
3
+ require 'omniauth-kakao'
4
+
5
+ client_id = ENV['KAKAO_CLIENT_ID']
6
+ if client_id == nil
7
+ class NoClientIDError < StandardError; end
8
+ raise NoClientIDError, "KAKAO_CLIENT_ID is nil. Please run example like `KAKAO_CLIENT_ID='<your-kakako-client-id>' ruby app.rb`"
9
+ end
10
+
11
+ use Rack::Session::Cookie
12
+
13
+ use OmniAuth::Builder do
14
+ provider :kakao, client_id
15
+ end
16
+
17
+ helpers do
18
+ def yaml_to_html(yaml)
19
+ display = yaml.split("\n")
20
+ display = display.map do |e|
21
+ e.gsub!(" ", "&nbsp;&nbsp;&nbsp;&nbsp;")
22
+ "<p>#{e}</p>"
23
+ end.join
24
+ end
25
+ end
26
+
27
+ get '/' do
28
+ erb :index
29
+ end
30
+
31
+ get '/auth/:provider/callback' do
32
+ @modal = {
33
+ title: "Success!",
34
+ body: yaml_to_html(request.env['omniauth.auth'].to_yaml)
35
+ }
36
+
37
+ erb :index
38
+ end
39
+
40
+ get '/auth/failure' do
41
+ @modal = {
42
+ title: "Failure",
43
+ body: "Error: #{params[:message]}"
44
+ }
45
+
46
+ erb :index
47
+ end
48
+
49
+ __END__
50
+ @@ index
51
+ <html>
52
+ <head>
53
+ <title>Test Application for Omniauth Kakao</title>
54
+ <link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css">
55
+ <link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap-theme.min.css">
56
+ <script src="https://code.jquery.com/jquery-2.1.0.min.js"></script>
57
+ <script src="//netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"></script>
58
+ <style>
59
+ #login-form {
60
+ margin-top: 30px;
61
+ text-align: center;
62
+ }
63
+
64
+ #login-form.panel-primary {
65
+ border-color: #FFEB00;
66
+ }
67
+
68
+ #login-form.panel-primary > .panel-heading {
69
+ background-image: -webkit-linear-gradient(top, #FFEB00 0, #FFEB00 100%);
70
+ background-image: -moz-linear-gradient(top, #FFEB00 0, #FFEB00 100%);
71
+ background-image: -o-linear-gradient(top, #FFEB00 0, #FFEB00 100%);
72
+ background-image: linear-gradient(top, #FFEB00 0, #FFEB00 100%);
73
+ background-color: #FFEB00;
74
+ border-color: #FFEB00;
75
+ color: #3D1D12;
76
+ }
77
+
78
+ .btn-kakao {
79
+ display: inline-block;
80
+ background-image: url("https://kauth.kakao.com/public/widget/login/kr/kr_02_medium.png");
81
+
82
+ width: 222px;
83
+ height: 49px;
84
+
85
+ line-height: 0;
86
+ font-size: 0;
87
+ color: transparent;
88
+ }
89
+ </style>
90
+ </head>
91
+ <body>
92
+ <div class="container">
93
+ <div class="row">
94
+ <div class="col-md-6 col-md-offset-3">
95
+ <div id="login-form" class="panel panel-primary">
96
+ <div class="panel-heading">
97
+ <h3 class="panel-title">Test Application for Omniauth Kakao</h3>
98
+ </div>
99
+
100
+ <div class="panel-body">
101
+ <a href="/auth/kakao" class="btn-kakao">카카오 계정으로 로그인</a>
102
+ </div>
103
+ </div>
104
+ </div>
105
+
106
+ <% if @modal %>
107
+ <div class="modal fade" id="auth-modal" tabindex="-1" role="dialog" aria-labelledby="auth-modal-label" aria-hidden="true">
108
+ <div class="modal-dialog modal-lg">
109
+ <div class="modal-content">
110
+ <div class="modal-header">
111
+ <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
112
+ <h4 class="modal-title" id="myModalLabel"><%= @modal[:title] %></h4>
113
+ </div>
114
+
115
+ <div class="modal-body">
116
+ <%= @modal[:body] %>
117
+ </div>
118
+
119
+ <div class="modal-footer">
120
+ <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
121
+ </div>
122
+ </div>
123
+ </div>
124
+ </div>
125
+
126
+ <script>
127
+ $(function(){
128
+ $('#auth-modal').modal('show');
129
+ });
130
+ </script>
131
+ <% end %>
132
+ </div>
133
+ </div>
134
+ </body>
135
+ </html>
@@ -1,5 +1,5 @@
1
1
  module Omniauth
2
2
  module Kakao
3
- VERSION = "0.0.2"
3
+ VERSION = "0.0.3"
4
4
  end
5
5
  end
@@ -30,7 +30,9 @@ module OmniAuth
30
30
  end
31
31
 
32
32
  def callback_phase
33
- @env["PATH_INFO"] = "/auth/kakao/callback"
33
+ previous_callback_path = options.delete(:callback_path)
34
+ @env["PATH_INFO"] = callback_path
35
+ options[:callback_path] = previous_callback_path
34
36
  super
35
37
  end
36
38
 
@@ -8,7 +8,7 @@ Gem::Specification.new do |s|
8
8
  s.platform = Gem::Platform::RUBY
9
9
  s.authors = ["Shayne Sung-Hee Kang"]
10
10
  s.email = ["shayne.kang@gmail.com"]
11
- s.homepage = "http://medium.com/@shaynekang"
11
+ s.homepage = "https://github.com/shaynekang/omniauth-kakao"
12
12
  s.summary = %q{OmniAuth strategy for Kakao}
13
13
  s.description = %q{OmniAuth strategy for Kakao(http://developers.kakao.com/)}
14
14
  s.license = "MIT"
@@ -19,7 +19,7 @@ describe OmniAuth::Strategies::Kakao do
19
19
  end
20
20
  end
21
21
 
22
- def generate_request(url, opts={})
22
+ def make_request(url, opts={})
23
23
  Rack::MockRequest.env_for(url, {
24
24
  'rack.session' => {},
25
25
  'SERVER_NAME' => SERVER_NAME,
@@ -28,9 +28,10 @@ describe OmniAuth::Strategies::Kakao do
28
28
 
29
29
  describe "GET /auth/kakao" do
30
30
  it "should redirect to authorize page" do
31
- request = generate_request('/auth/kakao')
31
+ request = make_request('/auth/kakao')
32
32
 
33
33
  code, env = middleware.call(request)
34
+
34
35
  code.should == 302
35
36
 
36
37
  expect_url = <<-EXPECT
@@ -38,11 +39,10 @@ describe OmniAuth::Strategies::Kakao do
38
39
  ?client_id=#{CLIENT_ID}
39
40
  &redirect_uri=http://#{SERVER_NAME}/oauth
40
41
  &response_type=code
41
- EXPECT
42
- expect_url = expect_url.gsub(/(\n|\t|\s)/, '')
42
+ EXPECT
43
+ .gsub(/(\n|\t|\s)/, '')
43
44
 
44
- actual_url = URI.decode(env['Location'])
45
- actual_url = actual_url.split("&state")[0]
45
+ actual_url = URI.decode(env['Location'].split("&state")[0])
46
46
 
47
47
  actual_url.should == expect_url
48
48
  end
@@ -54,7 +54,7 @@ describe OmniAuth::Strategies::Kakao do
54
54
  ACCESS_TOKEN = "dummy-access-token"
55
55
  REFRESH_TOKEN = "dummy-refresh-token"
56
56
 
57
- it "should request access token and user information" do
57
+ before do
58
58
  FakeWeb.register_uri(:post, "https://kauth.kakao.com/oauth/token",
59
59
  :content_type => "application/json;charset=UTF-8",
60
60
  :parameters => {
@@ -84,30 +84,33 @@ describe OmniAuth::Strategies::Kakao do
84
84
  }
85
85
  }.to_json
86
86
  )
87
+ end
87
88
 
88
- request = generate_request("/oauth?code=#{CODE}&state=#{STATE}", {
89
+ it "should request access token and user information" do
90
+ request = make_request("/oauth?code=#{CODE}&state=#{STATE}", {
89
91
  'rack.session' => {
90
92
  'omniauth.state' => STATE
91
93
  },
92
94
  })
93
95
 
94
96
  code, env = middleware.call(request)
97
+
95
98
  code.should == 200
96
99
 
97
- result = env['omniauth.auth']
100
+ response = env['omniauth.auth']
98
101
 
99
- result.provider.should == "kakao"
100
- result.uid.should == "123456789"
102
+ response.provider.should == "kakao"
103
+ response.uid.should == "123456789"
101
104
 
102
- information = result.info
105
+ information = response.info
103
106
  information.name.should == "John Doe"
104
107
  information.image.should == "http://xxx.kakao.com/.../aaa.jpg"
105
108
 
106
- credentials = result.credentials
109
+ credentials = response.credentials
107
110
  credentials.token.should == ACCESS_TOKEN
108
111
  credentials.refresh_token.should == REFRESH_TOKEN
109
112
 
110
- properties = result.extra.properties
113
+ properties = response.extra.properties
111
114
  properties.nickname.should == "John Doe"
112
115
  properties.thumbnail_image.should == "http://xxx.kakao.com/.../aaa.jpg"
113
116
  properties.profile_image.should == "http://xxx.kakao.com/.../bbb.jpg"
@@ -5,6 +5,7 @@
5
5
  #
6
6
  # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
7
7
  require 'fakeweb'
8
+ require 'json'
8
9
 
9
10
  $:.unshift File.expand_path('..', __FILE__)
10
11
  $:.unshift File.expand_path('../../lib', __FILE__)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omniauth-kakao
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
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-05 00:00:00.000000000 Z
11
+ date: 2014-05-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: omniauth
@@ -94,13 +94,16 @@ files:
94
94
  - Gemfile.lock
95
95
  - Guardfile
96
96
  - README.md
97
+ - example/Gemfile
98
+ - example/Gemfile.lock
99
+ - example/app.rb
97
100
  - lib/omniauth-kakao.rb
98
101
  - lib/omniauth-kakao/version.rb
99
102
  - lib/omniauth/strategies/kakao.rb
100
103
  - omniauth-kakao.gemspec
101
104
  - spec/omniauth/strategies/kakao_spec.rb
102
105
  - spec/spec_helper.rb
103
- homepage: http://medium.com/@shaynekang
106
+ homepage: https://github.com/shaynekang/omniauth-kakao
104
107
  licenses:
105
108
  - MIT
106
109
  metadata: {}