Integrating LDAP authentication into py4web
@nicozanf is already working on this.
Since Jun 29, 2025.
Assessment
This issue has not been assessed yet.
Description
I'm integrating LDAP authentication into my py4web app using py4web.utils.auth_plugins.ldap_plugin.LDAPPlugin, connected to an Active Directory server.
Here's some issues I encountered along the way:
❗ Issues Encountered:
LDAPPlugin.__init__() got an unexpected keyword argument 'use_tls'
→ Removed use_tls & timeout keys to make it work.
Default login page rendered only a single blank input with no labels
→ It seems the default auth.login() template doesn't render LDAP-based fields properly.
Auth.login() raises:
TypeError: Auth.login() missing 2 required positional arguments: 'email' and 'password'
→ I expected a form, not a function call.
💡 What Worked:
Using:
@action('index')
@action.uses('index.html', auth.user)
def index():
user = auth.get_user()
return dict(message=f"Hello {user['username']}")
Adding auth.use_username = True in common.py
Avoiding manual call to auth.login() in a controller (let py4web handle it via /auth/login route)
🙋♂️ Questions:
Is there a canonical way to render a working login form with LDAP (e.g., username/password)?
Is there a recommended template override or plugin fix for better LDAP support?
Are there plans to improve the docs around LDAPPlugin?
Thanks for the amazing work on py4web! I'd be happy to contribute improved docs/examples for LDAP if needed.
- Dominant language
- HTML
- Stars
- 319
- Forks
- 144
- Avg merge
- 6d 20h
- Merged PRs (30d)
- 3
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from web2py/py4web
-
Difficulty 3/5 1-2 days Newbie friendliness 48/100
-
Difficulty 5/5 Over a week Newbie friendliness 30/100
-
Difficulty 4/5 3-5 days Newbie friendliness 38/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 50/100
-
Difficulty 3/5 1-2 days Newbie friendliness 45/100