class LogStash::Filters::JWTFilter

This example filter will replace the contents of the default message field with whatever you specify in the configuration.

It is only intended to be used as an example.

Public Instance Methods

filter(event) click to toggle source
# File lib/logstash/filters/jwt.rb, line 39
def filter(event)
  if event.include?(@field)
    token = event[@field]
    begin
      decoded_token = JWT.decode token, @secret, true, { :algorithm => algorithm }
      @logger.debug? && @logger.debug("Decoded token is: #{decoded_token}")
      event['[@metadata][jwt_data]'] = decoded_token.first
      event.remove(@field) if @remove_token
      filter_matched(event)
    rescue => e
      @logger.error("Invalid JWT token. exception => #{e.inspect}") if @logger
    end
  end
end
register() click to toggle source
# File lib/logstash/filters/jwt.rb, line 34
def register
  # Add instance variables
end