Skip to content
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

Merged
merged 4 commits into from
Dec 19, 2024

Conversation

rcrisanti
Copy link
Contributor

@rcrisanti rcrisanti commented Dec 17, 2024

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.

Copy link
Contributor

github-actions bot commented Dec 17, 2024

CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅

@rcrisanti
Copy link
Contributor Author

I have read the CLA Document and I hereby sign the CLA

@rcrisanti
Copy link
Contributor Author

recheck

github-actions bot added a commit that referenced this pull request Dec 17, 2024
@rcrisanti rcrisanti force-pushed the feat/server-ldap-self-signed-cert branch from d2ed06a to 17e92bb Compare December 17, 2024 19:31
@rcrisanti rcrisanti force-pushed the feat/server-ldap-self-signed-cert branch from 17e92bb to 8c43f80 Compare December 17, 2024 20:09
@@ -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,
Copy link
Owner

@laurent22 laurent22 Dec 18, 2024

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';
Copy link
Owner

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)],
Copy link
Owner

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

Comment on lines 36 to 38
} else {
null;
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove

@rcrisanti rcrisanti force-pushed the feat/server-ldap-self-signed-cert branch from 9818770 to caa8e92 Compare December 18, 2024 23:52
@laurent22
Copy link
Owner

That looks good now, thank you for implementing this!

@laurent22 laurent22 merged commit 28ff17a into laurent22:dev Dec 19, 2024
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants