-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Fix handling of username_as_alias during LDAP authentication #15525
Conversation
There is a bug that was introduced in the LDAP authentication method by hashicorp#11000. It was thought to be backward compatible but has broken a number of users. Later a new parameter `username_as_alias` was introduced in hashicorp#14324 to make it possible for operators to restore the previous behavior. The way it is currently working is not completely backward compatible thought because when username_as_alias is set, a call to GetUserAliasAttributeValue() will first be made, then this value is completely discarded in pathLogin() and replaced by the username as expected. This is an issue because it makes useless calls to the LDAP server and will break backward compatibility if one of the constraints in GetUserAliasAttributeValue() is not respected, even though the resulting value will be discarded anyway. In order to maintain backward compatibility here we have to only call GetUserAliasAttributeValue() if necessary. Since this change of behavior was introduced in 1.9, this fix will need to be backported to the 1.9, 1.10 and 1.11 branches.
Thanks for the PR to address this! Can you include a test case to cover this scenario?
|
Hi @calvn, I added two tests, one for Can you please make a review? |
Co-authored-by: Calvin Leung Huang <1883212+calvn@users.noreply.github.com>
Hi @calvn do you think you will be able to do the review shortly? This is blocking one of our Vault enterprise client. |
Hi @remilapeyre, CI is failing due to a formatting error (please run Can you take a look at these? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes look good, though I'd like to hold off on the merge until @jasonodonnell is all good with some validation he is performing on his end.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
* Fix handling of username_as_alias during LDAP authentication There is a bug that was introduced in the LDAP authentication method by #11000. It was thought to be backward compatible but has broken a number of users. Later a new parameter `username_as_alias` was introduced in #14324 to make it possible for operators to restore the previous behavior. The way it is currently working is not completely backward compatible thought because when username_as_alias is set, a call to GetUserAliasAttributeValue() will first be made, then this value is completely discarded in pathLogin() and replaced by the username as expected. This is an issue because it makes useless calls to the LDAP server and will break backward compatibility if one of the constraints in GetUserAliasAttributeValue() is not respected, even though the resulting value will be discarded anyway. In order to maintain backward compatibility here we have to only call GetUserAliasAttributeValue() if necessary. Since this change of behavior was introduced in 1.9, this fix will need to be backported to the 1.9, 1.10 and 1.11 branches. * Add changelog * Add tests * Format code * Update builtin/credential/ldap/backend.go Co-authored-by: Calvin Leung Huang <1883212+calvn@users.noreply.github.com> * Format and fix declaration * Reword changelog Co-authored-by: Calvin Leung Huang <1883212+calvn@users.noreply.github.com> # Conflicts: # builtin/credential/ldap/backend_test.go
…#15556) * Fix handling of username_as_alias during LDAP authentication There is a bug that was introduced in the LDAP authentication method by #11000. It was thought to be backward compatible but has broken a number of users. Later a new parameter `username_as_alias` was introduced in #14324 to make it possible for operators to restore the previous behavior. The way it is currently working is not completely backward compatible thought because when username_as_alias is set, a call to GetUserAliasAttributeValue() will first be made, then this value is completely discarded in pathLogin() and replaced by the username as expected. This is an issue because it makes useless calls to the LDAP server and will break backward compatibility if one of the constraints in GetUserAliasAttributeValue() is not respected, even though the resulting value will be discarded anyway. In order to maintain backward compatibility here we have to only call GetUserAliasAttributeValue() if necessary. Since this change of behavior was introduced in 1.9, this fix will need to be backported to the 1.9, 1.10 and 1.11 branches. * Add changelog * Add tests * Format code * Update builtin/credential/ldap/backend.go Co-authored-by: Calvin Leung Huang <1883212+calvn@users.noreply.github.com> * Format and fix declaration * Reword changelog Co-authored-by: Calvin Leung Huang <1883212+calvn@users.noreply.github.com> # Conflicts: # builtin/credential/ldap/backend_test.go Co-authored-by: Rémi Lapeyre <remi.lapeyre@lenstra.fr>
Hi @calvn @jasonodonnell, thanks for reviewing the PR. Do you know when 1.9.7 will be released? We can't build it ourselves because we are using the enterprise version. |
…rp#15525) * Fix handling of username_as_alias during LDAP authentication There is a bug that was introduced in the LDAP authentication method by hashicorp#11000. It was thought to be backward compatible but has broken a number of users. Later a new parameter `username_as_alias` was introduced in hashicorp#14324 to make it possible for operators to restore the previous behavior. The way it is currently working is not completely backward compatible thought because when username_as_alias is set, a call to GetUserAliasAttributeValue() will first be made, then this value is completely discarded in pathLogin() and replaced by the username as expected. This is an issue because it makes useless calls to the LDAP server and will break backward compatibility if one of the constraints in GetUserAliasAttributeValue() is not respected, even though the resulting value will be discarded anyway. In order to maintain backward compatibility here we have to only call GetUserAliasAttributeValue() if necessary. Since this change of behavior was introduced in 1.9, this fix will need to be backported to the 1.9, 1.10 and 1.11 branches. * Add changelog * Add tests * Format code * Update builtin/credential/ldap/backend.go Co-authored-by: Calvin Leung Huang <1883212+calvn@users.noreply.github.com> * Format and fix declaration * Reword changelog Co-authored-by: Calvin Leung Huang <1883212+calvn@users.noreply.github.com>
There is a bug that was introduced in the LDAP authentication method by #11000.
It was thought to be backward compatible but has broken a number of users. Later
a new parameter
username_as_alias
was introduced in #14324to make it possible for operators to restore the previous behavior.
The way it is currently working is not completely backward compatible thought
because when username_as_alias is set, a call to GetUserAliasAttributeValue() will
first be made, then this value is completely discarded in pathLogin() and replaced
by the username as expected.
This is an issue because it makes useless calls to the LDAP server and will break
backward compatibility if one of the constraints in GetUserAliasAttributeValue()
is not respected, even though the resulting value will be discarded anyway.
In order to maintain backward compatibility here we have to only call
GetUserAliasAttributeValue() if necessary.
Since this change of behavior was introduced in 1.9, this fix will need to be
backported to the 1.9, 1.10 and 1.11 branches.