omniauth-mangoapps 0.3.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: b9ce4ff51c32194eb653845bd3c9e45c3a5590ed113377b5636eb3f3fe7e509b
4
+ data.tar.gz: ff8874cc88db8cb6b784e8856fb822c9d1e28d934deb182a72547616647538e4
5
+ SHA512:
6
+ metadata.gz: d554cfef85a9838591ded65b8e7cfcfb1cd1ac5f3c7ffd4bc7130fed4ff53977ad503941113b9f2686a46685a5b0784530c8b66248edafb6bc61d3af9394da55
7
+ data.tar.gz: c5480e4361a1ec1657ec9c93ecd9662c0ee0bb447a60feffa4fe70fe32f6bbb8e0fa3c4941b09b7defec382fcba1bced39caf168f7a30ec6894cf0e12628ed71
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in omniauth-digitalocean.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Phillip Baker
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,9 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ desc "Run specs"
5
+ RSpec::Core::RakeTask.new
6
+
7
+ desc "Default: run specs."
8
+ task :default => :spec
9
+ task :test => :spec
@@ -0,0 +1,87 @@
1
+ require 'omniauth-oauth2'
2
+ require 'multi_json'
3
+
4
+ module OmniAuth
5
+ module Strategies
6
+ #
7
+ # Authenticate to DigitalOcean via OAuth and retrieve basic user information.
8
+ # Usage:
9
+ # use OmniAuth::Strategies::Mangoapps, 'consumerkey', 'consumersecret', :scope => 'read write', :display => 'plain'
10
+ #
11
+ class Mangoapps < OmniAuth::Strategies::OAuth2
12
+ AUTHENTICATION_PARAMETERS = %w(display account state scope)
13
+ BASE_URL = "https://hub.mangoapps.com"
14
+ API_URL = "https://hub.mangoapps.com"
15
+
16
+ option :name, "mangoapps"
17
+
18
+ unless OmniAuth.config.test_mode
19
+ option :client_options, {
20
+ :authorize_url => "#{BASE_URL}/v1/oauth/authorize",
21
+ :token_url => "#{BASE_URL}/v1/oauth/token",
22
+ :site => BASE_URL
23
+ }
24
+ else
25
+ option :client_options, {
26
+ :authorize_url => "http://localhost:3000/v1/oauth/authorize",
27
+ :token_url => "http://localhost:3000/v1/oauth/token",
28
+ :site => "http://localhost:3000"
29
+ }
30
+ end
31
+
32
+ option :authorize_options, AUTHENTICATION_PARAMETERS
33
+
34
+ extra do
35
+ raw_info.parsed['account']
36
+ end
37
+
38
+ uid do
39
+ access_token.params['info']['uuid']
40
+ end
41
+
42
+ info do
43
+ access_token.params['info']
44
+ end
45
+
46
+ # Over-ride callback_url definition to maintain
47
+ # compatability with omniauth-oauth2 >= 1.4.0
48
+ #
49
+ # See: https://github.com/intridea/omniauth-oauth2/issues/81
50
+ def callback_url
51
+ full_host + script_name + callback_path
52
+ end
53
+
54
+ # Hook useful for appending parameters into the auth url before sending
55
+ # to provider.
56
+ def request_phase
57
+ super
58
+ end
59
+
60
+ # Hook used after response with code from provider. Used to prep token
61
+ # request from provider.
62
+ def callback_phase
63
+ super
64
+ end
65
+
66
+ def raw_info
67
+ @raw_info ||= access_token.get("#{API_URL}/me.json")
68
+ end
69
+
70
+ ##
71
+ # You can pass +display+, +state+ or +scope+ params to the auth request, if
72
+ # you need to set them dynamically. You can also set these options
73
+ # in the OmniAuth config :authorize_params option.
74
+ #
75
+ # /v1/auth/digialocean?display=fancy&state=ABC
76
+ #
77
+ def authorize_params
78
+ super.tap do |params|
79
+ AUTHENTICATION_PARAMETERS.each do |v|
80
+ params[v.to_sym] = request.params[v] if request.params[v]
81
+ end
82
+ end
83
+ end
84
+
85
+ end
86
+ end
87
+ end
@@ -0,0 +1,5 @@
1
+ module Omniauth
2
+ module Mangoapps
3
+ VERSION = "0.3.1"
4
+ end
5
+ end
@@ -0,0 +1,2 @@
1
+ require "omniauth-mangoapps/version"
2
+ require "omniauth/strategies/mangoapps"
@@ -0,0 +1,29 @@
1
+ lib = File.expand_path('../lib', __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require 'omniauth-mangoapps/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "omniauth-mangoapps"
7
+ spec.version = Omniauth::Mangoapps::VERSION
8
+ spec.authors = ["MangoApps API Engineering team"]
9
+ spec.email = ["api-engineering@mangoapps.com"]
10
+ spec.summary = %q{Official OmniAuth strategy for Mangoapps}
11
+ spec.description = %q{Official OmniAuth strategy for Mangoapps}
12
+ spec.homepage = "https://www.mangoapps.com"
13
+ spec.license = "MIT"
14
+
15
+ spec.files = `git ls-files`.split($/)
16
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
+ spec.require_paths = ["lib"]
19
+
20
+ spec.add_dependency "omniauth", "~> 2.0"
21
+ spec.add_dependency "omniauth-oauth2", "~> 1.0"
22
+
23
+ spec.add_development_dependency "bundler", "~> 2.0"
24
+ spec.add_development_dependency "rake"
25
+ spec.add_development_dependency "rspec", "~> 2.7"
26
+ spec.add_development_dependency "rack-test"
27
+ spec.add_development_dependency "simplecov"
28
+ spec.add_development_dependency "webmock"
29
+ end
@@ -0,0 +1,57 @@
1
+ require 'spec_helper'
2
+
3
+ describe OmniAuth::Strategies::Mangoapps do
4
+ subject do
5
+ described_class.new({})
6
+ end
7
+
8
+ describe "production client options" do
9
+ it { expect(subject.options.name).to eq("mangoapps") }
10
+
11
+ it { expect(subject.options.client_options.site).to eq("https://hub.mangoapps.com") }
12
+ it { expect(subject.options.client_options.authorize_url).to eq("https://hub.mangoapps.com/v1/oauth/authorize") }
13
+ it { expect(subject.options.client_options.token_url).to eq("https://hub.mangoapps.com/v1/oauth/token") }
14
+ end
15
+
16
+ describe "callback phase instance methods" do
17
+ let(:uuid) { 123 }
18
+ let(:response_params) {
19
+ {
20
+ 'info' => {
21
+ 'uuid' => uuid
22
+ }
23
+ }
24
+ }
25
+ let(:account_response) {
26
+ { 'account' =>
27
+ {
28
+ 'droplet_limit' => 25,
29
+ 'email' => 'foo@example.com',
30
+ 'uuid' => 'b6fc48dbf6d990634ce5f3c78dc9851e757381ef',
31
+ 'email_verified' => true
32
+ }
33
+ }
34
+ }
35
+ let(:account_json) { double(:json, parsed: account_response) }
36
+ let(:access_token) { double('AccessToken', params: response_params, get: account_json) }
37
+
38
+ before do
39
+ allow(subject).to receive(:access_token).and_return(access_token)
40
+ end
41
+
42
+ describe "#uid" do
43
+ it "returns uuid from the info hash" do
44
+ expect(subject.uid).to eq(uuid)
45
+ end
46
+ end
47
+
48
+ describe '#extra' do
49
+ it 'includes the information returned from the account endpoint' do
50
+ expect(subject.extra['droplet_limit']).to eq(25)
51
+ expect(subject.extra['email']).to eq("foo@example.com")
52
+ expect(subject.extra['uuid']).to eq("b6fc48dbf6d990634ce5f3c78dc9851e757381ef")
53
+ expect(subject.extra['email_verified']).to eq(true)
54
+ end
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,22 @@
1
+ require 'rspec'
2
+ require 'rack/test'
3
+ require 'webmock/rspec'
4
+ require 'omniauth'
5
+ require 'omniauth-digitalocean'
6
+
7
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
8
+ RSpec.configure do |config|
9
+ config.treat_symbols_as_metadata_keys_with_true_values = true
10
+ config.run_all_when_everything_filtered = true
11
+ config.filter_run :focus
12
+
13
+ config.include WebMock::API
14
+ config.include Rack::Test::Methods
15
+ config.extend OmniAuth::Test::StrategyMacros, :type => :strategy
16
+
17
+ # Run specs in random order to surface order dependencies. If you find an
18
+ # order dependency and want to debug it, you can fix the order by providing
19
+ # the seed, which is printed after each run.
20
+ # --seed 1234
21
+ config.order = 'random'
22
+ end
metadata ADDED
@@ -0,0 +1,167 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-mangoapps
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.3.1
5
+ platform: ruby
6
+ authors:
7
+ - MangoApps API Engineering team
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2022-03-03 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: omniauth
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: omniauth-oauth2
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '2.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '2.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '2.7'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '2.7'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rack-test
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: simplecov
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: webmock
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ description: Official OmniAuth strategy for Mangoapps
126
+ email:
127
+ - api-engineering@mangoapps.com
128
+ executables: []
129
+ extensions: []
130
+ extra_rdoc_files: []
131
+ files:
132
+ - ".gitignore"
133
+ - Gemfile
134
+ - LICENSE.txt
135
+ - Rakefile
136
+ - lib/omniauth-mangoapps.rb
137
+ - lib/omniauth-mangoapps/version.rb
138
+ - lib/omniauth/strategies/mangoapps.rb
139
+ - omniauth-mangoapps.gemspec
140
+ - spec/omniauth/strategies/mangoapps_spec.rb
141
+ - spec/spec_helper.rb
142
+ homepage: https://www.mangoapps.com
143
+ licenses:
144
+ - MIT
145
+ metadata: {}
146
+ post_install_message:
147
+ rdoc_options: []
148
+ require_paths:
149
+ - lib
150
+ required_ruby_version: !ruby/object:Gem::Requirement
151
+ requirements:
152
+ - - ">="
153
+ - !ruby/object:Gem::Version
154
+ version: '0'
155
+ required_rubygems_version: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - ">="
158
+ - !ruby/object:Gem::Version
159
+ version: '0'
160
+ requirements: []
161
+ rubygems_version: 3.3.7
162
+ signing_key:
163
+ specification_version: 4
164
+ summary: Official OmniAuth strategy for Mangoapps
165
+ test_files:
166
+ - spec/omniauth/strategies/mangoapps_spec.rb
167
+ - spec/spec_helper.rb