Integrating LDAP authentication into py4web

Open
#978 3 comments 0 reactions 1 assignee View on GitHub

@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

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from web2py/py4web

All issues in web2py/py4web

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.