logstash-filter-LDAPresolve 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +5 -0
- data/CHANGELOG.md +0 -0
- data/CONTRIBUTORS +11 -0
- data/DEVELOPER.md +2 -0
- data/Gemfile +2 -0
- data/LICENSE +13 -0
- data/NOTICE.TXT +5 -0
- data/README.md +156 -0
- data/Rakefile +1 -0
- data/lib/logstash/filters/LDAPresolve.rb +259 -0
- data/logstash-filter-LDAPresolve.gemspec +24 -0
- data/spec/filters/LDAPresolve_spec.rb +127 -0
- data/spec/spec_helper.rb +1 -0
- metadata +108 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 3d8cee25a04c992f639bf3007edc11cc618503ef
|
4
|
+
data.tar.gz: 9c99de7ed399ac6c2429d4a0dca4f0aa01e209c5
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: c3a8a7bb0e9c246047811f2d707366af818bb6a3b045341fa3afd08c60d34ba195483ecf8d17fdf0ab2630e223060784c163b6049e74347cfaaf94a0e7b5ffa4
|
7
|
+
data.tar.gz: 1bc3391cfac2e608d3b97482f0cd9e28aeb109bc293646ac24d3c1c953b6fa79118cd1d1962da0d311469a45f69d25852b36074bd30a57404c4965d456dbd5a2
|
data/.gitignore
ADDED
data/CHANGELOG.md
ADDED
File without changes
|
data/CONTRIBUTORS
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
The following is a list of people who have contributed ideas, code, bug
|
2
|
+
reports, or in general have helped logstash along its way.
|
3
|
+
|
4
|
+
Contributors:
|
5
|
+
* Aaron Mildenstein (untergeek)
|
6
|
+
* Pier-Hugues Pellerin (ph)
|
7
|
+
|
8
|
+
Note: If you've sent us patches, bug reports, or otherwise contributed to
|
9
|
+
Logstash, and you aren't on the list above and want to be, please let us know
|
10
|
+
and we'll make sure you're here. Contributions from folks like you are what make
|
11
|
+
open source awesome.
|
data/DEVELOPER.md
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
Copyright (c) 2012–2015 Elasticsearch <http://www.elastic.co>
|
2
|
+
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
you may not use this file except in compliance with the License.
|
5
|
+
You may obtain a copy of the License at
|
6
|
+
|
7
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
|
9
|
+
Unless required by applicable law or agreed to in writing, software
|
10
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
See the License for the specific language governing permissions and
|
13
|
+
limitations under the License.
|
data/NOTICE.TXT
ADDED
data/README.md
ADDED
@@ -0,0 +1,156 @@
|
|
1
|
+
# LDAPresolve Logstash Plugin
|
2
|
+
|
3
|
+
This is a plugin for [Logstash](https://github.com/elasticsearch/logstash).
|
4
|
+
|
5
|
+
It is fully free and fully open source. The license is Apache 2.0, meaning you are pretty much free to use it however you want in whatever way.
|
6
|
+
|
7
|
+
## Documentation
|
8
|
+
|
9
|
+
LDAPresolve filter will add to the event the fields 'login', 'user' and 'group' based on LDAP request
|
10
|
+
with provided uidNumber information.
|
11
|
+
and add LDAP_OK tag on success, otherwise error tag
|
12
|
+
LDAP_ERR: some LDAP connection or schema error
|
13
|
+
LDAP_UNK_USER: unknow uidNumber
|
14
|
+
LDAP_UNK_GROUP: unknow group
|
15
|
+
|
16
|
+
This filter useby default LDAPS but can be configure to use plain LDAP.
|
17
|
+
you can select the protocol you want to use via the use_ssl config setting
|
18
|
+
|
19
|
+
As all filters, this filter only processes 1 event at a time, so using this plugin can
|
20
|
+
significantly slow down your pipeline's throughput if you have a high latency network.
|
21
|
+
In order to reduce the slow down a cache mechanism is provided.
|
22
|
+
Cache holds the relevant information for a given uidNumber (full user name, group), and cache
|
23
|
+
entries are tagged with a timestamp of cache introduction
|
24
|
+
Basicaly uidNumber is first searched using the cache on the cache, checked for the timestamp.
|
25
|
+
if cache introduction time is older than persistence time then it is considered as not found and a LDAP
|
26
|
+
request is performed and cache updated for this specific uidNumber.
|
27
|
+
|
28
|
+
cache use and cache persistence time are adjustable form the config.
|
29
|
+
|
30
|
+
LDAP tree naming and schema may vary.
|
31
|
+
You must specify the DN where to lookcup for user and group information
|
32
|
+
User and group attributes are set to some reasonable values and are overwritable via the config
|
33
|
+
user attributes : 'uid', 'gidNumber', 'givenName', 'sn'
|
34
|
+
group attributes: 'dn'
|
35
|
+
|
36
|
+
If uidNumber is not found in LDAP, for user and group are set to default values, eg: Unknown.
|
37
|
+
|
38
|
+
## Example
|
39
|
+
|
40
|
+
assume we have on LDAPS (with no authent) an user John DOE with uidNumber 25377 that pertains to group nobody
|
41
|
+
For example with following envent structure.
|
42
|
+
```
|
43
|
+
{
|
44
|
+
"@version" => "1",
|
45
|
+
"@timestamp" => "2015-06-29:00:00.000Z",
|
46
|
+
"some_infos" => 'foo bar"
|
47
|
+
}
|
48
|
+
```
|
49
|
+
|
50
|
+
and the following init configuration
|
51
|
+
```
|
52
|
+
LDAPresolve {
|
53
|
+
uidNumber => 25377
|
54
|
+
host => "ldaps.pasteur.fr"
|
55
|
+
userdn => "ou=utilisateurs,dc=pasteur,dc=fr"
|
56
|
+
groupdn => "ou=entites,ou=groupes,dc=pasteur,dc=fr"
|
57
|
+
}
|
58
|
+
```
|
59
|
+
|
60
|
+
we will get this output
|
61
|
+
```
|
62
|
+
{
|
63
|
+
"@version" => "1",
|
64
|
+
"@timestamp" => "2015-06-29:00:00.000Z",
|
65
|
+
"some_infos" => 'foo bar"
|
66
|
+
"user" => "John DOE"
|
67
|
+
"group" => "nobody"
|
68
|
+
"login" => "jdoe"
|
69
|
+
}
|
70
|
+
```
|
71
|
+
|
72
|
+
# Usage
|
73
|
+
|
74
|
+
## 1 Installation
|
75
|
+
|
76
|
+
You can use the built-in plugin tool from Logstash to install the filter from https://rubygems.org/gems/logstash-filter-LDAPresolve
|
77
|
+
|
78
|
+
```
|
79
|
+
$LS_HOME/bin/plugin install logstash-filter-LDAPresolve
|
80
|
+
```
|
81
|
+
|
82
|
+
Or you can build it yourself:
|
83
|
+
|
84
|
+
```
|
85
|
+
git clone https://github.com/EricDeveaud/logstash_filter_LDAPresolve
|
86
|
+
cd logstash_filter_LDAPresolve
|
87
|
+
bundle install
|
88
|
+
bundle exec rspec
|
89
|
+
gem build logstash-filter-LDAPresolve.gemspec
|
90
|
+
$LS_HOME/bin/plugin install ./logstash-filter-rest-0.1.0.gem
|
91
|
+
```
|
92
|
+
|
93
|
+
## 2 Configuration
|
94
|
+
|
95
|
+
Add the following to the #filter# section of your logstash configuration
|
96
|
+
|
97
|
+
#### mandatory elements
|
98
|
+
```sh
|
99
|
+
LDAPresolve {
|
100
|
+
uidNumber => 7225
|
101
|
+
host => "ldap.somewhere.org"
|
102
|
+
userdn => "ou=users,dc=somewhere,dc=org"
|
103
|
+
groupdn => "ou=groups,dc=somewhere,dc=org"
|
104
|
+
}
|
105
|
+
```
|
106
|
+
|
107
|
+
#### auxiliary arguments
|
108
|
+
|
109
|
+
if your LDAP server use another port than the (339) default one
|
110
|
+
```sh
|
111
|
+
ldap_port => 1234
|
112
|
+
```
|
113
|
+
|
114
|
+
if your LDAPS server use another port than the (636) default one
|
115
|
+
```sh
|
116
|
+
ldaps_port => 1234
|
117
|
+
```
|
118
|
+
|
119
|
+
if you use a login//passord to log to your LDAP server
|
120
|
+
```sh
|
121
|
+
username => "some_loggin"
|
122
|
+
passord => "secretPassword"
|
123
|
+
```
|
124
|
+
|
125
|
+
if your LDAP use some specific attributes you can specify them for the filtering request
|
126
|
+
```sh
|
127
|
+
userattrs => ['attr1', 'attr2', ..]
|
128
|
+
groupattrs => ['attr1', 'attr2', ..]
|
129
|
+
```
|
130
|
+
|
131
|
+
defaut atributes used by LDAPresolve are the following:
|
132
|
+
```sh
|
133
|
+
userattrs => ['uid', 'gidNumber', 'givenName', 'sn'] that suits the posix account definitions.
|
134
|
+
groupattrs => ['dn']
|
135
|
+
```
|
136
|
+
|
137
|
+
## 3 Cache or not cache
|
138
|
+
|
139
|
+
LDAPresolve uses a basic cache mechanism by default. This cache mechanism can be disabled using the following configuration options
|
140
|
+
|
141
|
+
```sh
|
142
|
+
usecache => false
|
143
|
+
```
|
144
|
+
|
145
|
+
Cache retention is set by default to 300 second. you can change the cache retention duration using the following configuration options
|
146
|
+
|
147
|
+
```sh
|
148
|
+
cache_interval => number_of_seconds
|
149
|
+
```
|
150
|
+
|
151
|
+
# Contributing
|
152
|
+
All contributions are welcome: ideas, patches, documentation, bug reports, complaints, usggestions ...
|
153
|
+
|
154
|
+
|
155
|
+
|
156
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "logstash/devutils/rake"
|
@@ -0,0 +1,259 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require "logstash/filters/base"
|
3
|
+
require "logstash/namespace"
|
4
|
+
|
5
|
+
# LDAPresolve filter will add to the event the fields 'login', 'user' and 'group' based on LDAP request
|
6
|
+
# with provided uidNumber information.
|
7
|
+
# and add LDAP_OK on success, otherwise error tags are added to the event
|
8
|
+
# * LDAP_ERR: some LDAP connection or schema error
|
9
|
+
# * LDAP_UNK_USER: unknow uidNumber
|
10
|
+
# * LDAP_UNK_GROUP: unknow group
|
11
|
+
#
|
12
|
+
# This filter use by default LDAPS but can be configured to use plain LDAP.
|
13
|
+
# you can select the protocol you want to use via the use_ssl config setting
|
14
|
+
#
|
15
|
+
# As all filters, this filter only processes 1 event at a time, so using this plugin can
|
16
|
+
# significantly slow down your pipeline's throughput if you have a high latency network.
|
17
|
+
# In order to reduce the slow down a cache mechanism is provided.
|
18
|
+
# Cache holds the relevant information for a given uidNumber (full user name, group), and cache
|
19
|
+
# entries are tagged with a timestamp of cache introduction
|
20
|
+
# Basicaly uidNumber is first searched using the cache on the cache, checked for the timestamp.
|
21
|
+
# if cache introduction time is older than persistence time then it is considered as not found and a LDAP
|
22
|
+
# request is performed and cache updated for this specific uidNumber.
|
23
|
+
#
|
24
|
+
# cache use and cache persistence time are adjustable form the config.
|
25
|
+
#
|
26
|
+
# LDAP tree naming and schema may vary.
|
27
|
+
# You must specify the DN where to lookcup for user and group information
|
28
|
+
# User and group attributes are set to some reasonable values and are overwritable via the config
|
29
|
+
# user attributes : 'uid', 'gidNumber', 'givenName', 'sn'
|
30
|
+
# group attributes: 'dn'
|
31
|
+
#
|
32
|
+
# If uidNumber is not found in LDAP, for user and group are set to default values, eg: Unknown
|
33
|
+
#
|
34
|
+
#
|
35
|
+
# configure this filter from your Logstash filter config.
|
36
|
+
# [source, ruby]
|
37
|
+
# filter {
|
38
|
+
# LDAPresolve {
|
39
|
+
# uidNumber => uidNumber to resolve
|
40
|
+
# host => "my.LDAP.Server"
|
41
|
+
# userdn => "Domain Name to search for users information"
|
42
|
+
# groupdn => "Domain Name to search for group information"
|
43
|
+
# ldap_port => LDAP Server port (Default: 389)
|
44
|
+
# ldaps_port => LDAPS Server port (Default: 636)
|
45
|
+
# use_ssl => boolean (Default: true)
|
46
|
+
# username => "username to log on LDAP server" (Default '')
|
47
|
+
# password => "password to log on the LDAP server" Default '')
|
48
|
+
# }
|
49
|
+
# }
|
50
|
+
#
|
51
|
+
# Example
|
52
|
+
#
|
53
|
+
# assume we have on LDAPS (with no authent) an user John DOE with uidNumber 25377 that pertains to group nobody
|
54
|
+
# For example with following envent structure.
|
55
|
+
# {
|
56
|
+
# "@version" => "1",
|
57
|
+
# "@timestamp" => "2015-06-29:00:00.000Z",
|
58
|
+
# "some_infos" => 'foo bar"
|
59
|
+
# }
|
60
|
+
#
|
61
|
+
# and the following init configuration
|
62
|
+
#
|
63
|
+
# LDAPresolve {
|
64
|
+
# uidNumber => 25377
|
65
|
+
# host => "ldaps.pasteur.fr"
|
66
|
+
# userdn => "ou=utilisateurs,dc=pasteur,dc=fr"
|
67
|
+
# groupdn => "ou=entites,ou=groupes,dc=pasteur,dc=fr"
|
68
|
+
# }
|
69
|
+
#
|
70
|
+
# we will get this output
|
71
|
+
#
|
72
|
+
# {
|
73
|
+
# "@version" => "1",
|
74
|
+
# "@timestamp" => "2015-06-29:00:00.000Z",
|
75
|
+
# "some_infos" => 'foo bar"
|
76
|
+
# "user" => "John DOE"
|
77
|
+
# "group" => "nobody"
|
78
|
+
# "login" => "jdoe"
|
79
|
+
# }
|
80
|
+
|
81
|
+
class LogStash::Filters::LDAPresolve < LogStash::Filters::Base
|
82
|
+
|
83
|
+
config_name "LDAPresolve"
|
84
|
+
|
85
|
+
# uidNumber to resolve.
|
86
|
+
config :uidNumber, :validate => :string, :required => true
|
87
|
+
|
88
|
+
##--- LDAP server specific configuration
|
89
|
+
# LDAP host name
|
90
|
+
config :host, :validate => :string, :required => true
|
91
|
+
# LDAP//LDAPS port
|
92
|
+
config :ldap_port, :validate => :number, :required => false, :default => 389
|
93
|
+
config :ldaps_port, :validate => :number, :required => false, :default => 636
|
94
|
+
# use SSL ?
|
95
|
+
config :use_ssl, :validate => :boolean, :required => false, :default => false
|
96
|
+
# LDAP username used to log to LDAP server
|
97
|
+
config :username, :validate => :username, :required => false
|
98
|
+
# LDAP password used to log to LDAP server
|
99
|
+
config :password, :validate => :password, :required => false
|
100
|
+
# as LDAP tree naming convention may vary, you must specify the dn to use for OU's user
|
101
|
+
config :userdn, :validate => :string, :required => true
|
102
|
+
config :userattrs, :validate => :array, :required => false, :default => ['uid', 'gidNumber', 'givenName', 'sn']
|
103
|
+
# as LDAP tree naming convention may vary, you must specify the dn to use for OU's group
|
104
|
+
config :groupdn, :validate => :string, :required => true
|
105
|
+
config :groupattrs, :validate => :array, :required => false, :default => ['dn']
|
106
|
+
|
107
|
+
##--- cache settings true//false and time of cache renewal in sec
|
108
|
+
# shall we use caching true//false
|
109
|
+
config :useCache, :validate => :boolean, :required => false, :default => true
|
110
|
+
# cache persistence in second.
|
111
|
+
config :cache_interval, :validate => :number, :required => false, :default => 300
|
112
|
+
|
113
|
+
|
114
|
+
public
|
115
|
+
def register
|
116
|
+
require 'ldap'
|
117
|
+
@cache = {}
|
118
|
+
@DEFAULT = "Unknown"
|
119
|
+
@SUCCESS = "LDAP_OK"
|
120
|
+
@FAILURE = "LDAP_ERR"
|
121
|
+
@UNKNOWN = "LDAP_UNK"
|
122
|
+
end
|
123
|
+
|
124
|
+
public
|
125
|
+
def filter(event)
|
126
|
+
exitstatus = @SUCCESS
|
127
|
+
##--- first check cache for provided uidNumber
|
128
|
+
cached = false
|
129
|
+
if @useCache
|
130
|
+
cached = cached?(@uidNumber)
|
131
|
+
end
|
132
|
+
|
133
|
+
if cached
|
134
|
+
login, user , group = cached
|
135
|
+
else
|
136
|
+
@logger.info("prompt LDAP for #{@uidNumber} informations")
|
137
|
+
if use_ssl
|
138
|
+
conn = LDAP::SSLConn.new(host=@host, port=@ldaps_port)
|
139
|
+
else
|
140
|
+
conn = LDAP::Conn.new(host=@host, port=@ldap_port)
|
141
|
+
end
|
142
|
+
|
143
|
+
res = ldapsearch(conn, uidNumber)
|
144
|
+
user = res['user']
|
145
|
+
group = res['group']
|
146
|
+
login = res['login']
|
147
|
+
exitstatus = res['status']
|
148
|
+
errmsg = res['err']
|
149
|
+
|
150
|
+
##--- cache infos.
|
151
|
+
cacheUID(@uidNumber, login, user, group)
|
152
|
+
end
|
153
|
+
|
154
|
+
##--- finaly change event to embed login, user and group information
|
155
|
+
event["user"] = user
|
156
|
+
event["group"] = group
|
157
|
+
event["login"] = login
|
158
|
+
|
159
|
+
##--- add LDAPresolve exit tag, We can use this later to reparse+reindex logs if necessaryi.
|
160
|
+
if event["tags"]
|
161
|
+
event["tags"] << exitstatus
|
162
|
+
else
|
163
|
+
event["tags"]=[exitstatus]
|
164
|
+
end
|
165
|
+
|
166
|
+
# filter_matched should go in the last line of our successful code
|
167
|
+
filter_matched(event)
|
168
|
+
end # def filter
|
169
|
+
|
170
|
+
|
171
|
+
private
|
172
|
+
|
173
|
+
def cached?(uidNumber)
|
174
|
+
# checks if pgiven uidNumber appear in the cache
|
175
|
+
# then check for time it resides on the cache.
|
176
|
+
# if cache introdution time > cache_interval. claim that uidNumber is not cached to force
|
177
|
+
# update by the caller .
|
178
|
+
cached = @cache.fetch(uidNumber, false)
|
179
|
+
if cached and Time.now - cached[3] <= @cache_interval
|
180
|
+
return cached[0], cached[1], cached[2]
|
181
|
+
end
|
182
|
+
return false
|
183
|
+
end
|
184
|
+
|
185
|
+
def cacheUID(uidNumber, login, user, group)
|
186
|
+
# basic caching mechanism using a hash
|
187
|
+
# caveats, no size control.
|
188
|
+
@cache[uidNumber] = [login, user, group, Time.now]
|
189
|
+
end
|
190
|
+
|
191
|
+
def ldapsearch(conn, uidNumber)
|
192
|
+
ret = { 'login' => @DEFAULT, 'user' => @DEFAULT, 'group' => @DEFAULT, 'status' => @SUCCESS, 'err' => "" }
|
193
|
+
gid = 0
|
194
|
+
|
195
|
+
begin
|
196
|
+
conn.bind(username, password)
|
197
|
+
rescue LDAP::Error => err
|
198
|
+
@logger.error("Error: #{err.message}")
|
199
|
+
ret['err'] = err
|
200
|
+
ret['status'] = @FAILURE
|
201
|
+
return ret
|
202
|
+
end
|
203
|
+
|
204
|
+
|
205
|
+
# ok we bound, start search
|
206
|
+
scope = LDAP::LDAP_SCOPE_SUBTREE
|
207
|
+
##--- search LDAP for the user name
|
208
|
+
begin
|
209
|
+
conn.search(@userdn, scope, "(& (objectclass=posixAccount) (uidNumber=#{@uidNumber}))", @userattrs) { |entry|
|
210
|
+
|
211
|
+
# convert entry object to hash for easier manipulation
|
212
|
+
hashEntry = {}
|
213
|
+
for k in entry.get_attributes
|
214
|
+
hashEntry[k] = entry.vals(k).join(" ")
|
215
|
+
end
|
216
|
+
# generate user full name.
|
217
|
+
# in posix account we expect at least uid, gidNumber
|
218
|
+
# givenName and sn may be ommited so provide default value
|
219
|
+
ret['user'] = "#{hashEntry.fetch("givenName", "")} #{hashEntry.fetch("sn", @DEFAULT)}".strip
|
220
|
+
ret['login'] = "#{hashEntry.fetch("uid")}"
|
221
|
+
|
222
|
+
# extract gid for further interogation
|
223
|
+
gid = hashEntry.fetch("gidNumber", 0)
|
224
|
+
match = 1
|
225
|
+
}
|
226
|
+
rescue LDAP::Error => err
|
227
|
+
@logger.error("Error: #{err.message}")
|
228
|
+
ret['err'] = err
|
229
|
+
ret['status'] = @FAILURE
|
230
|
+
return ret
|
231
|
+
end
|
232
|
+
|
233
|
+
if ret['user'] == @DEFAULT
|
234
|
+
ret['status'] = "#{@UNKNOWN}_USER"
|
235
|
+
return ret
|
236
|
+
end
|
237
|
+
|
238
|
+
##--- search for GROUP name
|
239
|
+
filter = "(& (objectclass=posixGroup) (gidNumber=#{gid}))"
|
240
|
+
begin
|
241
|
+
conn.search(@groupdn, scope, filter, @groupattrs) { |entry|
|
242
|
+
ret['group'] = entry.dn.split(',')[0].split('=')[1]
|
243
|
+
}
|
244
|
+
rescue LDAP::Error => err
|
245
|
+
@logger.error("Error: #{err.message}")
|
246
|
+
ret['err'] = err
|
247
|
+
ret['status'] = @FAILURE
|
248
|
+
return ret
|
249
|
+
end
|
250
|
+
|
251
|
+
if ret['group'] == @DEFAULT
|
252
|
+
ret['status'] = "#{@UNKNOWN}_GROUP"
|
253
|
+
ret['group'] =ret['user']
|
254
|
+
return ret
|
255
|
+
end
|
256
|
+
|
257
|
+
return ret
|
258
|
+
end
|
259
|
+
end # class LogStash::Filters::LDAPresolve
|
@@ -0,0 +1,24 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.name = 'logstash-filter-LDAPresolve'
|
3
|
+
s.version = '0.1.1'
|
4
|
+
s.licenses = ['Apache License (2.0)']
|
5
|
+
s.summary = "This filter adds infodrmation fields from LDAP server based on the provided uid."
|
6
|
+
s.description = "This gem is a logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/plugin install gemname. This gem is not a stand-alone program"
|
7
|
+
s.authors = ["Eric Deveaud"]
|
8
|
+
s.email = 'edeveaud@pasteur.fr'
|
9
|
+
s.homepage = "http://projets.pasteur.fr"
|
10
|
+
s.require_paths = ["lib"]
|
11
|
+
|
12
|
+
# Files
|
13
|
+
s.files = `git ls-files`.split($\)
|
14
|
+
# Tests
|
15
|
+
s.test_files = s.files.grep(%r{^(test|spec|features)/})
|
16
|
+
|
17
|
+
# Special flag to let us know this is actually a logstash plugin
|
18
|
+
s.metadata = { "logstash_plugin" => "true", "logstash_group" => "filter" }
|
19
|
+
|
20
|
+
# Gem dependencies
|
21
|
+
s.add_runtime_dependency "logstash-core", '>= 1.4.0', '< 2.0.0'
|
22
|
+
s.add_runtime_dependency "jruby-ldap"
|
23
|
+
s.add_development_dependency 'logstash-devutils'
|
24
|
+
end
|
@@ -0,0 +1,127 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require "logstash/filters/LDAPresolve"
|
3
|
+
|
4
|
+
describe LogStash::Filters::LDAPresolve do
|
5
|
+
|
6
|
+
describe "check bind error" do
|
7
|
+
let(:config) do <<-CONFIG
|
8
|
+
filter {
|
9
|
+
LDAPresolve {
|
10
|
+
host => "none.pasteur.fr"
|
11
|
+
userdn => "ou=utilisateurs,dc=pasteur,dc=fr"
|
12
|
+
groupdn => "ou=entites,ou=groupes,dc=pasteur,dc=fr"
|
13
|
+
uidNumber => 1234
|
14
|
+
}
|
15
|
+
}
|
16
|
+
CONFIG
|
17
|
+
end
|
18
|
+
|
19
|
+
sample("test" => "test" ) do
|
20
|
+
expect(subject).to include('tags')
|
21
|
+
expect(subject["tags"]).to eq(["LDAP_ERR"])
|
22
|
+
|
23
|
+
end
|
24
|
+
end # bind test
|
25
|
+
|
26
|
+
# describe "unknown uidNumber" do
|
27
|
+
# let(:config) do <<-CONFIG
|
28
|
+
# filter {
|
29
|
+
# LDAPresolve {
|
30
|
+
# host => "ldap.pasteur.fr"
|
31
|
+
# userdn => "ou=utilisateurs,dc=pasteur,dc=fr"
|
32
|
+
# groupdn => "ou=entites,ou=groupes,dc=pasteur,dc=fr"
|
33
|
+
# uidNumber => 1234567890
|
34
|
+
# }
|
35
|
+
# }
|
36
|
+
# CONFIG
|
37
|
+
# end
|
38
|
+
#
|
39
|
+
# sample("test" => "test" ) do
|
40
|
+
# expect(subject).to include('user')
|
41
|
+
# expect(subject["user"]).to eq('Unknown')
|
42
|
+
# expect(subject).to include('group')
|
43
|
+
# expect(subject["group"]).to eq('Unknown')
|
44
|
+
# expect(subject).to include('tags')
|
45
|
+
# expect(subject["tags"]).to eq(["LDAP_UNK_USER"])
|
46
|
+
#
|
47
|
+
# end
|
48
|
+
# end # end unknow uid
|
49
|
+
#
|
50
|
+
#
|
51
|
+
# describe "uidNumber with no associated group" do
|
52
|
+
# let(:config) do <<-CONFIG
|
53
|
+
# filter {
|
54
|
+
# LDAPresolve {
|
55
|
+
# host => "ldap.pasteur.fr"
|
56
|
+
# userdn => "ou=utilisateurs,dc=pasteur,dc=fr"
|
57
|
+
# groupdn => "ou=entites,ou=groupes,dc=pasteur,dc=fr"
|
58
|
+
# uidNumber => 23865
|
59
|
+
# }
|
60
|
+
# }
|
61
|
+
# CONFIG
|
62
|
+
# end
|
63
|
+
#
|
64
|
+
# sample("test" => "test") do
|
65
|
+
# expect(subject).to include('user')
|
66
|
+
# expect(subject["user"]).to eq('biomaj')
|
67
|
+
# expect(subject).to include('group')
|
68
|
+
# expect(subject["group"]).to eq('biomaj')
|
69
|
+
# expect(subject).to include('tags')
|
70
|
+
# expect(subject["tags"]).to eq(["LDAP_UNK_GROUP"])
|
71
|
+
#
|
72
|
+
# end
|
73
|
+
# end #end no group name user
|
74
|
+
#
|
75
|
+
# describe "LDAP test" do
|
76
|
+
# let(:config) do <<-CONFIG
|
77
|
+
# filter {
|
78
|
+
# LDAPresolve {
|
79
|
+
# host => "ldap.pasteur.fr"
|
80
|
+
# userdn => "ou=utilisateurs,dc=pasteur,dc=fr"
|
81
|
+
# groupdn => "ou=entites,ou=groupes,dc=pasteur,dc=fr"
|
82
|
+
# use_ssl => false
|
83
|
+
# uidNumber => 7225
|
84
|
+
# }
|
85
|
+
# }
|
86
|
+
# CONFIG
|
87
|
+
# end
|
88
|
+
#
|
89
|
+
# sample("test" => "test") do
|
90
|
+
# expect(subject).to include('user')
|
91
|
+
# expect(subject["user"]).to eq('Eric DEVEAUD')
|
92
|
+
# expect(subject).to include('group')
|
93
|
+
# expect(subject["group"]).to eq('CIB')
|
94
|
+
# expect(subject).to include('login')
|
95
|
+
# expect(subject["login"]).to eq('edeveaud')
|
96
|
+
# expect(subject).to include('tags')
|
97
|
+
# expect(subject["tags"]).to eq(["LDAP_OK"])
|
98
|
+
#
|
99
|
+
# end
|
100
|
+
# end #end LDAP test
|
101
|
+
#
|
102
|
+
# describe "LDAPS test" do
|
103
|
+
# let(:config) do <<-CONFIG
|
104
|
+
# filter {
|
105
|
+
# LDAPresolve {
|
106
|
+
# host => "ldap.pasteur.fr"
|
107
|
+
# userdn => "ou=utilisateurs,dc=pasteur,dc=fr"
|
108
|
+
# groupdn => "ou=entites,ou=groupes,dc=pasteur,dc=fr"
|
109
|
+
# use_ssl => true
|
110
|
+
# uidNumber => 7225
|
111
|
+
# }
|
112
|
+
# }
|
113
|
+
# CONFIG
|
114
|
+
# end
|
115
|
+
#
|
116
|
+
# sample("test" => "test") do
|
117
|
+
# expect(subject).to include('user')
|
118
|
+
# expect(subject["user"]).to eq('Eric DEVEAUD')
|
119
|
+
# expect(subject).to include('group')
|
120
|
+
# expect(subject["group"]).to eq('CIB')
|
121
|
+
# expect(subject).to include('tags')
|
122
|
+
# expect(subject["tags"]).to eq(["LDAP_OK"])
|
123
|
+
#
|
124
|
+
# end
|
125
|
+
# end # end LDAPS test
|
126
|
+
|
127
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "logstash/devutils/rspec/spec_helper"
|
metadata
ADDED
@@ -0,0 +1,108 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: logstash-filter-LDAPresolve
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Eric Deveaud
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-07-10 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: logstash-core
|
15
|
+
version_requirements: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 1.4.0
|
20
|
+
- - <
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 2.0.0
|
23
|
+
requirement: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - '>='
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: 1.4.0
|
28
|
+
- - <
|
29
|
+
- !ruby/object:Gem::Version
|
30
|
+
version: 2.0.0
|
31
|
+
prerelease: false
|
32
|
+
type: :runtime
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: jruby-ldap
|
35
|
+
version_requirements: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - '>='
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '0'
|
40
|
+
requirement: !ruby/object:Gem::Requirement
|
41
|
+
requirements:
|
42
|
+
- - '>='
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
version: '0'
|
45
|
+
prerelease: false
|
46
|
+
type: :runtime
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: logstash-devutils
|
49
|
+
version_requirements: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
requirement: !ruby/object:Gem::Requirement
|
55
|
+
requirements:
|
56
|
+
- - '>='
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
version: '0'
|
59
|
+
prerelease: false
|
60
|
+
type: :development
|
61
|
+
description: This gem is a logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/plugin install gemname. This gem is not a stand-alone program
|
62
|
+
email: edeveaud@pasteur.fr
|
63
|
+
executables: []
|
64
|
+
extensions: []
|
65
|
+
extra_rdoc_files: []
|
66
|
+
files:
|
67
|
+
- .gitignore
|
68
|
+
- CHANGELOG.md
|
69
|
+
- CONTRIBUTORS
|
70
|
+
- DEVELOPER.md
|
71
|
+
- Gemfile
|
72
|
+
- LICENSE
|
73
|
+
- NOTICE.TXT
|
74
|
+
- README.md
|
75
|
+
- Rakefile
|
76
|
+
- lib/logstash/filters/LDAPresolve.rb
|
77
|
+
- logstash-filter-LDAPresolve.gemspec
|
78
|
+
- spec/filters/LDAPresolve_spec.rb
|
79
|
+
- spec/spec_helper.rb
|
80
|
+
homepage: http://projets.pasteur.fr
|
81
|
+
licenses:
|
82
|
+
- Apache License (2.0)
|
83
|
+
metadata:
|
84
|
+
logstash_plugin: 'true'
|
85
|
+
logstash_group: filter
|
86
|
+
post_install_message:
|
87
|
+
rdoc_options: []
|
88
|
+
require_paths:
|
89
|
+
- lib
|
90
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
91
|
+
requirements:
|
92
|
+
- - '>='
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: '0'
|
95
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
96
|
+
requirements:
|
97
|
+
- - '>='
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
version: '0'
|
100
|
+
requirements: []
|
101
|
+
rubyforge_project:
|
102
|
+
rubygems_version: 2.4.8
|
103
|
+
signing_key:
|
104
|
+
specification_version: 4
|
105
|
+
summary: This filter adds infodrmation fields from LDAP server based on the provided uid.
|
106
|
+
test_files:
|
107
|
+
- spec/filters/LDAPresolve_spec.rb
|
108
|
+
- spec/spec_helper.rb
|