omniauth-digitalocean 0.0.1 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 7a2026f9593fd5db82cbc423791d3d677075ecea
4
- data.tar.gz: 2170318d211223151e5aab533e1bb2cee4d7a45e
2
+ SHA256:
3
+ metadata.gz: 570bb5803a60b925bc0e4887acd7357ef6a06a5e99743d9bfad405ed89bc9ea4
4
+ data.tar.gz: 7fd81e141f01263a8ecc20e1e962246bbb564be8f220dd8aa6630943aa55b41e
5
5
  SHA512:
6
- metadata.gz: 45c610ff7a46f2a066f2043db9d6d9600081bdd7c3ebd99f1233f72f5cbbcb7f7ebf3fd7e9b98d03a2c717ec0c025b19c205c5c907bf8491aaa7f2c8c078a005
7
- data.tar.gz: 114836396c8bd959a8fd23241824270edac9b3631ad80d389a5c398de420ada5d67330fc0658b3348c0cd0b55608370a58151e7609882ea8d76a48e056a0c754
6
+ metadata.gz: 393b6e6920c1ffe5a99a7768415edb2857d6a8b15f8bac34b511c34d8e6de47e75b31053b710f039cf44c90ea761c7736b7b496aaef115e9f1cf9fb9b07705f5
7
+ data.tar.gz: cd004a7c54f78e04fe77e1083c1721c4acf67b028569ae6c7dcc14c0ee7ec77872874dadbea4b57ac7b1768efa84225a08783889ef9f88f477d3a51f9d0f08ae
@@ -0,0 +1,36 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [ main ]
6
+ pull_request:
7
+ branches: [ main ]
8
+
9
+ jobs:
10
+ test:
11
+ strategy:
12
+ fail-fast: true
13
+ matrix:
14
+ os: [ ubuntu-latest, macos-latest ]
15
+ ruby: [ 2.5, 2.6, 2.7 ]
16
+ runs-on: ubuntu-latest
17
+ steps:
18
+ - uses: actions/checkout@v2
19
+ - uses: ruby/setup-ruby@v1
20
+ with:
21
+ ruby-version: ${{ matrix.ruby }}
22
+
23
+ # Cache dependencies.
24
+ - uses: actions/cache@v1
25
+ with:
26
+ path: vendor/bundle
27
+ key: bundle-use-ruby-${{ matrix.os }}-${{ matrix.ruby }}-${{ hashFiles('**/Gemfile.lock') }}
28
+ restore-keys: |
29
+ bundle-use-ruby-${{ matrix.os }}-${{ matrix.ruby }}-
30
+ - name: Setup
31
+ run: |
32
+ gem install bundler
33
+ bundle install --jobs 4 --retry 3
34
+ - name: Test
35
+ run: |
36
+ bundle exec rspec ./spec
@@ -0,0 +1,38 @@
1
+ # Publishes Ruby Gem for release when a tag is created
2
+ # that matches the pattern "v*" (ie. v0.1.0).
3
+ name: Publish Ruby Gem
4
+
5
+ on:
6
+ push:
7
+ tags:
8
+ - 'v*'
9
+
10
+ jobs:
11
+ build:
12
+ name: Build + Publish
13
+ runs-on: ubuntu-latest
14
+
15
+ steps:
16
+ - uses: actions/checkout@v2
17
+
18
+ - uses: actions/setup-ruby@v1
19
+ with:
20
+ ruby-version: 2.6
21
+
22
+ - uses: actions/cache@v1
23
+ with:
24
+ path: vendor/bundle
25
+ key: bundle-use-ruby-ubuntu-latest-2.6-${{ hashFiles('**/Gemfile.lock') }}
26
+ restore-keys: |
27
+ bundle-use-ruby-ubuntu-latest-2.6-
28
+
29
+ - name: Publish to RubyGems
30
+ run: |
31
+ mkdir -p $HOME/.gem
32
+ touch $HOME/.gem/credentials
33
+ chmod 0600 $HOME/.gem/credentials
34
+ printf -- "---\n:rubygems_api_key: ${RUBYGEMS_AUTH_TOKEN}\n" > $HOME/.gem/credentials
35
+ gem build *.gemspec
36
+ gem push *.gem
37
+ env:
38
+ RUBYGEMS_AUTH_TOKEN: ${{secrets.RUBYGEMS_AUTH_TOKEN}}
data/README.md CHANGED
@@ -36,9 +36,9 @@ end
36
36
 
37
37
  For additional information, refer to the [OmniAuth wiki](https://github.com/intridea/omniauth/wiki).
38
38
 
39
- See the [example](https://github.com/digitaloceancloud/omniauth-digitalocean/blob/master/example/sinatra/config.ru) Sinatra app for full examples
39
+ See the [example](https://github.com/digitaloceancloud/omniauth-digitalocean/blob/master/examples/sinatra/config.ru) Sinatra app for full examples
40
40
 
41
- Note: before running example app, please add your applicaation id and secret to ` example/config.ru ` file.
41
+ Note: before running example app, please add your application id and secret to ` example/config.ru ` file.
42
42
 
43
43
  ## License
44
44
 
@@ -0,0 +1,7 @@
1
+ # Sinatra Example
2
+
3
+ How to use omniauth-digitalocean strategy with Sinatra.
4
+
5
+ ## Setup
6
+
7
+ Create an application on http://cloud.digitalocean.com/settings/application and set the ENV variables DIGITALOCEAN_APP_ID and DIGITALOCEAN_SECRET.
@@ -3,22 +3,26 @@ require 'bundler/setup'
3
3
  require 'sinatra'
4
4
  require 'omniauth-digitalocean'
5
5
 
6
- get '/' do
7
- redirect '/auth/digitalocean'
8
- end
6
+ class DigitalOceanExample < Sinatra::Base
7
+ use Rack::Session::Cookie
9
8
 
10
- get '/auth/:provider/callback' do
11
- content_type 'text/plain'
12
- request.env['omniauth.auth'].to_hash.inspect rescue "No Data"
13
- end
9
+ get '/' do
10
+ redirect '/auth/digitalocean'
11
+ end
14
12
 
15
- get '/auth/failure' do
16
- content_type 'text/plain'
17
- request.env['omniauth.auth'].to_hash.inspect rescue "No Data"
18
- end
13
+ get '/auth/:provider/callback' do
14
+ content_type 'text/plain'
15
+ request.env['omniauth.auth'].to_hash.inspect rescue "No Data"
16
+ end
19
17
 
20
- use Rack::Session::Cookie
18
+ get '/auth/failure' do
19
+ content_type 'text/plain'
20
+ request.env['omniauth.auth'].to_hash.inspect rescue "No Data"
21
+ end
21
22
 
22
- use OmniAuth::Builder do
23
- provider :digitalocean, "2431aea9301744c9243e5777d31d6375cd4d8673f86569e125ad880b8f4f38b3", "a5e779f88e6f8053f400fb917aaa3cf89f23e2f72d85f3e375ebc02b93153787", scope: "read write"
23
+ use OmniAuth::Builder do
24
+ provider OmniAuth::Strategies::Digitalocean, ENV["DIGITALOCEAN_APP_ID"], ENV["DIGITALOCEAN_SECRET"], scope: "read write"
25
+ end
24
26
  end
27
+
28
+ run DigitalOceanExample.run!
@@ -1,5 +1,5 @@
1
1
  module Omniauth
2
2
  module Digitalocean
3
- VERSION = "0.0.1"
3
+ VERSION = "0.3.1"
4
4
  end
5
5
  end
@@ -9,10 +9,11 @@ module OmniAuth
9
9
  # use OmniAuth::Strategies::Digitalocean, 'consumerkey', 'consumersecret', :scope => 'read write', :display => 'plain'
10
10
  #
11
11
  class Digitalocean < OmniAuth::Strategies::OAuth2
12
- AUTHENTICATION_PARAMETERS = %w(display state scope)
12
+ AUTHENTICATION_PARAMETERS = %w(display account state scope)
13
13
  BASE_URL = "https://cloud.digitalocean.com"
14
+ API_URL = "https://api.digitalocean.com"
14
15
 
15
- option :name, :digitalocean
16
+ option :name, "digitalocean"
16
17
 
17
18
  unless OmniAuth.config.test_mode
18
19
  option :client_options, {
@@ -30,14 +31,26 @@ module OmniAuth
30
31
 
31
32
  option :authorize_options, AUTHENTICATION_PARAMETERS
32
33
 
34
+ extra do
35
+ raw_info.parsed['account']
36
+ end
37
+
33
38
  uid do
34
- access_token.params['uid']
39
+ access_token.params['info']['uuid']
35
40
  end
36
41
 
37
42
  info do
38
43
  access_token.params['info']
39
44
  end
40
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
+
41
54
  # Hook useful for appending parameters into the auth url before sending
42
55
  # to provider.
43
56
  def request_phase
@@ -50,6 +63,10 @@ module OmniAuth
50
63
  super
51
64
  end
52
65
 
66
+ def raw_info
67
+ @raw_info ||= access_token.get("#{API_URL}/v2/account")
68
+ end
69
+
53
70
  ##
54
71
  # You can pass +display+, +state+ or +scope+ params to the auth request, if
55
72
  # you need to set them dynamically. You can also set these options
@@ -5,11 +5,11 @@ require 'omniauth-digitalocean/version'
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = "omniauth-digitalocean"
7
7
  spec.version = Omniauth::Digitalocean::VERSION
8
- spec.authors = ["Phillip Baker"]
9
- spec.email = ["phillip@digitalocean.com"]
10
- spec.summary = %q{Oauth2 strategy for authentication via DO.}
11
- spec.description = %q{Write a longer description. Optional.}
12
- spec.homepage = ""
8
+ spec.authors = ["DigitalOcean API Engineering team"]
9
+ spec.email = ["api-engineering@digitalocean.com"]
10
+ spec.summary = %q{Official OmniAuth strategy for Digitalocean}
11
+ spec.description = %q{Official OmniAuth strategy for Digitalocean}
12
+ spec.homepage = "https://github.com/digitalocean/omniauth-digitalocean"
13
13
  spec.license = "MIT"
14
14
 
15
15
  spec.files = `git ls-files`.split($/)
@@ -17,10 +17,10 @@ Gem::Specification.new do |spec|
17
17
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
18
  spec.require_paths = ["lib"]
19
19
 
20
- spec.add_dependency "omniauth", "~> 1.0"
20
+ spec.add_dependency "omniauth", "~> 2.0"
21
21
  spec.add_dependency "omniauth-oauth2", "~> 1.0"
22
22
 
23
- spec.add_development_dependency "bundler", "~> 1.5"
23
+ spec.add_development_dependency "bundler", "~> 2.0"
24
24
  spec.add_development_dependency "rake"
25
25
  spec.add_development_dependency "rspec", "~> 2.7"
26
26
  spec.add_development_dependency "rack-test"
@@ -1,16 +1,57 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe OmniAuth::Strategies::DigitalOcean do
3
+ describe OmniAuth::Strategies::Digitalocean do
4
4
  subject do
5
- OmniAuth::Strategies::DigitalOcean.new({})
5
+ described_class.new({})
6
6
  end
7
7
 
8
- context "client options" do
9
- it { expect(subject.options.name).to eq(:digitalocean) }
8
+ describe "production client options" do
9
+ it { expect(subject.options.name).to eq("digitalocean") }
10
10
 
11
11
  it { expect(subject.options.client_options.site).to eq("https://cloud.digitalocean.com") }
12
12
  it { expect(subject.options.client_options.authorize_url).to eq("https://cloud.digitalocean.com/v1/oauth/authorize") }
13
13
  it { expect(subject.options.client_options.token_url).to eq("https://cloud.digitalocean.com/v1/oauth/token") }
14
14
  end
15
15
 
16
- end
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
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omniauth-digitalocean
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
- - Phillip Baker
7
+ - DigitalOcean API Engineering team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-22 00:00:00.000000000 Z
11
+ date: 2021-06-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: omniauth
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.0'
19
+ version: '2.0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '1.0'
26
+ version: '2.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: omniauth-oauth2
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '1.5'
47
+ version: '2.0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '1.5'
54
+ version: '2.0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rake
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -122,19 +122,22 @@ dependencies:
122
122
  - - ">="
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0'
125
- description: Write a longer description. Optional.
125
+ description: Official OmniAuth strategy for Digitalocean
126
126
  email:
127
- - phillip@digitalocean.com
127
+ - api-engineering@digitalocean.com
128
128
  executables: []
129
129
  extensions: []
130
130
  extra_rdoc_files: []
131
131
  files:
132
+ - ".github/workflows/ci.yaml"
133
+ - ".github/workflows/release.yaml"
132
134
  - ".gitignore"
133
135
  - Gemfile
134
136
  - LICENSE.txt
135
137
  - README.md
136
138
  - Rakefile
137
139
  - examples/sinatra/Gemfile
140
+ - examples/sinatra/README.md
138
141
  - examples/sinatra/config.ru
139
142
  - lib/omniauth-digitalocean.rb
140
143
  - lib/omniauth-digitalocean/version.rb
@@ -142,7 +145,7 @@ files:
142
145
  - omniauth-digitalocean.gemspec
143
146
  - spec/omniauth/strategies/digitalocean_spec.rb
144
147
  - spec/spec_helper.rb
145
- homepage: ''
148
+ homepage: https://github.com/digitalocean/omniauth-digitalocean
146
149
  licenses:
147
150
  - MIT
148
151
  metadata: {}
@@ -161,11 +164,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
161
164
  - !ruby/object:Gem::Version
162
165
  version: '0'
163
166
  requirements: []
164
- rubyforge_project:
165
- rubygems_version: 2.2.0
167
+ rubygems_version: 3.0.3.1
166
168
  signing_key:
167
169
  specification_version: 4
168
- summary: Oauth2 strategy for authentication via DO.
170
+ summary: Official OmniAuth strategy for Digitalocean
169
171
  test_files:
170
172
  - spec/omniauth/strategies/digitalocean_spec.rb
171
173
  - spec/spec_helper.rb