omniauth-kakao 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +10 -0
- data/example/Gemfile +1 -0
- data/example/Gemfile.lock +13 -10
- data/example/app.rb +13 -1
- data/lib/omniauth-kakao/version.rb +1 -1
- data/lib/omniauth/strategies/kakao.rb +3 -1
- data/spec/omniauth/strategies/kakao_spec.rb +29 -3
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: af773d971e3a8b86ac99c335e3658178694b47c7
|
4
|
+
data.tar.gz: 9af03cdf45f938068faf7ed4bd78e81186eedc7e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9540a11176807a5195f5d50e0e26849e6488c2f137cbc60cf69cc5feb3d4bdc1dc35556c963051fecc0cc87b217131af6476559e6d39d27d09e28817dc550475
|
7
|
+
data.tar.gz: d2fd6c6763a2bd52d1be736a0dba14e686622af0131a65695166b8f080af686d36cffa3b6f354d8c8196d909d329580bbd6222e760bc350200c464a978f2fcc1
|
data/README.md
CHANGED
@@ -29,6 +29,9 @@ Here's a quick example, adding the middleware to a Rails app in `config/initiali
|
|
29
29
|
```ruby
|
30
30
|
Rails.application.config.middleware.use OmniAuth::Builder do
|
31
31
|
provider :kakao, ENV['KAKAO_CLIENT_ID']
|
32
|
+
|
33
|
+
# 또는 Redirect Path를 설정하고 싶다면(or if you want to customize your Redirect Path)
|
34
|
+
# provider :kakao, ENV['KAKAO_CLIENT_ID'], {:redirect_path => ENV['REDIRECT_PATH']}
|
32
35
|
end
|
33
36
|
```
|
34
37
|
|
@@ -52,6 +55,9 @@ You can test omniauth-kakao in the `example/` folder.
|
|
52
55
|
cd example/
|
53
56
|
bundle install
|
54
57
|
KAKAO_CLIENT_ID='<your-kakako-client-id>' ruby app.rb
|
58
|
+
|
59
|
+
# 또는 Redirect Path를 설정하고 싶다면(or if you want to customize your Redirect Path)
|
60
|
+
# KAKAO_CLIENT_ID='<your-kakako-client-id>' REDIRECT_PATH='<your-redirect-path>' ruby app.rb
|
55
61
|
```
|
56
62
|
|
57
63
|
Then open `http://localhost:4567/` in your browser.
|
@@ -92,6 +98,10 @@ Here's an example *Auth Hash* available in `request.env['omniauth.auth']`:
|
|
92
98
|
}
|
93
99
|
```
|
94
100
|
|
101
|
+
## Contributors
|
102
|
+
* [Shayne Sung-Hee Kang](https://github.com/shaynekang)
|
103
|
+
* [Hong Chulju](https://github.com/fegs)
|
104
|
+
|
95
105
|
## Contribute
|
96
106
|
|
97
107
|
1. Fork the repository.
|
data/example/Gemfile
CHANGED
data/example/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: ../
|
3
3
|
specs:
|
4
|
-
omniauth-kakao (0.1.
|
4
|
+
omniauth-kakao (0.1.1)
|
5
5
|
omniauth (~> 1.0)
|
6
6
|
omniauth-oauth2 (~> 1.1)
|
7
7
|
|
@@ -10,28 +10,30 @@ GEM
|
|
10
10
|
specs:
|
11
11
|
faraday (0.9.0)
|
12
12
|
multipart-post (>= 1.2, < 3)
|
13
|
-
hashie (
|
14
|
-
jwt (0.
|
15
|
-
multi_json (1.10.
|
13
|
+
hashie (3.3.1)
|
14
|
+
jwt (1.0.0)
|
15
|
+
multi_json (1.10.1)
|
16
16
|
multi_xml (0.5.5)
|
17
17
|
multipart-post (2.0.0)
|
18
|
-
oauth2 (0.
|
18
|
+
oauth2 (1.0.0)
|
19
19
|
faraday (>= 0.8, < 0.10)
|
20
|
-
jwt (~>
|
20
|
+
jwt (~> 1.0)
|
21
21
|
multi_json (~> 1.3)
|
22
22
|
multi_xml (~> 0.5)
|
23
23
|
rack (~> 1.2)
|
24
|
-
omniauth (1.2.
|
25
|
-
hashie (>= 1.2, <
|
24
|
+
omniauth (1.2.2)
|
25
|
+
hashie (>= 1.2, < 4)
|
26
26
|
rack (~> 1.0)
|
27
|
-
omniauth-oauth2 (1.
|
27
|
+
omniauth-oauth2 (1.2.0)
|
28
28
|
faraday (>= 0.8, < 0.10)
|
29
29
|
multi_json (~> 1.3)
|
30
|
-
oauth2 (~> 0
|
30
|
+
oauth2 (~> 1.0)
|
31
31
|
omniauth (~> 1.2)
|
32
32
|
rack (1.5.2)
|
33
33
|
rack-protection (1.5.3)
|
34
34
|
rack
|
35
|
+
shotgun (0.9)
|
36
|
+
rack (>= 1.0)
|
35
37
|
sinatra (1.4.5)
|
36
38
|
rack (~> 1.4)
|
37
39
|
rack-protection (~> 1.4)
|
@@ -43,4 +45,5 @@ PLATFORMS
|
|
43
45
|
|
44
46
|
DEPENDENCIES
|
45
47
|
omniauth-kakao!
|
48
|
+
shotgun (~> 0.9)
|
46
49
|
sinatra (~> 1.4.5)
|
data/example/app.rb
CHANGED
@@ -8,10 +8,12 @@ if client_id == nil
|
|
8
8
|
raise NoClientIDError, "KAKAO_CLIENT_ID is nil. Please run example like `KAKAO_CLIENT_ID='<your-kakako-client-id>' ruby app.rb`"
|
9
9
|
end
|
10
10
|
|
11
|
+
redirect_path = ENV['REDIRECT_PATH'] || OmniAuth::Strategies::Kakao::DEFAULT_REDIRECT_PATH
|
12
|
+
|
11
13
|
use Rack::Session::Cookie
|
12
14
|
|
13
15
|
use OmniAuth::Builder do
|
14
|
-
provider :kakao, client_id
|
16
|
+
provider :kakao, client_id, {:redirect_path => redirect_path}
|
15
17
|
end
|
16
18
|
|
17
19
|
helpers do
|
@@ -24,6 +26,10 @@ helpers do
|
|
24
26
|
end
|
25
27
|
end
|
26
28
|
|
29
|
+
before do
|
30
|
+
@redirect_path = redirect_path
|
31
|
+
end
|
32
|
+
|
27
33
|
get '/' do
|
28
34
|
erb :index
|
29
35
|
end
|
@@ -86,6 +92,11 @@ __END__
|
|
86
92
|
font-size: 0;
|
87
93
|
color: transparent;
|
88
94
|
}
|
95
|
+
|
96
|
+
#redirect-path {
|
97
|
+
text-align: right;
|
98
|
+
margin: 20px 0 0 0;
|
99
|
+
}
|
89
100
|
</style>
|
90
101
|
</head>
|
91
102
|
<body>
|
@@ -99,6 +110,7 @@ __END__
|
|
99
110
|
|
100
111
|
<div class="panel-body">
|
101
112
|
<a href="/auth/kakao" class="btn-kakao">카카오 계정으로 로그인</a>
|
113
|
+
<p id="redirect-path"><small>Redirect Path: <%= @redirect_path %></small></p>
|
102
114
|
</div>
|
103
115
|
</div>
|
104
116
|
</div>
|
@@ -3,6 +3,8 @@ require 'omniauth-oauth2'
|
|
3
3
|
module OmniAuth
|
4
4
|
module Strategies
|
5
5
|
class Kakao < OmniAuth::Strategies::OAuth2
|
6
|
+
DEFAULT_REDIRECT_PATH = "/oauth"
|
7
|
+
|
6
8
|
option :name, 'kakao'
|
7
9
|
|
8
10
|
option :client_options, {
|
@@ -26,7 +28,7 @@ module OmniAuth
|
|
26
28
|
|
27
29
|
def initialize(app, *args, &block)
|
28
30
|
super
|
29
|
-
options[:callback_path] =
|
31
|
+
options[:callback_path] = options[:redirect_path] || DEFAULT_REDIRECT_PATH
|
30
32
|
end
|
31
33
|
|
32
34
|
def callback_phase
|
@@ -10,12 +10,12 @@ describe OmniAuth::Strategies::Kakao do
|
|
10
10
|
OmniAuth.config.logger.level = 5
|
11
11
|
end
|
12
12
|
|
13
|
-
|
13
|
+
def make_middleware(client_id, opts={})
|
14
14
|
app = ->(env) { [200, env, "app"] }
|
15
15
|
|
16
|
-
middleware = OmniAuth::Strategies::Kakao.new(app)
|
16
|
+
middleware = OmniAuth::Strategies::Kakao.new(app, opts)
|
17
17
|
middleware.tap do |middleware|
|
18
|
-
middleware.options.client_id =
|
18
|
+
middleware.options.client_id = client_id
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
@@ -29,6 +29,7 @@ describe OmniAuth::Strategies::Kakao do
|
|
29
29
|
describe "GET /auth/kakao" do
|
30
30
|
it "should redirect to authorize page" do
|
31
31
|
request = make_request('/auth/kakao')
|
32
|
+
middleware = make_middleware(CLIENT_ID)
|
32
33
|
|
33
34
|
code, env = middleware.call(request)
|
34
35
|
|
@@ -46,6 +47,27 @@ describe OmniAuth::Strategies::Kakao do
|
|
46
47
|
|
47
48
|
actual_url.should == expect_url
|
48
49
|
end
|
50
|
+
|
51
|
+
it "should customize redirect path" do
|
52
|
+
request = make_request('/auth/kakao')
|
53
|
+
middleware = make_middleware(CLIENT_ID, redirect_path: '/auth/kakao/callback')
|
54
|
+
|
55
|
+
code, env = middleware.call(request)
|
56
|
+
|
57
|
+
code.should == 302
|
58
|
+
|
59
|
+
expect_url = <<-EXPECT
|
60
|
+
https://kauth.kakao.com/oauth/authorize
|
61
|
+
?client_id=#{CLIENT_ID}
|
62
|
+
&redirect_uri=http://#{SERVER_NAME}/auth/kakao/callback
|
63
|
+
&response_type=code
|
64
|
+
EXPECT
|
65
|
+
.gsub(/(\n|\t|\s)/, '')
|
66
|
+
|
67
|
+
actual_url = URI.decode(env['Location'].split("&state")[0])
|
68
|
+
|
69
|
+
actual_url.should == expect_url
|
70
|
+
end
|
49
71
|
end
|
50
72
|
|
51
73
|
describe "GET /oauth" do
|
@@ -93,6 +115,8 @@ describe OmniAuth::Strategies::Kakao do
|
|
93
115
|
},
|
94
116
|
})
|
95
117
|
|
118
|
+
middleware = make_middleware(CLIENT_ID)
|
119
|
+
|
96
120
|
code, env = middleware.call(request)
|
97
121
|
|
98
122
|
code.should == 200
|
@@ -133,6 +157,7 @@ describe OmniAuth::Strategies::Kakao do
|
|
133
157
|
describe "GET /auth/kakao" do
|
134
158
|
it "should redirect to callback url (/auth/kakao/callback)" do
|
135
159
|
request = make_request("/auth/kakao")
|
160
|
+
middleware = make_middleware(CLIENT_ID)
|
136
161
|
code, env = middleware.call(request)
|
137
162
|
|
138
163
|
code.should == 302
|
@@ -145,6 +170,7 @@ describe OmniAuth::Strategies::Kakao do
|
|
145
170
|
describe "GET /auth/kakao/callback" do
|
146
171
|
it "should request registered mock" do
|
147
172
|
request = make_request("/auth/kakao/callback")
|
173
|
+
middleware = make_middleware(CLIENT_ID)
|
148
174
|
code, env = middleware.call(request)
|
149
175
|
|
150
176
|
code.should == 200
|