Unverified Commit c3945283 authored by Matthieu Simonin's avatar Matthieu Simonin Committed by msimonin
Browse files

[inria-2.3.1] Update to 2.3.1

- Update sharelatex docker image version
- Update the creation script
  + make the test user password stronger
   (overleaf now enforce a validation check)
   + Align with latest version
- Update the login response logic
  + HTML if the login is successful
  + json if the login fails (same as before)
- Bump version to 1.0.0.alpha-0
parent 66140d43
......@@ -52,7 +52,9 @@ py36-functionnal: &base-functionnal
- docker exec --workdir /var/www/sharelatex -i sharelatex grunt user:test --email=joe@inria.fr
- export CI_BASE_URL=http://172.17.0.1:8080
- export CI_USERNAME=joe@inria.fr
- export CI_PASSWORD=test
# NOTE(msimonin): the password is hardcoded in the user creation script in
# sharelatex/tests/CreateUserTest.coffee
- export CI_PASSWORD=Testtest42
# let's test !
# the python interpreter version is taken from the TOXENV var
- tox
......
......@@ -45,6 +45,8 @@ version of ShareLatex/Overleaf CE version. Roughly we have the following mapping
- sharelatex/overleaf
* - 0.Y.Z
- 1.2.1
* - 1.Y.Z
- 2.3.1
Note on passwords management
----------------------------
......
from json.decoder import JSONDecodeError
import logging
import re
# try to find CAS form
from lxml import html
import os
import requests
from pathlib import Path
import re
import requests
import threading
import uuid
import zipfile
......@@ -136,30 +140,38 @@ def walk_files(project_data):
return walk_project_data(project_data, lambda x: x["type"] == "file")
def check_error(json):
"""Check if there's an error in the returned json from sharelatex.
def check_login_error(response):
"""Check if there's an error in the request response
This assumes json to be a dict like the following
{
"message":
{
"text": "Your email or password is incorrect. Please try again",
"type": "error"
}
}
The response text is
- HTML if the auth is successful
- json: otherwise
{
"message":
{
"text": "Your email or password is incorrect. Please try again",
"type": "error"
}
}
Args:
json (dict): message returned by the sharelatex server
response (request response): message returned by the sharelatex server
Raise:
Exception with the corresponding text in the message
"""
message = json.get("message")
if message is None:
return
t = message.get("type")
if t is not None and t == "error":
raise Exception(message.get("text", "Unknown error"))
try:
json = response.json()
message = json.get("message")
if message is None:
return
t = message.get("type")
if t is not None and t == "error":
raise Exception(message.get("text", "Unknown error"))
except JSONDecodeError:
# this migh be a successful login here
logger.info("Loggin successful")
pass
def get_csrf_Token(html_text):
......@@ -213,11 +225,8 @@ class SyncClient:
logger.debug(" try login")
_r = self._post(login_url, data=self.login_data, verify=self.verify)
_r.raise_for_status()
check_error(_r.json())
check_login_error(_r)
else:
# try to find CAS form
from lxml import html
logger.debug(" try CAS login")
a = html.fromstring(r.text)
if len(a.forms) == 1:
......
__version__ = "0.5.5"
__version__ = "1.0.0.alpha-0"
......@@ -8,11 +8,12 @@ module.exports = (grunt) ->
process.exit(1)
settings = require "settings-sharelatex"
UserRegistrationHandler = require "../web/app/js/Features/User/UserRegistrationHandler"
OneTimeTokenHandler = require "../web/app/js/Features/Security/OneTimeTokenHandler"
UserRegistrationHandler = require "../web/app/src/Features/User/UserRegistrationHandler"
OneTimeTokenHandler = require "../web/app/src/Features/Security/OneTimeTokenHandler"
UserRegistrationHandler.registerNewUser {
email: email
password: "test"
# NOTE(msimonin): we need a /strong/ password otherwise we don't validate
password: "Testtest42"
}, (error, user) ->
if error? and error?.message != "EmailAlreadyRegistered"
throw error
......@@ -21,7 +22,7 @@ module.exports = (grunt) ->
user.save (error) ->
throw error if error?
ONE_WEEK = 7 * 24 * 60 * 60 # seconds
OneTimeTokenHandler.getNewToken user._id, { expiresIn: ONE_WEEK }, (err, token)->
OneTimeTokenHandler.getNewToken "password", { expiresIn: ONE_WEEK, email:user.email, user_id: user._id.toString() }, (err, token)->
return next(err) if err?
console.log ""
......
version: "2.2"
# NOTE(msimonin) this comes from https://github.com/overleaf/overleaf/blob/02098ca23b2f4301f737296bb73652c7cf207730/docker-compose.yml
# With the following differences:
# - I removed any volume definition (we don't need them in this env)
# - I bound on *:8080 in particular this will be reachable on the
# (deterministic) docker bridge ip (172.17.0.1)
version: '2.2'
services:
sharelatex:
restart: always
image: sharelatex/sharelatex:v1.2.1
container_name: sharelatex
# hack
command: /sbin/my_init
entrypoint: python3
# /hack
depends_on:
mongo:
condition: service_healthy
redis:
condition: service_started
privileged: true
ports:
# binding on docker bridge
- 172.17.0.1:8080:80
links:
- mongo
- redis
########################################################################
#### Server Pro: Un-comment the following line to mount the docker ####
#### socket, required for Sibling Containers to work ####
########################################################################
# - /var/run/docker.sock:/var/run/docker.sock
environment:
SHARELATEX_APP_NAME: Overleaf Community Edition
SHARELATEX_MONGO_URL: mongodb://mongo/sharelatex
# Same property, unfortunately with different names in
# different locations
SHARELATEX_REDIS_HOST: redis
REDIS_HOST: redis
ENABLED_LINKED_FILE_TYPES: "url,project_file"
# Enables Thumbnail generation using ImageMagick
ENABLE_CONVERSIONS: "true"
# Disables email confirmation requirement
EMAIL_CONFIRMATION_DISABLED: "true"
## Set for SSL via nginx-proxy
#VIRTUAL_HOST: 103.112.212.22
# SHARELATEX_SITE_URL: http://sharelatex.mydomain.com
# SHARELATEX_NAV_TITLE: Our ShareLaTeX Instance
# SHARELATEX_HEADER_IMAGE_URL: http://somewhere.com/mylogo.png
# SHARELATEX_ADMIN_EMAIL: support@it.com
# SHARELATEX_LEFT_FOOTER: '[{"text": "Powered by <a href=\"https://www.sharelatex.com\">ShareLaTeX</a> 2016"},{"text": "Another page I want to link to can be found <a href=\"here\">here</a>"} ]'
# SHARELATEX_RIGHT_FOOTER: '[{"text": "Hello I am on the Right"} ]'
# SHARELATEX_EMAIL_FROM_ADDRESS: "team@sharelatex.com"
# SHARELATEX_EMAIL_AWS_SES_ACCESS_KEY_ID:
# SHARELATEX_EMAIL_AWS_SES_SECRET_KEY:
# SHARELATEX_EMAIL_SMTP_HOST: smtp.mydomain.com
# SHARELATEX_EMAIL_SMTP_PORT: 587
# SHARELATEX_EMAIL_SMTP_SECURE: false
# SHARELATEX_EMAIL_SMTP_USER:
# SHARELATEX_EMAIL_SMTP_PASS:
# SHARELATEX_EMAIL_SMTP_TLS_REJECT_UNAUTH: true
# SHARELATEX_EMAIL_SMTP_IGNORE_TLS: false
# SHARELATEX_CUSTOM_EMAIL_FOOTER: "<div>This system is run by department x </div>"
################
## Server Pro ##
################
# SANDBOXED_COMPILES: 'true'
# SANDBOXED_COMPILES_SIBLING_CONTAINERS: 'true'
# SANDBOXED_COMPILES_HOST_DIR: '/var/sharelatex_data/data/compiles'
# SYNCTEX_BIN_HOST_PATH: '/var/sharelatex_data/bin/synctex'
# DOCKER_RUNNER: 'false'
## Works with test LDAP server shown at bottom of docker compose
# SHARELATEX_LDAP_URL: 'ldap://ldap:389'
# SHARELATEX_LDAP_SEARCH_BASE: 'ou=people,dc=planetexpress,dc=com'
# SHARELATEX_LDAP_SEARCH_FILTER: '(uid={{username}})'
# SHARELATEX_LDAP_BIND_DN: 'cn=admin,dc=planetexpress,dc=com'
# SHARELATEX_LDAP_BIND_CREDENTIALS: 'GoodNewsEveryone'
# SHARELATEX_LDAP_EMAIL_ATT: 'mail'
# SHARELATEX_LDAP_NAME_ATT: 'cn'
# SHARELATEX_LDAP_LAST_NAME_ATT: 'sn'
# SHARELATEX_LDAP_UPDATE_USER_DETAILS_ON_LOGIN: 'true'
# SHARELATEX_TEMPLATES_USER_ID: "578773160210479700917ee5"
# SHARELATEX_NEW_PROJECT_TEMPLATE_LINKS: '[ {"name":"All Templates","url":"/templates/all"}]'
# SHARELATEX_PROXY_LEARN: "true"
mongo:
restart: always
image: mongo
container_name: mongo
expose:
- 27017
healthcheck:
test: echo 'db.stats().ok' | mongo localhost:27017/test --quiet
interval: 10s
timeout: 10s
retries: 5
redis:
restart: always
image: redis
container_name: redis
expose:
- 6379
# ldap:
# restart: always
# image: rroemhild/test-openldap
# container_name: ldap
# expose:
# - 389
# See https://github.com/jwilder/nginx-proxy for documentation on how to configure the nginx-proxy container,
# and https://github.com/overleaf/overleaf/wiki/HTTPS-reverse-proxy-using-Nginx for an example of some recommended
# settings. We recommend using a properly managed nginx instance outside of the Overleaf Server Pro setup,
# but the example here can be used if you'd prefer to run everything with docker-compose
# nginx-proxy:
# image: jwilder/nginx-proxy
# container_name: nginx-proxy
# ports:
# #- "80:80"
# - "443:443"
# volumes:
# - /var/run/docker.sock:/tmp/docker.sock:ro
# - /home/sharelatex/tmp:/etc/nginx/certs
sharelatex:
restart: always
# Server Pro users:
# image: quay.io/sharelatex/sharelatex-pro
image: registry.gitlab.inria.fr/sed-rennes/overleaf/overleaf/overleaf:inria-2.3.1
container_name: sharelatex
# hack
command: /sbin/my_init
entrypoint: python3
# /hack
depends_on:
mongo:
condition: service_healthy
redis:
condition: service_started
ports:
- 0.0.0.0:8080:80
links:
- mongo
- redis
########################################################################
#### Server Pro: Un-comment the following line to mount the docker ####
#### socket, required for Sibling Containers to work ####
########################################################################
# - /var/run/docker.sock:/var/run/docker.sock
environment:
SHARELATEX_APP_NAME: Overleaf Community Edition
SHARELATEX_MONGO_URL: mongodb://mongo/sharelatex
# Same property, unfortunately with different names in
# different locations
SHARELATEX_REDIS_HOST: redis
REDIS_HOST: redis
ENABLED_LINKED_FILE_TYPES: 'url,project_file'
# Enables Thumbnail generation using ImageMagick
ENABLE_CONVERSIONS: 'true'
# Disables email confirmation requirement
EMAIL_CONFIRMATION_DISABLED: 'true'
# temporary fix for LuaLaTex compiles
# see https://github.com/overleaf/overleaf/issues/695
TEXMFVAR: /var/lib/sharelatex/tmp/texmf-var
## Set for SSL via nginx-proxy
#VIRTUAL_HOST: 103.112.212.22
# SHARELATEX_SITE_URL: http://sharelatex.mydomain.com
# SHARELATEX_NAV_TITLE: Our ShareLaTeX Instance
# SHARELATEX_HEADER_IMAGE_URL: http://somewhere.com/mylogo.png
# SHARELATEX_ADMIN_EMAIL: support@it.com
# SHARELATEX_LEFT_FOOTER: '[{"text": "Powered by <a href=\"https://www.sharelatex.com\">ShareLaTeX</a> 2016"},{"text": "Another page I want to link to can be found <a href=\"here\">here</a>"} ]'
# SHARELATEX_RIGHT_FOOTER: '[{"text": "Hello I am on the Right"} ]'
# SHARELATEX_EMAIL_FROM_ADDRESS: "team@sharelatex.com"
# SHARELATEX_EMAIL_AWS_SES_ACCESS_KEY_ID:
# SHARELATEX_EMAIL_AWS_SES_SECRET_KEY:
# SHARELATEX_EMAIL_SMTP_HOST: smtp.mydomain.com
# SHARELATEX_EMAIL_SMTP_PORT: 587
# SHARELATEX_EMAIL_SMTP_SECURE: false
# SHARELATEX_EMAIL_SMTP_USER:
# SHARELATEX_EMAIL_SMTP_PASS:
# SHARELATEX_EMAIL_SMTP_TLS_REJECT_UNAUTH: true
# SHARELATEX_EMAIL_SMTP_IGNORE_TLS: false
# SHARELATEX_CUSTOM_EMAIL_FOOTER: "<div>This system is run by department x </div>"
################
## Server Pro ##
################
# SANDBOXED_COMPILES: 'true'
# SANDBOXED_COMPILES_SIBLING_CONTAINERS: 'true'
# SANDBOXED_COMPILES_HOST_DIR: '/var/sharelatex_data/data/compiles'
# SYNCTEX_BIN_HOST_PATH: '/var/sharelatex_data/bin/synctex'
# DOCKER_RUNNER: 'false'
## Works with test LDAP server shown at bottom of docker compose
# SHARELATEX_LDAP_URL: 'ldap://ldap:389'
# SHARELATEX_LDAP_SEARCH_BASE: 'ou=people,dc=planetexpress,dc=com'
# SHARELATEX_LDAP_SEARCH_FILTER: '(uid={{username}})'
# SHARELATEX_LDAP_BIND_DN: 'cn=admin,dc=planetexpress,dc=com'
# SHARELATEX_LDAP_BIND_CREDENTIALS: 'GoodNewsEveryone'
# SHARELATEX_LDAP_EMAIL_ATT: 'mail'
# SHARELATEX_LDAP_NAME_ATT: 'cn'
# SHARELATEX_LDAP_LAST_NAME_ATT: 'sn'
# SHARELATEX_LDAP_UPDATE_USER_DETAILS_ON_LOGIN: 'true'
# SHARELATEX_TEMPLATES_USER_ID: "578773160210479700917ee5"
# SHARELATEX_NEW_PROJECT_TEMPLATE_LINKS: '[ {"name":"All Templates","url":"/templates/all"}]'
# SHARELATEX_PROXY_LEARN: "true"
mongo:
restart: always
image: mongo
container_name: mongo
expose:
- 27017
healthcheck:
test: echo 'db.stats().ok' | mongo localhost:27017/test --quiet
interval: 10s
timeout: 10s
retries: 5
redis:
restart: always
image: redis:5
container_name: redis
expose:
- 6379
# ldap:
# restart: always
# image: rroemhild/test-openldap
# container_name: ldap
# expose:
# - 389
# See https://github.com/jwilder/nginx-proxy for documentation on how to configure the nginx-proxy container,
# and https://github.com/overleaf/overleaf/wiki/HTTPS-reverse-proxy-using-Nginx for an example of some recommended
# settings. We recommend using a properly managed nginx instance outside of the Overleaf Server Pro setup,
# but the example here can be used if you'd prefer to run everything with docker-compose
# nginx-proxy:
# image: jwilder/nginx-proxy
# container_name: nginx-proxy
# ports:
# #- "80:80"
# - "443:443"
# volumes:
# - /var/run/docker.sock:/tmp/docker.sock:ro
# - /home/sharelatex/tmp:/etc/nginx/certs
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment