logstash-filter-auth0jwt 0.1.1 → 0.1.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 13944d2420bbbf12cde034a9f5f1cf67c40a4a31
4
- data.tar.gz: e57da54c0362bf6e663b3b77f7f18218f37fcdb3
3
+ metadata.gz: 735eca9fd8ea461d5e1d82d217417d3ea6baa07a
4
+ data.tar.gz: 1d9ef06731bcf034c69f8eee6c94f43832948c9b
5
5
  SHA512:
6
- metadata.gz: 2fa8568c1cd99b6808ecb756c2962574fb463d952e8548f0c25c1c589b48d62ebd08e6cd24043406290c5ccf8bf43be4470a7215b8c3e9e51dda1e68d867670a
7
- data.tar.gz: f348aeb62befac8ac28c32a0005bf621514724e9d74b92d3f75f2395fcd3825ec386ec570274dfe675682bf318c9258f5c5597409f893290f3f5d851252ffce3
6
+ metadata.gz: a152000687c1e73e9e04fb979da8b51f9840ef1a8fbd8a6b58d81e32ea808913ea28573d9acf5e7bd1ecb70d2e7724b3aa1ec8f8027343e25eeb7f83edd12779
7
+ data.tar.gz: 92199db6ac084638b6a75045431bfaf0187e6f72c5b9296b1efe8fe25d7898e39baaa019ca7414317fcde5162b47a001edd92165548d71787bb2b2fb18496028
@@ -37,13 +37,14 @@ class LogStash::Filters::Auth0Jwt < LogStash::Filters::Base
37
37
  public
38
38
  def filter(event)
39
39
 
40
+ jwt = event['jwt']
40
41
  if @last_purge - Time.now > @purge_seconds
41
42
  @cache.clear
42
43
  end
43
44
 
44
- if !@cache[event['jwt']]
45
+ if !@cache[jwt]
45
46
  data = {
46
- id_token: event['jwt']
47
+ id_token: jwt
47
48
  }
48
49
  uri = URI.parse("https://#{@domain}/tokeninfo")
49
50
  headers = {'Content-Type' => "application/json"}
@@ -53,20 +54,25 @@ class LogStash::Filters::Auth0Jwt < LogStash::Filters::Base
53
54
  request.body = data.to_json
54
55
  response = https.request(request)
55
56
 
56
- userHash = JSON.parse(response.body)
57
-
58
- include_user_properties.each { |user_property|
59
-
60
- if userHash[user_property]
61
- event.set(user_property, userHash[user_property])
62
- end
63
- }
64
-
65
- @cache[event['jwt']] = response.code == "200"
57
+ if response.code == "200"
58
+ userHash = JSON.parse(response.body)
59
+ @cache[jwt] = userHash
60
+ else
61
+ @cache[jwt] = nil
62
+ end
66
63
  end
67
64
 
68
- if @cache[event['jwt']] != true
65
+ include_user_properties.each { |user_property|
66
+ if !@cache[jwt].nil? && @cache[jwt][user_property]
67
+ event.set(user_property, @cache[jwt][user_property])
68
+ end
69
+ }
70
+
71
+ if @cache[jwt].nil?
72
+ @logger.debug("JWT not authorised, event dropped")
69
73
  event.cancel
74
+ else
75
+ @logger.debug("JWT authorised")
70
76
  end
71
77
 
72
78
  # filter_matched should go in the last line of our successful code
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'logstash-filter-auth0jwt'
3
- s.version = '0.1.1'
3
+ s.version = '0.1.2'
4
4
  s.licenses = ['Apache License (2.0)']
5
5
  s.summary = 'Logstash filter plugin for Auth0 JWT validation.'
6
6
  s.description = 'Logstash filter plugin for Auth0 JWT validation.'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-filter-auth0jwt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Price