omniauth-feishu 0.1.5 → 0.1.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/lib/omniauth/feishu/version.rb +1 -1
- data/lib/omniauth/strategies/feishu.rb +54 -44
- data/omniauth-feishu.gemspec +3 -3
- metadata +11 -39
- data/Gemfile.lock +0 -59
- data/_config.yml +0 -2
- data/bin/console +0 -14
- data/bin/setup +0 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ac97f7c1d2639fdb1b2812ec5d6cb66cc636be214d17b69a89c00e32e3981551
|
4
|
+
data.tar.gz: 02ddf74e3a7255059390cc9dbf268572050f52ad00a9fc9ede60fdc1e60998ea
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fa62ebaa035fa8c04b2e27ab8064340fb2d5209a20dfc85de806ddcf6413608a68e6378647c5ce92e090295392b9e6fb1783217cd247ffb0ae6f16136394db08
|
7
|
+
data.tar.gz: 1ba97b40558d0c54f4cba6bbfaa155082620a090dc6420f3dcc9103c2fd18b44c59956336a05526ea19f2ffdef6f5077ada17563a0232fe9efd491449e18c981
|
data/.gitignore
CHANGED
@@ -2,21 +2,26 @@ require 'omniauth-oauth2'
|
|
2
2
|
|
3
3
|
module OmniAuth
|
4
4
|
module Strategies
|
5
|
+
|
6
|
+
# 飞书登录
|
7
|
+
#
|
8
|
+
# 飞书要求请求采用 json 格式主体,很多都需要自定义
|
9
|
+
# 官方文档: https://open.feishu.cn/document/ukTMukTMukTM/uETOwYjLxkDM24SM5AjN
|
5
10
|
class Feishu < OmniAuth::Strategies::OAuth2
|
6
11
|
class NoAppAccessTokenError < StandardError; end
|
7
12
|
|
8
|
-
attr_reader :app_access_token
|
9
|
-
|
10
13
|
option :name, 'feishu'
|
11
14
|
|
12
15
|
option :client_options, {
|
13
|
-
site: 'https://open.feishu.cn',
|
14
|
-
authorize_url:
|
15
|
-
token_url:
|
16
|
-
app_access_token_url:
|
17
|
-
user_info_url:
|
16
|
+
site: 'https://open.feishu.cn/open-apis/authen/v1/',
|
17
|
+
authorize_url: 'user_auth_page_beta',
|
18
|
+
token_url: 'access_token',
|
19
|
+
app_access_token_url: 'https://open.feishu.cn/open-apis/auth/v3/app_access_token/internal',
|
20
|
+
user_info_url: 'user_info'
|
18
21
|
}
|
19
22
|
|
23
|
+
uid { raw_info['user_id'] }
|
24
|
+
|
20
25
|
info do
|
21
26
|
{
|
22
27
|
name: raw_info['name'],
|
@@ -26,24 +31,21 @@ module OmniAuth
|
|
26
31
|
avatar_thumb: raw_info['avatar_thumb'],
|
27
32
|
avatar_middle: raw_info['avatar_middle'],
|
28
33
|
avatar_big: raw_info['avatar_big'],
|
29
|
-
user_id: raw_info['user_id'],
|
30
|
-
union_id: raw_info['union_id'],
|
31
|
-
open_id: raw_info['open_id'],
|
32
|
-
en_name: raw_info['en_name']
|
33
|
-
app_access_token: @app_access_token
|
34
|
+
user_id: raw_info['user_id'],
|
35
|
+
union_id: raw_info['union_id'],
|
36
|
+
open_id: raw_info['open_id'],
|
37
|
+
en_name: raw_info['en_name']
|
34
38
|
}
|
35
39
|
end
|
36
40
|
|
37
41
|
def raw_info
|
38
|
-
@raw_info ||=
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
response_body['data']
|
46
|
-
end
|
42
|
+
@raw_info ||= client.request(:get, options.client_options.user_info_url,
|
43
|
+
{ headers: {
|
44
|
+
'Content-Type' => 'application/json; charset=utf-8',
|
45
|
+
'Authorization' => "Bearer #{access_token.token}"
|
46
|
+
}
|
47
|
+
})
|
48
|
+
.parsed['data']
|
47
49
|
end
|
48
50
|
|
49
51
|
def authorize_params
|
@@ -52,35 +54,43 @@ module OmniAuth
|
|
52
54
|
end
|
53
55
|
end
|
54
56
|
|
57
|
+
# 飞书采用非标准 OAuth 2 请求体和返回结构体,需要自定义
|
55
58
|
def build_access_token
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
59
|
+
code = request.params['code']
|
60
|
+
data = client.request(:post, options.client_options.token_url,
|
61
|
+
{ body: {
|
62
|
+
code: code,
|
63
|
+
grant_type: 'authorization_code'
|
64
|
+
}.to_json,
|
65
|
+
headers: {
|
66
|
+
'Content-Type' => 'application/json; charset=utf-8',
|
67
|
+
'Authorization' => "Bearer #{app_access_token}"
|
68
|
+
}
|
69
|
+
})
|
70
|
+
.parsed['data']
|
64
71
|
|
65
|
-
|
66
|
-
get_app_access_token
|
67
|
-
super
|
72
|
+
::OAuth2::AccessToken.from_hash(client, data)
|
68
73
|
end
|
69
74
|
|
70
75
|
private
|
71
76
|
|
72
|
-
def
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
77
|
+
def app_access_token
|
78
|
+
return @app_access_token if @app_access_token
|
79
|
+
|
80
|
+
@app_access_token ||= client.request(:post, options.client_options.app_access_token_url,
|
81
|
+
{ body: {
|
82
|
+
app_id: options.client_id,
|
83
|
+
app_secret: options.client_secret
|
84
|
+
}.to_json,
|
85
|
+
headers: {
|
86
|
+
'Content-Type' => 'application/json; charset=utf-8'
|
87
|
+
}
|
88
|
+
})
|
89
|
+
.parsed['app_access_token']
|
90
|
+
|
91
|
+
raise NoAppAccessTokenError, 'No app access token' unless @app_access_token
|
92
|
+
|
93
|
+
@app_access_token
|
84
94
|
end
|
85
95
|
end
|
86
96
|
end
|
data/omniauth-feishu.gemspec
CHANGED
@@ -11,10 +11,10 @@ Gem::Specification.new do |spec|
|
|
11
11
|
spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
|
12
12
|
spec.license = "MIT"
|
13
13
|
|
14
|
-
spec.add_dependency "omniauth-oauth2", "
|
14
|
+
spec.add_dependency "omniauth-oauth2", ">= 1.6.0", "< 2"
|
15
15
|
|
16
|
-
spec.add_development_dependency "rake"
|
17
|
-
spec.add_development_dependency "rspec"
|
16
|
+
# spec.add_development_dependency "rake"
|
17
|
+
# spec.add_development_dependency "rspec"
|
18
18
|
|
19
19
|
spec.files = `git ls-files`.split("\n")
|
20
20
|
spec.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
metadata
CHANGED
@@ -1,76 +1,48 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: omniauth-feishu
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Renny
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-04-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: omniauth-oauth2
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: 1.6.0
|
20
|
-
type: :runtime
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - "~>"
|
17
|
+
- - ">="
|
25
18
|
- !ruby/object:Gem::Version
|
26
19
|
version: 1.6.0
|
27
|
-
-
|
28
|
-
name: rake
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - ">="
|
20
|
+
- - "<"
|
32
21
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
34
|
-
type: :
|
22
|
+
version: '2'
|
23
|
+
type: :runtime
|
35
24
|
prerelease: false
|
36
25
|
version_requirements: !ruby/object:Gem::Requirement
|
37
26
|
requirements:
|
38
27
|
- - ">="
|
39
28
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
41
|
-
-
|
42
|
-
name: rspec
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - ">="
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '0'
|
48
|
-
type: :development
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - ">="
|
29
|
+
version: 1.6.0
|
30
|
+
- - "<"
|
53
31
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
32
|
+
version: '2'
|
55
33
|
description:
|
56
34
|
email:
|
57
35
|
- rennyallen@hotmail.com
|
58
|
-
executables:
|
59
|
-
- console
|
60
|
-
- setup
|
36
|
+
executables: []
|
61
37
|
extensions: []
|
62
38
|
extra_rdoc_files: []
|
63
39
|
files:
|
64
40
|
- ".gitignore"
|
65
41
|
- ".travis.yml"
|
66
42
|
- Gemfile
|
67
|
-
- Gemfile.lock
|
68
43
|
- LICENSE
|
69
44
|
- README.md
|
70
45
|
- Rakefile
|
71
|
-
- _config.yml
|
72
|
-
- bin/console
|
73
|
-
- bin/setup
|
74
46
|
- lib/omniauth/feishu.rb
|
75
47
|
- lib/omniauth/feishu/version.rb
|
76
48
|
- lib/omniauth/strategies/feishu.rb
|
@@ -94,7 +66,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
94
66
|
- !ruby/object:Gem::Version
|
95
67
|
version: '0'
|
96
68
|
requirements: []
|
97
|
-
rubygems_version: 3.
|
69
|
+
rubygems_version: 3.1.4
|
98
70
|
signing_key:
|
99
71
|
specification_version: 4
|
100
72
|
summary: Lark(Feishu) OAuth2 Strategy for OmniAuth
|
data/Gemfile.lock
DELETED
@@ -1,59 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
omniauth-feishu (0.1.5)
|
5
|
-
omniauth-oauth2 (~> 1.6.0)
|
6
|
-
|
7
|
-
GEM
|
8
|
-
remote: https://rubygems.org/
|
9
|
-
specs:
|
10
|
-
diff-lcs (1.4.4)
|
11
|
-
faraday (1.3.0)
|
12
|
-
faraday-net_http (~> 1.0)
|
13
|
-
multipart-post (>= 1.2, < 3)
|
14
|
-
ruby2_keywords
|
15
|
-
faraday-net_http (1.0.0)
|
16
|
-
hashie (4.1.0)
|
17
|
-
jwt (2.2.2)
|
18
|
-
multi_json (1.15.0)
|
19
|
-
multi_xml (0.6.0)
|
20
|
-
multipart-post (2.1.1)
|
21
|
-
oauth2 (1.4.4)
|
22
|
-
faraday (>= 0.8, < 2.0)
|
23
|
-
jwt (>= 1.0, < 3.0)
|
24
|
-
multi_json (~> 1.3)
|
25
|
-
multi_xml (~> 0.5)
|
26
|
-
rack (>= 1.2, < 3)
|
27
|
-
omniauth (1.9.1)
|
28
|
-
hashie (>= 3.4.6)
|
29
|
-
rack (>= 1.6.2, < 3)
|
30
|
-
omniauth-oauth2 (1.6.0)
|
31
|
-
oauth2 (~> 1.1)
|
32
|
-
omniauth (~> 1.9)
|
33
|
-
rack (2.2.3)
|
34
|
-
rake (12.3.2)
|
35
|
-
rspec (3.10.0)
|
36
|
-
rspec-core (~> 3.10.0)
|
37
|
-
rspec-expectations (~> 3.10.0)
|
38
|
-
rspec-mocks (~> 3.10.0)
|
39
|
-
rspec-core (3.10.1)
|
40
|
-
rspec-support (~> 3.10.0)
|
41
|
-
rspec-expectations (3.10.1)
|
42
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
43
|
-
rspec-support (~> 3.10.0)
|
44
|
-
rspec-mocks (3.10.1)
|
45
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
46
|
-
rspec-support (~> 3.10.0)
|
47
|
-
rspec-support (3.10.1)
|
48
|
-
ruby2_keywords (0.0.2)
|
49
|
-
|
50
|
-
PLATFORMS
|
51
|
-
ruby
|
52
|
-
|
53
|
-
DEPENDENCIES
|
54
|
-
omniauth-feishu!
|
55
|
-
rake (~> 12.0)
|
56
|
-
rspec
|
57
|
-
|
58
|
-
BUNDLED WITH
|
59
|
-
2.1.4
|
data/_config.yml
DELETED
data/bin/console
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require "bundler/setup"
|
4
|
-
require "omniauth/feishu"
|
5
|
-
|
6
|
-
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
-
# with your gem easier. You can also use a different console, if you like.
|
8
|
-
|
9
|
-
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
-
# require "pry"
|
11
|
-
# Pry.start
|
12
|
-
|
13
|
-
require "irb"
|
14
|
-
IRB.start(__FILE__)
|