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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d7bef3b09e1ac850ed6010582efdfb2fb6751279f6e86ab1cfbc55f1ad60eb6f
4
- data.tar.gz: 4200cef9f0e4d3801e45331b6dec4579e57e4abe8ae6b5c42ef30994918ed35c
3
+ metadata.gz: e5ae720ac596d23897dbeb2406198b453ca8fbabef9da6249dfa8d74bc6def0d
4
+ data.tar.gz: cfd5a799793ff75f5f982b669889b5019e655ecadb33ef0ce7fa3722198bb757
5
5
  SHA512:
6
- metadata.gz: 3b12f3b0768c268d351ce9edf8eae01abed9d4300a3f46add1336d8a0f7e085338959dd253d61e1e0645f571b29c1f116dd6b5a5129ad38e695bf587d7c4b14a
7
- data.tar.gz: fa41d87117206a3b5a15bccc8e9b4c701c7c4819260b642e93f451540f8608431a7f36f55d86d4f172580bf23a81e9e8a26be0cfda7394dada2e89417ba2ca29
6
+ metadata.gz: 3b73b6f6ce03ebb09534b815ce892731832501da4ecd2deacd2ec965e66ed9a660f4fb6db99acdcae511bfd05d43f4629ebf10cd881a5c96ae854544564ac03d
7
+ data.tar.gz: ee8046761d77f31f11aad1b969d68375dd31dbde7ab4287124f5b07f71c55fb4f8b0856bee4699650bf59a13f5340ff7be0ace4f1cce19b55e4653c9c5f8bdc4
@@ -0,0 +1,5 @@
1
+ language: ruby
2
+ rvm:
3
+ - '2.4.1'
4
+ - '2.5.0'
5
+ - '2.6.3'
@@ -0,0 +1,19 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ omniauth-feishu (0.1.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ rake (12.3.2)
10
+
11
+ PLATFORMS
12
+ ruby
13
+
14
+ DEPENDENCIES
15
+ omniauth-feishu!
16
+ rake (~> 12.0)
17
+
18
+ BUNDLED WITH
19
+ 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
- # Omniauth::Feishu
1
+ # OmniAuth Feishu
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/omniauth/feishu`. To experiment with that code, run `bin/console` for an interactive prompt.
3
+ Strategy to authenticate with Feishu via OAuth2 in OmniAuth.
4
4
 
5
- TODO: Delete this and the text above, and describe your gem
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
- TODO: Write usage instructions here
33
+ Here's an example for adding the middleware to a Rails app in `config/initializers/omniauth.rb`:
26
34
 
27
- ## Development
35
+ ```ruby
36
+ Rails.application.config.middleware.use OmniAuth::Builder do
37
+ provider :feishu, 'App ID', 'App Secret'
38
+ end
39
+ ```
28
40
 
29
- After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
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/[USERNAME]/omniauth-feishu.
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
@@ -1,2 +1,6 @@
1
1
  require "bundler/gem_tasks"
2
- task :default => :spec
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1 @@
1
+ theme: jekyll-theme-cayman
@@ -1,4 +1,5 @@
1
1
  require "omniauth/feishu/version"
2
+ require "omniauth/strategies/feishu"
2
3
 
3
4
  module Omniauth
4
5
  module Feishu
@@ -1,5 +1,5 @@
1
1
  module Omniauth
2
2
  module Feishu
3
- VERSION = "0.1.0"
3
+ VERSION = "0.1.2"
4
4
  end
5
5
  end
@@ -37,6 +37,12 @@ module OmniAuth
37
37
  end
38
38
  end
39
39
 
40
+ def authorize_params
41
+ super.tap do |params|
42
+ params[:app_id] = options.client_id
43
+ end
44
+ end
45
+
40
46
  def build_access_token
41
47
  resp = Faraday.post(
42
48
  options.client_options.token_url,
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.0
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-06 00:00:00.000000000 Z
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