omniauth-webex 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 9f04a4b531b28f901575e97cd5b4d9da553c310396aa57b99217dcb98aeb102e
4
+ data.tar.gz: b6c13682014360fd3ed2d19db5bfe5290847adbc4cb075d6b093db6010ae6e8b
5
+ SHA512:
6
+ metadata.gz: a2c1e7ce242a33e99fb89b533b8c3a2a85a923ecc7ae2a069692984ebeb6a4183ddd836b72632f0206ff5b2868ef51097b3c6342d4c31a3914e112343496462a
7
+ data.tar.gz: ea090b5cdf2b222528f9ec83c5145a4ed28d2e5e6087f3f80a1dbe0d9a30c927cbaf9a11c856fcbeb78f710cf215b388c444ec8ee1838e767664c3540c86dbf9
data/.LICENSE ADDED
@@ -0,0 +1,9 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2021 Jamie Wright
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
+
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Gemfile ADDED
@@ -0,0 +1,9 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
4
+
5
+ gem "rack", ">= 2.0"
6
+
7
+ group :test do
8
+ gem "rspec", "~> 3.10.0"
9
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,77 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ omniauth-webex (0.0.1)
5
+ omniauth-oauth2 (~> 1.7)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ diff-lcs (1.4.4)
11
+ faraday (1.8.0)
12
+ faraday-em_http (~> 1.0)
13
+ faraday-em_synchrony (~> 1.0)
14
+ faraday-excon (~> 1.1)
15
+ faraday-httpclient (~> 1.0.1)
16
+ faraday-net_http (~> 1.0)
17
+ faraday-net_http_persistent (~> 1.1)
18
+ faraday-patron (~> 1.0)
19
+ faraday-rack (~> 1.0)
20
+ multipart-post (>= 1.2, < 3)
21
+ ruby2_keywords (>= 0.0.4)
22
+ faraday-em_http (1.0.0)
23
+ faraday-em_synchrony (1.0.0)
24
+ faraday-excon (1.1.0)
25
+ faraday-httpclient (1.0.1)
26
+ faraday-net_http (1.0.1)
27
+ faraday-net_http_persistent (1.2.0)
28
+ faraday-patron (1.0.0)
29
+ faraday-rack (1.0.0)
30
+ hashie (4.1.0)
31
+ jwt (2.3.0)
32
+ multi_json (1.15.0)
33
+ multi_xml (0.6.0)
34
+ multipart-post (2.1.1)
35
+ oauth2 (1.4.7)
36
+ faraday (>= 0.8, < 2.0)
37
+ jwt (>= 1.0, < 3.0)
38
+ multi_json (~> 1.3)
39
+ multi_xml (~> 0.5)
40
+ rack (>= 1.2, < 3)
41
+ omniauth (2.0.4)
42
+ hashie (>= 3.4.6)
43
+ rack (>= 1.6.2, < 3)
44
+ rack-protection
45
+ omniauth-oauth2 (1.7.1)
46
+ oauth2 (~> 1.4)
47
+ omniauth (>= 1.9, < 3)
48
+ rack (2.2.3)
49
+ rack-protection (2.1.0)
50
+ rack
51
+ rake (13.0.6)
52
+ rspec (3.10.0)
53
+ rspec-core (~> 3.10.0)
54
+ rspec-expectations (~> 3.10.0)
55
+ rspec-mocks (~> 3.10.0)
56
+ rspec-core (3.10.1)
57
+ rspec-support (~> 3.10.0)
58
+ rspec-expectations (3.10.1)
59
+ diff-lcs (>= 1.2.0, < 2.0)
60
+ rspec-support (~> 3.10.0)
61
+ rspec-mocks (3.10.2)
62
+ diff-lcs (>= 1.2.0, < 2.0)
63
+ rspec-support (~> 3.10.0)
64
+ rspec-support (3.10.2)
65
+ ruby2_keywords (0.0.5)
66
+
67
+ PLATFORMS
68
+ x86_64-darwin-19
69
+
70
+ DEPENDENCIES
71
+ omniauth-webex!
72
+ rack (>= 2.0)
73
+ rake (> 10.0.0)
74
+ rspec (~> 3.10.0)
75
+
76
+ BUNDLED WITH
77
+ 2.2.4
data/README.md ADDED
@@ -0,0 +1,124 @@
1
+ OmniAuth Webex
2
+ ==============
3
+
4
+ The [Webex](https://webex.com) strategy for [OmniAuth](https://github.com/omniauth/omniauth).
5
+
6
+ ## DESCRIPTION
7
+
8
+ The Webex strategy for OmniAuth. This is for [Webex Integrations](https://developer.webex.com/docs/integrations) to allow a user to OAuth with a Webex instance and get access to it's API.
9
+
10
+ ## INSTALLATION
11
+
12
+ Add the following to your `Gemfile`:
13
+
14
+ ```
15
+ gem "omniauth-webex"
16
+ ```
17
+
18
+ And then run `bundle install`
19
+
20
+ ## USAGE
21
+
22
+ `OmniAuth::Strategies::Webex` is simply a Rack middleware. Read the OmniAuth docs detailed instructions https://github.com/omniauth/omniauth.
23
+
24
+ ### Rails app
25
+
26
+ For a Rails app, you will need to configure it by creating an initializer in `config/initializers/omniauth.rb`. The following is an example:
27
+
28
+ ```
29
+ Rails.application.config.middleware.use OmniAuth::Builder do
30
+ provider :facebook, ENV["WEBEX_CLIENT_ID"], ENV["WEBEX_CLIENT_SECRET"],
31
+ provider_ignores_state: true,
32
+ scope: "spark:people_read"
33
+ end
34
+ ```
35
+
36
+ ### Sinatra app
37
+
38
+ For a Sinatra app, you will need to configure your Sinatra app to use the middleware. The following is an example:
39
+
40
+ ```
41
+ class MyApp < Sinatra::Base
42
+ configure do
43
+ set :sessions, true
44
+ end
45
+
46
+ use OmniAuth::Builder do
47
+ provider :webex, ENV["WEBEX_CLIENT_ID"], ENV["WEBEX_CLIENT_SECRET"],
48
+ provider_ignores_state: true,
49
+ scope: "spark:people_read"
50
+ end
51
+ end
52
+ ```
53
+
54
+ ### Auth Hash
55
+
56
+ Here is an example of the data that will be available in `request.env["omniauth.auth"]`
57
+
58
+ ```
59
+ {
60
+ "provider": "webex",
61
+ "uid": "YsdkjdfjdfklsfHDF",
62
+ "info"=> {
63
+ "id": "YsdkjdfjdfklsfHDF",
64
+ "emails": ["jimmy@example.com"],
65
+ "phoneNumbers": [],
66
+ "displayName": "Jimmy Page",
67
+ "nickName": "jimmy",
68
+ "firstName": "Jimmy",
69
+ "lastName": "Page",
70
+ "avatar": "https://avatar-prod-us-west-2.webexcontent.com/Avtr~auyadskasdhhd",
71
+ "orgId": "YHDHDKidhaH",
72
+ "created": "2021-08-19T20:59:20.767Z",
73
+ "lastModified": "2021-10-06T15:01:06.205Z",
74
+ "lastActivity": "2021-10-07T16:14:41.441Z",
75
+ "status": "active",
76
+ "type": "person"
77
+ },
78
+ "credentials": {
79
+ "token": "HGDT7DGHyds",
80
+ "refresh_token": "Zhdjks6GHD",
81
+ "expires_at": 1634832891,
82
+ "expires": true
83
+ },
84
+ "extra": {
85
+ "raw_info": {
86
+ "id": "YsdkjdfjdfklsfHDF",
87
+ "emails": ["jimmy@example.com"],
88
+ "phoneNumbers": [],
89
+ "displayName": "Jimmy Page",
90
+ "nickName": "jimmy",
91
+ "firstName": "Jimmy",
92
+ "lastName": "Page",
93
+ "avatar": "https://avatar-prod-us-west-2.webexcontent.com/Avtr~auyadskasdhhd",
94
+ "orgId": "YHDHDKidhaH",
95
+ "created": "2021-08-19T20:59:20.767Z",
96
+ "lastModified": "2021-10-06T15:01:06.205Z",
97
+ "lastActivity": "2021-10-07T16:14:41.441Z",
98
+ "status": "active",
99
+ "type": "person"
100
+ }
101
+ }
102
+ }
103
+ ```
104
+
105
+ ## RUNNING TESTS
106
+
107
+ This project is covered by unit tests. They can be run with the following command.
108
+
109
+ ```
110
+ bundle exec rake spec
111
+ ```
112
+
113
+ ## CONTRIBUTING
114
+
115
+ 1. Fork the repository `gh repo fork https://github.com/jwright/omniauth-webex`
116
+ 1. Create a feature branch `git checkout -b my-awesome-feature`
117
+ 1. Codez!
118
+ 1. Commit your changes (small commits please)
119
+ 1. Push your new branch `git push origin my-awesome-feature`
120
+ 1. Create a pull request `gh pr create --head my-fork:my-awesome-feature`
121
+
122
+ ## LICENSE
123
+
124
+ This project is licensed under the [MIT License](LICENSE.md).
data/Rakefile ADDED
@@ -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,36 @@
1
+ require "omniauth/strategies/oauth2"
2
+
3
+ module OmniAuth
4
+ module Strategies
5
+ class Webex < OmniAuth::Strategies::OAuth2
6
+ option :name, "webex"
7
+
8
+ option :authorize_options, [:scope]
9
+
10
+ option :client_options,
11
+ site: "https://webexapis.com",
12
+ authorize_url: "https://webexapis.com/v1/authorize",
13
+ token_url: "https://webexapis.com/v1/access_token"
14
+
15
+ uid { raw_info["id"] }
16
+
17
+ info do
18
+ raw_info
19
+ end
20
+
21
+ extra do
22
+ hash = {}
23
+ hash["raw_info"] = raw_info unless skip_info?
24
+ hash
25
+ end
26
+
27
+ def callback_url
28
+ full_host + script_name + callback_path
29
+ end
30
+
31
+ def raw_info
32
+ @raw_info ||= access_token.get("v1/people/me").parsed || {}
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,5 @@
1
+ module OmniAuth
2
+ module Webex
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,2 @@
1
+ require "omniauth/webex/version"
2
+ require "omniauth/strategies/webex"
@@ -0,0 +1 @@
1
+ require "omniauth/webex"
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ require File.expand_path(
4
+ File.join("..", "lib", "omniauth", "webex", "version"),
5
+ __FILE__
6
+ )
7
+
8
+ Gem::Specification.new do |s|
9
+ s.name = "omniauth-webex"
10
+ s.version = OmniAuth::Webex::VERSION
11
+ s.authors = ["Jamie Wright"]
12
+ s.email = ["jamie@brilliantfantastic.com"]
13
+ s.homepage = "https://github.com/jwright/omniauth-webex"
14
+ s.description = %(A Webex OAuth strategy for OmniAuth)
15
+ s.summary = %(A Webex OAuth strategy for OmniAuth. This allows you to add login with Webex to your Ruby apps.)
16
+ s.license = "MIT"
17
+
18
+ s.files = `git ls-files`.split("\n")
19
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
20
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
21
+ s.require_paths = ["lib"]
22
+ s.required_ruby_version = Gem::Requirement.new(">= 2.2")
23
+
24
+ s.add_dependency "omniauth-oauth2", "~> 1.7"
25
+
26
+ s.add_development_dependency "rake", "> 10.0.0"
27
+ end
@@ -0,0 +1,79 @@
1
+ require "spec_helper"
2
+
3
+ RSpec.describe OmniAuth::Strategies::Webex do
4
+ let(:raw_info) do
5
+ {
6
+ "id" => "12345",
7
+ "emails" => ["jimmy@zeppelin.com"],
8
+ "nickName" => "jimmy",
9
+ "displayName" => "Jimmy Page"
10
+ }
11
+ end
12
+
13
+ subject(:strategy) do
14
+ OmniAuth::Strategies::Webex.new("appid", "secret")
15
+ end
16
+
17
+ describe "#options" do
18
+ it "has the correct name" do
19
+ expect(strategy.options.name).to eq "webex"
20
+ end
21
+
22
+ describe "#authorize_options" do
23
+ it "includes a scope option" do
24
+ expect(strategy.options.authorize_options).to include :scope
25
+ end
26
+ end
27
+
28
+ describe "#client_options" do
29
+ it "has the correct site" do
30
+ expect(strategy.options.client_options.site).to eq "https://webexapis.com"
31
+ end
32
+
33
+ it "has the correct authorize url" do
34
+ expect(strategy.options.client_options.authorize_url).to eq "https://webexapis.com/v1/authorize"
35
+ end
36
+
37
+ it "has the correct token url" do
38
+ expect(strategy.options.client_options.token_url).to eq "https://webexapis.com/v1/access_token"
39
+ end
40
+ end
41
+
42
+ describe "#callback_url" do
43
+ let(:env) { {} }
44
+ let(:request) do
45
+ double("Request",
46
+ scheme: "https",
47
+ url: "https://somewhere.com",
48
+ script_name: "",
49
+ query_string: "?foo=bar",
50
+ env: env)
51
+ end
52
+
53
+ before do
54
+ allow(strategy).to receive(:request).and_return(request)
55
+ strategy.instance_variable_set(:@env, env)
56
+ end
57
+
58
+ it "does not contain additional parameters" do
59
+ expect(strategy.callback_url).to eq "https://somewhere.com/auth/webex/callback"
60
+ end
61
+ end
62
+
63
+ describe "#info" do
64
+ before { allow(strategy).to receive(:raw_info).and_return raw_info }
65
+
66
+ it "returns the raw info for the user" do
67
+ expect(strategy.info).to eq raw_info
68
+ end
69
+ end
70
+
71
+ describe "#uid" do
72
+ before { allow(strategy).to receive(:raw_info).and_return raw_info }
73
+
74
+ it "returns the id for the user" do
75
+ expect(strategy.uid).to eq "12345"
76
+ end
77
+ end
78
+ end
79
+ end
@@ -0,0 +1,22 @@
1
+ require "rspec"
2
+ require "omniauth/strategies/webex"
3
+
4
+ RSpec.configure do |config|
5
+ config.expect_with :rspec do |expectations|
6
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
7
+ end
8
+
9
+ config.mock_with :rspec do |mocks|
10
+ mocks.verify_partial_doubles = true
11
+ end
12
+
13
+ config.shared_context_metadata_behavior = :apply_to_host_groups
14
+ config.filter_run_when_matching :focus
15
+ config.disable_monkey_patching!
16
+ config.warnings = true
17
+ if config.files_to_run.one?
18
+ config.default_formatter = "doc"
19
+ end
20
+ config.order = :random
21
+ Kernel.srand config.seed
22
+ end
metadata ADDED
@@ -0,0 +1,86 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-webex
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Jamie Wright
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2021-10-07 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.7'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.7'
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.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.0
41
+ description: A Webex OAuth strategy for OmniAuth
42
+ email:
43
+ - jamie@brilliantfantastic.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - ".LICENSE"
49
+ - Gemfile
50
+ - Gemfile.lock
51
+ - README.md
52
+ - Rakefile
53
+ - lib/omniauth-webex.rb
54
+ - lib/omniauth/strategies/webex.rb
55
+ - lib/omniauth/webex.rb
56
+ - lib/omniauth/webex/version.rb
57
+ - omniauth-webex.gemspec
58
+ - spec/omniauth/strategies/webex_spec.rb
59
+ - spec/spec_helper.rb
60
+ homepage: https://github.com/jwright/omniauth-webex
61
+ licenses:
62
+ - MIT
63
+ metadata: {}
64
+ post_install_message:
65
+ rdoc_options: []
66
+ require_paths:
67
+ - lib
68
+ required_ruby_version: !ruby/object:Gem::Requirement
69
+ requirements:
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ version: '2.2'
73
+ required_rubygems_version: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - ">="
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ requirements: []
79
+ rubygems_version: 3.1.4
80
+ signing_key:
81
+ specification_version: 4
82
+ summary: A Webex OAuth strategy for OmniAuth. This allows you to add login with Webex
83
+ to your Ruby apps.
84
+ test_files:
85
+ - spec/omniauth/strategies/webex_spec.rb
86
+ - spec/spec_helper.rb