Class: LogStash::Filters::JwtDecoder

Inherits:
Base
  • Object
show all
Defined in:
lib/logstash/filters/jwt_decoder.rb

Instance Method Summary collapse

Instance Method Details

#filter(event) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/logstash/filters/jwt_decoder.rb', line 32

def filter(event)
    # Replace the event message with our message as configured in the
    # config file.
    raw_message = event.get(@access_token_field)
    if(raw_message)
      if match = raw_message.match(@token_pattern)
        token = match.captures[@match_group_index]
        decoded_token = JWT.decode token, nil, false

        result = Hash.new

        @extract.each do |key, value|
          jsonPath = JsonPath.new(value)
          result[key] = jsonPath.first(decoded_token)
        end

        event.set(@output_field, result)

        filter_matched(event)
      end
    end
end

#registerObject



27
28
29
# File 'lib/logstash/filters/jwt_decoder.rb', line 27

def register
  # Add instance variables
end