omniauth-box2 0.0.1 → 2.0.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 +7 -0
- data/README.md +75 -15
- data/lib/omniauth/box2/version.rb +7 -0
- data/lib/omniauth/box2.rb +4 -0
- data/lib/omniauth/strategies/box.rb +57 -0
- data/lib/omniauth-box2/version.rb +3 -5
- data/lib/omniauth-box2.rb +2 -41
- data/omniauth-box2.gemspec +29 -16
- metadata +47 -31
- data/.gitignore +0 -17
- data/Gemfile +0 -4
- data/Rakefile +0 -1
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 1681f74e62caa96e65e15d9f6832ab8c4b703d9d27d820ab126bb3f433f69ec2
|
|
4
|
+
data.tar.gz: a294ab333dbf19ede72114d6b7fdbe59be9cdf27e842d3f50c09b66f5bfdbce5
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: e68f7e2cc8cfb255b4c90a22d2030a4e9a33e239035f9b59d762799892a796e7a062c866097e8df90e8a36e748496201d137d922109baa693e74b3aec29b7c9e
|
|
7
|
+
data.tar.gz: 6ac68e16746151212e3e7303000c0129946d05da6089ade90f02461781618cc2e286a066f9acee8903051f849e152199e2025d615f081523340bfd7511652a09
|
data/README.md
CHANGED
|
@@ -1,29 +1,89 @@
|
|
|
1
|
-
# OmniAuth
|
|
1
|
+
# OmniAuth Box2 Strategy
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://github.com/icoretech/omniauth-box2/actions/workflows/test.yml?query=branch%3Amain)
|
|
4
|
+
[](https://rubygems.org/gems/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
|
-
|
|
12
|
+
```ruby
|
|
13
|
+
gem 'omniauth-box2'
|
|
14
|
+
```
|
|
10
15
|
|
|
11
|
-
|
|
16
|
+
Then run:
|
|
12
17
|
|
|
13
|
-
|
|
18
|
+
```bash
|
|
19
|
+
bundle install
|
|
20
|
+
```
|
|
14
21
|
|
|
15
|
-
|
|
22
|
+
## Usage
|
|
16
23
|
|
|
17
|
-
|
|
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
|
-
##
|
|
30
|
+
## Auth Hash
|
|
31
|
+
|
|
32
|
+
Example payload from `request.env['omniauth.auth']` (real flow shape, anonymized):
|
|
33
|
+
|
|
34
|
+
```json
|
|
35
|
+
{
|
|
36
|
+
"uid": "123456789",
|
|
37
|
+
"info": {
|
|
38
|
+
"name": "Sample User",
|
|
39
|
+
"email": "sample@example.test"
|
|
40
|
+
},
|
|
41
|
+
"extra": {
|
|
42
|
+
"raw_info": {
|
|
43
|
+
"type": "user",
|
|
44
|
+
"id": "123456789",
|
|
45
|
+
"name": "Sample User",
|
|
46
|
+
"login": "sample@example.test",
|
|
47
|
+
"created_at": "2012-05-09T09:12:30-07:00",
|
|
48
|
+
"modified_at": "2026-03-04T19:21:50-08:00",
|
|
49
|
+
"language": "en",
|
|
50
|
+
"timezone": "Europe/Amsterdam",
|
|
51
|
+
"space_amount": 999999999999999,
|
|
52
|
+
"space_used": 74112195069,
|
|
53
|
+
"max_upload_size": 53687091200,
|
|
54
|
+
"status": "active",
|
|
55
|
+
"job_title": "CEO",
|
|
56
|
+
"phone": "+390000000000",
|
|
57
|
+
"address": "",
|
|
58
|
+
"avatar_url": "https://example.app.box.com/api/avatar/large/123456789",
|
|
59
|
+
"notification_email": null
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
Notes:
|
|
66
|
+
- `uid` is mapped from `raw_info.id` (as string)
|
|
67
|
+
- `info.name` is mapped from `raw_info.name`
|
|
68
|
+
- `info.email` is mapped from `raw_info.login`
|
|
69
|
+
- `extra.raw_info` is the full `users/me` response
|
|
70
|
+
|
|
71
|
+
## Provider Endpoints
|
|
72
|
+
|
|
73
|
+
The strategy uses current Box OAuth and API endpoints:
|
|
74
|
+
- Authorize URL: `https://account.box.com/api/oauth2/authorize`
|
|
75
|
+
- Token URL: `https://api.box.com/oauth2/token`
|
|
76
|
+
- User info URL: `https://api.box.com/2.0/users/me`
|
|
77
|
+
|
|
78
|
+
## Development
|
|
20
79
|
|
|
21
|
-
|
|
80
|
+
```bash
|
|
81
|
+
bundle install
|
|
82
|
+
bundle exec rake lint
|
|
83
|
+
bundle exec rake test_unit
|
|
84
|
+
bundle exec rake test_rails_integration
|
|
85
|
+
```
|
|
22
86
|
|
|
23
|
-
##
|
|
87
|
+
## License
|
|
24
88
|
|
|
25
|
-
|
|
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
|
|
89
|
+
MIT License. See `LICENSE.txt`.
|
|
@@ -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
|
data/lib/omniauth-box2.rb
CHANGED
|
@@ -1,42 +1,3 @@
|
|
|
1
|
-
|
|
1
|
+
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
|
|
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'
|
data/omniauth-box2.gemspec
CHANGED
|
@@ -1,21 +1,34 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
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
|
|
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
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
24
|
+
spec.files = Dir[
|
|
25
|
+
'lib/**/*.rb',
|
|
26
|
+
'README*',
|
|
27
|
+
'LICENSE*',
|
|
28
|
+
'*.gemspec'
|
|
29
|
+
]
|
|
30
|
+
spec.require_paths = ['lib']
|
|
19
31
|
|
|
20
|
-
|
|
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
|
-
|
|
5
|
-
version: 0.0.1
|
|
4
|
+
version: 2.0.1
|
|
6
5
|
platform: ruby
|
|
7
6
|
authors:
|
|
8
7
|
- Claudio Poli
|
|
9
|
-
autorequire:
|
|
10
8
|
bindir: bin
|
|
11
9
|
cert_chain: []
|
|
12
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
13
11
|
dependencies:
|
|
14
12
|
- !ruby/object:Gem::Dependency
|
|
15
|
-
name:
|
|
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.
|
|
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.
|
|
30
|
-
description:
|
|
45
|
+
version: '1.9'
|
|
46
|
+
description: OAuth2 strategy for OmniAuth that authenticates users with Box and exposes
|
|
47
|
+
account metadata.
|
|
31
48
|
email:
|
|
32
|
-
-
|
|
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/
|
|
48
|
-
licenses:
|
|
49
|
-
|
|
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: '
|
|
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
|
-
|
|
67
|
-
|
|
68
|
-
|
|
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
data/Gemfile
DELETED
data/Rakefile
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
require "bundler/gem_tasks"
|