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

Add LDAP mode for basic authentication #871

Merged
merged 2 commits into from
Dec 5, 2022

Conversation

samanhappy
Copy link
Collaborator

No description provided.

@samanhappy samanhappy changed the title add LDAP authentication validator Add LDAP authentication validator Dec 1, 2022
@samanhappy samanhappy changed the title Add LDAP authentication validator Add LDAP mode for basic authentication Dec 2, 2022
@codecov-commenter
Copy link

codecov-commenter commented Dec 2, 2022

Codecov Report

Base: 76.07% // Head: 76.03% // Decreases project coverage by -0.04% ⚠️

Coverage data is based on head (d238bea) compared to base (f440e84).
Patch coverage: 55.81% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #871      +/-   ##
==========================================
- Coverage   76.07%   76.03%   -0.05%     
==========================================
  Files         110      110              
  Lines       12698    12741      +43     
==========================================
+ Hits         9660     9687      +27     
- Misses       2492     2508      +16     
  Partials      546      546              
Impacted Files Coverage Δ
pkg/filters/validator/basicauth.go 75.00% <55.81%> (-3.81%) ⬇️
pkg/filters/proxy/pool.go 79.30% <0.00%> (-0.88%) ⬇️
pkg/cluster/cluster.go 61.15% <0.00%> (+1.05%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

Comment on lines 367 to 379
defer luc.client.Close()
if err := luc.client.Connect(); err != nil {
logger.Warnf("failed to connect LDAP server %v", err)
return false
}

userdn := fmt.Sprintf("%s=%s,%s", luc.spec.UID, username, luc.spec.BaseDN)
if err := luc.client.Conn.Bind(userdn, password); err != nil {
logger.Warnf("failed to bind LDAP user %v", err)
return false
}

return true
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could this function be called concurrently?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this quesion is very considerate, the client.Connect() will create a connection if not exists and then store it which can be used by other function like Conn.Bind, but the code defer luc.client.Close() will break it and could case concurrency problem, so I remove it.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we sure that luc.client.Conn.Bind is goroutine safe.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it should be safe according to https://github.com/go-ldap/ldap/blob/master/ldap_test.go#L198, and I also did a test which shows safe.

@suchen-sci suchen-sci merged commit a8eb6c7 into easegress-io:main Dec 5, 2022
@samanhappy samanhappy deleted the ldap branch December 5, 2022 06:14
caoshengdong pushed a commit to caoshengdong/easegress that referenced this pull request Dec 20, 2022
* add LDAP mode for basic authentication

* hold connection to avoid concurrenty problem
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants