Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[1.17.0-rc1] LDAP Group Sync for organization teams issue with escaped characters in LDAP #20181

Closed
gd197 opened this issue Jun 30, 2022 · 9 comments · Fixed by #20200
Closed
Labels

Comments

@gd197
Copy link

gd197 commented Jun 30, 2022

Description

in our company AD (LDAP) , members of a group object are described according to their DN in the form:
member=CN=NAME\, SURNAME,OU=SITE,OU=Internal,OU=People,DC=my,DC=company,DC=corp
that is the exact extract from ldapsearch command on linux.
Unfortunately, the escaped coma (",") in the DN is not correctly managed by the synchronization task, all our users are managed that way
This lead to the following error log :
2022/06/30 15:43:12 ...dap/source_search.go:215:listLdapGroupMemberships() [E] [62bda870] Failed group search using filter[(member=CN=NAME\, SURNAME,OU=SITE,OU=Internal,OU=People,DC=my,DC=company,DC=corp)]: LDAP Result Code 201 "Filter Compile Error": ldap: invalid characters for escape in filter: encoding/hex: invalid byte: U+002C ','

Gitea Version

1.17-RC1

Can you reproduce the bug on the Gitea demo site?

No

Log Gist

No response

Screenshots

No response

Git Version

No response

Operating System

RHEL 7

How are you running Gitea?

Using package from release tab on github

Database

MySQL

@gd197
Copy link
Author

gd197 commented Jul 1, 2022

most probably related to #9169 ?

@zeripath
Copy link
Contributor

zeripath commented Jul 1, 2022

Are you able to tell us how they should be escaped?

@zeripath
Copy link
Contributor

zeripath commented Jul 1, 2022

Should this be:

member=CN=NAME\\\, SURNAME\,OU=SITE\,OU=Internal\,OU=People\,DC=my\,DC=company\,DC=corp

@zeripath
Copy link
Contributor

zeripath commented Jul 1, 2022

Or is it actually:

member=CN=NAME\\, SURNAME,OU=SITE,OU=Internal,OU=People,DC=my,DC=company,DC=corp

zeripath added a commit to zeripath/gitea that referenced this issue Jul 1, 2022
The uid provided to the group filter must be properly escaped using the provided
ldap.EscapeFilter function.

Fix go-gitea#20181

Signed-off-by: Andrew Thornton <art27@cantab.net>
@zeripath
Copy link
Contributor

zeripath commented Jul 1, 2022

It would be helpful if you could check the associated PR to ensure it fixes your issue.

@gd197
Copy link
Author

gd197 commented Jul 4, 2022

Sry for my late reply, can you tell me how can I get the associated build amd64 ? I do not have the capability to build gitea in my env.
Thx for your fast answer
The correct escaping in my case is
member=CN=NAME\\, SURNAME,OU=SITE,OU=Internal,OU=People,DC=my,DC=company,DC=corp

@rmie
Copy link

rmie commented Jul 4, 2022

@zeripath: #9169 (comment)

The recommendation there was to use \5c; but it involved strings entered via UI, likely that this caused additional escaping requirements.

Should this be:
member=CN=NAME\\\, SURNAME\,OU=SITE\,OU=Internal\,OU=People\,DC=my\,DC=company\,DC=corp

no

Or is it actually:
member=CN=NAME\\, SURNAME,OU=SITE,OU=Internal,OU=People,DC=my,DC=company,DC=corp

yes, sans \\, it might be \5c, as well

I can't build and test from source, is the PR built as docker image?

@zeripath
Copy link
Contributor

zeripath commented Jul 4, 2022

Sry for my late reply, can you tell me how can I get the associated build amd64 ? I do not have the capability to build gitea in my env.

Honestly building Gitea is very very simple especially for amd64. I've previously built PRs for people but it's really something that I save for those personally sponsoring me.

The correct escaping in my case is
member=CN=NAME\\, SURNAME,OU=SITE,OU=Internal,OU=People,DC=my,DC=company,DC=corp

Ok so my PR will do the right thing.

@rmie
Copy link

rmie commented Jul 4, 2022

@zeripath just built and tested your PR, it solves the issue for me

zeripath added a commit that referenced this issue Jul 5, 2022
The uid provided to the group filter must be properly escaped using the provided
ldap.EscapeFilter function.

Fix #20181

Signed-off-by: Andrew Thornton <art27@cantab.net>
zeripath added a commit to zeripath/gitea that referenced this issue Jul 5, 2022
Backport go-gitea#20200

The uid provided to the group filter must be properly escaped using the provided
ldap.EscapeFilter function.

Fix go-gitea#20181

Signed-off-by: Andrew Thornton <art27@cantab.net>
zeripath added a commit that referenced this issue Jul 6, 2022
Backport #20200

The uid provided to the group filter must be properly escaped using the provided
ldap.EscapeFilter function.

Fix #20181

Signed-off-by: Andrew Thornton <art27@cantab.net>
dineshsalunke pushed a commit to dineshsalunke/gitea that referenced this issue Jul 9, 2022
The uid provided to the group filter must be properly escaped using the provided
ldap.EscapeFilter function.

Fix go-gitea#20181

Signed-off-by: Andrew Thornton <art27@cantab.net>
vsysoev pushed a commit to IntegraSDL/gitea that referenced this issue Aug 10, 2022
The uid provided to the group filter must be properly escaped using the provided
ldap.EscapeFilter function.

Fix go-gitea#20181

Signed-off-by: Andrew Thornton <art27@cantab.net>
@go-gitea go-gitea locked and limited conversation to collaborators May 3, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants