omniauth-feishu 0.1.0 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +4 -0
- data/Gemfile.lock +59 -0
- data/LICENSE +21 -0
- data/README.md +68 -8
- data/Rakefile +5 -1
- data/_config.yml +2 -0
- data/lib/omniauth/feishu.rb +1 -0
- data/lib/omniauth/feishu/version.rb +1 -1
- data/lib/omniauth/strategies/feishu.rb +18 -1
- data/omniauth-feishu.gemspec +8 -7
- metadata +54 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bd59f95721489e7949dc0289eca3441dd317ed19bb8def94f757063e7d90cd7f
|
4
|
+
data.tar.gz: 67c141202a467cac93c3267938a637ab820fed6678757b6e8a835faf56006720
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 82e1e911346a351f7d7bd0a6b092f587d691489578dc49ce0ad71a793e3028fda368b926e1f2fa9c350227d807f0e3f9db176d613b68863932a06c3fda787629
|
7
|
+
data.tar.gz: a71bbda1517549ce0f99b152fa4b1ac7ec4471a5abbb10a1496b7c3e94c46314a99a61bf643f7b238349253646592bbec6ea914a50b037c84e5a511f78f8bf0b
|
data/.travis.yml
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,59 @@
|
|
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/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2021 Renny Ren
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
CHANGED
@@ -1,8 +1,9 @@
|
|
1
|
-
#
|
1
|
+
# OmniAuth Feishu
|
2
2
|
|
3
|
-
|
3
|
+
Strategy to authenticate with Feishu via OAuth2 in OmniAuth.
|
4
4
|
|
5
|
-
|
5
|
+
[![Gem Version](https://badge.fury.io/rb/omniauth-feishu.svg)](http://badge.fury.io/rb/omniauth-feishu)
|
6
|
+
[![Build Status](https://travis-ci.org/renny-ren/omniauth-feishu.svg?branch=master)](https://travis-ci.org/renny-ren/omniauth-feishu)
|
6
7
|
|
7
8
|
## Installation
|
8
9
|
|
@@ -20,17 +21,76 @@ Or install it yourself as:
|
|
20
21
|
|
21
22
|
$ gem install omniauth-feishu
|
22
23
|
|
24
|
+
## Before You Begin
|
25
|
+
|
26
|
+
You should have already created your app in feishu platform, if not, go to https://open.feishu.cn/app/ to create one.
|
27
|
+
|
28
|
+
Take note of your App Id and App Secret because that is what your web application will use to authenticate against the Feishu API.
|
29
|
+
Make sure to set a redirect URL or else you may get authentication error.
|
30
|
+
|
23
31
|
## Usage
|
24
32
|
|
25
|
-
|
33
|
+
Here's an example for adding the middleware to a Rails app in `config/initializers/omniauth.rb`:
|
34
|
+
|
35
|
+
```ruby
|
36
|
+
Rails.application.config.middleware.use OmniAuth::Builder do
|
37
|
+
provider :feishu, 'App ID', 'App Secret'
|
38
|
+
end
|
39
|
+
```
|
40
|
+
|
41
|
+
## Devise Usage
|
42
|
+
Adapted from [Devise OmniAuth Instructions](https://github.com/plataformatec/devise/wiki/OmniAuth:-Overview)
|
26
43
|
|
27
|
-
|
44
|
+
```ruby
|
45
|
+
# app/models/user.rb
|
46
|
+
class User < ApplicationRecord
|
47
|
+
#...
|
48
|
+
devise :omniauthable, omniauth_providers: %i[feishu]
|
49
|
+
#...
|
50
|
+
end
|
51
|
+
|
52
|
+
# config/initializers/devise.rb
|
53
|
+
config.omniauth :feishu, 'App ID', 'App Secret'
|
54
|
+
|
55
|
+
# Below controller assumes callback route configuration following
|
56
|
+
# in config/routes.rb
|
57
|
+
Devise.setup do |config|
|
58
|
+
# ...
|
59
|
+
devise_for :users, controllers: { omniauth_callbacks: 'users/omniauth_callbacks' }
|
60
|
+
end
|
61
|
+
|
62
|
+
# app/controllers/users/omniauth_callbacks_controller.rb
|
63
|
+
class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController
|
64
|
+
def feishu
|
65
|
+
@user = User.from_omniauth(request.env["omniauth.auth"])
|
66
|
+
if @user.persisted?
|
67
|
+
sign_in_and_redirect @user, event: :authentication
|
68
|
+
else
|
69
|
+
session["devise.feishu"] = request.env["omniauth.auth"]
|
70
|
+
redirect_to new_user_registration_url
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
def failure
|
75
|
+
flash[:alert] = request.env["omniauth.error"]
|
76
|
+
redirect_to root_path
|
77
|
+
end
|
78
|
+
end
|
79
|
+
```
|
28
80
|
|
29
|
-
|
81
|
+
Devise will create the following url methods:
|
82
|
+
- user_feishu_omniauth_authorize_path
|
83
|
+
- user_feishu_omniauth_callback_path
|
30
84
|
|
31
|
-
|
85
|
+
So you may add a button like this:
|
86
|
+
```
|
87
|
+
<%= link_to "Sign in with feishu", user_feishu_omniauth_authorize_path, class: "btn" %>
|
88
|
+
```
|
32
89
|
|
33
90
|
## Contributing
|
34
91
|
|
35
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
92
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/renny-ren/omniauth-feishu.
|
93
|
+
|
94
|
+
## License
|
36
95
|
|
96
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
CHANGED
data/_config.yml
ADDED
data/lib/omniauth/feishu.rb
CHANGED
@@ -17,11 +17,22 @@ module OmniAuth
|
|
17
17
|
user_info_url: "https://open.feishu.cn/open-apis/authen/v1/user_info"
|
18
18
|
}
|
19
19
|
|
20
|
+
uid { raw_info['user_id'] }
|
21
|
+
|
20
22
|
info do
|
21
23
|
{
|
22
24
|
name: raw_info['name'],
|
23
25
|
email: raw_info['email'],
|
24
|
-
mobile: raw_info['mobile']
|
26
|
+
mobile: raw_info['mobile'],
|
27
|
+
avatar_url: raw_info['avatar_url'],
|
28
|
+
avatar_thumb: raw_info['avatar_thumb'],
|
29
|
+
avatar_middle: raw_info['avatar_middle'],
|
30
|
+
avatar_big: raw_info['avatar_big'],
|
31
|
+
user_id: raw_info['user_id'],
|
32
|
+
union_id: raw_info['union_id'],
|
33
|
+
open_id: raw_info['open_id'],
|
34
|
+
en_name: raw_info['en_name'],
|
35
|
+
app_access_token: @app_access_token
|
25
36
|
}
|
26
37
|
end
|
27
38
|
|
@@ -37,6 +48,12 @@ module OmniAuth
|
|
37
48
|
end
|
38
49
|
end
|
39
50
|
|
51
|
+
def authorize_params
|
52
|
+
super.tap do |params|
|
53
|
+
params[:app_id] = options.client_id
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
40
57
|
def build_access_token
|
41
58
|
resp = Faraday.post(
|
42
59
|
options.client_options.token_url,
|
data/omniauth-feishu.gemspec
CHANGED
@@ -11,12 +11,13 @@ 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
|
-
|
15
|
-
|
16
|
-
spec.
|
17
|
-
|
18
|
-
|
19
|
-
spec.
|
20
|
-
spec.
|
14
|
+
spec.add_dependency "omniauth-oauth2", "~> 1.6.0"
|
15
|
+
|
16
|
+
spec.add_development_dependency "rake"
|
17
|
+
spec.add_development_dependency "rspec"
|
18
|
+
|
19
|
+
spec.files = `git ls-files`.split("\n")
|
20
|
+
spec.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
21
|
+
spec.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
|
21
22
|
spec.require_paths = ["lib"]
|
22
23
|
end
|
metadata
CHANGED
@@ -1,26 +1,74 @@
|
|
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.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Renny
|
8
8
|
autorequire:
|
9
|
-
bindir:
|
9
|
+
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
12
|
-
dependencies:
|
11
|
+
date: 2021-07-08 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: omniauth-oauth2
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
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
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 1.6.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
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
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
13
55
|
description:
|
14
56
|
email:
|
15
57
|
- rennyallen@hotmail.com
|
16
|
-
executables:
|
58
|
+
executables:
|
59
|
+
- console
|
60
|
+
- setup
|
17
61
|
extensions: []
|
18
62
|
extra_rdoc_files: []
|
19
63
|
files:
|
20
64
|
- ".gitignore"
|
65
|
+
- ".travis.yml"
|
21
66
|
- Gemfile
|
67
|
+
- Gemfile.lock
|
68
|
+
- LICENSE
|
22
69
|
- README.md
|
23
70
|
- Rakefile
|
71
|
+
- _config.yml
|
24
72
|
- bin/console
|
25
73
|
- bin/setup
|
26
74
|
- lib/omniauth/feishu.rb
|
@@ -46,7 +94,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
46
94
|
- !ruby/object:Gem::Version
|
47
95
|
version: '0'
|
48
96
|
requirements: []
|
49
|
-
rubygems_version: 3.0.
|
97
|
+
rubygems_version: 3.0.9
|
50
98
|
signing_key:
|
51
99
|
specification_version: 4
|
52
100
|
summary: Lark(Feishu) OAuth2 Strategy for OmniAuth
|