omniauth-box2 0.0.1 → 2.0.0

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 1eb42982286259f28f744e65e152b418b989729467d9d400aa3cc96b9eed2006
4
+ data.tar.gz: abd212dc0f629ab6f3fec9793165f75b9f933fbc168d2f746e449ceeea985a9c
5
+ SHA512:
6
+ metadata.gz: f79a41d5bf8927c0d9319f9feaa67b85e4811ac93478f9be61377e835aefc6654f0e04d53974865c33519fe7296f8ac224ed6e70564cb7cb5ca06e078f83f963
7
+ data.tar.gz: b7c668819a26117dca2ff8ec2184546bbfdd1186a06ae2d1a3b11a08a8bc74bf0376a9474d684172ef66376901268aa3e383268ced221a2b2562a82f5b9a4bc3
data/README.md CHANGED
@@ -1,29 +1,54 @@
1
- # OmniAuth Box Strategy
1
+ # OmniAuth Box2 Strategy
2
2
 
3
- This gem provides a simple way to authenticate to Box using OmniAuth with OAuth2.
3
+ [![Test](https://github.com/icoretech/omniauth-box2/actions/workflows/test.yml/badge.svg)](https://github.com/icoretech/omniauth-box2/actions/workflows/test.yml)
4
+ [![Gem Version](https://badge.fury.io/rb/omniauth-box2.svg)](https://badge.fury.io/rb/omniauth-box2)
5
+
6
+ This gem provides an [OmniAuth](https://github.com/omniauth/omniauth) strategy for Box OAuth2.
4
7
 
5
8
  ## Installation
6
9
 
7
10
  Add this line to your application's Gemfile:
8
11
 
9
- gem 'omniauth-box2'
12
+ ```ruby
13
+ gem 'omniauth-box2'
14
+ ```
10
15
 
11
- And then execute:
16
+ Then run:
12
17
 
13
- $ bundle
18
+ ```bash
19
+ bundle install
20
+ ```
14
21
 
15
- Or install it yourself as:
22
+ ## Usage
16
23
 
17
- $ gem install omniauth-box2
24
+ ```ruby
25
+ Rails.application.config.middleware.use OmniAuth::Builder do
26
+ provider :box, ENV.fetch('BOX_CLIENT_ID'), ENV.fetch('BOX_CLIENT_SECRET')
27
+ end
28
+ ```
18
29
 
19
- ## Usage
30
+ Auth hash fields exposed by this strategy:
31
+ - `uid` from Box user `id`
32
+ - `info[:name]` from Box user `name`
33
+ - `info[:email]` from Box user `login`
34
+ - `extra['raw_info']` full Box user payload
35
+
36
+ ## Provider Endpoints
37
+
38
+ The strategy uses current Box OAuth and API endpoints:
39
+ - Authorize URL: `https://account.box.com/api/oauth2/authorize`
40
+ - Token URL: `https://api.box.com/oauth2/token`
41
+ - User info URL: `https://api.box.com/2.0/users/me`
42
+
43
+ ## Development
20
44
 
21
- TODO: Write usage instructions here
45
+ ```bash
46
+ bundle install
47
+ bundle exec rake lint
48
+ bundle exec rake test_unit
49
+ bundle exec rake test_rails_integration
50
+ ```
22
51
 
23
- ## Contributing
52
+ ## License
24
53
 
25
- 1. Fork it
26
- 2. Create your feature branch (`git checkout -b my-new-feature`)
27
- 3. Commit your changes (`git commit -am 'Add some feature'`)
28
- 4. Push to the branch (`git push origin my-new-feature`)
29
- 5. Create new Pull Request
54
+ MIT License. See `LICENSE.txt`.
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module OmniAuth
4
+ module Box2
5
+ VERSION = '2.0.0'
6
+ end
7
+ end
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'omniauth/box2/version'
4
+ require 'omniauth/strategies/box'
@@ -0,0 +1,57 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'omniauth-oauth2'
4
+
5
+ module OmniAuth
6
+ module Strategies
7
+ # OmniAuth strategy for Box OAuth2.
8
+ class Box < OmniAuth::Strategies::OAuth2
9
+ option :name, 'box'
10
+
11
+ option :client_options,
12
+ site: 'https://api.box.com/2.0',
13
+ authorize_url: 'https://account.box.com/api/oauth2/authorize',
14
+ token_url: 'https://api.box.com/oauth2/token',
15
+ connection_opts: {
16
+ headers: {
17
+ user_agent: 'icoretech-omniauth-box2 gem',
18
+ accept: 'application/json',
19
+ content_type: 'application/json'
20
+ }
21
+ }
22
+
23
+ uid { raw_info['id'].to_s }
24
+
25
+ info do
26
+ {
27
+ name: raw_info['name'],
28
+ email: raw_info['login']
29
+ }.compact
30
+ end
31
+
32
+ extra do
33
+ {
34
+ 'raw_info' => raw_info
35
+ }
36
+ end
37
+
38
+ def raw_info
39
+ @raw_info ||= access_token.get('users/me').parsed
40
+ end
41
+
42
+ # Ensure token exchange uses a stable callback URI that matches provider config.
43
+ def callback_url
44
+ options[:callback_url] || super
45
+ end
46
+
47
+ # Prevent authorization response params from being appended to redirect_uri.
48
+ def query_string
49
+ return '' if request.params['code']
50
+
51
+ super
52
+ end
53
+ end
54
+
55
+ Box2 = Box
56
+ end
57
+ end
@@ -1,5 +1,3 @@
1
- module Omniauth
2
- module Box2
3
- VERSION = "0.0.1"
4
- end
5
- end
1
+ # frozen_string_literal: true
2
+
3
+ require 'omniauth/box2/version'
data/lib/omniauth-box2.rb CHANGED
@@ -1,42 +1,3 @@
1
- require 'omniauth/strategies/oauth2'
1
+ # frozen_string_literal: true
2
2
 
3
- module OmniAuth
4
- module Strategies
5
- class Box < OmniAuth::Strategies::OAuth2
6
- # Give your strategy a name.
7
- option :name, "box"
8
-
9
- # This is where you pass the options you would pass when
10
- # initializing your consumer from the OAuth gem.
11
- option :client_options, {
12
- :site => 'https://api.box.com/2.0',
13
- :authorize_url => 'https://api.box.com/oauth2/authorize',
14
- :token_url => 'https://api.box.com/oauth2/token',
15
- }
16
-
17
- # These are called after authentication has succeeded. If
18
- # possible, you should try to set the UID without making
19
- # additional calls (if the user id is returned with the token
20
- # or as a URI parameter). This may not be possible with all
21
- # providers.
22
- uid{ raw_info['id'] }
23
-
24
- info do
25
- {
26
- :name => raw_info['name'],
27
- :email => raw_info['email']
28
- }
29
- end
30
-
31
- extra do
32
- {
33
- 'raw_info' => raw_info
34
- }
35
- end
36
-
37
- def raw_info
38
- @raw_info ||= access_token.get('users/me').parsed
39
- end
40
- end
41
- end
42
- end
3
+ require 'omniauth/box2'
@@ -1,21 +1,34 @@
1
- # -*- encoding: utf-8 -*-
2
- lib = File.expand_path('../lib', __FILE__)
1
+ # frozen_string_literal: true
2
+
3
+ lib = File.expand_path('lib', __dir__)
3
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'omniauth-box2/version'
5
+ require 'omniauth/box2/version'
6
+
7
+ Gem::Specification.new do |spec|
8
+ spec.name = 'omniauth-box2'
9
+ spec.version = OmniAuth::Box2::VERSION
10
+ spec.authors = ['Claudio Poli']
11
+ spec.email = ['masterkain@gmail.com']
12
+
13
+ spec.summary = 'OmniAuth strategy for Box OAuth2 authentication.'
14
+ spec.description = 'OAuth2 strategy for OmniAuth that authenticates users with Box and exposes account metadata.'
15
+ spec.homepage = 'https://github.com/icoretech/omniauth-box2'
16
+ spec.license = 'MIT'
17
+ spec.required_ruby_version = '>= 3.2'
5
18
 
6
- Gem::Specification.new do |gem|
7
- gem.name = "omniauth-box2"
8
- gem.version = Omniauth::Box2::VERSION
9
- gem.authors = ["Claudio Poli"]
10
- gem.email = ["masterkain@gmail.com\n"]
11
- gem.description = %q{OmniAuth strategy for Box}
12
- gem.summary = %q{OmniAuth strategy for Box}
13
- gem.homepage = "https://github.com/masterkain/omniauth-box2"
19
+ spec.metadata['source_code_uri'] = 'https://github.com/icoretech/omniauth-box2'
20
+ spec.metadata['bug_tracker_uri'] = 'https://github.com/icoretech/omniauth-box2/issues'
21
+ spec.metadata['changelog_uri'] = 'https://github.com/icoretech/omniauth-box2/releases'
22
+ spec.metadata['rubygems_mfa_required'] = 'true'
14
23
 
15
- gem.files = `git ls-files`.split($/)
16
- gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
- gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
- gem.require_paths = ["lib"]
24
+ spec.files = Dir[
25
+ 'lib/**/*.rb',
26
+ 'README*',
27
+ 'LICENSE*',
28
+ '*.gemspec'
29
+ ]
30
+ spec.require_paths = ['lib']
19
31
 
20
- gem.add_dependency 'omniauth', '~> 1.0'
32
+ spec.add_dependency 'cgi', '>= 0.3.6'
33
+ spec.add_dependency 'omniauth-oauth2', '>= 1.8', '< 1.9'
21
34
  end
metadata CHANGED
@@ -1,71 +1,87 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omniauth-box2
3
3
  version: !ruby/object:Gem::Version
4
- prerelease:
5
- version: 0.0.1
4
+ version: 2.0.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Claudio Poli
9
- autorequire:
10
8
  bindir: bin
11
9
  cert_chain: []
12
- date: 2013-02-16 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
13
11
  dependencies:
14
12
  - !ruby/object:Gem::Dependency
15
- name: omniauth
13
+ name: cgi
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - ">="
17
+ - !ruby/object:Gem::Version
18
+ version: 0.3.6
16
19
  type: :runtime
20
+ prerelease: false
21
+ version_requirements: !ruby/object:Gem::Requirement
22
+ requirements:
23
+ - - ">="
24
+ - !ruby/object:Gem::Version
25
+ version: 0.3.6
26
+ - !ruby/object:Gem::Dependency
27
+ name: omniauth-oauth2
17
28
  requirement: !ruby/object:Gem::Requirement
18
- none: false
19
29
  requirements:
20
- - - ~>
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: '1.8'
33
+ - - "<"
21
34
  - !ruby/object:Gem::Version
22
- version: '1.0'
35
+ version: '1.9'
36
+ type: :runtime
23
37
  prerelease: false
24
38
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
39
  requirements:
27
- - - ~>
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ version: '1.8'
43
+ - - "<"
28
44
  - !ruby/object:Gem::Version
29
- version: '1.0'
30
- description: OmniAuth strategy for Box
45
+ version: '1.9'
46
+ description: OAuth2 strategy for OmniAuth that authenticates users with Box and exposes
47
+ account metadata.
31
48
  email:
32
- - ! 'masterkain@gmail.com
33
-
34
- '
49
+ - masterkain@gmail.com
35
50
  executables: []
36
51
  extensions: []
37
52
  extra_rdoc_files: []
38
53
  files:
39
- - .gitignore
40
- - Gemfile
41
54
  - LICENSE.txt
42
55
  - README.md
43
- - Rakefile
44
56
  - lib/omniauth-box2.rb
45
57
  - lib/omniauth-box2/version.rb
58
+ - lib/omniauth/box2.rb
59
+ - lib/omniauth/box2/version.rb
60
+ - lib/omniauth/strategies/box.rb
46
61
  - omniauth-box2.gemspec
47
- homepage: https://github.com/masterkain/omniauth-box2
48
- licenses: []
49
- post_install_message:
62
+ homepage: https://github.com/icoretech/omniauth-box2
63
+ licenses:
64
+ - MIT
65
+ metadata:
66
+ source_code_uri: https://github.com/icoretech/omniauth-box2
67
+ bug_tracker_uri: https://github.com/icoretech/omniauth-box2/issues
68
+ changelog_uri: https://github.com/icoretech/omniauth-box2/releases
69
+ rubygems_mfa_required: 'true'
50
70
  rdoc_options: []
51
71
  require_paths:
52
72
  - lib
53
73
  required_ruby_version: !ruby/object:Gem::Requirement
54
- none: false
55
74
  requirements:
56
- - - ! '>='
75
+ - - ">="
57
76
  - !ruby/object:Gem::Version
58
- version: '0'
77
+ version: '3.2'
59
78
  required_rubygems_version: !ruby/object:Gem::Requirement
60
- none: false
61
79
  requirements:
62
- - - ! '>='
80
+ - - ">="
63
81
  - !ruby/object:Gem::Version
64
82
  version: '0'
65
83
  requirements: []
66
- rubyforge_project:
67
- rubygems_version: 1.8.24
68
- signing_key:
69
- specification_version: 3
70
- summary: OmniAuth strategy for Box
84
+ rubygems_version: 3.6.9
85
+ specification_version: 4
86
+ summary: OmniAuth strategy for Box OAuth2 authentication.
71
87
  test_files: []
data/.gitignore DELETED
@@ -1,17 +0,0 @@
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 DELETED
@@ -1,4 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- # Specify your gem's dependencies in omniauth-box2.gemspec
4
- gemspec
data/Rakefile DELETED
@@ -1 +0,0 @@
1
- require "bundler/gem_tasks"