omniauth-webex-oauth2 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 17b5b67027846ca07c3ba22efdd8dcab600ca44b
4
+ data.tar.gz: e019c303d628a9e0e5f56d67379a4a24bad05955
5
+ SHA512:
6
+ metadata.gz: 7273ec56bf6479438faf82a9f8fde0a5ae9fa7738a3aefff22d35a02fd2c30b327da58f51230fdc16f2a5423566264af640b76a54070259e986af933466dc1f9
7
+ data.tar.gz: 4ed3111c30d6ff930f0b58c55f5768e8cd350e5e200c14494a41d91a815f1e34dd36a69602206590117bfb776012a3eebdc013d9436007291d0f69ddea45cb60
@@ -0,0 +1,50 @@
1
+ *.gem
2
+ *.rbc
3
+ /.config
4
+ /coverage/
5
+ /InstalledFiles
6
+ /pkg/
7
+ /spec/reports/
8
+ /spec/examples.txt
9
+ /test/tmp/
10
+ /test/version_tmp/
11
+ /tmp/
12
+
13
+ # Used by dotenv library to load environment variables.
14
+ # .env
15
+
16
+ ## Specific to RubyMotion:
17
+ .dat*
18
+ .repl_history
19
+ build/
20
+ *.bridgesupport
21
+ build-iPhoneOS/
22
+ build-iPhoneSimulator/
23
+
24
+ ## Specific to RubyMotion (use of CocoaPods):
25
+ #
26
+ # We recommend against adding the Pods directory to your .gitignore. However
27
+ # you should judge for yourself, the pros and cons are mentioned at:
28
+ # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
29
+ #
30
+ # vendor/Pods/
31
+
32
+ ## Documentation cache and generated files:
33
+ /.yardoc/
34
+ /_yardoc/
35
+ /doc/
36
+ /rdoc/
37
+
38
+ ## Environment normalization:
39
+ /.bundle/
40
+ /vendor/bundle
41
+ /lib/bundler/man/
42
+
43
+ # for a library or gem, you might want to ignore these files since the code is
44
+ # intended to run in multiple environments; otherwise, check them in:
45
+ # Gemfile.lock
46
+ # .ruby-version
47
+ # .ruby-gemset
48
+
49
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
50
+ .rvmrc
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
@@ -0,0 +1,7 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.6
4
+ - 2.3.3
5
+ - 2.4.0
6
+ before_install:
7
+ - gem install bundler -v 1.16.1
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
4
+ gem 'pry'
5
+ gem 'pry-coolline'
6
+ gem 'pry-nav'
@@ -0,0 +1,72 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ omniauth-webex-oauth2 (0.0.1)
5
+ omniauth-oauth2 (~> 1.2)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ coderay (1.1.2)
11
+ coolline (0.5.0)
12
+ unicode_utils (~> 1.4)
13
+ diff-lcs (1.2.5)
14
+ faraday (0.9.2)
15
+ multipart-post (>= 1.2, < 3)
16
+ hashie (3.4.4)
17
+ jwt (1.5.4)
18
+ method_source (0.8.2)
19
+ multi_json (1.12.2)
20
+ multi_xml (0.5.5)
21
+ multipart-post (2.0.0)
22
+ oauth2 (1.2.0)
23
+ faraday (>= 0.8, < 0.10)
24
+ jwt (~> 1.0)
25
+ multi_json (~> 1.3)
26
+ multi_xml (~> 0.5)
27
+ rack (>= 1.2, < 3)
28
+ omniauth (1.3.1)
29
+ hashie (>= 1.2, < 4)
30
+ rack (>= 1.0, < 3)
31
+ omniauth-oauth2 (1.3.1)
32
+ oauth2 (~> 1.0)
33
+ omniauth (~> 1.2)
34
+ pry (0.10.4)
35
+ coderay (~> 1.1.0)
36
+ method_source (~> 0.8.1)
37
+ slop (~> 3.4)
38
+ pry-coolline (0.2.5)
39
+ coolline (~> 0.5)
40
+ pry-nav (0.2.4)
41
+ pry (>= 0.9.10, < 0.11.0)
42
+ rack (1.6.8)
43
+ rake (10.1.0)
44
+ rspec (3.4.0)
45
+ rspec-core (~> 3.4.0)
46
+ rspec-expectations (~> 3.4.0)
47
+ rspec-mocks (~> 3.4.0)
48
+ rspec-core (3.4.4)
49
+ rspec-support (~> 3.4.0)
50
+ rspec-expectations (3.4.0)
51
+ diff-lcs (>= 1.2.0, < 2.0)
52
+ rspec-support (~> 3.4.0)
53
+ rspec-mocks (3.4.1)
54
+ diff-lcs (>= 1.2.0, < 2.0)
55
+ rspec-support (~> 3.4.0)
56
+ rspec-support (3.4.1)
57
+ slop (3.6.0)
58
+ unicode_utils (1.4.0)
59
+
60
+ PLATFORMS
61
+ ruby
62
+
63
+ DEPENDENCIES
64
+ omniauth-webex-oauth2!
65
+ pry
66
+ pry-coolline
67
+ pry-nav
68
+ rake (~> 10.0)
69
+ rspec (~> 3.4)
70
+
71
+ BUNDLED WITH
72
+ 1.16.2
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2018 Suhas Nehete
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.
@@ -0,0 +1,47 @@
1
+ # OmniAuth::Strategies::Webex
2
+
3
+ OAuth2 Strategy for [Cisco WebEx Teams (Cisco Spark)](https://www.webex.com/products/teams/index.html)
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile along with OmniAuth:
8
+
9
+ ```ruby
10
+ gem 'omniauth'
11
+ gem 'omniauth-webex-oauth2'
12
+ ```
13
+
14
+ And then execute:
15
+
16
+ $ bundle
17
+
18
+ Or install it yourself as:
19
+
20
+ $ gem install omniauth-webex-oauth2
21
+
22
+ ## Usage
23
+
24
+ You can register your application [here](https://developer.webex.com/authentication.html) and get `client_id` & `client_secret`.
25
+
26
+ Here's an example for adding the middleware to a Rails app in config/initializers/omniauth.rb:
27
+ ```ruby
28
+ Rails.application.config.middleware.use OmniAuth::Builder do
29
+ provider :webex, ENV["WEBEX_CLIENT_ID"], ENV["WEBEX_CLIENT_SECRET"]
30
+ end
31
+ ```
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome.
36
+
37
+ 1. Fork it
38
+ 2. Create your feature branch (`git checkout -b new-feature`)
39
+ 3. Commit your changes along with test cases (`git commit -m 'Add feature'`)
40
+ 4. If possible squash your commits to one commit if they all belong to same feature.
41
+ 5. Push to the branch (`git push origin new-feature`)
42
+ 6. Create new Pull Request.
43
+
44
+
45
+ ## License
46
+
47
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
@@ -0,0 +1,6 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task default: :spec
@@ -0,0 +1 @@
1
+ require File.join('omniauth', 'webex')
@@ -0,0 +1,28 @@
1
+ require 'omniauth-oauth2'
2
+ module OmniAuth
3
+ module Strategies
4
+ class Webex < OmniAuth::Strategies::OAuth2
5
+ option :name, 'webex'
6
+
7
+ option :client_options, {
8
+ authorize_url: 'https://api.ciscospark.com/v1/authorize',
9
+ token_url: 'https://api.ciscospark.com/v1/access_token'
10
+ }
11
+
12
+ def authorize_params
13
+ options.authorize_params[:scope] = 'spark-compliance:memberships_read spark:all spark-compliance:memberships_write spark-admin:people_write spark-admin:roles_read spark-admin:organizations_read spark-compliance:events_read spark-compliance:rooms_read spark-compliance:team_memberships_read spark-compliance:messages_write spark:kms spark-compliance:team_memberships_write spark-compliance:teams_read spark-admin:licenses_read spark-compliance:messages_read spark-admin:people_read'
14
+ super
15
+ end
16
+
17
+ def build_access_token
18
+ Rails.logger.debug 'Omniauth build access token'
19
+ options.token_params[:headers] = { 'Authorization' => basic_auth_header }
20
+ super
21
+ end
22
+
23
+ def basic_auth_header
24
+ 'Basic '
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1 @@
1
+ require File.join('omniauth', 'strategies', 'webex')
@@ -0,0 +1,5 @@
1
+ module OmniAuth
2
+ module Webex
3
+ VERSION = '0.0.1'
4
+ end
5
+ end
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ puts lib
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+ require 'omniauth/webex/version'
6
+
7
+ Gem::Specification.new do |spec|
8
+ spec.name = 'omniauth-webex-oauth2'
9
+ spec.version = OmniAuth::Webex::VERSION
10
+ spec.authors = ['Suhas Nehete']
11
+ spec.email = ['suhas0284@gmail.com']
12
+
13
+ spec.summary = %q{A Cisco WebEx Teams (Cisco Spark) OAuth2 strategy.}
14
+ spec.description = %q{A Cisco WebEx Teams (Cisco Spark) OAuth2 strategy. Create account and generate client_id and client_secret.}
15
+ spec.homepage = 'https://github.com/suhaspan/omniauth-webex-oauth2'
16
+ spec.license = 'MIT'
17
+
18
+ spec.files = `git ls-files -z`.split("\x0")
19
+ spec.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
20
+ spec.require_paths = ['lib']
21
+
22
+ spec.add_runtime_dependency 'omniauth-oauth2', '~> 1.2'
23
+
24
+ spec.add_development_dependency 'rake', '~> 10.0'
25
+ spec.add_development_dependency 'rspec', '~> 3.4'
26
+ end
@@ -0,0 +1,64 @@
1
+ require 'spec_helper'
2
+ require 'omniauth-webex-oauth2'
3
+
4
+ describe OmniAuth::Strategies::Webex do
5
+ let(:request) { double('Request', :params => {}, :cookies => {}, :env => {}) }
6
+ let(:app) {
7
+ lambda do
8
+ [200, {}, ["Hello."]]
9
+ end
10
+ }
11
+
12
+ subject do
13
+ OmniAuth::Strategies::Webex.new(app, 'appid', 'secret', @options || {}).tap do |strategy|
14
+ allow(strategy).to receive(:request) {
15
+ request
16
+ }
17
+ end
18
+ end
19
+
20
+ before do
21
+ OmniAuth.config.test_mode = true
22
+ end
23
+
24
+ after do
25
+ OmniAuth.config.test_mode = false
26
+ end
27
+
28
+ it 'has a version number' do
29
+ expect(OmniAuth::Webex::VERSION).not_to be nil
30
+ end
31
+
32
+ describe '#client_options' do
33
+ it 'has correct authorize_url' do
34
+ expect(subject.client.options[:authorize_url]).to eq('https://api.ciscospark.com/v1/authorize')
35
+ end
36
+
37
+ it 'has correct token_url' do
38
+ expect(subject.client.options[:token_url]).to eq('https://api.ciscospark.com/v1/access_token')
39
+ end
40
+ end
41
+
42
+ describe '#callback_path' do
43
+ it 'has the correct callback path' do
44
+ expect(subject.callback_path).to eq('/auth/webex/callback')
45
+ end
46
+ end
47
+
48
+ describe '#access_token' do
49
+ before :each do
50
+ response = double('access token',
51
+ access_token: 'access_token',
52
+ refresh_token: 'refresh_token',
53
+ expires_in: 3600,
54
+ expires_at: 12345,
55
+ ).as_null_object
56
+ allow(subject).to receive(:access_token) { response }
57
+ end
58
+
59
+ it { expect(subject.access_token.access_token).to eq('access_token') }
60
+ it { expect(subject.access_token.expires_in).to eq(3600) }
61
+ it { expect(subject.access_token.expires_at).to eq(12345) }
62
+ it { expect(subject.access_token.refresh_token).to eq('refresh_token') }
63
+ end
64
+ end
@@ -0,0 +1,2 @@
1
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
2
+ require 'omniauth/webex'
metadata ADDED
@@ -0,0 +1,104 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-webex-oauth2
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Suhas Nehete
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2018-07-06 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.2'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.2'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.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: '3.4'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.4'
55
+ description: A Cisco WebEx Teams (Cisco Spark) OAuth2 strategy. Create account and
56
+ generate client_id and client_secret.
57
+ email:
58
+ - suhas0284@gmail.com
59
+ executables: []
60
+ extensions: []
61
+ extra_rdoc_files: []
62
+ files:
63
+ - ".gitignore"
64
+ - ".rspec"
65
+ - ".travis.yml"
66
+ - Gemfile
67
+ - Gemfile.lock
68
+ - LICENSE
69
+ - README.md
70
+ - Rakefile
71
+ - lib/omniauth-webex-oauth2.rb
72
+ - lib/omniauth/strategies/webex.rb
73
+ - lib/omniauth/webex.rb
74
+ - lib/omniauth/webex/version.rb
75
+ - omniauth-webex-oauth2.gemspec
76
+ - spec/omniauth/strategies/webex_spec.rb
77
+ - spec/spec_helper.rb
78
+ homepage: https://github.com/suhaspan/omniauth-webex-oauth2
79
+ licenses:
80
+ - MIT
81
+ metadata: {}
82
+ post_install_message:
83
+ rdoc_options: []
84
+ require_paths:
85
+ - lib
86
+ required_ruby_version: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - ">="
89
+ - !ruby/object:Gem::Version
90
+ version: '0'
91
+ required_rubygems_version: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - ">="
94
+ - !ruby/object:Gem::Version
95
+ version: '0'
96
+ requirements: []
97
+ rubyforge_project:
98
+ rubygems_version: 2.6.14
99
+ signing_key:
100
+ specification_version: 4
101
+ summary: A Cisco WebEx Teams (Cisco Spark) OAuth2 strategy.
102
+ test_files:
103
+ - spec/omniauth/strategies/webex_spec.rb
104
+ - spec/spec_helper.rb