17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
# File 'lib/logstash/filters/oauthenticator.rb', line 17
def filter(event)
match = event[@source].match(/\A(OAuthenticator authenticated an authentic request) with Authorization: /)
if match
authorization = match.post_match
begin
event['oauth'] = OAuthenticator.parse_authorization(authorization)
rescue OAuthenticator::Error => parse_exception
nil
end
event[@source] = match[1] if @consume
end
if event['request'].is_a?(Hash) && event['request']['headers'].is_a?(Hash)
authorization = event['request']['headers'].inject(nil) { |a, (k,v)| k.is_a?(String) && k.downcase == 'authorization' ? v : a }
if authorization.is_a?(String)
begin
event['request']['oauth'] = OAuthenticator.parse_authorization(authorization)
rescue OAuthenticator::Error => parse_exception
nil
end
end
end
end
|