Skip to content

Auth override email of ldap plugin #982

Open
@bammab

Description

@bammab

Hi,

when using the ldap auth plugin with "manage_user": True against an AD, the email of the user will be read, but overriden by "[email protected]".
I have temporary fixed this behavior with this code (added lines marked with a plus):

    def get_or_register_user(self, user):
         db = self.db
         # if we have an sso_id we use it to id the user
         if user.get("sso_id"):
             keyid = "sso_id"
             row = (
                 db(db.auth_user.sso_id == user["sso_id"]).select(limitby=(0, 1)).first()
             )
             # the sso source is always more authoritative so update the record
             if row:
+                if row.email and "email" in user and user.get("email").endswith("example.com"):
+                    del user["email"]
                 row.update_record(**user)
                 # pass the full user
                 user = row.as_dict()

I don't know if this could be side effacts or break something.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions