omniauth-geekpark 1.0.4 → 1.1.1
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 +5 -5
- data/Gemfile.lock +3 -3
- data/lib/omniauth/strategies/geekpark.rb +3 -1
- data/lib/omniauth/strategies/synced.rb +29 -0
- data/lib/omniauth/strategies/wechat.rb +2 -2
- data/lib/omniauth/strategies/wechat_service.rb +94 -0
- data/lib/omniauth-geekpark/version.rb +1 -1
- data/lib/omniauth-geekpark.rb +2 -0
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 1a2ff60a5562a3016e57b4fbed16ecc0b08eb0a83912aaccc16dd4fa7bde93c7
|
4
|
+
data.tar.gz: 0fac56d8ce9bfebf66374aa75996b05af62c3163e9c5e7182d74e19819e6b54e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f5c554964289e65ddd3e6f1586cdbec91168bc00bdcc33baa15f77b5d368773cfe7f53a42bad8303228a0075691b1df13fcb75e2abb63cab494aef9dd63dcd1f
|
7
|
+
data.tar.gz: 41dc11a4606d59aba003f83063ad33d4ae49410369106a0c8e2ee7af01940c0469c4da74fa218d675a18e20fb77aa0c6c01eaf3da1656683f99d18edf37dae66
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
omniauth-geekpark (0.
|
4
|
+
omniauth-geekpark (1.0.4)
|
5
5
|
omniauth (~> 1.0)
|
6
6
|
omniauth-oauth2 (= 1.3.1)
|
7
7
|
|
@@ -43,7 +43,7 @@ GEM
|
|
43
43
|
rb-inotify (>= 0.9.7)
|
44
44
|
lumberjack (1.0.10)
|
45
45
|
method_source (0.8.2)
|
46
|
-
multi_json (1.12.
|
46
|
+
multi_json (1.12.1)
|
47
47
|
multi_xml (0.5.5)
|
48
48
|
multipart-post (2.0.0)
|
49
49
|
nenv (0.3.0)
|
@@ -111,4 +111,4 @@ DEPENDENCIES
|
|
111
111
|
webmock (~> 1.24, >= 1.24.2)
|
112
112
|
|
113
113
|
BUNDLED WITH
|
114
|
-
1.12.
|
114
|
+
1.12.4
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module OmniAuth
|
2
|
+
module Strategies
|
3
|
+
class Synced < OmniAuth::Strategies::OAuth2
|
4
|
+
option :client_options, {
|
5
|
+
site: 'https://www.jiqizhixin.com/',
|
6
|
+
authorize_url: '/oauth/authorize',
|
7
|
+
token_url: '/oauth/token'
|
8
|
+
}
|
9
|
+
|
10
|
+
uid { raw_info['id'] }
|
11
|
+
|
12
|
+
info do
|
13
|
+
{
|
14
|
+
nickname: raw_info['name'],
|
15
|
+
avatar_url: raw_info['avatar_url'],
|
16
|
+
email: raw_info['email'],
|
17
|
+
bio: raw_info['bio'],
|
18
|
+
pubinfo: raw_info['pubinfo']
|
19
|
+
}
|
20
|
+
end
|
21
|
+
|
22
|
+
def raw_info
|
23
|
+
@raw_info ||= access_token.get('/api/v3/user').parsed
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
OmniAuth.config.add_camelization 'synced', 'Synced'
|
@@ -3,7 +3,7 @@ module OmniAuth
|
|
3
3
|
class WeChat < OmniAuth::Strategies::OAuth2
|
4
4
|
option :client_options, {
|
5
5
|
site: 'https://api.weixin.qq.com',
|
6
|
-
authorize_url: 'https://open.weixin.qq.com/connect/
|
6
|
+
authorize_url: 'https://open.weixin.qq.com/connect/qrconnect',
|
7
7
|
token_url: 'https://api.weixin.qq.com/sns/oauth2/access_token',
|
8
8
|
}
|
9
9
|
|
@@ -42,7 +42,7 @@ module OmniAuth
|
|
42
42
|
appid: options.client_id,
|
43
43
|
redirect_uri: callback_url,
|
44
44
|
response_type: 'code',
|
45
|
-
scope: '
|
45
|
+
scope: request.params['scope'] || 'snsapi_login',
|
46
46
|
})
|
47
47
|
if OmniAuth.config.test_mode
|
48
48
|
@env ||= {}
|
@@ -0,0 +1,94 @@
|
|
1
|
+
module OmniAuth
|
2
|
+
module Strategies
|
3
|
+
class WeChatService < OmniAuth::Strategies::OAuth2
|
4
|
+
option :client_options, {
|
5
|
+
site: 'https://api.weixin.qq.com',
|
6
|
+
authorize_url: 'https://open.weixin.qq.com/connect/oauth2/authorize',
|
7
|
+
token_url: 'https://api.weixin.qq.com/sns/oauth2/access_token',
|
8
|
+
}
|
9
|
+
|
10
|
+
option :provider_ignores_state, true
|
11
|
+
|
12
|
+
uid { raw_info['unionid'] }
|
13
|
+
|
14
|
+
info do
|
15
|
+
{
|
16
|
+
nickname: raw_info['nickname'],
|
17
|
+
city: raw_info['city'],
|
18
|
+
avatar: raw_info['headimgurl'],
|
19
|
+
openid: access_token['openid']
|
20
|
+
}
|
21
|
+
end
|
22
|
+
|
23
|
+
def raw_info
|
24
|
+
@raw_info ||= begin
|
25
|
+
response = access_token.get(
|
26
|
+
'/sns/userinfo',
|
27
|
+
{ params: { access_token: access_token.token,
|
28
|
+
openid: access_token['openid'],
|
29
|
+
lang: 'zh-CN' },
|
30
|
+
parse: :json }
|
31
|
+
).parsed
|
32
|
+
log :debug, response
|
33
|
+
response
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def request_phase
|
38
|
+
redirect client.authorize_url(authorize_params)+'#wechat_redirect'
|
39
|
+
end
|
40
|
+
|
41
|
+
def authorize_params
|
42
|
+
params = options.authorize_params.merge({
|
43
|
+
appid: options.client_id,
|
44
|
+
redirect_uri: callback_url,
|
45
|
+
response_type: 'code',
|
46
|
+
state: request.params['state'],
|
47
|
+
scope: request.params['scope'] || 'snsapi_userinfo'
|
48
|
+
})
|
49
|
+
if OmniAuth.config.test_mode
|
50
|
+
@env ||= {}
|
51
|
+
@env["rack.session"] ||= {}
|
52
|
+
end
|
53
|
+
unless options.provider_ignores_state
|
54
|
+
params[:state] = SecureRandom.hex(24)
|
55
|
+
session["omniauth.state"] = params[:state]
|
56
|
+
end
|
57
|
+
params
|
58
|
+
end
|
59
|
+
|
60
|
+
def token_params
|
61
|
+
{ appid: options.client_id, secret: options.client_secret }
|
62
|
+
end
|
63
|
+
|
64
|
+
def callback_phase
|
65
|
+
# 其它 app 需要获取微信openid 时,将 callbackurl 传入 state 参数
|
66
|
+
if request.params['state'].match(/\Ahttps?:\/\/(.*\.)?geekpark\.net\/.*\z/)
|
67
|
+
uri = URI(request.params['state'])
|
68
|
+
query = Rack::Utils.parse_nested_query(uri.query).merge(code: request.params['code'])
|
69
|
+
uri.query = URI.encode_www_form query
|
70
|
+
env['omniauth.redirect'] = uri.to_s
|
71
|
+
call_app!
|
72
|
+
else
|
73
|
+
super
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
protected
|
78
|
+
|
79
|
+
def build_access_token
|
80
|
+
request_params = {
|
81
|
+
appid: options.client_id,
|
82
|
+
secret: options.client_secret,
|
83
|
+
code: request.params['code'],
|
84
|
+
grant_type: 'authorization_code',
|
85
|
+
parse: :json
|
86
|
+
}
|
87
|
+
client.get_token(request_params, {mode: :query})
|
88
|
+
end
|
89
|
+
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
OmniAuth.config.add_camelization('wechatservice', 'WeChatService')
|
data/lib/omniauth-geekpark.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: omniauth-geekpark
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- HaoYunfei
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2022-01-16 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: omniauth
|
@@ -120,7 +120,9 @@ files:
|
|
120
120
|
- lib/omniauth-geekpark/helper.rb
|
121
121
|
- lib/omniauth-geekpark/version.rb
|
122
122
|
- lib/omniauth/strategies/geekpark.rb
|
123
|
+
- lib/omniauth/strategies/synced.rb
|
123
124
|
- lib/omniauth/strategies/wechat.rb
|
125
|
+
- lib/omniauth/strategies/wechat_service.rb
|
124
126
|
- lib/omniauth/strategies/weibo.rb
|
125
127
|
- lib/patch/omniauth-oauth2.rb
|
126
128
|
- omniauth-geekpark.gemspec
|
@@ -143,8 +145,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
143
145
|
- !ruby/object:Gem::Version
|
144
146
|
version: '0'
|
145
147
|
requirements: []
|
146
|
-
|
147
|
-
rubygems_version: 2.5.1
|
148
|
+
rubygems_version: 3.2.2
|
148
149
|
signing_key:
|
149
150
|
specification_version: 4
|
150
151
|
summary: OmniAuth strategies for GeekPark. Includes geekpark, weibo and wechat.
|