logstash-filter-auth0jwt 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/logstash/filters/auth0jwt.rb +19 -13
- data/logstash-filter-auth0jwt.gemspec +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 735eca9fd8ea461d5e1d82d217417d3ea6baa07a
|
4
|
+
data.tar.gz: 1d9ef06731bcf034c69f8eee6c94f43832948c9b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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[
|
45
|
+
if !@cache[jwt]
|
45
46
|
data = {
|
46
|
-
id_token:
|
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
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
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
|
-
|
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.
|
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.'
|