rom-ldap 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (104) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +251 -0
  3. data/CONTRIBUTING.md +18 -0
  4. data/README.md +172 -0
  5. data/TODO.md +33 -0
  6. data/config/responses.yml +328 -0
  7. data/lib/dry/monitor/ldap/colorizers/default.rb +17 -0
  8. data/lib/dry/monitor/ldap/colorizers/rouge.rb +31 -0
  9. data/lib/dry/monitor/ldap/logger.rb +58 -0
  10. data/lib/rom-ldap.rb +1 -0
  11. data/lib/rom/ldap.rb +22 -0
  12. data/lib/rom/ldap/alias.rb +30 -0
  13. data/lib/rom/ldap/associations.rb +6 -0
  14. data/lib/rom/ldap/associations/core.rb +23 -0
  15. data/lib/rom/ldap/associations/many_to_many.rb +18 -0
  16. data/lib/rom/ldap/associations/many_to_one.rb +22 -0
  17. data/lib/rom/ldap/associations/one_to_many.rb +32 -0
  18. data/lib/rom/ldap/associations/one_to_one.rb +19 -0
  19. data/lib/rom/ldap/associations/self_ref.rb +35 -0
  20. data/lib/rom/ldap/attribute.rb +327 -0
  21. data/lib/rom/ldap/client.rb +185 -0
  22. data/lib/rom/ldap/client/authentication.rb +118 -0
  23. data/lib/rom/ldap/client/operations.rb +233 -0
  24. data/lib/rom/ldap/commands.rb +6 -0
  25. data/lib/rom/ldap/commands/create.rb +41 -0
  26. data/lib/rom/ldap/commands/delete.rb +17 -0
  27. data/lib/rom/ldap/commands/update.rb +35 -0
  28. data/lib/rom/ldap/constants.rb +193 -0
  29. data/lib/rom/ldap/dataset.rb +286 -0
  30. data/lib/rom/ldap/dataset/conversion.rb +62 -0
  31. data/lib/rom/ldap/dataset/dsl.rb +299 -0
  32. data/lib/rom/ldap/dataset/persistence.rb +44 -0
  33. data/lib/rom/ldap/directory.rb +126 -0
  34. data/lib/rom/ldap/directory/capabilities.rb +71 -0
  35. data/lib/rom/ldap/directory/entry.rb +200 -0
  36. data/lib/rom/ldap/directory/env.rb +155 -0
  37. data/lib/rom/ldap/directory/operations.rb +282 -0
  38. data/lib/rom/ldap/directory/password.rb +122 -0
  39. data/lib/rom/ldap/directory/root.rb +187 -0
  40. data/lib/rom/ldap/directory/tokenization.rb +66 -0
  41. data/lib/rom/ldap/directory/transactions.rb +31 -0
  42. data/lib/rom/ldap/directory/vendors/active_directory.rb +129 -0
  43. data/lib/rom/ldap/directory/vendors/apache_ds.rb +27 -0
  44. data/lib/rom/ldap/directory/vendors/e_directory.rb +16 -0
  45. data/lib/rom/ldap/directory/vendors/open_directory.rb +12 -0
  46. data/lib/rom/ldap/directory/vendors/open_dj.rb +25 -0
  47. data/lib/rom/ldap/directory/vendors/open_ldap.rb +35 -0
  48. data/lib/rom/ldap/directory/vendors/three_eight_nine.rb +16 -0
  49. data/lib/rom/ldap/directory/vendors/unknown.rb +22 -0
  50. data/lib/rom/ldap/dsl.rb +76 -0
  51. data/lib/rom/ldap/errors.rb +47 -0
  52. data/lib/rom/ldap/expression.rb +77 -0
  53. data/lib/rom/ldap/expression_encoder.rb +174 -0
  54. data/lib/rom/ldap/extensions.rb +50 -0
  55. data/lib/rom/ldap/extensions/active_support_notifications.rb +26 -0
  56. data/lib/rom/ldap/extensions/compatibility.rb +11 -0
  57. data/lib/rom/ldap/extensions/dsml.rb +165 -0
  58. data/lib/rom/ldap/extensions/msgpack.rb +23 -0
  59. data/lib/rom/ldap/extensions/optimised_json.rb +25 -0
  60. data/lib/rom/ldap/extensions/rails_log_subscriber.rb +38 -0
  61. data/lib/rom/ldap/formatter.rb +26 -0
  62. data/lib/rom/ldap/functions.rb +207 -0
  63. data/lib/rom/ldap/gateway.rb +145 -0
  64. data/lib/rom/ldap/ldif.rb +74 -0
  65. data/lib/rom/ldap/ldif/exporter.rb +77 -0
  66. data/lib/rom/ldap/ldif/importer.rb +95 -0
  67. data/lib/rom/ldap/mapper_compiler.rb +19 -0
  68. data/lib/rom/ldap/matchers.rb +69 -0
  69. data/lib/rom/ldap/message_queue.rb +7 -0
  70. data/lib/rom/ldap/oid.rb +101 -0
  71. data/lib/rom/ldap/parsers/abstract_syntax.rb +91 -0
  72. data/lib/rom/ldap/parsers/attribute.rb +290 -0
  73. data/lib/rom/ldap/parsers/filter_syntax.rb +133 -0
  74. data/lib/rom/ldap/pdu.rb +285 -0
  75. data/lib/rom/ldap/plugin/pagination.rb +145 -0
  76. data/lib/rom/ldap/plugins.rb +7 -0
  77. data/lib/rom/ldap/projection_dsl.rb +38 -0
  78. data/lib/rom/ldap/relation.rb +135 -0
  79. data/lib/rom/ldap/relation/exporting.rb +72 -0
  80. data/lib/rom/ldap/relation/reading.rb +461 -0
  81. data/lib/rom/ldap/relation/writing.rb +64 -0
  82. data/lib/rom/ldap/responses.rb +17 -0
  83. data/lib/rom/ldap/restriction_dsl.rb +45 -0
  84. data/lib/rom/ldap/schema.rb +123 -0
  85. data/lib/rom/ldap/schema/attributes_inferrer.rb +59 -0
  86. data/lib/rom/ldap/schema/dsl.rb +13 -0
  87. data/lib/rom/ldap/schema/inferrer.rb +50 -0
  88. data/lib/rom/ldap/schema/type_builder.rb +133 -0
  89. data/lib/rom/ldap/scope.rb +19 -0
  90. data/lib/rom/ldap/search_request.rb +249 -0
  91. data/lib/rom/ldap/socket.rb +210 -0
  92. data/lib/rom/ldap/tasks/ldap.rake +103 -0
  93. data/lib/rom/ldap/tasks/ldif.rake +80 -0
  94. data/lib/rom/ldap/transaction.rb +29 -0
  95. data/lib/rom/ldap/type_map.rb +88 -0
  96. data/lib/rom/ldap/types.rb +158 -0
  97. data/lib/rom/ldap/version.rb +17 -0
  98. data/lib/rom/plugins/relation/ldap/active_directory.rb +182 -0
  99. data/lib/rom/plugins/relation/ldap/auto_restrictions.rb +69 -0
  100. data/lib/rom/plugins/relation/ldap/e_directory.rb +27 -0
  101. data/lib/rom/plugins/relation/ldap/instrumentation.rb +35 -0
  102. data/lib/rouge/lexers/ldap.rb +72 -0
  103. data/lib/rouge/themes/ldap.rb +49 -0
  104. metadata +231 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: d55b8ce14fb58a188849c42fe14bd2f544f6dfd92baed22b6f51e7606912f962
4
+ data.tar.gz: aab10466f1913470ffee5d8f11920ebe7b47c28a4ab06af3a48b41c65406c03d
5
+ SHA512:
6
+ metadata.gz: 3adec0a51363520adea1d39cd4c47adb697428390315bc282651299e840c59ea7c4c0eea05668a90cee8d49246fe4f77b4d1b63d482b3a693fde4462870b83b2
7
+ data.tar.gz: c137ac63e72a7ca07d01e978acf2990dd2f5d49e3bf8a0ee2f869d593bb844839ed491d51a231e4cdb971439fe51f9d472fcb0e4c6023cba5305f13b10b05608
data/CHANGELOG.md ADDED
@@ -0,0 +1,251 @@
1
+ ## unreleased
2
+
3
+ <!-- TODO -->
4
+ [Compare v0.2.1...master](https://gitlab.com/peterdavidhamilton/rom-ldap/compare/v0.2.1...master)
5
+
6
+
7
+ # 0.2.1 / 2021-02-19
8
+
9
+ ### Fixed
10
+
11
+ - Replace use of deprecated URI.encode/decode method for compatibility with Ruby v2.7. [#ref](https://gitlab.com/peterdavidhamilton/rom-ldap/commit/e2f8da009319d70f895a273c9b85a693906179f9)
12
+ - Fix DSML export of an entry with `ObjectClasses` omitted. [#ref](https://gitlab.com/peterdavidhamilton/rom-ldap/commit/acb7df93446ec8da01764159c0d5dee4168bd8e0)
13
+ - Correct misnamed error classes raise by the directory. [#ref](https://gitlab.com/peterdavidhamilton/rom-ldap/commit/acb7df93446ec8da01764159c0d5dee4168bd8e0)
14
+ - Remove old development code and a general tidy up. [#ref](https://gitlab.com/peterdavidhamilton/rom-ldap/commit/55bf78d8953066a5391b90c0c53e17839fa27ef1)
15
+ - Run more specs against all four test LDAP vendors. [#ref](https://gitlab.com/peterdavidhamilton/rom-ldap/commit/ff8d9279348fc3789415e769dd12c99fc2a875e6)
16
+ - Restrict `gemspec` to Ruby version 2, preventing keyword params errors when running v3.
17
+ - Fix ApacheDS docker container state contamination between loads.
18
+
19
+ ### Changed
20
+
21
+ - Replace current year on license.
22
+ - Simplify `docker-compose.yml` and `gitlab-ci.yml` removing deprecated ENV vars.
23
+ - Build docker images with custom schema preloaded. [#ref](https://gitlab.com/peterdavidhamilton/rom-ldap/commit/ae2c17f464dd3906a9156c7e24da031f39505627)
24
+ - Update specs for testing ordering against OpenLDAP with the `sssvlv` overlay module. [#ref](https://gitlab.com/peterdavidhamilton/rom-ldap/commit/ff8d9279348fc3789415e769dd12c99fc2a875e6)
25
+ - Remove volumes for LDAP vendors in `docker-compose.yml`.
26
+ - Remove rom-ldap rake tasks from the gem Rakefile and only load in the examples folder. [#ref](https://gitlab.com/peterdavidhamilton/rom-ldap/commit/ae2c17f464dd3906a9156c7e24da031f39505627)
27
+ - Remove comparison of total entries from `ldif:import` task as this is dependent on the connection using the correct base, the same as the entries being imported.
28
+ - Simplify the `gemspec` dependencies.
29
+
30
+
31
+ ## Added
32
+
33
+ - Add missing Style/FrozenStringLiteralComment lines.
34
+ - Add spec for ldap unix socket connections.
35
+ - Add extension for using the [OJ](http://www.ohler.com/oj/) gem. [#ref](https://gitlab.com/peterdavidhamilton/rom-ldap/commit/694b0563d96b81446c1172d3f5e5499ca329de93)
36
+ - Add attribute ordering to the custom wildlife schema attributes. [#ref](https://gitlab.com/peterdavidhamilton/rom-ldap/commit/ae2c17f464dd3906a9156c7e24da031f39505627)
37
+ - Allow the `DEFAULT_VENDOR` environment variable to change the default vendor used in a spec. [#ref](https://gitlab.com/peterdavidhamilton/rom-ldap/commit/8894b2d50de01a3eb73ac9d48944cc52e68981b6)
38
+
39
+
40
+ [Compare v0.2.0...v0.2.1](https://gitlab.com/peterdavidhamilton/rom-ldap/compare/v0.2.0...0.2.1)
41
+
42
+
43
+
44
+ # 0.2.0 / 2020-03-08
45
+
46
+ ### Changed
47
+
48
+ - Move LDIF for specs under fixtures folder
49
+ - Make the 'people' factory in specs usable by all vendors by dropping the non-standard attribute apple-imhandle
50
+ - Deleted non-ldap related methods like #qualified
51
+ - Internal parsing of query strings and abstract criteria
52
+ - Type mapping from oid to ruby classes
53
+ - `Dry::Transformer` replaces `Transproc`
54
+ - Update to dry-types 1.2
55
+ - Make switching between vendors easier by replacing vendor-specific extensions with reloadable module injection [#ref](https://gitlab.com/peterdavidhamilton/rom-ldap/commit/04e828a9c327fadd0829839903e3953c5709ac0a)
56
+ - Folder structure for vendor specific code [#ref](https://gitlab.com/peterdavidhamilton/rom-ldap/commit/04e828a9c327fadd0829839903e3953c5709ac0a)
57
+ - Simplify parsing as functions from string > ast > expression [#ref](https://gitlab.com/peterdavidhamilton/rom-ldap/commit/0a71e469fe9f13cec9a2d111d5f2814e6c490dae)
58
+
59
+ ### Fixed
60
+
61
+ - Allow username and password inside uri
62
+ - Handle IPV6 loopback addresses so localhost can be used
63
+ - Test suite readability against all four vendors
64
+ - Make running specs easier inside and outside of a docker environment with URI switching based on the context in which the suite is run
65
+ - Running specs inside Docker
66
+ - Rubocop errors
67
+ - Gitlab CI/CD pipeline
68
+ - Projected tuple attributes
69
+ - Renamed tuple attributes [#ref](https://gitlab.com/peterdavidhamilton/rom-ldap/commit/c0670d38b866d28afba94fddd34fddb7df8d5d23)
70
+ - Ordering results
71
+ - Building deeply nested expression queries [#ref](https://gitlab.com/peterdavidhamilton/rom-ldap/commit/0a71e469fe9f13cec9a2d111d5f2814e6c490dae)
72
+
73
+ ### Added
74
+
75
+ - Implement the tree control in the client delete method making deletion of entries with children more efficient
76
+ - Gateway configuration using ENV VARS
77
+ - LDIF import functionality as rake task
78
+ - Generating fixtures to LDIF using factories and `relation#to_ldif`
79
+ - Missing query operators used inside `relation#where` blocks
80
+ - Raw filter string parsing inside `relation#where` blocks
81
+ - Extra OIDs
82
+
83
+ [Compare v0.1.0...v0.2.0](https://gitlab.com/peterdavidhamilton/rom-ldap/compare/v0.1.0...0.2.0)
84
+
85
+
86
+
87
+ # 0.1.0 / 2019-03-15
88
+
89
+ ### Changed
90
+
91
+ - [BREAKING] rom-core (4.2.1) depends upon dry-types (0.15.0) which is only supported by ruby 2.4 and above. Change minimum supported version to 2.4
92
+
93
+ ### Fixed
94
+
95
+ - Use [Semantic Versioning](https://semver.org/) from now on, however changing the Ruby version dependency should constitute a MAJOR change, we are not yet ready for the public 1.0.0 release
96
+
97
+ [Compare v0.1.0...v0.0.14](https://gitlab.com/peterdavidhamilton/rom-ldap/compare/v0.1.0...v0.0.14)
98
+
99
+
100
+
101
+ # 0.0.14 / 2019-03-15
102
+
103
+ ### Added
104
+
105
+ - Draft `dry-monitor` LDAP logger [#ref](https://gitlab.com/peterdavidhamilton/rom-ldap/commit/018dbd51b1d675b3153d8ec1d12a2a1f0416243b)
106
+
107
+ ### Changed
108
+
109
+ - Remove Struct convenience class [#ref](https://gitlab.com/peterdavidhamilton/rom-ldap/commit/0c151d6aac915094a85096b40269efbe9099d042)
110
+
111
+
112
+ [Compare v0.0.13...v0.0.14](https://gitlab.com/peterdavidhamilton/rom-ldap/compare/v0.0.13...v0.0.14)
113
+
114
+
115
+
116
+ # 0.0.13 / 2019-03-14
117
+
118
+ ### Added
119
+
120
+ - Docker setup [#ref](https://gitlab.com/peterdavidhamilton/rom-ldap/commit/7b08f6f69b9fa39a9700b45b72d91fe094a3442b)
121
+ - `CHANGELOG.md` [#ref](https://gitlab.com/peterdavidhamilton/rom-ldap/commit/0731b6a467fd97a4769f9bc481a2975f0638b1b9)
122
+ - New `ROM::LDAP::Relation` methods #to_dsml and #to_msgpack [#ref](https://gitlab.com/peterdavidhamilton/rom-ldap/commit/cc9d250584ba8cf3e875f7aa0f3754f676fdf2db)
123
+ - Introduce `ROM::LDAP::RestrictionDSL` from rom-sql
124
+ [#ref](https://gitlab.com/peterdavidhamilton/rom-ldap/commit/f0ddfe6a062fd63c1d6ab305d2cc97c50abf170d)
125
+ - Prepare connection variables using `ROM::LDAP::Directory::ENV` [#ref](https://gitlab.com/peterdavidhamilton/rom-ldap/commit/bbe8c8d07db0fe7daedff0921d4f11f9eacf374d)
126
+ - Add `ROM::LDAP::Dataset` reverse functionality [#ref](https://gitlab.com/peterdavidhamilton/rom-ldap/commit/c03d52e4a71764d0d44255367cbee17b786fd4e6)
127
+
128
+ ### Changed
129
+
130
+ - Improve `ROM::LDAP::Dataset` param validation and defaults [#ref](https://gitlab.com/peterdavidhamilton/rom-ldap/commit/c03d52e4a71764d0d44255367cbee17b786fd4e6)
131
+ - [BREAKING] Use LDAPURI (`'ldap://127.0.0.1:389'`) to initialise a `ROM::LDAP::Gateway` [#ref](https://gitlab.com/peterdavidhamilton/rom-ldap/commit/55072ce9640b3cc736f05753d9b6c3b48ea64b85)
132
+ - Replace `Net::TCPClient` dependency with `ROM::LDAP::Client` and handle new URI connection params [#ref](https://gitlab.com/peterdavidhamilton/rom-ldap/commit/33962e2ad6db42c29bc3e4e515469d560ca17c68)
133
+
134
+ ### Fixed
135
+
136
+ - `ROM::LDAP::Gateway` now accepts extenions and has no responsibility for creating a connection [#ref](https://gitlab.com/peterdavidhamilton/rom-ldap/commit/55072ce9640b3cc736f05753d9b6c3b48ea64b85)
137
+ - `ROM::LDAP::Directory::Entry` can be tested like a hash in specs using #include [#ref](https://gitlab.com/peterdavidhamilton/rom-ldap/commit/5868646492f0ff1c4e88185c8221e3f95837b0c6)
138
+
139
+
140
+ [Compare v0.0.12...v0.0.13](https://gitlab.com/peterdavidhamilton/rom-ldap/compare/v0.0.12...v0.0.13)
141
+
142
+
143
+
144
+
145
+
146
+
147
+ # 0.0.12 / 2018-10-23
148
+
149
+ ### Added
150
+
151
+ - Missing `bin/console` and `bin/setup` scripts added [#ref](https://gitlab.com/peterdavidhamilton/rom-ldap/commit/621fcc2280564114edbe9c3acba4e344a9814436)
152
+
153
+ ### Changed
154
+
155
+ - Compatible with Ruby >= 2.3 [#ref](https://gitlab.com/peterdavidhamilton/rom-ldap/commit/621fcc2280564114edbe9c3acba4e344a9814436)
156
+ - Improve demo fixtures and add new study attribute to explore joins [#ref](https://gitlab.com/peterdavidhamilton/rom-ldap/commit/673f933baacaf31e077b8cfd26064ea92d418849)
157
+
158
+ ### Fixed
159
+
160
+ - Rubocop warnings [#ref](https://gitlab.com/peterdavidhamilton/rom-ldap/commit/8a6620dd170e1a63fa6eda923f0a09ade02d9808)
161
+
162
+
163
+ [Compare v0.0.11...v0.0.12](https://gitlab.com/peterdavidhamilton/rom-ldap/compare/v0.0.11...v0.0.12)
164
+
165
+
166
+
167
+ # 0.0.11 / 2018-03-27
168
+
169
+
170
+ ### Fixed
171
+
172
+ - `ROM::LDAP::Directory#delete` now returns the deleted tuple [#ref](https://gitlab.com/peterdavidhamilton/rom-ldap/commit/6d5438c502406f1ed36bbe30e46f18ec2be413de)
173
+
174
+
175
+ [Compare v0.0.10...v0.0.11](https://gitlab.com/peterdavidhamilton/rom-ldap/compare/v0.0.10...v0.0.11)
176
+
177
+
178
+
179
+ # 0.0.10 / 2018-03-02
180
+
181
+ ### Added
182
+
183
+ - `ROM::LDAP::Dataset#shuffle` [#ref](https://gitlab.com/peterdavidhamilton/rom-ldap/commit/2fce12f854cce4fdd4a7f6758bbf54b1f23cefa2)
184
+
185
+ ### Fixed
186
+
187
+ - `ROM::LDAP::Directory` now identifies Microsoft Active Directory [#ref](https://gitlab.com/peterdavidhamilton/rom-ldap/commit/d6729beb894f45eb8bf0fcd3d49f4e16ba33dfc1)
188
+
189
+ [Compare v0.0.9...v0.0.10](https://gitlab.com/peterdavidhamilton/rom-ldap/compare/v0.0.9...v0.0.10)
190
+
191
+
192
+
193
+ # 0.0.9 / 2017-12-07
194
+
195
+ [Compare v0.0.8...v0.0.9](https://gitlab.com/peterdavidhamilton/rom-ldap/compare/v0.0.8...v0.0.9)
196
+
197
+
198
+
199
+ # 0.0.8 / 2017-11-25
200
+
201
+ [Compare v0.0.7...v0.0.8](https://gitlab.com/peterdavidhamilton/rom-ldap/compare/v0.0.7...v0.0.8)
202
+
203
+
204
+
205
+ # 0.0.7 / 2017-11-02
206
+
207
+ [Compare v0.0.6...v0.0.7](https://gitlab.com/peterdavidhamilton/rom-ldap/compare/v0.0.6...v0.0.7)
208
+
209
+
210
+
211
+ # 0.0.6 / 2017-10-18
212
+
213
+ [Compare v0.0.5...v0.0.6](https://gitlab.com/peterdavidhamilton/rom-ldap/compare/v0.0.5...v0.0.6)
214
+
215
+
216
+
217
+ # 0.0.5 / 2017-06-28
218
+
219
+ [Compare v0.0.4...v0.0.5](https://gitlab.com/peterdavidhamilton/rom-ldap/compare/v0.0.4...v0.0.5)
220
+
221
+
222
+
223
+ # 0.0.4 / 2017-06-21
224
+
225
+ [Compare v0.0.3...v0.0.4](https://gitlab.com/peterdavidhamilton/rom-ldap/compare/v0.0.3...v0.0.4)
226
+
227
+
228
+
229
+ # 0.0.3 / 2017-03-24
230
+
231
+ [Compare v0.0.2...v0.0.3](https://gitlab.com/peterdavidhamilton/rom-ldap/compare/v0.0.2...v0.0.3)
232
+
233
+
234
+
235
+ # 0.0.2 / 2017-01-23
236
+
237
+ [Compare v0.0.1...v0.0.2](https://gitlab.com/peterdavidhamilton/rom-ldap/compare/v0.0.1...v0.0.2)
238
+
239
+
240
+
241
+ # 0.0.1 / 2016-07-18
242
+
243
+ [Compare v0.0.0...v0.0.1](https://gitlab.com/peterdavidhamilton/rom-ldap/compare/v0.0.0...v0.0.1)
244
+
245
+
246
+
247
+
248
+
249
+ # 0.0.0 / 2016-07-17
250
+
251
+ Initial Commit.
data/CONTRIBUTING.md ADDED
@@ -0,0 +1,18 @@
1
+ # Issue Guidelines
2
+
3
+ ## Reporting bugs
4
+
5
+ If you found a bug, report an issue and describe what's the expected behavior
6
+ versus what actually happens. If the bug causes a crash, attach a full backtrace.
7
+ If possible, a reproduction script showing the problem is highly appreciated.
8
+
9
+ ## Help wanted
10
+
11
+ If you have experience of ROM and LDAP and can contribute to this project your
12
+ contributions are very welcome. Functionality like secure connections and transactions
13
+ are still to be implemented.
14
+
15
+ ## Asking for help
16
+
17
+ If you need help getting started and the documentation is lacking you can try
18
+ emailing me at peter[at]pdhamilton.uk.
data/README.md ADDED
@@ -0,0 +1,172 @@
1
+ # ROM-LDAP
2
+
3
+ [![pipeline status][pipeline]][branch] [![coverage report][coverage]][branch]
4
+
5
+
6
+ [ROM-LDAP][rom-ldap] is a [ROM][rom-rb] adapter for [LDAP][ldap] and provides lightweight directory object mapping for Ruby.
7
+ This gem makes it easier to use LDAP in your project or even as your primary datastore and an alternative to back-ends like MongoDB or CouchDB.
8
+
9
+
10
+
11
+ ## Requirements
12
+
13
+ [ROM-LDAP][rom-ldap] is compatible with versions of [Ruby][ruby] from 2.4 to 2.7.
14
+
15
+
16
+
17
+ ## History
18
+
19
+ This project has evolved from a refactoring of the [net-ldap][net-ldap] gem and tries to emulate the functionality of
20
+ [rom-sql][rom-sql] which is itself backed by the [sequel][sequel] gem.
21
+
22
+
23
+ A more detailed walk-through of [rom-ldap][rom-ldap] can be found at [pdhamilton.uk][pdhamilton].
24
+
25
+ ## Installation
26
+
27
+ Add this line to your Gemfile:
28
+
29
+ ```ruby
30
+ gem 'rom-ldap'
31
+ ```
32
+
33
+
34
+ #### Configuration
35
+
36
+ To configure a gateway connection to an LDAP server you can use environment variables or pass in a URI:
37
+
38
+ ```ruby
39
+
40
+ config = ROM::Configuration.new(:ldap, 'ldap://cn=admin,dc=rom,dc=ldap:topsecret@openldap')
41
+
42
+ ENV['LDAPURI'] = 'ldap://cn=admin,dc=rom,dc=ldap:topsecret@openldap'
43
+
44
+ config = ROM::Configuration.new(:ldap)
45
+
46
+ rom = ROM.container(config)
47
+
48
+ directory = ROM.container(config).directory
49
+
50
+ => #<ROM::LDAP::Directory
51
+ uri='ldap://cn=admin,dc=rom,dc=ldap:topsecret@openldap'
52
+ vendor='OpenLDAP'
53
+ version='0.0' />
54
+
55
+ ```
56
+
57
+ #### Extensions
58
+
59
+ For the greatest compatibility with Ruby method naming you can pass the optional "compatibility" extension whilst configuring the gateway.
60
+ This will format the attributes of directory entries into names suitable for ruby methods by converting _camelCase_ and _kebab-case_ to _snake_case_.
61
+
62
+ ```ruby
63
+ config = ROM::Configuration.new(:ldap, extensions: [:compatibility])
64
+ ```
65
+
66
+ The `ROM::LDAP::Relation` class already has support for exporting to `JSON`, `YAML` and `LDIF`.
67
+ Other extensions are available including exporting to `DSML` format.
68
+
69
+ ```ruby
70
+ config = ROM::Configuration.new(:ldap, extensions: [:dsml_export]) do |conf|
71
+ conf.relation(:all) { schema('(cn=*)', infer: true) }
72
+ end
73
+
74
+ rom = ROM.container(config)
75
+
76
+ rom.relations[:all].to_dsml
77
+ ```
78
+
79
+
80
+
81
+
82
+ ## LDAP Servers
83
+
84
+ The project has docker provision for four opensource LDAP servers to test against;
85
+ see `spec/fixtures/vendors.yml` for connection details.
86
+ Allow the dependent services to boot before running the specs in the gem container.
87
+
88
+ $ cd docker
89
+ $ docker-compose up -d apacheds openldap 389ds opendj
90
+ $ docker-compose up rom
91
+
92
+
93
+ 1. _[ApacheDS][apacheds]_ is an extensible and embeddable directory server entirely written in Java.
94
+
95
+ 2. _[OpenLDAP][openldap]_ is a high performance replacement for Oracle Corporation's Berkeley DB.
96
+ It is mostly written in C and its functionality can be extended with additional modules.
97
+
98
+ 3. _[389DS][389ds]_ from the Fedora Project is also written in Java.
99
+
100
+ 4. _[OpenDJ][opendj]_ Community Edition from the Open Identity Platform is written in Java.
101
+
102
+
103
+ A custom schema is loaded into each of the servers and defines attribute types and object classes used
104
+ in the tests and [examples](#examples).
105
+
106
+
107
+ ## Seed Data
108
+
109
+ _[Apache Directory Studio][apachestudio]_ is a cross-platform platform LDAP management application with a graphic interface.
110
+ For convenience, you can import the predefined connection settings for the docker environment using the included file
111
+ `spec/fixtures/vendors.lbc`.
112
+
113
+ Alternatively, if you have the `ldapmodify` command installed on your development machine,
114
+ you can use a rake task to import a folder of LDIF files:
115
+
116
+ $ LDAPURI=ldap://localhost:4389 \
117
+ LDAPBINDDN='cn=Directory Manager' \
118
+ LDAPBINDPW=topsecret \
119
+ LDAPDIR=./examples/ldif \
120
+ rake ldap:modify
121
+
122
+ Or, you could import the _1000_ example users included with this project, with no dependency on other software.
123
+ The `DEBUG` variable will print to screen any response from the server that would normally be logged.
124
+
125
+ $ DEBUG=y \
126
+ LDAPURI='ldap://cn=Directory Manager:topsecret@localhost:4389' \
127
+ rake 'ldif:import[examples/ldif/users.ldif]'
128
+
129
+
130
+ ## Examples
131
+
132
+ The console script connects and loads [Pry][pry] so you can explore your directory on the command line.
133
+
134
+ $ ./bin/console
135
+
136
+ To see a demonstration in action you can explore the examples after loading the seed data.
137
+
138
+ $ rake 'ldif:import[examples/ldif/animals.ldif]'
139
+
140
+ $ ./examples/fauna.rb
141
+
142
+ Check out _[Fauna][fauna]_ which is a more complete version of the example above and models data on evolutionary taxonomy.
143
+
144
+ If you use _[Rails][rails]_ then try the _[rom-ldap-rails][rom-ldap-rails]_ repository,
145
+ for a skeleton version of this same example applied to the [Ruby on Rails][rails] framework.
146
+
147
+
148
+
149
+
150
+
151
+
152
+ [389ds]: https://www.port389.org
153
+ [apacheds]: http://directory.apache.org/apacheds/downloads
154
+ [apachestudio]: http://directory.apache.org/studio/downloads
155
+ [branch]: https://gitlab.com/peterdavidhamilton/rom-ldap/commits/master
156
+ [coverage]: https://gitlab.com/peterdavidhamilton/rom-ldap/badges/master/coverage.svg
157
+ [fauna]: https://gitlab.com/peterdavidhamilton/fauna
158
+ [ldap-ber]: https://gitlab.com/peterdavidhamilton/ldap-ber
159
+ [ldap]: https://ldap.com
160
+ [net-ldap]: https://github.com/ruby-ldap/ruby-net-ldap
161
+ [opendj]: https://www.openidentityplatform.org/opendj
162
+ [openldap]: http://www.openldap.org
163
+ [pdhamilton]: https://pdhamilton.uk/projects/rom-ldap
164
+ [pipeline]: https://gitlab.com/peterdavidhamilton/rom-ldap/badges/master/pipeline.svg
165
+ [pry]: http://pryrepl.org
166
+ [rails]: https://rubyonrails.org
167
+ [rom-ldap-rails]: https://gitlab.com/peterdavidhamilton/rom-ldap-rails
168
+ [rom-ldap]: https://gitlab.com/peterdavidhamilton/rom-ldap
169
+ [rom-rb]: https://rom-rb.org
170
+ [rom-sql]: https://rom-rb.org/5.0/learn/sql
171
+ [ruby]: https://www.ruby-lang.org/en/downloads
172
+ [sequel]: http://sequel.jeremyevans.net