Cloudron makes it easy to run web apps like WordPress, Nextcloud, GitLab on your server. Find out more or install now.


Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Bookmarks
  • Search
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo

Cloudron Forum

Apps | Demo | Docs | Install
E

eng0waleed

@eng0waleed
About
Posts
1
Topics
1
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • LDAP login fails when username contains dots - Taiga strips special characters
    E eng0waleed

    Describe the bug
    LDAP authentication fails when the LDAP username contains dots (e.g., john.doe). Taiga strips dots from usernames during user creation, storing johndoe instead of john.doe. On subsequent LDAP logins, the plugin looks up john.doe, doesn't find it, and tries to create a new user, which fails due to duplicate email constraint.
    To Reproduce

    User with LDAP uid john.doe and email john.doe@example.com logs in for the first time
    Taiga creates user with username johndoe (dot stripped)
    User logs in again via LDAP
    Plugin searches for username john.doe - not found
    Plugin tries to create new user - fails with duplicate email error

    Error Log:

    taiga.users.models.User.DoesNotExist: User matching query does not exist.
    During handling of the above exception, another exception occurred:
    django.db.utils.IntegrityError: duplicate key value violates unique constraint "users_user_email_243f6e77_uniq"
    Proposed Fix
    Option A: Normalize username before lookup (strip dots to match Taiga's behavior)
    python@transaction.atomic
    def ldap_register(username: str, email: str, full_name: str):
        user_model = get_user_model()
        normalized_username = username.replace('.', '')
        try:
            user = user_model.objects.get(username=normalized_username)
        except user_model.DoesNotExist:
            user = user_model.objects.create(
                email=email,
                username=normalized_username,
                full_name=full_name
            )
        return user
    Option B: Lookup by email as fallback
    python@transaction.atomic
    def ldap_register(username: str, email: str, full_name: str):
        user_model = get_user_model()
        try:
            user = user_model.objects.get(username=username)
        except user_model.DoesNotExist:
            if email:
                try:
                    user = user_model.objects.get(email=email)
                    return user
                except user_model.DoesNotExist:
                    pass
            user = user_model.objects.create(
                email=email,
                username=username,
                full_name=full_name
            )
        return user
    
    Taiga
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • Bookmarks
  • Search