Overleaf/README.md

141 lines
4.8 KiB
Markdown
Raw Normal View History

2020-05-13 22:48:02 +02:00
# Free Overleaf Ldap Implementation
2020-05-13 19:08:35 +02:00
This repo contains an improved, free ldap authentication and authorisation
2020-05-13 22:45:04 +02:00
for sharelatex/[overleaf](https://github.com/overleaf/overleaf) community
2021-02-22 10:32:36 +01:00
edition. Currently this repo uses sharelatex:latest.
2020-05-13 19:08:35 +02:00
The inital idea for this implementation was taken from
[worksasintended](https://github.com/worksasintended).
### Limitations:
2020-05-13 22:45:04 +02:00
This implementation uses *no* ldap bind user - it tries to bind to the ldap (using ldapts) with
2020-05-13 19:08:35 +02:00
the uid and credentials of the user which tries to login.
2020-05-15 13:35:05 +02:00
2020-05-15 13:51:58 +02:00
Only valid LDAP users or email users registered by an admin can login.
2020-05-15 13:35:05 +02:00
This module authenticates against the local DB if `ALLOW_EMAIL_LOGIN` is set to `true` if this fails
it tries to authenticate against the specified LDAP server.
2020-05-13 19:08:35 +02:00
2020-05-15 13:53:44 +02:00
*Note:*
2020-05-15 13:35:05 +02:00
- LDAP Users can not change their password for the ldap username login. They have to change it at the ldap server.
2020-05-15 13:51:58 +02:00
- LDAP Users can reset their local db password. Then they can decide if they login with either their ldap user and password or with their email and local db password.
- Users can not change their email. The email address is taken from the ldap server (mail) field. (or by invitation through an admin).
This ldap mail field has to contain a valid mail address. Firstname and lastname are taken from the fields "givenName" and "sn".
2020-05-13 19:08:35 +02:00
If you want to use different fields change the code in AuthenticationManager.js lines 297-299.
2020-05-15 13:35:05 +02:00
- Admins can invite non ldap users directly (via email). Additionally (``link sharing`` of projects is possible).
2020-05-13 19:08:35 +02:00
*Important:*
2020-05-15 13:54:54 +02:00
Sharelatex/Overleaf uses the email address to identify users: If you change the email in the LDAP you have to update the corresponding field
2020-05-15 13:35:05 +02:00
in the mongo db.
2020-05-13 19:08:35 +02:00
```
2021-03-10 21:24:49 +01:00
docker exec -it mongo /bin/bash
2020-05-13 19:08:35 +02:00
mongo
use sharelatex
db.users.find({email:"EMAIL"}).pretty()
db.users.update({email : OLDEMAIL},{$set: { email : NEWEMAIL}});
```
## Configuration
### Domain Configuration
Edit the [.env](.env) file
2020-05-15 13:35:05 +02:00
2020-05-13 19:08:35 +02:00
```
MYDOMAIN=example.com
MYMAIL=email@example.com
2020-05-13 19:44:38 +02:00
MYDATA=/data
2020-05-13 19:08:35 +02:00
```
*MYDATA* is the location (mount-point) for all data and will hold several directories:
- mongo_data: Mongo DB
- redis_data: Redis dump.rdb
- sharelatex: all projects, tmp files, user files templates and ...
- letsencrypt: https certificates
2021-03-10 21:24:49 +01:00
*MYDOMAIN* is the FQDN for sharelatex and traefik (letsencrypt) <br/>
*MYDOMAIN*:8443 Traefik Dashboard - Login uses traefik/user.htpasswd : user:admin pass:adminPass change this (e.g. generate a password with htpasswd)
2020-05-15 13:51:58 +02:00
*MYMAIL* is the admin mailaddress
2020-05-13 19:08:35 +02:00
2020-05-18 17:07:36 +02:00
```
LOGIN_TEXT=username
COLLAB_TEXT=Direct share with collaborators is enabled only for activated users!
```
2020-05-18 17:11:00 +02:00
*LOGIN_TEXT* : displayed instead of email-adress field (login.pug) <br/>
2020-05-18 17:07:36 +02:00
*COLLAB_TEXT* : displayed for email invitation (share.pug)
2020-05-13 19:08:35 +02:00
### LDAP Configuration
Edit [docker-compose.yml](docker-compose.yml) to fit your local setup.
```
LDAP_SERVER: ldaps://LDAPSERVER:636
2020-05-14 12:31:20 +02:00
LDAP_BASE: dc=DOMAIN,dc=TLD
LDAP_BINDDN: ou=someunit,ou=people,dc=DOMAIN,dc=TLS
2020-05-13 19:08:35 +02:00
# By default tries to bind directly with the ldap user - this user has to be in the LDAP GROUP
# you have to set a group filter a minimal groupfilter would be: '(objectClass=person)'
2020-05-13 19:08:35 +02:00
LDAP_GROUP_FILTER: '(memberof=GROUPNAME,ou=groups,dc=DOMAIN,dc=TLD)'
# If user is in ADMIN_GROUP on user creation (first login) isAdmin is set to true.
# Admin Users can invite external (non ldap) users. This feature makes only sense
2020-05-15 13:35:05 +02:00
# when ALLOW_EMAIL_LOGIN is set to 'true'. Additionally admins can send
# system wide messages.
#LDAP_ADMIN_GROUP_FILTER: '(memberof=cn=ADMINGROUPNAME,ou=groups,dc=DOMAIN,dc=TLD)'
ALLOW_EMAIL_LOGIN: 'false'
# All users in the LDAP_GROUP_FILTER are loaded from the ldap server into contacts.
LDAP_CONTACTS: 'false'
2020-05-13 19:08:35 +02:00
```
### LDAP Contacts
2020-05-13 19:08:35 +02:00
2020-05-15 13:58:57 +02:00
If you enable LDAP_CONTACTS, then all users in LDAP_GROUP_FILTER are loaded from the ldap server into the contacts.
At the moment this happens every time you click on "Share" within a project.
2020-05-13 19:08:35 +02:00
The user search happens without bind - so if your LDAP needs a bind you can adapt this in the
2020-05-15 13:58:57 +02:00
function `getLdapContacts()` in ContactsController.js (line 92)
if you want to enable this function set:
2020-05-13 19:08:35 +02:00
```
LDAP_CONTACTS: 'true'
2020-05-13 19:08:35 +02:00
```
### Sharelatex Configuration
2020-05-15 13:35:05 +02:00
Edit SHARELATEX_ environment variables in [docker-compose.yml](docker-compose.yml) to fit your local setup
(e.g. proper SMTP server, Header, Footer, App Name,...). See https://github.com/overleaf/overleaf/wiki/Quick-Start-Guide for more details.
2020-05-13 19:08:35 +02:00
2020-05-13 19:15:26 +02:00
## Installation, Usage and Inital startup
2020-05-13 19:08:35 +02:00
Install the docker engine: https://docs.docker.com/engine/install/
Install docker-compose:
(if you need pip: apt install python3-pip)
```
pip install docker-compose
```
use the command
```
make
```
2020-05-19 17:00:08 +02:00
to generate the ldap-overleaf-sl docker image.
2020-05-13 19:08:35 +02:00
use the command
```
docker network create web
```
to create a network for the docker instances.
2021-03-10 21:24:49 +01:00
Then start docker containers (with loadbalancer):
2020-05-13 19:08:35 +02:00
```
2021-03-10 21:24:49 +01:00
export NUMINSTANCES=1
docker-compose up -d --scale sharelatex=$NUMINSTANCES
2020-05-13 19:08:35 +02:00
```