boxr 0.27.0 → 0.28.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 +4 -4
- data/README.md +2 -2
- data/examples/jwt_auth.rb +2 -2
- data/lib/boxr/auth.rb +9 -8
- data/lib/boxr/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b15e90705ae77e54c7e29b60d798f78fb2f43df2
|
4
|
+
data.tar.gz: 88b53548306c6f9aecc6521f3392fe16bcfb3ce8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3bb9d947f065884e1647534bab48dd7a1127d3262e55f339982fef9d4eaef930fc1f57c85436543ddbc76a63528fcf989a2ae7f350188381b6ce3b93f355a383
|
7
|
+
data.tar.gz: a2eb5cbc5cefb115f3f5db3b39ea7654391f4a6beb3e193b5dc3a92cf5b74728bb9e51e85a3b86e93cd904e4418be8ac63203445b2547cefce563039330d8740
|
data/README.md
CHANGED
@@ -116,9 +116,9 @@ Boxr::refresh_tokens(refresh_token, client_id: ENV['BOX_CLIENT_ID'], client_secr
|
|
116
116
|
Boxr::revoke_tokens(token, client_id: ENV['BOX_CLIENT_ID'], client_secret: ENV['BOX_CLIENT_SECRET'])
|
117
117
|
|
118
118
|
#JWT methods
|
119
|
-
Boxr::get_enterprise_token(private_key: ENV['JWT_PRIVATE_KEY'], private_key_password: ENV['JWT_PRIVATE_KEY_PASSWORD'], enterprise_id: ENV['BOX_ENTERPRISE_ID'], client_id: ENV['BOX_CLIENT_ID'])
|
119
|
+
Boxr::get_enterprise_token(private_key: ENV['JWT_PRIVATE_KEY'], private_key_password: ENV['JWT_PRIVATE_KEY_PASSWORD'], enterprise_id: ENV['BOX_ENTERPRISE_ID'], client_id: ENV['BOX_CLIENT_ID'], client_secret: ENV['BOX_CLIENT_SECRET'])
|
120
120
|
|
121
|
-
Boxr::get_user_token(user_id, private_key: ENV['JWT_PRIVATE_KEY'], private_key_password: ENV['JWT_PRIVATE_KEY_PASSWORD'], client_id: ENV['BOX_CLIENT_ID'])
|
121
|
+
Boxr::get_user_token(user_id, private_key: ENV['JWT_PRIVATE_KEY'], private_key_password: ENV['JWT_PRIVATE_KEY_PASSWORD'], client_id: ENV['BOX_CLIENT_ID'], client_secret: ENV['BOX_CLIENT_SECRET'])
|
122
122
|
```
|
123
123
|
#### [Folders](https://developers.box.com/docs/#folders)
|
124
124
|
```ruby
|
data/examples/jwt_auth.rb
CHANGED
@@ -4,9 +4,9 @@ require 'awesome_print'
|
|
4
4
|
require 'openssl'
|
5
5
|
|
6
6
|
|
7
|
-
private_key = OpenSSL::PKey::RSA.new(File.read(ENV['
|
7
|
+
private_key = OpenSSL::PKey::RSA.new(File.read(ENV['JWT_PRIVATE_KEY_PATH']), ENV['JWT_PRIVATE_KEY_PASSWORD'])
|
8
8
|
|
9
9
|
#make sure ENV['BOX_ENTERPRISE_ID'] and ENV['BOX_CLIENT_ID'] are set
|
10
|
-
response = Boxr::get_enterprise_token(private_key)
|
10
|
+
response = Boxr::get_enterprise_token(private_key: private_key)
|
11
11
|
|
12
12
|
ap response
|
data/lib/boxr/auth.rb
CHANGED
@@ -25,15 +25,17 @@ module Boxr
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def self.get_enterprise_token(private_key: ENV['JWT_PRIVATE_KEY'], private_key_password: ENV['JWT_PRIVATE_KEY_PASSWORD'],
|
28
|
-
enterprise_id: ENV['BOX_ENTERPRISE_ID'], client_id: ENV['BOX_CLIENT_ID'])
|
28
|
+
enterprise_id: ENV['BOX_ENTERPRISE_ID'], client_id: ENV['BOX_CLIENT_ID'], client_secret: ENV['BOX_CLIENT_SECRET'])
|
29
29
|
unlocked_private_key = unlock_key(private_key, private_key_password)
|
30
|
-
|
30
|
+
assertion = jwt_assertion(unlocked_private_key, client_id, enterprise_id, "enterprise")
|
31
|
+
get_token(grant_type: JWT_GRANT_TYPE, assertion: assertion, client_id: client_id, client_secret: client_secret)
|
31
32
|
end
|
32
33
|
|
33
34
|
def self.get_user_token(user_id, private_key: ENV['JWT_PRIVATE_KEY'], private_key_password: ENV['JWT_PRIVATE_KEY_PASSWORD'],
|
34
|
-
client_id: ENV['BOX_CLIENT_ID'])
|
35
|
+
client_id: ENV['BOX_CLIENT_ID'], client_secret: ENV['BOX_CLIENT_SECRET'])
|
35
36
|
unlocked_private_key = unlock_key(private_key, private_key_password)
|
36
|
-
|
37
|
+
assertion = jwt_assertion(unlocked_private_key, client_id, user_id, "user")
|
38
|
+
get_token(grant_type: JWT_GRANT_TYPE, assertion: assertion, client_id: client_id, client_secret: client_secret)
|
37
39
|
end
|
38
40
|
|
39
41
|
def self.refresh_tokens(refresh_token, client_id: ENV['BOX_CLIENT_ID'], client_secret: ENV['BOX_CLIENT_SECRET'])
|
@@ -59,7 +61,7 @@ module Boxr
|
|
59
61
|
private
|
60
62
|
|
61
63
|
|
62
|
-
def self.
|
64
|
+
def self.jwt_assertion(private_key, iss, sub, box_sub_type)
|
63
65
|
payload = {
|
64
66
|
iss: iss,
|
65
67
|
sub: sub,
|
@@ -68,9 +70,8 @@ module Boxr
|
|
68
70
|
jti: SecureRandom.hex(64),
|
69
71
|
exp: (Time.now.utc + 10).to_i
|
70
72
|
}
|
71
|
-
|
72
|
-
|
73
|
-
get_token(grant_type: JWT_GRANT_TYPE, assertion: assertion)
|
73
|
+
|
74
|
+
JWT.encode(payload, private_key, "RS256")
|
74
75
|
end
|
75
76
|
|
76
77
|
def self.auth_post(uri, body)
|
data/lib/boxr/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: boxr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.28.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chad Burnette
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-08-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|