Repository: rickbergfalk/sqlpad
Pull request #707 (2020-06-25 05:54:33)

preliminary LDAP docs


Patch:
diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml
index 9ff38bf4..140a153d 100644
--- a/.github/workflows/lint.yml
+++ b/.github/workflows/lint.yml
@@ -1,7 +1,6 @@
-
 name: lint
 
-on: [push]
+on: [push, pull_request]
 
 jobs:
   lint:
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 8eaf25fd..202a1500 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -30,15 +30,11 @@ Of course if you'd like to start the work without opening an issue with the unde
 
 Once a pull request has been submitted, a maintainer will review your pull request and either merge it, request changes, or close it with an explanation.
 
-## Becoming a Maintainer
+## Collaborator Invite
 
-If you've made a significant contribution to SQLPad and would like to become a core maintainer, please get in touch by emailing rick.bergfalk@gmail.com.
+If you've made a significant contribution to SQLPad you'll be invited to join as a collaborator. This will give you commit access to non-protected branches, the ability to review PRs, merge approved PRs, and lots of other things.
 
-Maintainers will get commit access to the repository, and will be requested to review pull requests and provide input on project direction. You might be pinged every now and then to review a pull request or provide your opinion on project direction.
-
-There is no hard commitment associated with becoming a maintainer. SQLPad is a side project worked on in people's spare time, and you can stop being a maintainer at any time.
-
-If you actively use SQLPad, have the JavaScript expertise, and think you might have just a few hours every month or two to help with bugs or library updates please consider it.
+No pressure to accept the invite or even do anything with the access. Contribute as much or as little as you'd like, even if it is just to weigh in on the direction of the project.
 
 ## Contributing Money
 
diff --git a/client/src/SignIn.js b/client/src/SignIn.js
index 8a9d5f06..870e2fc0 100644
--- a/client/src/SignIn.js
+++ b/client/src/SignIn.js
@@ -39,12 +39,20 @@ function SignIn() {
     return;
   }
 
+  function PlaceholderForUsername() {
+    if (config.ldapConfigured) {
+      return 'Username or e-mail address';
+    } else {
+      return 'e-mail address';
+    }
+  }
+
   const localForm = (
     <form onSubmit={signIn}>
       <Input
         name="email"
         type="email"
-        placeholder="LDAP User / Email"
+        placeholder={PlaceholderForUsername()}
         onChange={(e) => setEmail(e.target.value)}
         required
       />
diff --git a/docs/authentication.md b/docs/authentication.md
index e3f5e449..a1e01ed6 100644
--- a/docs/authentication.md
+++ b/docs/authentication.md
@@ -96,6 +96,18 @@ SAML-based authentication can be enabled by setting the necessary environment va
 
 SQLPad users do not need to be added ahead of time, and may be created on the fly using `samlAutoSignUp`. Whenever a new user is detected (unable to match to existing user email), a user record will be added to SQLPad's user table and a user signed in. By default users are not auto-created and must otherwise be added ahead of time.
 
+## LDAP (Experimental)
+
+LDAP-based authentication can be enabled by setting the necessary environment variables:
+
+- `ENABLE_LDAP_AUTH`
+- `LDAP_URL`
+- `LDAP_BASE_DN`
+- `LDAP_USERNAME`
+- `LDAP_PASSWORD`
+
+Users sign in to LDAP using a username (and not an e-mail address).
+
 ## Allowed Domains for User Administration
 
 An entire domain can be allowed for username administration by setting enviornment variable `SQLPAD_ALLOWED_DOMAINS`. This may be particularly useful in combination with OAuth.
diff --git a/docs/configuration.md b/docs/configuration.md
index 2dadfaaa..e67a47b6 100644
--- a/docs/configuration.md
+++ b/docs/configuration.md
@@ -425,3 +425,38 @@ When supplying both `id` and `email`, `id` will be used for user matching instea
 
 - Key: `authProxyHeaders`
 - Env: `SQLPAD_AUTH_PROXY_HEADERS`
+
+## enableLdapAuth
+
+Set to `true` to enable LDAP authentication
+
+- Key: `enableLdapAuth`
+- Env: `ENABLE_LDAP_AUTH`
+
+## ldapUrl
+
+LDAP server URL. Examples: `ldap://localhost:389`, `ldaps://ad.corporate.com:636`
+
+- Key: `ldapUrl`
+- Env: `LDAP_URL`
+
+## ldapBaseDN
+
+LDAP Base DN
+
+- Key: `ldapBaseDN`
+- Env: `LDAP_BASE_DN`
+
+## ldapUsername
+
+Username for LDAP lookup
+
+- Key: `ldapUsername`
+- Env: `LDAP_USERNAME`
+
+## ldapPassword
+
+Password for LDAP user used for LDAP lookup
+
+- Key: `ldapPassword`
+- Env: `LDAP_PASSWORD`
diff --git a/server/routes/app.js b/server/routes/app.js
index d4839599..a3302e9d 100644
--- a/server/routes/app.js
+++ b/server/routes/app.js
@@ -33,6 +33,7 @@ async function getApp(req, res) {
       samlConfigured: Boolean(config.get('samlEntryPoint')),
       samlLinkHtml: config.get('samlLinkHtml'),
       smtpConfigured: config.smtpConfigured(),
+      ldapConfigured: config.get('enableLdapAuth'),
     },
     version: packageJson.version,
   });


Test patch:
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index 0fd492c7..d6517cd6 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -1,7 +1,6 @@
-
 name: test
 
-on: [push]
+on: [push, pull_request]
 
 jobs:
   test:
diff --git a/server/test/api/app.js b/server/test/api/app.js
index 6f300382..edf281c2 100644
--- a/server/test/api/app.js
+++ b/server/test/api/app.js
@@ -25,6 +25,7 @@ const expectedConfigKeys = [
   'localAuthConfigured',
   'samlConfigured',
   'samlLinkHtml',
+  'ldapConfigured',
 ];
 
 describe('api/app', function () {