tzispa 0.4.19 → 0.4.20

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: f8c4e5038e11872df4106f2a28d1c53f0e57b5d1
4
- data.tar.gz: 0a162f26076bea941914d18026a059631491f800
3
+ metadata.gz: 3197510a2f09d089d86ccbcfb7424fce4b8192c6
4
+ data.tar.gz: 2e32c5bbab804583c89b41fea43d8b324553be9f
5
5
  SHA512:
6
- metadata.gz: 39e4591c649b0d4fe1dc624d44253397d301ce7bfe668a77628609c0024d30eab73c27b2bb500c54115d52f78c6e789c69fca5406a83823416ae8c0f193e1c16
7
- data.tar.gz: 35f3581757bc4bacf6b7be1192396282dc366a04b2fe97c83d2bd49d9dd769d6af8c8dc3b90a3acbd8a364bed28ee77d0274260f92ac47615e76861c7e9e3f2d
6
+ metadata.gz: 0934629f301584f65e53616a95ad6aebf78f1b4450f21afe118cf260eff0266c919c4a2728338b69c73dfefcfbf120620d2f1ec77125332d9c664fceaf5b433f
7
+ data.tar.gz: 6dd16f75dacdf75f6e8df2cc0aa2c6abc725ab07e465f4fdc984f7d254d30992fd9d444667bfbcb5d34243dbf5c9322b9ac5cde59d919b59962362e7c8425cbd
data/CHANGELOG.md CHANGED
@@ -2,6 +2,9 @@ Tzispa
2
2
 
3
3
  General purpose web framework
4
4
 
5
+ ## v0.4.20
6
+ - Add signed_api route and controller previous api controller is for unsigned api calls
7
+
5
8
  ## v0.4.19
6
9
  - fix cli api command errors
7
10
 
@@ -56,7 +59,7 @@ General purpose web framework
56
59
  - middleware management fixes
57
60
 
58
61
  ## v0.4.5
59
- - remove _load_assets_middleware
62
+ - remove load_assets_middleware
60
63
  - add browser detection capability
61
64
  - App environment constants names moved to app.rb
62
65
  - code beautify
@@ -4,7 +4,6 @@ require 'json'
4
4
  require 'tzispa/domain'
5
5
  require 'tzispa/controller/base'
6
6
  require 'tzispa/controller/exceptions'
7
- require 'tzispa/helpers/security'
8
7
  require 'tzispa/helpers/response'
9
8
  require 'tzispa/utils/string'
10
9
 
@@ -13,7 +12,6 @@ module Tzispa
13
12
  module Controller
14
13
  class Api < Base
15
14
 
16
- include Tzispa::Helpers::Security
17
15
  include Tzispa::Helpers::Response
18
16
 
19
17
  attr_reader :hnd
@@ -40,7 +38,6 @@ module Tzispa
40
38
 
41
39
 
42
40
  def dispatch!
43
- raise Error::InvalidSign.new unless sign?
44
41
  @handler, domain_name = context.router_params[:handler].split('.').reverse
45
42
  @domain = domain_name.nil? ? context.app.domain : Tzispa::Domain.new(name: domain_name)
46
43
  @verb = context.router_params[:verb]
@@ -121,15 +118,6 @@ module Tzispa
121
118
  response['X-API-STATE'] = "#{hnd.status}"
122
119
  end
123
120
 
124
- def sign?
125
- context.router_params[:sign] == sign_array([
126
- context.router_params[:handler],
127
- context.router_params[:verb],
128
- context.router_params[:predicate]
129
- ],
130
- context.app.config.salt)
131
- end
132
-
133
121
  end
134
122
  end
135
123
  end
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+ require 'tzispa/controller/api'
3
+ require 'tzispa/helpers/security'
4
+
5
+ module Tzispa
6
+ module Controller
7
+ class SignedApi < Api
8
+
9
+ include Tzispa::Helpers::Security
10
+
11
+
12
+ def dispatch!
13
+ raise Error::InvalidSign.new unless sign?
14
+ super
15
+ end
16
+
17
+ private
18
+
19
+ def sign?
20
+ context.router_params[:sign] == sign_array([
21
+ context.router_params[:handler],
22
+ context.router_params[:verb],
23
+ context.router_params[:predicate]
24
+ ],
25
+ context.app.config.salt)
26
+ end
27
+
28
+ end
29
+ end
30
+ end
data/lib/tzispa/routes.rb CHANGED
@@ -49,6 +49,10 @@ module Tzispa
49
49
  add :api, path, methods, controller || 'api:dispatch!'
50
50
  end
51
51
 
52
+ def signed_api(path, methods=nil, controller=nil)
53
+ add :api, path, methods, controller || 'signed_api:dispatch!'
54
+ end
55
+
52
56
  def site(path, methods=nil, controller=nil)
53
57
  add :site, path, methods, controller || 'layout:render!'
54
58
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Tzispa
4
- VERSION = '0.4.19'
4
+ VERSION = '0.4.20'
5
5
  FRAMEWORK_NAME = 'Tzispa'
6
6
  GEM_NAME = 'tzispa'
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tzispa
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.19
4
+ version: 0.4.20
5
5
  platform: ruby
6
6
  authors:
7
7
  - Juan Antonio Piñero
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-06-13 00:00:00.000000000 Z
11
+ date: 2016-06-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack
@@ -181,6 +181,7 @@ files:
181
181
  - lib/tzispa/controller/exceptions.rb
182
182
  - lib/tzispa/controller/http_error.rb
183
183
  - lib/tzispa/controller/layout.rb
184
+ - lib/tzispa/controller/signed_api.rb
184
185
  - lib/tzispa/data/entity.rb
185
186
  - lib/tzispa/domain.rb
186
187
  - lib/tzispa/http/context.rb