escher-rack_middleware 0.1.4 → 0.2.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: 4cd9b0e4b7df1e4c1232946434010fee3c8ae77c
4
- data.tar.gz: 58cf8a2a29d3182c9a98ff16133efbfbdf51fefa
3
+ metadata.gz: f4a7bc5b0a47c5fbe29fbbdf6559e7376e5ff512
4
+ data.tar.gz: 69aa7a6cb082ce00306d5eb61b378a48aa003203
5
5
  SHA512:
6
- metadata.gz: 6d5935971da2f18aa7ff03982db5fdde296bdefed042738b16f92106b072ca8711e78ab292ae086015b4708b4f23b08bc3a284b644ca93d527f9b7e3aa4c2b39
7
- data.tar.gz: dfb268abc738d99e6770d0672763dec5628716599cf4ce846368da6f7916b951ea1f66575594b58b3a4dfa91dc746c66e5ea982ec4f4b6a0cf58c65d104c848c
6
+ metadata.gz: 2025d9067746de935c0773cc2975a91b44069ec6d1a2ec1c192e4b4b173c15adb3d4c6bb635ca17f6f742394c2db54a7d224263d7a2ef9d4ff4a0451eb4eec3c
7
+ data.tar.gz: a129eb14e73cca9846969f9f6307f6eb720b39e90f84fa85acc813f45f5ebdb4d845540714d6a00bc2e5db1165753100605cfa83d2645d677e6d988e1ff9213a
@@ -11,21 +11,17 @@ module Escher::RackMiddleware::Authenticator::Helper
11
11
  def authorized_with?(escher_authenticator, request_env)
12
12
 
13
13
  request_env['escher.request.api_key_id'] = escher_authenticator.authenticate(
14
- Rack::Request.new(request_env),credentials
15
- )
14
+ Rack::Request.new(request_env), credentials)
16
15
 
17
- requester_succeed_log_msg = [
18
- request_env['escher.request.api_key_id'],
19
- request_env['REQUEST_URI']
20
- ].join(' => ')
21
-
22
- logger.debug("authentication succeeded!(#{requester_succeed_log_msg})")
16
+ request_env.delete('escher.error') rescue nil
17
+ logger.debug(log_message(request_env))
23
18
 
24
19
  true
25
20
 
26
21
  rescue Escher::EscherError => ex
27
22
 
28
- logger.warn("authentication failed!(#{ex.message})")
23
+ request_env['escher.error'] = ex.message || ex.inspect
24
+ logger.warn(log_message(request_env))
29
25
 
30
26
  false
31
27
 
@@ -4,4 +4,35 @@ module Escher::RackMiddleware::Logging::Helper
4
4
  self.class.logger
5
5
  end
6
6
 
7
+ # default log object to be used if further verbosity required
8
+ def default_log_message(request_env)
9
+ {}
10
+ end
11
+
12
+ def log_message(request_env)
13
+
14
+ message = default_log_message(request_env)
15
+
16
+ regexp = /^escher\./
17
+ request_env.select { |k, v| k.to_s =~ regexp }.each do |k, v|
18
+ message[k.to_s.gsub(regexp, '')] = v
19
+ end
20
+
21
+ rack_env = Rack::Request.new(request_env)
22
+
23
+ message['request.host'] = rack_env.host
24
+ message['request.method'] = rack_env.request_method
25
+ message['request.endpoint'] = rack_env.path_info
26
+ message['requester.address'] = rack_env.ip
27
+
28
+ message['request.authentication'] = if request_env['escher.error']
29
+ 'failed'
30
+ else
31
+ 'succeeded'
32
+ end
33
+
34
+ return message.inspect
35
+
36
+ end
37
+
7
38
  end
@@ -1,2 +1,2 @@
1
1
  require 'escher/rack_middleware'
2
- Escher::RackMiddleware::VERSION = '0.1.4'
2
+ Escher::RackMiddleware::VERSION = '0.2.0'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: escher-rack_middleware
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Luzsi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-14 00:00:00.000000000 Z
11
+ date: 2015-04-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler