ldapie 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,40 @@
1
+ # Use Python 3.9 slim as base image
2
+ FROM python:3.9-slim
3
+
4
+ # Add metadata
5
+ LABEL maintainer="LDAPie Project"
6
+ LABEL description="Modern LDAP client command-line interface tool inspired by HTTPie"
7
+ LABEL org.opencontainers.image.source="https://github.com/ruslanfialkovskii/ldapie"
8
+
9
+ # Set working directory
10
+ WORKDIR /app
11
+
12
+ # Install required system dependencies
13
+ RUN apt-get update && apt-get install -y --no-install-recommends \
14
+ libldap2-dev \
15
+ libsasl2-dev \
16
+ && rm -rf /var/lib/apt/lists/*
17
+
18
+ # Copy requirements first to leverage Docker cache
19
+ COPY requirements.txt .
20
+ RUN pip install --no-cache-dir -r requirements.txt
21
+
22
+ # Copy the application
23
+ COPY src/ src/
24
+ COPY ldapie .
25
+ COPY completion.zsh .
26
+ COPY setup.py .
27
+ COPY README.md .
28
+ COPY LICENSE .
29
+
30
+ # Make the ldapie script executable
31
+ RUN chmod +x ./ldapie
32
+
33
+ # Create a symbolic link to make ldapie available in PATH
34
+ RUN ln -s /app/ldapie /usr/local/bin/ldapie
35
+
36
+ # Set the entrypoint to the ldapie script
37
+ ENTRYPOINT ["ldapie"]
38
+
39
+ # Default command (can be overridden)
40
+ CMD ["--help"]
ldapie-0.1.0/LICENSE ADDED
@@ -0,0 +1,15 @@
1
+ # GNU GENERAL PUBLIC LICENSE
2
+
3
+ Version 3, 29 June 2007
4
+
5
+ Copyright (C) 2007 Free Software Foundation, Inc.
6
+ <https://www.gnu.org/licenses/gpl-3.0.html>
7
+ Everyone is permitted to copy and distribute verbatim copies
8
+ of this license document, but changing it is not allowed.
9
+
10
+ Preamble
11
+
12
+ The GNU General Public License is a free, copyleft license for
13
+ software and other kinds of works.
14
+
15
+ Full license text: <https://www.gnu.org/licenses/gpl-3.0.txt>
@@ -0,0 +1,10 @@
1
+ include LICENSE
2
+ include README.md
3
+ include ROADMAP.md
4
+ include requirements.txt
5
+ include completion.zsh
6
+ include Makefile
7
+ include Dockerfile
8
+
9
+ recursive-include tests *.py
10
+ recursive-include src *.py
ldapie-0.1.0/Makefile ADDED
@@ -0,0 +1,76 @@
1
+ .PHONY: setup install test demo clean
2
+
3
+ # Default target
4
+ all: install
5
+
6
+ # Setup development environment
7
+ setup:
8
+ python -m venv venv
9
+ . venv/bin/activate && pip install -r requirements.txt
10
+ . venv/bin/activate && pip install -e .
11
+
12
+ # Install the package
13
+ install:
14
+ pip install -e .
15
+
16
+ # Run tests
17
+ test:
18
+ pytest
19
+
20
+ # Run the demo
21
+ demo:
22
+ python tests/demo.py
23
+
24
+ # Run the enhanced demo
25
+ demo-enhanced:
26
+ python tests/enhanced_demo.py
27
+
28
+ # Install shell completion for zsh
29
+ install-completion:
30
+ mkdir -p ~/.zsh/completion
31
+ cp completion.zsh ~/.zsh/completion/_ldapie
32
+ @echo "Add the following to your ~/.zshrc if you haven't already:"
33
+ @echo "fpath=(~/.zsh/completion \$$fpath)"
34
+ @echo "autoload -Uz compinit && compinit"
35
+
36
+ # Clean up temporary files and builds
37
+ clean:
38
+ rm -rf build/
39
+ rm -rf dist/
40
+ rm -rf *.egg-info
41
+ rm -rf __pycache__/
42
+ rm -rf src/__pycache__/
43
+ rm -rf tests/__pycache__/
44
+ find . -type d -name __pycache__ -exec rm -rf {} +
45
+ find . -type f -name '*.pyc' -delete
46
+
47
+ # Build distribution packages
48
+ dist:
49
+ python setup.py sdist bdist_wheel
50
+
51
+ # Check for lint issues
52
+ lint:
53
+ flake8 src tests
54
+
55
+ # Format code with Black
56
+ format:
57
+ black src tests
58
+
59
+ # Generate documentation
60
+ docs:
61
+ cd docs && make html
62
+
63
+ # Help
64
+ help:
65
+ @echo "Available targets:"
66
+ @echo " setup - Set up development environment"
67
+ @echo " install - Install the package in development mode"
68
+ @echo " test - Run tests"
69
+ @echo " demo - Run the demo with mock LDAP server"
70
+ @echo " demo-enhanced - Run the enhanced demo with interactive mock LDAP server"
71
+ @echo " install-completion - Install shell completion for zsh"
72
+ @echo " clean - Clean up temporary files and builds"
73
+ @echo " dist - Build distribution packages"
74
+ @echo " lint - Check for lint issues"
75
+ @echo " format - Format code with Black"
76
+ @echo " docs - Generate documentation"
ldapie-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,386 @@
1
+ Metadata-Version: 2.4
2
+ Name: ldapie
3
+ Version: 0.1.0
4
+ Summary: A modern LDAP client CLI tool inspired by HTTPie
5
+ Home-page: https://github.com/ruslanfialkovskii/ldapie
6
+ Author: LDAPie Team
7
+ Author-email: LDAPie Team <author@example.com>
8
+ License: # GNU GENERAL PUBLIC LICENSE
9
+
10
+ Version 3, 29 June 2007
11
+
12
+ Copyright (C) 2007 Free Software Foundation, Inc.
13
+ <https://www.gnu.org/licenses/gpl-3.0.html>
14
+ Everyone is permitted to copy and distribute verbatim copies
15
+ of this license document, but changing it is not allowed.
16
+
17
+ Preamble
18
+
19
+ The GNU General Public License is a free, copyleft license for
20
+ software and other kinds of works.
21
+
22
+ Full license text: <https://www.gnu.org/licenses/gpl-3.0.txt>
23
+
24
+ Requires-Python: >=3.8
25
+ Description-Content-Type: text/markdown
26
+ License-File: LICENSE
27
+ Dynamic: author
28
+ Dynamic: home-page
29
+ Dynamic: license-file
30
+ Dynamic: requires-python
31
+
32
+ # LDAPie
33
+
34
+ A modern LDAP client CLI tool inspired by [HTTPie](https://httpie.io), using [ldap3](https://github.com/cannatag/ldap3) for LDAP operations and [Rich](https://github.com/Textualize/rich) for beautiful terminal output.
35
+
36
+ [![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0)
37
+ [![Python Version](https://img.shields.io/badge/python-3.7%2B-blue.svg)](https://www.python.org/downloads/)
38
+
39
+ LDAPie makes LDAP operations more accessible and intuitive with a modern command-line interface, beautiful output, and comprehensive features for both beginners and LDAP experts.
40
+
41
+ ## Features
42
+
43
+ - Beautiful, colorized output with syntax highlighting
44
+ - Intuitive command-line interface
45
+ - LDAP operations: search, add, modify, delete, and rename entries
46
+ - Interactive mode with terminal UI interface
47
+ - Multiple output formats: Rich text, JSON, LDIF, CSV, and tree view
48
+ - Anonymous and authenticated connections
49
+ - Support for SSL/TLS connections
50
+ - Certificate-based authentication
51
+ - Multiple search scope options (base, one, sub)
52
+ - Theme support with light and dark modes
53
+ - Secure password handling options
54
+ - Shell completion for Bash, Zsh, and Fish
55
+ - Directory navigation in interactive mode
56
+ - Context-sensitive help system with smart suggestions
57
+
58
+ ## Quick Start
59
+
60
+ ```bash
61
+ # Clone the repository
62
+ git clone https://github.com/ruslanfialkovskii/ldapie.git
63
+ cd ldapie
64
+
65
+ # Create a virtual environment and install dependencies
66
+ python3 -m venv venv
67
+ source venv/bin/activate
68
+ pip install -r requirements.txt
69
+
70
+ # Make the wrapper scripts executable
71
+ chmod +x ldapie ldapie.sh
72
+
73
+ # Try the automated demo with a mock LDAP server
74
+ ./ldapie.sh --demo
75
+
76
+ # Install shell completion (optional)
77
+ ./ldapie --install-completion
78
+ ```
79
+
80
+ The automated demo will showcase all major features of LDAPie using a mock LDAP server, so you don't need a real LDAP server to get started.
81
+
82
+ ## Installation
83
+
84
+ ### Option 1: Install from Source
85
+
86
+ ```bash
87
+ # Create a virtual environment (optional but recommended)
88
+ python3 -m venv venv
89
+ source venv/bin/activate
90
+
91
+ # Install the required packages
92
+ pip install -r requirements.txt
93
+
94
+ # Install in development mode
95
+ pip install -e .
96
+ ```
97
+
98
+ ### Option 2: Quick Setup Script
99
+
100
+ ```bash
101
+ # Make the wrapper script executable
102
+ chmod +x ldapie
103
+
104
+ # Use the wrapper script directly
105
+ ./ldapie search localhost "dc=example,dc=com"
106
+ ```
107
+
108
+ ### Option 3: Using Docker
109
+
110
+ ```bash
111
+ # Build the Docker image
112
+ docker build -t ldapie .
113
+
114
+ # Run using Docker
115
+ docker run -it ldapie search ldap.example.com "dc=example,dc=com"
116
+ ```
117
+
118
+ ## Shell Completion
119
+
120
+ LDAPie provides shell completion for Bash, Zsh, and Fish:
121
+
122
+ ```bash
123
+ # Install shell completion
124
+ ./ldapie --install-completion
125
+
126
+ # Show completion script without installing
127
+ ./ldapie --show-completion
128
+ ```
129
+
130
+ ## Usage
131
+
132
+ LDAPie provides a command-line interface for LDAP operations:
133
+
134
+ ```bash
135
+ ldapie search <host> <base_dn> [<filter>] [options]
136
+ ldapie info <host> [options]
137
+ ldapie compare <host> <dn1> <dn2> [options]
138
+ ldapie schema <host> [<object_class>] [options]
139
+ ldapie add <host> <dn> [options]
140
+ ldapie modify <host> <dn> [options]
141
+ ldapie delete <host> <dn> [options]
142
+ ldapie rename <host> <dn> <new_rdn> [options]
143
+ ldapie interactive [options]
144
+ ```
145
+
146
+ ## Context-Sensitive Help System
147
+
148
+ LDAPie includes a comprehensive context-sensitive help system that provides smart suggestions based on your current context and command history:
149
+
150
+ - **Progressive Help**: Type '?' after any partial command to get context-specific help
151
+ - **Command Validation**: Use the `--validate` flag to check and preview commands without execution
152
+ - **Smart Suggestions**: Get intelligent recommendations based on your current operation context
153
+ - **"Did you mean...?"**: Get automatic corrections for mistyped commands
154
+ - **History-Aware Help**: Suggestions are informed by your previous commands and operations
155
+
156
+ Examples:
157
+
158
+ ```bash
159
+ # Get help for a partial command
160
+ ./ldapie search?
161
+
162
+ # Validate a command without executing it
163
+ ./ldapie search ldap.example.com "dc=example,dc=com" --validate
164
+
165
+ # Get help during interactive mode
166
+ ldapie> search?
167
+ ```
168
+
169
+ ## Usage Examples
170
+
171
+ ### LDAP Search Operations
172
+
173
+ ```bash
174
+ # Basic search
175
+ ./ldapie search ldap.example.com "dc=example,dc=com"
176
+
177
+ # Search with filter
178
+ ./ldapie search ldap.example.com "dc=example,dc=com" "(objectClass=person)"
179
+
180
+ # Authenticate with username and password
181
+ ./ldapie search ldap.example.com "dc=example,dc=com" "(uid=admin)" -u "cn=admin,dc=example,dc=com" -p secret
182
+
183
+ # Specify attributes to retrieve
184
+ ./ldapie search ldap.example.com "dc=example,dc=com" "(cn=*)" -a cn -a mail -a uid
185
+
186
+ # Use SSL/TLS
187
+ ./ldapie search ldaps.example.com "dc=example,dc=com" --ssl
188
+
189
+ # Output in JSON format
190
+ ./ldapie search ldap.example.com "dc=example,dc=com" --json
191
+
192
+ # Output in LDIF format
193
+ ./ldapie search ldap.example.com "dc=example,dc=com" --ldif
194
+
195
+ # Output in CSV format
196
+ ./ldapie search ldap.example.com "dc=example,dc=com" --csv
197
+
198
+ # Display results as a tree
199
+ ./ldapie search ldap.example.com "dc=example,dc=com" --tree
200
+
201
+ # Secure password handling (will prompt for password)
202
+ ./ldapie search ldap.example.com "dc=example,dc=com" -u "cn=admin,dc=example,dc=com"
203
+
204
+ # Limit search results
205
+ ./ldapie search ldap.example.com "dc=example,dc=com" --limit 10
206
+
207
+ # Save results to a file
208
+ ./ldapie search ldap.example.com "dc=example,dc=com" --json --output results.json
209
+ ```
210
+
211
+ ### Get LDAP Server Information
212
+
213
+ ```bash
214
+ # Get server information
215
+ ./ldapie info ldap.example.com
216
+
217
+ # Authenticate to get server information
218
+ ./ldapie info ldap.example.com -u "cn=admin,dc=example,dc=com" -p secret
219
+ ```
220
+
221
+ ### Compare Two LDAP Entries
222
+
223
+ ```bash
224
+ # Compare two LDAP entries
225
+ ./ldapie compare ldap.example.com "uid=user1,ou=people,dc=example,dc=com" "uid=user2,ou=people,dc=example,dc=com"
226
+
227
+ # Compare specific attributes
228
+ ./ldapie compare ldap.example.com "uid=user1,ou=people,dc=example,dc=com" "uid=user2,ou=people,dc=example,dc=com" -a uid -a cn -a mail
229
+ ```
230
+
231
+ ### Get Schema Information
232
+
233
+ ```bash
234
+ # Get a list of all object classes
235
+ ./ldapie schema ldap.example.com
236
+
237
+ # Get information about a specific object class
238
+ ./ldapie schema ldap.example.com person
239
+
240
+ # Get information about a specific attribute
241
+ ./ldapie schema ldap.example.com --attr mail
242
+ ```
243
+
244
+ ### Add New LDAP Entry
245
+
246
+ ```bash
247
+ # Add a simple entry
248
+ ./ldapie add ldap.example.com "cn=newuser,ou=people,dc=example,dc=com" --class inetOrgPerson --attr cn=newuser --attr sn=User --attr uid=newuser -u "cn=admin,dc=example,dc=com"
249
+
250
+ # Add an entry from LDIF file
251
+ ./ldapie add ldap.example.com --ldif entries.ldif -u "cn=admin,dc=example,dc=com"
252
+
253
+ # Add an entry from JSON file
254
+ ./ldapie add ldap.example.com "cn=newgroup,ou=groups,dc=example,dc=com" --json group.json -u "cn=admin,dc=example,dc=com"
255
+ ```
256
+
257
+ ### Modify LDAP Entry
258
+
259
+ ```bash
260
+ # Add a value to an attribute
261
+ ./ldapie modify ldap.example.com "cn=user1,ou=people,dc=example,dc=com" --add mail=user1@example2.com -u "cn=admin,dc=example,dc=com"
262
+
263
+ # Replace an attribute value
264
+ ./ldapie modify ldap.example.com "cn=user1,ou=people,dc=example,dc=com" --replace mobile=555-1234 -u "cn=admin,dc=example,dc=com"
265
+
266
+ # Delete an attribute value
267
+ ./ldapie modify ldap.example.com "cn=user1,ou=people,dc=example,dc=com" --delete mail=user1@example.com -u "cn=admin,dc=example,dc=com"
268
+
269
+ # Delete an entire attribute
270
+ ./ldapie modify ldap.example.com "cn=user1,ou=people,dc=example,dc=com" --delete mobile -u "cn=admin,dc=example,dc=com"
271
+ ```
272
+
273
+ ### Delete LDAP Entry
274
+
275
+ ```bash
276
+ # Delete an entry
277
+ ./ldapie delete ldap.example.com "cn=user1,ou=people,dc=example,dc=com" -u "cn=admin,dc=example,dc=com"
278
+
279
+ # Delete an entry and all its children (recursive)
280
+ ./ldapie delete ldap.example.com "ou=people,dc=example,dc=com" --recursive -u "cn=admin,dc=example,dc=com"
281
+ ```
282
+
283
+ ### Rename or Move LDAP Entry
284
+
285
+ ```bash
286
+ # Rename an entry (change RDN)
287
+ ./ldapie rename ldap.example.com "cn=user1,ou=people,dc=example,dc=com" "cn=user1renamed" -u "cn=admin,dc=example,dc=com"
288
+
289
+ # Move an entry to a different location
290
+ ./ldapie rename ldap.example.com "cn=user1,ou=people,dc=example,dc=com" "cn=user1" --parent "ou=admins,dc=example,dc=com" -u "cn=admin,dc=example,dc=com"
291
+ ```
292
+
293
+ ### Interactive Mode
294
+
295
+ ```bash
296
+ # Start interactive mode
297
+ ./ldapie interactive
298
+
299
+ # Start interactive mode and connect to a server
300
+ ./ldapie interactive --host ldap.example.com --user "cn=admin,dc=example,dc=com" --base "dc=example,dc=com"
301
+
302
+ # Start interactive mode with SSL
303
+ ./ldapie interactive --host ldap.example.com --ssl --base "dc=example,dc=com"
304
+ ```
305
+
306
+ In interactive mode, you can use commands like:
307
+
308
+ - `connect ldap.example.com 389 admin --ssl` - Connect to server
309
+ - `ls` - List entries in current base DN
310
+ - `cd ou=people,dc=example,dc=com` - Change base DN
311
+ - `search "(objectClass=person)" cn mail` - Search for entries
312
+ - `show 0` - Show first entry from last search
313
+ - `add cn=user,ou=people,dc=example,dc=com person cn=User sn=User` - Add entry
314
+ - `delete cn=user,ou=people,dc=example,dc=com` - Delete entry
315
+ - `help` - Show all available commands
316
+
317
+ ## Password Handling
318
+
319
+ LDAPie supports several methods for securely handling passwords:
320
+
321
+ ### Interactive Password Prompt
322
+
323
+ The most secure method is to not specify the password on the command line and let the tool prompt for it:
324
+
325
+ ```bash
326
+ ./ldapie search ldap.example.com "dc=example,dc=com" -u "cn=admin,dc=example,dc=com"
327
+ # You'll be prompted to enter password securely
328
+ ```
329
+
330
+ ### Passwords With Special Characters
331
+
332
+ If you need to provide passwords containing special shell characters on the command line:
333
+
334
+ 1. Use single quotes to prevent shell interpretation:
335
+
336
+ ```bash
337
+ ./ldapie search ldap.example.com "dc=example,dc=com" -u "user" -p 'password!with#special@chars'
338
+ ```
339
+
340
+ 2. Use environment variables:
341
+
342
+ ```bash
343
+ export LDAP_PASSWORD="password!with#special@chars"
344
+ ./ldapie search ldap.example.com "dc=example,dc=com" -u "user" -p "$LDAP_PASSWORD"
345
+ ```
346
+
347
+ 3. Escape special characters:
348
+
349
+ ```bash
350
+ ./ldapie search ldap.example.com "dc=example,dc=com" -u "user" -p "password\!with\#special\@chars"
351
+ ```
352
+
353
+ ## Help
354
+
355
+ ```bash
356
+ ./ldapie --help
357
+ ./ldapie search --help
358
+ ./ldapie info --help
359
+ ./ldapie compare --help
360
+ ./ldapie schema --help
361
+ ./ldapie add --help
362
+ ./ldapie modify --help
363
+ ./ldapie delete --help
364
+ ./ldapie rename --help
365
+ ./ldapie interactive --help
366
+ ```
367
+
368
+ ## Themes
369
+
370
+ LDAPie supports light and dark themes that can be set through the `--theme` option or environment variable:
371
+
372
+ ```bash
373
+ # Set theme using command-line option
374
+ ./ldapie search ldap.example.com "dc=example,dc=com" --theme light
375
+
376
+ # Set theme using environment variable
377
+ LDAPIE_THEME=light ./ldapie search ldap.example.com "dc=example,dc=com"
378
+ ```
379
+
380
+ ## Contributing
381
+
382
+ Contributions are welcome! Please feel free to submit a Pull Request.
383
+
384
+ ## License
385
+
386
+ This project is licensed under the GNU General Public License v3.0 - see the LICENSE file for details.