omniauth-feishu 0.1.0 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +5 -0
- data/Gemfile.lock +19 -0
- data/LICENSE +21 -0
- data/README.md +59 -8
- data/Rakefile +5 -1
- data/_config.yml +1 -0
- data/lib/omniauth/feishu.rb +1 -0
- data/lib/omniauth/feishu/version.rb +1 -1
- data/lib/omniauth/strategies/feishu.rb +6 -0
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e5ae720ac596d23897dbeb2406198b453ca8fbabef9da6249dfa8d74bc6def0d
|
4
|
+
data.tar.gz: cfd5a799793ff75f5f982b669889b5019e655ecadb33ef0ce7fa3722198bb757
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3b73b6f6ce03ebb09534b815ce892731832501da4ecd2deacd2ec965e66ed9a660f4fb6db99acdcae511bfd05d43f4629ebf10cd881a5c96ae854544564ac03d
|
7
|
+
data.tar.gz: ee8046761d77f31f11aad1b969d68375dd31dbde7ab4287124f5b07f71c55fb4f8b0856bee4699650bf59a13f5340ff7be0ace4f1cce19b55e4653c9c5f8bdc4
|
data/.travis.yml
ADDED
data/Gemfile.lock
ADDED
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,67 @@ 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`:
|
26
34
|
|
27
|
-
|
35
|
+
```ruby
|
36
|
+
Rails.application.config.middleware.use OmniAuth::Builder do
|
37
|
+
provider :feishu, 'App ID', 'App Secret'
|
38
|
+
end
|
39
|
+
```
|
28
40
|
|
29
|
-
|
41
|
+
## Devise Usage
|
42
|
+
Adapted from [Devise OmniAuth Instructions](https://github.com/plataformatec/devise/wiki/OmniAuth:-Overview)
|
43
|
+
|
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
|
+
redirect_to root_path
|
76
|
+
end
|
77
|
+
end
|
78
|
+
```
|
30
79
|
|
31
|
-
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
80
|
|
33
81
|
## Contributing
|
34
82
|
|
35
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
83
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/renny-ren/omniauth-feishu.
|
84
|
+
|
85
|
+
## License
|
36
86
|
|
87
|
+
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
@@ -0,0 +1 @@
|
|
1
|
+
theme: jekyll-theme-cayman
|
data/lib/omniauth/feishu.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
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.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Renny
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-01-
|
11
|
+
date: 2021-01-07 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email:
|
@@ -18,9 +18,13 @@ extensions: []
|
|
18
18
|
extra_rdoc_files: []
|
19
19
|
files:
|
20
20
|
- ".gitignore"
|
21
|
+
- ".travis.yml"
|
21
22
|
- Gemfile
|
23
|
+
- Gemfile.lock
|
24
|
+
- LICENSE
|
22
25
|
- README.md
|
23
26
|
- Rakefile
|
27
|
+
- _config.yml
|
24
28
|
- bin/console
|
25
29
|
- bin/setup
|
26
30
|
- lib/omniauth/feishu.rb
|