omniauth-kakao-access-token 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/.gitignore +2 -0
- data/Gemfile +4 -0
- data/README.markdown +48 -0
- data/lib/omniauth-kakao-access-token.rb +2 -0
- data/lib/omniauth-kakao-access-token/version.rb +5 -0
- data/lib/omniauth/strategies/kakao-access-token.rb +79 -0
- data/omniauth-kakao-access-token.gemspec +18 -0
- metadata +79 -0
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
ZjBlZDZiODQ5NmE1YjE2YzVkNzhjYTJjOTA4NWQyNjQyYWJiOTkxMg==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
ZjM1Mjg4MThkZGNiOTU5ZDcyZTllNWQzN2FiZmE4YmIzM2M4MjE4ZQ==
|
7
|
+
SHA512:
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
NDBmMDZkMTdiYjQ1NTdiZjIxZDZjYWE2YzM0ZGMxMGY4NWUyMTQ4YmY3MzRl
|
10
|
+
YTkzNmNhYWViNTY3NWEyYTFhNDE0NzI0MGUwY2JmYWRiZmU3NDc0MDgyNzg2
|
11
|
+
ZGQ2Mzg5ZjVhODQxZjI2MDA3MTYzODJhYzQ1ZTMwMGQ4NTg2ZGU=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
OWFkYTNlZDFkMjY4NjVmMTZlZjA0YjY0NmU3ZmZkNjJmMWJiODVlYjIyNDEz
|
14
|
+
ZDFiZjRkZDcyZTQ3OGQ3MjhkMzk5NzkzM2M0ODNiZTAyMzJhMWZiY2Q2OWFj
|
15
|
+
YWMxODMxMTgxYmEwYWFhZGFjYzM0MTg2Yzk2MTQ2MzVkMzNkNWQ=
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/README.markdown
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
# OmniAuth Kakao Access Token
|
2
|
+
|
3
|
+
Kakao Access Token Strategy for OmniAuth 1.0.
|
4
|
+
|
5
|
+
Supports client-side flow only.
|
6
|
+
|
7
|
+
Mostly shamelessly copied from [omniauth-facebook-access-token](https://github.com/SoapSeller/omniauth-facebook-access-token)
|
8
|
+
|
9
|
+
## Usage
|
10
|
+
|
11
|
+
### Server-Side
|
12
|
+
`OmniAuth::Strategies::KakaoAccessToken` is simply a Rack middleware. Read the OmniAuth 1.0 docs for detailed instructions: https://github.com/intridea/omniauth.
|
13
|
+
|
14
|
+
### Client-Side
|
15
|
+
|
16
|
+
Login via ajax GET/POST call to `/auth/kakao_access_token/callback` while providing `token`
|
17
|
+
|
18
|
+
## License
|
19
|
+
|
20
|
+
omniauth-kakao-access-token is licensed under MIT license.
|
21
|
+
|
22
|
+
Copyright (C) 2015 Seok Heo <heoseok87@leevi.co.kr>
|
23
|
+
|
24
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
25
|
+
this software and associated documentation files (the "Software"), to deal in
|
26
|
+
the Software without restriction, including without limitation the rights to
|
27
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
28
|
+
of the Software, and to permit persons to whom the Software is furnished to do
|
29
|
+
so, subject to the following conditions:
|
30
|
+
|
31
|
+
The above copyright notice and this permission notice shall be included in all
|
32
|
+
copies or substantial portions of the Software.
|
33
|
+
|
34
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
35
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
36
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
37
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
38
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
39
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
40
|
+
SOFTWARE.
|
41
|
+
|
42
|
+
Copyright (c) 2012 by Dor Shahaf
|
43
|
+
|
44
|
+
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:
|
45
|
+
|
46
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
47
|
+
|
48
|
+
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,79 @@
|
|
1
|
+
require 'omniauth-oauth2'
|
2
|
+
|
3
|
+
module OmniAuth
|
4
|
+
module Strategies
|
5
|
+
class KakaoAccessToken
|
6
|
+
include OmniAuth::Strategies::OAuth2
|
7
|
+
option :name, 'kakao_access_token'
|
8
|
+
|
9
|
+
option :client_options, {
|
10
|
+
:site => 'https://kauth.kakao.com',
|
11
|
+
:authorize_path => '/oauth/authorize',
|
12
|
+
:token_url => '/oauth/token',
|
13
|
+
}
|
14
|
+
|
15
|
+
uid { raw_info['id'].to_s }
|
16
|
+
|
17
|
+
info do
|
18
|
+
{
|
19
|
+
'name' => raw_properties['nickname'],
|
20
|
+
'image' => raw_properties['thumbnail_image'],
|
21
|
+
}
|
22
|
+
end
|
23
|
+
|
24
|
+
extra do
|
25
|
+
{'properties' => raw_properties}
|
26
|
+
end
|
27
|
+
|
28
|
+
credentials do
|
29
|
+
hash = {'token' => access_token.token}
|
30
|
+
hash.merge!('refresh_token' => access_token.refresh_token) if access_token.expires? && access_token.refresh_token
|
31
|
+
hash.merge!('expires_at' => access_token.expires_at) if access_token.expires?
|
32
|
+
hash.merge!('expires' => access_token.expires?)
|
33
|
+
hash
|
34
|
+
end
|
35
|
+
|
36
|
+
def raw_info
|
37
|
+
@raw_info ||= access_token.get('https://kapi.kakao.com/v1/user/me', {}).parsed || {}
|
38
|
+
end
|
39
|
+
|
40
|
+
def raw_properties
|
41
|
+
@raw_properties ||= raw_info['properties']
|
42
|
+
end
|
43
|
+
|
44
|
+
def callback_phase
|
45
|
+
if !request.params['token'] || request.params['token'].to_s.empty?
|
46
|
+
raise ArgumentError.new("No access token provided.")
|
47
|
+
end
|
48
|
+
|
49
|
+
self.access_token = build_access_token
|
50
|
+
self.access_token = self.access_token.refresh! if self.access_token.expired?
|
51
|
+
|
52
|
+
hash = auth_hash
|
53
|
+
hash[:provider] = "kakao"
|
54
|
+
self.env['omniauth.auth'] = hash
|
55
|
+
call_app!
|
56
|
+
|
57
|
+
rescue ::OAuth::Error => e
|
58
|
+
fail!(:invalid_credentials, e)
|
59
|
+
rescue ::MultiJson::DecodeError => e
|
60
|
+
fail!(:invalid_response, e)
|
61
|
+
rescue ::Timeout::Error, ::Errno::ETIMEDOUT => e
|
62
|
+
fail!(:timeout, e)
|
63
|
+
rescue ::SocketError => e
|
64
|
+
fail!(:failed_to_connect, e)
|
65
|
+
end
|
66
|
+
|
67
|
+
protected
|
68
|
+
|
69
|
+
def build_access_token
|
70
|
+
hash = request.params.slice("token", "expires_at", "expires", "refresh_token")
|
71
|
+
hash.update(options.access_token_options)
|
72
|
+
::OAuth2::AccessToken.from_hash(
|
73
|
+
client,
|
74
|
+
hash
|
75
|
+
)
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/omniauth-kakao-access-token/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ["Seok Heo"]
|
6
|
+
gem.email = ["heoseok87@leevi.co.kr"]
|
7
|
+
gem.description = %q{A kakao strategy using token for OmniAuth. Can be used for client side kakao login. }
|
8
|
+
gem.summary = %q{A kakao strategy using token for OmniAuth.}
|
9
|
+
gem.homepage = "https://github.com/LEEVI-dev/omniauth_kakao_access_token"
|
10
|
+
gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
11
|
+
gem.files = `git ls-files`.split("\n")
|
12
|
+
gem.name = "omniauth-kakao-access-token"
|
13
|
+
gem.require_paths = ["lib"]
|
14
|
+
gem.version = OmniAuth::KakaoAccessToken::VERSION
|
15
|
+
|
16
|
+
gem.add_dependency 'omniauth', '~> 1.0'
|
17
|
+
gem.add_dependency 'omniauth-oauth2', '~> 1.1'
|
18
|
+
end
|
metadata
ADDED
@@ -0,0 +1,79 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: omniauth-kakao-access-token
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Seok Heo
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-05-18 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
|
+
description: ! 'A kakao strategy using token for OmniAuth. Can be used for client
|
42
|
+
side kakao login. '
|
43
|
+
email:
|
44
|
+
- heoseok87@leevi.co.kr
|
45
|
+
executables: []
|
46
|
+
extensions: []
|
47
|
+
extra_rdoc_files: []
|
48
|
+
files:
|
49
|
+
- .gitignore
|
50
|
+
- Gemfile
|
51
|
+
- README.markdown
|
52
|
+
- lib/omniauth-kakao-access-token.rb
|
53
|
+
- lib/omniauth-kakao-access-token/version.rb
|
54
|
+
- lib/omniauth/strategies/kakao-access-token.rb
|
55
|
+
- omniauth-kakao-access-token.gemspec
|
56
|
+
homepage: https://github.com/LEEVI-dev/omniauth_kakao_access_token
|
57
|
+
licenses: []
|
58
|
+
metadata: {}
|
59
|
+
post_install_message:
|
60
|
+
rdoc_options: []
|
61
|
+
require_paths:
|
62
|
+
- lib
|
63
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - ! '>='
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '0'
|
68
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
69
|
+
requirements:
|
70
|
+
- - ! '>='
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: '0'
|
73
|
+
requirements: []
|
74
|
+
rubyforge_project:
|
75
|
+
rubygems_version: 2.4.6
|
76
|
+
signing_key:
|
77
|
+
specification_version: 4
|
78
|
+
summary: A kakao strategy using token for OmniAuth.
|
79
|
+
test_files: []
|