Class: LogStash::Filters::JWTDecode
- Inherits:
-
Base
- Object
- Base
- LogStash::Filters::JWTDecode
- Defined in:
- lib/logstash/filters/jwt-decode.rb
Overview
This filter will decode the jwt token in your message event and retrievs the values as specified in ‘extract_fields` and adds the extracted values to the event.
It is only intended to be used as an .
Instance Method Summary collapse
Instance Method Details
#filter(event) ⇒ Object
40 41 42 43 44 45 46 47 |
# File 'lib/logstash/filters/jwt-decode.rb', line 40 def filter(event) decoded_token = JWT.decode event.get(@match), @key, false, {algorithm: @signature_alg} @extract_fields.each do |k, v| event.set(k , getValueFromDecodedToken(v, decoded_token[0])) end # filter_matched should go in the last line of our successful code filter_matched(event) end |
#register ⇒ Object
32 33 34 35 36 37 |
# File 'lib/logstash/filters/jwt-decode.rb', line 32 def register # Add instance variables if not ['NONE', 'HMAC', 'RSASSA', 'ECDSA'].include? @signature_alg raise LogStash::ConfigurationError, "JWTDecode plugin: Invalid signature_alg '#{@signature_alg}' must be one of NONE, HMAC, RSASSA and ECDSA" end end |