smhaller / ldap-overleaf-sl

Free LDAP and OAuth2 Authentication and Authorisation for Sharelatex / Overleaf (Community Edition)
GNU Affero General Public License v3.0
74 stars 35 forks source link

Fix parsing the LDAP_CONTACTS environment variable #13

Closed davidmehren closed 3 years ago

davidmehren commented 3 years ago

The current code skips loading contact information from LDAP if !process.env.LDAP_CONTACTS evaluates to true.

This is nearly never the case, as process.env contains strings and non-empty strings evaluate to true, making the negation falsy. Only an empty string in LDAP_CONTACTS (or not setting the environment variable at all) skips the contact loading.

This PR changes the logic to only load contacts from LDAP if the LDAP_CONTACTS environment variable is explicitly set to "true" (case insensitive). This should bring the behaviour of the application more in line with the expectation and the docs.