-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Support for LDAP server authentication #279
Conversation
Limitations as of this commit: - tlsOptions can only be specified in config.json, not as env vars - authentication failures are not yet gracefully handled by the UI - instead the error message is shown on a blank page (/auth/ldap) - no email address is associated with the LDAP user's account - no picture/profile URL is associated with the LDAP user's account - we might have to generate our own access + refresh tokens, because we aren't using oauth. The currently generated tokens are just a placeholder. - 'LDAP Sign in' needs to be translated to each locale
Hi @alecdwm
|
- return bad request if no username or password given - return to referer url on auth success - flash error message on auth failure
- previously was a separate modal - now is located on main modal, like email auth
Thanks for the feedback! 😁 Open points:
|
To the latest point: if you have an email address available, there are still gravatar or libravatar. |
If my understanding of LDAP is correct, it's always bound to an identity provider, right?
These don't need to be included in a first version. All in all, 🎉 for LDAP-support! |
Profile pictures are good to go! The LDAP username is used to seed a RNG, which then selects a background colour from of a list of possible colours that I stole from here (alphabetcolors). Next the first letter is stripped off, uppercased and used along with the selected colour to format an SVG. Finally, the SVG (stored in memory as a UTF8-encoded string) is encoded into base64 with the prefix Support for embedding the generated image into an img tag looks comprehensive, for all intents and purposes. For example:
|
@alecdwm Very clever move! And any else need to concern before merge this PR? |
@jackycute Cheers! As far as I can tell, By seeding Should be ready to merge! |
@alecdwm Thanks! |
@jackycute Oh neat! I should have looked closer and seen that >.< |
Small tip: pass |
var color = randomcolor({seed: name}); | ||
var color = randomcolor({ | ||
seed: name, | ||
luminosity: 'dark', |
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.
Please remove the redundant comma after the last option.
OK, looks all good. @almereyda @neopostmodern Could you please help? |
I can confirm that authentication against our institutional LDAP worked as of 3491f97. I can look through the code in detail if you want me to but from what I've skimmed through it seemed pretty sound. We should discuss if the configuration value for the name of the LDAP provider is a show-stopper or if we rather move ahead to get this into master and I'll file a subsequent PR for the features mentioned above? |
I think we could continue commit here until we support multiple providers. And for multiple LDAP providers, you'll need to pass an array to ldap config. Thanks guys! 👍 |
@jackycute I see two possible approaches to multiple-ldap-provider support:
I imagine approach 2 would be simpler to implement (with less changes), but security favours approach 1. Either way, the hackmd host will need to provide the LDAP configuration via an array. This is not a problem for the config file, but how should we approach the environment variables? |
@alecdwm Let me show you the way: vesse/passport-ldapauth#24 |
I think the support of multiple LDAP providers might need more discussion. |
Agree, I think we should postpone that into another PR. |
OK, so we merge this first. |
Hello!
I have here a proposal PR for enabling LDAP authentication via the vesse/passport-ldapauth library.
This PR is not quite ready to be merged. The LDAP authentication process is functional, but I want to open a channel for discussion regarding the following items before I continue to finish it up:
1. Optional tlsOptions for LDAP auth
The vesse/passport-ldapauth lib allows us to connect to TLS-enabled LDAP servers by specifying a
tlsOptions
object in our config.Possible parameters are the same as those offered by the Node.js tls module.
Some of these parameters take values that are not specifiable on the command line, such as
socket <net.Socket>
,secureContext <object>
andsession <Buffer>
.I propose to make only the
ca <string>
TLS option available as an environment variable, which will take the root certificate used to generate the LDAP server's TLS cert as a string in PEM format.2. Generating access/refresh tokens
HackMD uses token based authentication. I didn't look very deep, but it seems that so far we've been able to consume the tokens generated by OAuth, and haven't needed to manage token generation/expiry ourselves.
Unfortunately though, LDAP authentication involves sending a username|password combination and receiving either a success message with user data, or an error message.
If one wants to use token based auth, it's left to the client.
In this commit, some very simple tokens are generated in the following format:
debug-[access/refresh]-token|LDAP-[ldap-uidNumber]|[secretkey]|[timestamp]
e.g.
debug-access-token|LDAP-1892|pommes|1481665157094
This is not a secure solution as the tokens are neither hashed nor encrypted, and there is (as far as I am aware) no mechanism to expire them.
I am very open to hear if anyone has a preferred structure for the tokens, how they should be secured, how they should be expired, and of course whether I'm missing something and we don't need to create tokens at all! 😁
3. Other notes
(my test server doesn't store LDAP users' emails, I'm not sure if that's standard or not)
Relevant Issues
#93
#272