-
-
Notifications
You must be signed in to change notification settings - Fork 5.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
Server: allow self-signed certificate for ldap auth #11531
Server: allow self-signed certificate for ldap auth #11531
Conversation
CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅ |
I have read the CLA Document and I hereby sign the CLA |
recheck |
d2ed06a
to
17e92bb
Compare
17e92bb
to
8c43f80
Compare
packages/server/src/config.ts
Outdated
@@ -125,6 +125,7 @@ function ldapConfigFromEnv(env: EnvVariables): LdapConfig[] { | |||
baseDN: env.LDAP_1_BASE_DN, | |||
bindDN: env.LDAP_1_BIND_DN, | |||
bindPW: env.LDAP_1_BIND_PW, | |||
sslCaFile: env.LDAP_1_SSL_CA_FILE, |
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 use "tls" instead of "ssl" for all properties and env variables
@@ -3,6 +3,7 @@ import { User } from '../services/database/types'; | |||
import Logger from '@joplin/utils/Logger'; | |||
import { LdapConfig } from './types'; | |||
import { ErrorForbidden } from './errors'; | |||
import { readFileSync } from 'node:fs'; |
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 use readFile
from fs/promises
. We generally don't use sync function since they block the main thread
let tlsOptions; | ||
if (sslCaFile.length !== 0) { | ||
tlsOptions = { | ||
ca: [readFileSync(sslCaFile)], |
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.
Don't forget to use await readFile
here
} else { | ||
null; | ||
} |
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
9818770
to
caa8e92
Compare
That looks good now, thank you for implementing this! |
This adds the ability to specify a local certificate file for using the LDAP authentication with a self-signed certificate. This was first proposed in the forum here. It adds new env variables (
LDAP_1_TLS_CA_FILE
&LDAP_2_TLS_CA_FILE
) that can point to the appropriate public key.I'm not sure if there is any way to include a test for this, but I tested it locally and it seems to be working well.