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
  1. Cloudron Forum
  2. Taiga
  3. LDAP login fails when username contains dots - Taiga strips special characters

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

Scheduled Pinned Locked Moved Solved Taiga
4 Posts 3 Posters 27 Views 3 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Offline
    E Offline
    eng0waleed
    wrote last edited by james
    #1

    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
    
    1 Reply Last reply
    1
    • nebulonN Away
      nebulonN Away
      nebulon
      Staff
      wrote last edited by
      #2

      This seems to be the same as https://forum.cloudron.io/topic/14497/cloudron-auth-support-doesn-t-seem-to-work/6

      I thought we had fixed that with the other auth module. @james do you remember?

      1 Reply Last reply
      1
      • jamesJ Online
        jamesJ Online
        james
        Staff
        wrote last edited by
        #3

        Hello @nebulon
        I also think that we had worked on this issue before.
        I am looking into it.

        1 Reply Last reply
        0
        • nebulonN Away
          nebulonN Away
          nebulon
          Staff
          wrote last edited by
          #4

          We published a new app which should fix this now.

          1 Reply Last reply
          0
          • nebulonN nebulon marked this topic as a question
          • nebulonN nebulon has marked this topic as solved
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

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