unimatrix 2.9.0 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 65a1bfb24d46b588eac2edb5671df43c98de1656
4
- data.tar.gz: a9ee431261fed4cd050913a52aa35c9cdf7bd166
3
+ metadata.gz: 4344e3e42d575fbf08f8267a7e0e3a546c7d48d4
4
+ data.tar.gz: 2aa2efd5c15c702fbba8b5a944210343bc838af6
5
5
  SHA512:
6
- metadata.gz: 6ba8df20d0fb3a46d8f57396a051f173996fc4001d21b6b4ebbfee7fb29072a94ffe58850f89cee09d81e714668f276d25b859e9161b43f25e76dd6ab2ad825d
7
- data.tar.gz: fc16202719fd231eae1768958705fcf414959213b44b2658416f7ecb217a45168e7826adf572234a68a3a35399c3f91ccd846c1c96996f1efb881d791c6bb3c0
6
+ metadata.gz: f1d7b43535c668da3a3df7f018f57dc9860dbbec02746abcf0c11c9ddcc3ddbebd8b1bb334e05f6ab027d2e8d6073608a4445dffea362de0808639710e3fab13
7
+ data.tar.gz: 71ec51345c28f823c5d7d40d1e6cef186c45deece4c2986c1e0af929905c130ccab30dfb156b516d541b65add88eb7c26a261fa44bf57f3443639410d5da906a
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.9.0
1
+ 3.0.0
@@ -5,31 +5,33 @@ module Unimatrix::Archivist
5
5
  include Unimatrix::Blueprintable
6
6
 
7
7
  field :id
8
+ field :uuid
9
+ field :realm_uuid
10
+ field :type_name
11
+ field :language
8
12
  field :creator_uuid
9
13
  field :picture_uuid
10
14
  field :provider
11
15
  field :provider_uid
12
16
  field :provider_url
17
+ field :name
18
+ field :short_name
13
19
  field :description
14
20
  field :short_description
15
- field :short_name
16
- field :originated_at
17
- field :destroyed_at
18
21
  field :slug
19
22
  field :note
20
- field :type_name
21
- field :language
22
- field :uuid
23
- field :realm_uuid
24
- field :component_uuids
23
+ field :legacy_id
24
+ field :legacy_uid
25
25
  field relationships: [ :category, :person, :season, :asset, :athlete ]
26
- field :name
27
26
  field :created_at
28
27
  field :updated_at
28
+ field :originated_at
29
+ field :destroyed_at
29
30
 
30
31
  has_many :artifact_locators
31
32
  has_many :artifact_relationships
32
- has_many :errors
33
+ has_many :components
34
+ has_many :errors
33
35
 
34
36
  end
35
37
 
@@ -1,7 +1,7 @@
1
1
  module Unimatrix::Archivist
2
2
 
3
3
  class Blueprint < Unimatrix::Resource
4
-
4
+
5
5
  field :id
6
6
  field :uuid
7
7
  field :realm_uuid
@@ -11,7 +11,8 @@ module Unimatrix::Archivist
11
11
  field :resource_type_name
12
12
  field :created_at
13
13
  field :updated_at
14
-
14
+ field :destroyed_at
15
+
15
16
  has_many :blueprint_attributes
16
17
  has_many :errors
17
18
 
@@ -2,14 +2,16 @@ module Unimatrix::Archivist
2
2
 
3
3
  class BlueprintAttribute < Unimatrix::Resource
4
4
 
5
- field :id
5
+ field :id
6
6
  field :uuid
7
7
  field :realm_uuid
8
+ field :type_name
8
9
  field :blueprint_uuid
9
10
  field :name
10
11
  field :readable
11
12
  field :writable
12
13
  field :type
14
+ field :allow_nil
13
15
  field :validates_uniqueness
14
16
  field :validates_uniqueness_scope
15
17
  field :validates_presence
@@ -20,13 +22,11 @@ module Unimatrix::Archivist
20
22
  field :validates_length_maximum
21
23
  field :validates_in
22
24
  field :validates_not_in
23
- field :validates_numeric
24
- field :validates_numeric_integer
25
25
  field :validates_numeric_minimum
26
26
  field :validates_numeric_maximum
27
- field :validates_type
28
27
  field :created_at
29
28
  field :updated_at
29
+ field :destroyed_at
30
30
 
31
31
  has_many :errors
32
32
 
@@ -1,14 +1,15 @@
1
1
  module Unimatrix::Archivist
2
2
 
3
- class Component < Unimatrix::DynamicResource
4
-
3
+ class Component < Unimatrix::Resource
4
+
5
5
  field :id
6
6
  field :uuid
7
7
  field :realm_uuid
8
8
  field :type_name
9
9
  field :created_at
10
10
  field :updated_at
11
-
11
+ field :destroyed_at
12
+
12
13
  has_one :artifact
13
14
  has_many :errors
14
15
 
@@ -0,0 +1,9 @@
1
+ module Unimatrix::Archivist
2
+
3
+ class EmbedComponent < Component
4
+
5
+ field :embed_code
6
+
7
+ end
8
+
9
+ end
@@ -0,0 +1,7 @@
1
+ module Unimatrix::Archivist
2
+
3
+ class GalleryComponent < Component
4
+
5
+ end
6
+
7
+ end
@@ -0,0 +1,9 @@
1
+ module Unimatrix::Archivist
2
+
3
+ class HeadlineComponent < Component
4
+
5
+ field :text
6
+
7
+ end
8
+
9
+ end
@@ -0,0 +1,11 @@
1
+ module Unimatrix::Archivist
2
+
3
+ class PictureComponent < Component
4
+
5
+ field :credit_text
6
+ field :credit_url
7
+ field :caption
8
+
9
+ end
10
+
11
+ end
@@ -0,0 +1,9 @@
1
+ module Unimatrix::Archivist
2
+
3
+ class SectionComponent < Component
4
+
5
+ field :text
6
+
7
+ end
8
+
9
+ end
@@ -0,0 +1,9 @@
1
+ module Unimatrix::Archivist
2
+
3
+ class TextComponent < Component
4
+
5
+ field :text
6
+
7
+ end
8
+
9
+ end
@@ -0,0 +1,7 @@
1
+ module Unimatrix::Archivist
2
+
3
+ class UnknownComponent < Component
4
+
5
+ end
6
+
7
+ end
@@ -0,0 +1,7 @@
1
+ module Unimatrix::Archivist
2
+
3
+ class VideoComponent < Component
4
+
5
+ end
6
+
7
+ end
@@ -9,7 +9,7 @@ module Unimatrix::Authorization
9
9
  @client_secret = args[ :client_secret ]
10
10
  end
11
11
 
12
- def request_token
12
+ def request_token( options={} )
13
13
  uri = URI.parse( "#{ Unimatrix.configuration.authorization_url }/token" )
14
14
  params = { "grant_type" => "client_credentials" }
15
15
  http = Net::HTTP.new( uri.host, uri.port )
@@ -27,7 +27,14 @@ module Unimatrix::Authorization
27
27
  body = JSON.parse( response.body )
28
28
  body = body[ 'token' ] if body[ 'token' ].present?
29
29
 
30
- body[ 'access_token' ] rescue nil
30
+ if options[ :with_expiry ]
31
+ {
32
+ access_token: ( body[ 'access_token' ] rescue nil ),
33
+ expires_in: ( body[ 'expires_in' ] rescue nil )
34
+ }
35
+ else
36
+ body[ 'access_token' ] rescue nil
37
+ end
31
38
  else
32
39
  puts "ERROR: #{ response.body }"
33
40
  end
@@ -7,7 +7,10 @@ module Unimatrix::Authorization
7
7
  end
8
8
 
9
9
  def before( controller )
10
- access_token = controller.params[ 'access_token' ]
10
+ client_id = Unimatrix.configuration.client_id
11
+ client_secret = Unimatrix.configuration.client_secret
12
+ access_token = controller.params[ 'access_token' ] || \
13
+ controller.retrieve_client_token( client_id, client_secret )
11
14
 
12
15
  realm_uuid = begin
13
16
  if controller.respond_to?( :realm_uuid )
@@ -96,6 +99,8 @@ module Unimatrix::Authorization
96
99
  realm_uuid,
97
100
  resource_server
98
101
  )
102
+ else
103
+ nil
99
104
  end
100
105
  end
101
106
 
@@ -106,6 +111,19 @@ module Unimatrix::Authorization
106
111
  access_token: access_token,
107
112
  resource: "realm/#{ realm_uuid }::#{ resource_server }::#{ resource_name }/*"
108
113
  ).read
114
+ else
115
+ nil
116
+ end
117
+ end
118
+
119
+ def request_client_token( client_id, client_secret )
120
+ if client_id && client_secret
121
+ ClientCredentialsGrant.new(
122
+ client_id: client_id,
123
+ client_secret: client_secret
124
+ ).request_token( with_expiry: true )
125
+ else
126
+ nil
109
127
  end
110
128
  end
111
129
 
@@ -3,7 +3,10 @@ module Unimatrix::Authorization
3
3
  class RequiresResourceOwner
4
4
 
5
5
  def before( controller )
6
- access_token = controller.params[ 'access_token' ]
6
+ client_id = Unimatrix.configuration.client_id
7
+ client_secret = Unimatrix.configuration.client_secret
8
+ access_token = controller.params[ 'access_token' ] || \
9
+ controller.retrieve_client_token( client_id, client_secret )
7
10
 
8
11
  if access_token.present?
9
12
  resource_owner = controller.retrieve_resource_owner( access_token )
@@ -18,6 +18,8 @@ module Unimatrix::Authorization
18
18
  ) do
19
19
  request_policies( resource_name, access_token, realm_uuid, resource_server )
20
20
  end
21
+ else
22
+ nil
21
23
  end
22
24
  end
23
25
 
@@ -29,6 +31,40 @@ module Unimatrix::Authorization
29
31
  ) do
30
32
  request_resource_owner( access_token )
31
33
  end
34
+ else
35
+ nil
36
+ end
37
+ end
38
+
39
+ def retrieve_client_token( client_id, client_secret )
40
+ if client_id && client_secret
41
+ key = [ client_id, client_secret ].join
42
+ expires_in = nil
43
+
44
+ token = Rails.cache.fetch(
45
+ "keymaker-client_token-#{ Digest::SHA1.hexdigest( key ) }",
46
+ expires_in: 1.minute
47
+ ) do
48
+ token_hash = request_client_token( client_id, client_secret )
49
+
50
+ if token_hash && token_hash[ :expires_in ] && token_hash[ :expires_in ] < 60
51
+ expires_in = token_hash[ :expires_in ]
52
+ end
53
+
54
+ token_hash[ :access_token ] rescue nil
55
+ end
56
+
57
+ if expires_in
58
+ Rails.cache.write(
59
+ "keymaker-client_token-#{ Digest::SHA1.hexdigest( key ) }",
60
+ token,
61
+ expires_in: expires_in
62
+ )
63
+ end
64
+
65
+ token
66
+ else
67
+ nil
32
68
  end
33
69
  end
34
70
 
@@ -31,6 +31,9 @@ module Unimatrix
31
31
 
32
32
  field :authorization_url, default: ENV[ 'UNIMATRIX_AUTHORIZATION_API_URL' ] ||
33
33
  'http://us-west-2.keymaker.boxxspring.net'
34
+
35
+ field :client_id, default: ENV[ 'KEYMAKER_CLIENT' ]
36
+ field :client_secret, default: ENV[ 'KEYMAKER_SECRET' ]
34
37
  end
35
38
 
36
39
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: unimatrix
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.9.0
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jackson Souza
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-06-25 00:00:00.000000000 Z
11
+ date: 2018-07-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -116,6 +116,14 @@ files:
116
116
  - lib/unimatrix/archivist/blueprint.rb
117
117
  - lib/unimatrix/archivist/blueprint_attribute.rb
118
118
  - lib/unimatrix/archivist/component.rb
119
+ - lib/unimatrix/archivist/embed_component.rb
120
+ - lib/unimatrix/archivist/gallery_component.rb
121
+ - lib/unimatrix/archivist/headline_component.rb
122
+ - lib/unimatrix/archivist/picture_component.rb
123
+ - lib/unimatrix/archivist/section_component.rb
124
+ - lib/unimatrix/archivist/text_component.rb
125
+ - lib/unimatrix/archivist/unknown_component.rb
126
+ - lib/unimatrix/archivist/video_component.rb
119
127
  - lib/unimatrix/attribute_error.rb
120
128
  - lib/unimatrix/authorization/client_credentials_grant.rb
121
129
  - lib/unimatrix/authorization/error.rb