Compare commits
7 commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
712e0c4075 | ||
![]() |
fa0d0ee3f8 | ||
![]() |
e42db20779 | ||
![]() |
a4ddc221ba | ||
![]() |
de1e8ea6a8 | ||
![]() |
af055f127c | ||
![]() |
cf640f60aa |
6158 changed files with 846490 additions and 0 deletions
44
.github/ISSUE_TEMPLATE.md
vendored
Normal file
44
.github/ISSUE_TEMPLATE.md
vendored
Normal file
|
@ -0,0 +1,44 @@
|
|||
<!--
|
||||
|
||||
Note: If you are using www.overleaf.com and have a problem,
|
||||
or if you would like to request a new feature please contact
|
||||
the support team at support@overleaf.com
|
||||
|
||||
This form should only be used to report bugs in the
|
||||
Community Edition release of Overleaf.
|
||||
|
||||
-->
|
||||
|
||||
|
||||
|
||||
<!-- BUG REPORT TEMPLATE -->
|
||||
|
||||
## Steps to Reproduce
|
||||
<!-- Describe the steps leading up to when / where you found the bug. -->
|
||||
<!-- Screenshots may be helpful here. -->
|
||||
|
||||
1.
|
||||
2.
|
||||
3.
|
||||
|
||||
## Expected Behaviour
|
||||
<!-- What should have happened when you completed the steps above? -->
|
||||
|
||||
## Observed Behaviour
|
||||
<!-- What actually happened when you completed the steps above? -->
|
||||
<!-- Screenshots may be helpful here. -->
|
||||
|
||||
## Context
|
||||
<!-- How has this issue affected you? What were you trying to accomplish? -->
|
||||
|
||||
## Technical Info
|
||||
<!-- Provide any technical details that may be applicable (or N/A if not applicable). -->
|
||||
|
||||
* URL:
|
||||
* Browser Name and version:
|
||||
* Operating System and version (desktop or mobile):
|
||||
* Signed in as:
|
||||
* Project and/or file:
|
||||
|
||||
## Analysis
|
||||
<!--- Optionally, document investigation of / suggest a fix for the bug, e.g. 'comes from this line / commit' -->
|
11
.github/PULL_REQUEST_TEMPLATE.md
vendored
Normal file
11
.github/PULL_REQUEST_TEMPLATE.md
vendored
Normal file
|
@ -0,0 +1,11 @@
|
|||
## Description
|
||||
<!-- Goal of the pull request -->
|
||||
|
||||
|
||||
## Related issues / Pull Requests
|
||||
<!-- Fixes #xyz, Contributes to #xyz, Related to #xyz-->
|
||||
|
||||
|
||||
## Contributor Agreement
|
||||
|
||||
- [ ] I confirm I have signed the [Contributor License Agreement](https://github.com/overleaf/overleaf/blob/master/CONTRIBUTING.md#contributor-license-agreement)
|
6
.gitignore
vendored
Normal file
6
.gitignore
vendored
Normal file
|
@ -0,0 +1,6 @@
|
|||
# docker image build
|
||||
.dockerignore
|
||||
|
||||
# user defined files
|
||||
.env
|
||||
docker-compose.override.yml
|
43
CONTRIBUTING.md
Normal file
43
CONTRIBUTING.md
Normal file
|
@ -0,0 +1,43 @@
|
|||
Contributing to Overleaf
|
||||
==========================
|
||||
|
||||
Thank you for reading this! If you'd like to report a bug or join in the development
|
||||
of Overleaf, then here are some notes on how to do that.
|
||||
|
||||
Reporting bugs and opening issues
|
||||
---------------------------------
|
||||
|
||||
If you'd like to report a bug or open an issue, please **[check if there is an existing issue](https://github.com/overleaf/overleaf/issues).**
|
||||
If there is then please add any more information that you have, or give it a 👍.
|
||||
|
||||
When submitting an issue please describe the issue as clearly as possible, including how to
|
||||
reproduce the bug, which situations it appears in, what you expected to happen, and what actually happens.
|
||||
If you can include a screenshot for front end issues that is very helpful.
|
||||
|
||||
**Note**: If you are using [www.overleaf.com](www.overleaf.com) and have a problem, or if you would like to request a new feature, please contact the Support team at support@overleaf.com. Raise an issue here only to report bugs in the Community Edition release of Overleaf.
|
||||
|
||||
Pull Requests
|
||||
-------------
|
||||
|
||||
See [our wiki](https://github.com/overleaf/overleaf/wiki)
|
||||
for how to manage the Overleaf development environment and for our developer guidelines.
|
||||
|
||||
We love pull requests, so be bold with them! Don't be afraid of going ahead
|
||||
and changing something, or adding a new feature. We're very happy to work with you
|
||||
to get your changes merged into Overleaf.
|
||||
|
||||
If you're looking for something to work on, have a look at the [open issues](https://github.com/overleaf/overleaf/issues).
|
||||
|
||||
Security
|
||||
--------
|
||||
|
||||
Please see [our security policy](https://github.com/overleaf/overleaf/security/policy) if you would like to report a potential security vulnerability.
|
||||
|
||||
Contributor License Agreement
|
||||
-----------------------------
|
||||
|
||||
Before we can accept any contributions of code, we need you to agree to our
|
||||
[Contributor License Agreement](https://docs.google.com/forms/d/e/1FAIpQLSef79XH3mb7yIiMzZw-yALEegS-wyFetvjTiNBfZvf_IHD2KA/viewform?usp=sf_link).
|
||||
This is to ensure that you own the copyright of your contribution, and that you
|
||||
agree to give us a license to use it in both the open source version, and the version
|
||||
of Overleaf running at www.overleaf.com, which may have additional changes.
|
661
LICENSE
Normal file
661
LICENSE
Normal file
|
@ -0,0 +1,661 @@
|
|||
GNU AFFERO GENERAL PUBLIC LICENSE
|
||||
Version 3, 19 November 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU Affero General Public License is a free, copyleft license for
|
||||
software and other kinds of works, specifically designed to ensure
|
||||
cooperation with the community in the case of network server software.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
our General Public Licenses are intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
Developers that use our General Public Licenses protect your rights
|
||||
with two steps: (1) assert copyright on the software, and (2) offer
|
||||
you this License which gives you legal permission to copy, distribute
|
||||
and/or modify the software.
|
||||
|
||||
A secondary benefit of defending all users' freedom is that
|
||||
improvements made in alternate versions of the program, if they
|
||||
receive widespread use, become available for other developers to
|
||||
incorporate. Many developers of free software are heartened and
|
||||
encouraged by the resulting cooperation. However, in the case of
|
||||
software used on network servers, this result may fail to come about.
|
||||
The GNU General Public License permits making a modified version and
|
||||
letting the public access it on a server without ever releasing its
|
||||
source code to the public.
|
||||
|
||||
The GNU Affero General Public License is designed specifically to
|
||||
ensure that, in such cases, the modified source code becomes available
|
||||
to the community. It requires the operator of a network server to
|
||||
provide the source code of the modified version running there to the
|
||||
users of that server. Therefore, public use of a modified version, on
|
||||
a publicly accessible server, gives the public access to the source
|
||||
code of the modified version.
|
||||
|
||||
An older license, called the Affero General Public License and
|
||||
published by Affero, was designed to accomplish similar goals. This is
|
||||
a different license, not a version of the Affero GPL, but Affero has
|
||||
released a new version of the Affero GPL which permits relicensing under
|
||||
this license.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU Affero General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Remote Network Interaction; Use with the GNU General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, if you modify the
|
||||
Program, your modified version must prominently offer all users
|
||||
interacting with it remotely through a computer network (if your version
|
||||
supports such interaction) an opportunity to receive the Corresponding
|
||||
Source of your version by providing access to the Corresponding Source
|
||||
from a network server at no charge, through some standard or customary
|
||||
means of facilitating copying of software. This Corresponding Source
|
||||
shall include the Corresponding Source for any work covered by version 3
|
||||
of the GNU General Public License that is incorporated pursuant to the
|
||||
following paragraph.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the work with which it is combined will remain governed by version
|
||||
3 of the GNU General Public License.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU Affero General Public License from time to time. Such new versions
|
||||
will be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU Affero General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU Affero General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU Affero General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If your software can interact with users remotely through a computer
|
||||
network, you should also make sure that it provides a way for users to
|
||||
get its source. For example, if your program is a web application, its
|
||||
interface could display a "Source" link that leads users to an archive
|
||||
of the code. There are many ways you could offer source, and different
|
||||
solutions will be better for different programs; see section 13 for the
|
||||
specific requirements.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU AGPL, see
|
||||
<http://www.gnu.org/licenses/>.
|
3
bin/shared/mongodb-init-replica-set.js
Normal file
3
bin/shared/mongodb-init-replica-set.js
Normal file
|
@ -0,0 +1,3 @@
|
|||
/* eslint-disable no-undef */
|
||||
|
||||
rs.initiate({ _id: 'overleaf', members: [{ _id: 0, host: 'mongo:27017' }] })
|
3
develop/.gitignore
vendored
Normal file
3
develop/.gitignore
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
/compiles/*
|
||||
!.gitkeep
|
||||
.env
|
90
develop/README.md
Normal file
90
develop/README.md
Normal file
|
@ -0,0 +1,90 @@
|
|||
# Overleaf Community Edition, development environment
|
||||
|
||||
## Building and running
|
||||
|
||||
In this `develop` directory, build the services:
|
||||
|
||||
```shell
|
||||
bin/build
|
||||
```
|
||||
|
||||
> [!NOTE]
|
||||
> If Docker is running out of RAM while building the services in parallel, create a `.env` file in this directory containing `COMPOSE_PARALLEL_LIMIT=1`.
|
||||
|
||||
Then start the services:
|
||||
|
||||
```shell
|
||||
bin/up
|
||||
```
|
||||
|
||||
Once the services are running, open <http://localhost/launchpad> to create the first admin account.
|
||||
|
||||
## TeX Live
|
||||
|
||||
Compiling a PDF requires building a TeX Live image to handle the compilation inside Docker:
|
||||
|
||||
```shell
|
||||
docker build texlive -t texlive-full
|
||||
```
|
||||
|
||||
> [!NOTE]
|
||||
> To compile on a macOS host, you may need to override the path to the Docker socket by creating a `.env` file in this directory, containing
|
||||
> `DOCKER_SOCKET_PATH=/var/run/docker.sock.raw`
|
||||
|
||||
## Development
|
||||
|
||||
To avoid running `bin/build && bin/up` after every code change, you can run Overleaf
|
||||
Community Edition in _development mode_, where services will automatically update on code changes.
|
||||
|
||||
To do this, use the included `bin/dev` script:
|
||||
|
||||
```shell
|
||||
bin/dev
|
||||
```
|
||||
|
||||
This will start all services using `nodemon`, which will automatically monitor the code and restart the services as necessary.
|
||||
|
||||
To improve performance, you can start only a subset of the services in development mode by providing a space-separated list to the `bin/dev` script:
|
||||
|
||||
```shell
|
||||
bin/dev [service1] [service2] ... [serviceN]
|
||||
```
|
||||
|
||||
> [!NOTE]
|
||||
> Starting the `web` service in _development mode_ will only update the `web`
|
||||
> service when backend code changes. In order to automatically update frontend
|
||||
> code as well, make sure to start the `webpack` service in _development mode_
|
||||
> as well.
|
||||
|
||||
If no services are named, all services will start in development mode.
|
||||
|
||||
## Debugging
|
||||
|
||||
When run in _development mode_ most services expose a debugging port to which
|
||||
you can attach a debugger such as
|
||||
[the inspector in Chrome's Dev Tools](chrome://inspect/) or one integrated into
|
||||
an IDE. The following table shows the port exposed on the **host machine** for
|
||||
each service:
|
||||
|
||||
| Service | Port |
|
||||
| ------------------ | ---- |
|
||||
| `web` | 9229 |
|
||||
| `clsi` | 9230 |
|
||||
| `chat` | 9231 |
|
||||
| `contacts` | 9232 |
|
||||
| `docstore` | 9233 |
|
||||
| `document-updater` | 9234 |
|
||||
| `filestore` | 9235 |
|
||||
| `notifications` | 9236 |
|
||||
| `real-time` | 9237 |
|
||||
| `references` | 9238 |
|
||||
| `history-v1` | 9239 |
|
||||
| `project-history` | 9240 |
|
||||
|
||||
To attach to a service using Chrome's _remote debugging_, go to
|
||||
<chrome://inspect/> and make sure _Discover network targets_ is checked. Next
|
||||
click _Configure..._ and add an entry `localhost:[service port]` for each of the
|
||||
services you want to attach a debugger to.
|
||||
|
||||
After adding an entry, the service will show up as a _Remote Target_ that you
|
||||
can inspect and debug.
|
3
develop/bin/build
Executable file
3
develop/bin/build
Executable file
|
@ -0,0 +1,3 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
docker compose build --pull "$@"
|
3
develop/bin/dev
Executable file
3
develop/bin/dev
Executable file
|
@ -0,0 +1,3 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
docker-compose -f docker-compose.yml -f docker-compose.dev.yml up --no-deps --detach "$@"
|
3
develop/bin/down
Executable file
3
develop/bin/down
Executable file
|
@ -0,0 +1,3 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
docker compose down "$@"
|
9
develop/bin/logs
Executable file
9
develop/bin/logs
Executable file
|
@ -0,0 +1,9 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
docker compose logs --follow --tail 10 --no-color "$@" \
|
||||
| ggrep --line-buffered --invert-match "global.gc" \
|
||||
| ggrep --line-buffered --invert-match "health.check" \
|
||||
| ggrep --line-buffered --invert-match "slow event loop" \
|
||||
| ggrep --line-buffered --invert-match "process.memoryUsage" \
|
||||
| ggrep --line-buffered --only-matching "[{].*" \
|
||||
| bunyan --output short
|
3
develop/bin/shell
Executable file
3
develop/bin/shell
Executable file
|
@ -0,0 +1,3 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
docker compose exec -it "$@" /bin/bash
|
3
develop/bin/up
Executable file
3
develop/bin/up
Executable file
|
@ -0,0 +1,3 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
docker compose up --detach "$@"
|
0
develop/compiles/.gitkeep
Normal file
0
develop/compiles/.gitkeep
Normal file
21
develop/dev.env
Normal file
21
develop/dev.env
Normal file
|
@ -0,0 +1,21 @@
|
|||
CHAT_HOST=chat
|
||||
CLSI_HOST=clsi
|
||||
CONTACTS_HOST=contacts
|
||||
DOCSTORE_HOST=docstore
|
||||
DOCUMENT_UPDATER_HOST=document-updater
|
||||
FILESTORE_HOST=filestore
|
||||
GRACEFUL_SHUTDOWN_DELAY_SECONDS=0
|
||||
HISTORY_V1_HOST=history-v1
|
||||
LISTEN_ADDRESS=0.0.0.0
|
||||
MONGO_HOST=mongo
|
||||
MONGO_URL=mongodb://mongo/sharelatex?directConnection=true
|
||||
NOTIFICATIONS_HOST=notifications
|
||||
PROJECT_HISTORY_HOST=project-history
|
||||
REALTIME_HOST=real-time
|
||||
REDIS_HOST=redis
|
||||
REFERENCES_HOST=references
|
||||
SESSION_SECRET=foo
|
||||
WEBPACK_HOST=webpack
|
||||
WEB_API_PASSWORD=overleaf
|
||||
WEB_API_USER=overleaf
|
||||
WEB_HOST=web
|
150
develop/docker-compose.dev.yml
Normal file
150
develop/docker-compose.dev.yml
Normal file
|
@ -0,0 +1,150 @@
|
|||
services:
|
||||
clsi:
|
||||
command: ["node", "--watch", "app.js"]
|
||||
environment:
|
||||
- NODE_OPTIONS=--inspect=0.0.0.0:9229
|
||||
ports:
|
||||
- "127.0.0.1:9230:9229"
|
||||
volumes:
|
||||
- ../services/clsi/app:/overleaf/services/clsi/app
|
||||
- ../services/clsi/app.js:/overleaf/services/clsi/app.js
|
||||
- ../services/clsi/config:/overleaf/services/clsi/config
|
||||
|
||||
chat:
|
||||
command: ["node", "--watch", "app.js"]
|
||||
environment:
|
||||
- NODE_OPTIONS=--inspect=0.0.0.0:9229
|
||||
ports:
|
||||
- "127.0.0.1:9231:9229"
|
||||
volumes:
|
||||
- ../services/chat/app:/overleaf/services/chat/app
|
||||
- ../services/chat/app.js:/overleaf/services/chat/app.js
|
||||
- ../services/chat/config:/overleaf/services/chat/config
|
||||
|
||||
contacts:
|
||||
command: ["node", "--watch", "app.js"]
|
||||
environment:
|
||||
- NODE_OPTIONS=--inspect=0.0.0.0:9229
|
||||
ports:
|
||||
- "127.0.0.1:9232:9229"
|
||||
volumes:
|
||||
- ../services/contacts/app:/overleaf/services/contacts/app
|
||||
- ../services/contacts/app.js:/overleaf/services/contacts/app.js
|
||||
- ../services/contacts/config:/overleaf/services/contacts/config
|
||||
|
||||
docstore:
|
||||
command: ["node", "--watch", "app.js"]
|
||||
environment:
|
||||
- NODE_OPTIONS=--inspect=0.0.0.0:9229
|
||||
ports:
|
||||
- "127.0.0.1:9233:9229"
|
||||
volumes:
|
||||
- ../services/docstore/app:/overleaf/services/docstore/app
|
||||
- ../services/docstore/app.js:/overleaf/services/docstore/app.js
|
||||
- ../services/docstore/config:/overleaf/services/docstore/config
|
||||
|
||||
document-updater:
|
||||
command: ["node", "--watch", "app.js"]
|
||||
environment:
|
||||
- NODE_OPTIONS=--inspect=0.0.0.0:9229
|
||||
ports:
|
||||
- "127.0.0.1:9234:9229"
|
||||
volumes:
|
||||
- ../services/document-updater/app:/overleaf/services/document-updater/app
|
||||
- ../services/document-updater/app.js:/overleaf/services/document-updater/app.js
|
||||
- ../services/document-updater/config:/overleaf/services/document-updater/config
|
||||
|
||||
filestore:
|
||||
command: ["node", "--watch", "app.js"]
|
||||
environment:
|
||||
- NODE_OPTIONS=--inspect=0.0.0.0:9229
|
||||
ports:
|
||||
- "127.0.0.1:9235:9229"
|
||||
volumes:
|
||||
- ../services/filestore/app:/overleaf/services/filestore/app
|
||||
- ../services/filestore/app.js:/overleaf/services/filestore/app.js
|
||||
- ../services/filestore/config:/overleaf/services/filestore/config
|
||||
|
||||
history-v1:
|
||||
command: ["node", "--watch", "app.js"]
|
||||
environment:
|
||||
- NODE_OPTIONS=--inspect=0.0.0.0:9229
|
||||
ports:
|
||||
- "127.0.0.1:9239:9229"
|
||||
volumes:
|
||||
- ../services/history-v1/api:/overleaf/services/history-v1/api
|
||||
- ../services/history-v1/app.js:/overleaf/services/history-v1/app.js
|
||||
- ../services/history-v1/config:/overleaf/services/history-v1/config
|
||||
- ../services/history-v1/storage:/overleaf/services/history-v1/storage
|
||||
- ../services/history-v1/knexfile.js:/overleaf/services/history-v1/knexfile.js
|
||||
- ../services/history-v1/migrations:/overleaf/services/history-v1/migrations
|
||||
|
||||
notifications:
|
||||
command: ["node", "--watch", "app.js"]
|
||||
environment:
|
||||
- NODE_OPTIONS=--inspect=0.0.0.0:9229
|
||||
ports:
|
||||
- "127.0.0.1:9236:9229"
|
||||
volumes:
|
||||
- ../services/notifications/app:/overleaf/services/notifications/app
|
||||
- ../services/notifications/app.js:/overleaf/services/notifications/app.js
|
||||
- ../services/notifications/config:/overleaf/services/notifications/config
|
||||
|
||||
project-history:
|
||||
command: ["node", "--watch", "app.js"]
|
||||
environment:
|
||||
- NODE_OPTIONS=--inspect=0.0.0.0:9229
|
||||
ports:
|
||||
- "127.0.0.1:9240:9229"
|
||||
volumes:
|
||||
- ../services/project-history/app:/overleaf/services/project-history/app
|
||||
- ../services/project-history/app.js:/overleaf/services/project-history/app.js
|
||||
- ../services/project-history/config:/overleaf/services/project-history/config
|
||||
|
||||
real-time:
|
||||
command: ["node", "--watch", "app.js"]
|
||||
environment:
|
||||
- NODE_OPTIONS=--inspect=0.0.0.0:9229
|
||||
ports:
|
||||
- "127.0.0.1:9237:9229"
|
||||
volumes:
|
||||
- ../services/real-time/app:/overleaf/services/real-time/app
|
||||
- ../services/real-time/app.js:/overleaf/services/real-time/app.js
|
||||
- ../services/real-time/config:/overleaf/services/real-time/config
|
||||
|
||||
references:
|
||||
command: ["node", "--watch", "app.js"]
|
||||
environment:
|
||||
- NODE_OPTIONS=--inspect=0.0.0.0:9229
|
||||
ports:
|
||||
- "127.0.0.1:9238:9229"
|
||||
volumes:
|
||||
- ../services/references/app:/overleaf/services/references/app
|
||||
- ../services/references/config:/overleaf/services/references/config
|
||||
- ../services/references/app.js:/overleaf/services/references/app.js
|
||||
|
||||
web:
|
||||
command: ["node", "--watch", "app.js", "--watch-locales"]
|
||||
environment:
|
||||
- NODE_OPTIONS=--inspect=0.0.0.0:9229
|
||||
ports:
|
||||
- "127.0.0.1:9229:9229"
|
||||
volumes:
|
||||
- ../services/web/app:/overleaf/services/web/app
|
||||
- ../services/web/app.mjs:/overleaf/services/web/app.mjs
|
||||
- ../services/web/config:/overleaf/services/web/config
|
||||
- ../services/web/locales:/overleaf/services/web/locales
|
||||
- ../services/web/modules:/overleaf/services/web/modules
|
||||
- ../services/web/public:/overleaf/services/web/public
|
||||
|
||||
webpack:
|
||||
volumes:
|
||||
- ../services/web/app:/overleaf/services/web/app
|
||||
- ../services/web/config:/overleaf/services/web/config
|
||||
- ../services/web/frontend:/overleaf/services/web/frontend
|
||||
- ../services/web/locales:/overleaf/services/web/locales
|
||||
- ../services/web/modules:/overleaf/services/web/modules
|
||||
- ../services/web/public:/overleaf/services/web/public
|
||||
- ../services/web/transform:/overleaf/services/web/transform
|
||||
- ../services/web/types:/overleaf/services/web/types
|
||||
- ../services/web/webpack-plugins:/overleaf/services/web/webpack-plugins
|
182
develop/docker-compose.yml
Normal file
182
develop/docker-compose.yml
Normal file
|
@ -0,0 +1,182 @@
|
|||
volumes:
|
||||
clsi-cache:
|
||||
clsi-output:
|
||||
filestore-public-files:
|
||||
filestore-template-files:
|
||||
filestore-uploads:
|
||||
filestore-user-files:
|
||||
mongo-data:
|
||||
redis-data:
|
||||
sharelatex-data:
|
||||
web-data:
|
||||
history-v1-buckets:
|
||||
|
||||
services:
|
||||
chat:
|
||||
build:
|
||||
context: ..
|
||||
dockerfile: services/chat/Dockerfile
|
||||
env_file:
|
||||
- dev.env
|
||||
|
||||
clsi:
|
||||
build:
|
||||
context: ..
|
||||
dockerfile: services/clsi/Dockerfile
|
||||
env_file:
|
||||
- dev.env
|
||||
environment:
|
||||
- DOCKER_RUNNER=true
|
||||
- TEXLIVE_IMAGE=texlive-full # docker build texlive -t texlive-full
|
||||
- COMPILES_HOST_DIR=${PWD}/compiles
|
||||
user: root
|
||||
volumes:
|
||||
- ${PWD}/compiles:/overleaf/services/clsi/compiles
|
||||
- ${DOCKER_SOCKET_PATH:-/var/run/docker.sock}:/var/run/docker.sock
|
||||
- clsi-cache:/overleaf/services/clsi/cache
|
||||
- clsi-output:/overleaf/services/clsi/output
|
||||
|
||||
contacts:
|
||||
build:
|
||||
context: ..
|
||||
dockerfile: services/contacts/Dockerfile
|
||||
env_file:
|
||||
- dev.env
|
||||
|
||||
docstore:
|
||||
build:
|
||||
context: ..
|
||||
dockerfile: services/docstore/Dockerfile
|
||||
env_file:
|
||||
- dev.env
|
||||
|
||||
document-updater:
|
||||
build:
|
||||
context: ..
|
||||
dockerfile: services/document-updater/Dockerfile
|
||||
env_file:
|
||||
- dev.env
|
||||
|
||||
filestore:
|
||||
build:
|
||||
context: ..
|
||||
dockerfile: services/filestore/Dockerfile
|
||||
env_file:
|
||||
- dev.env
|
||||
# environment:
|
||||
# - ENABLE_CONVERSIONS=true
|
||||
volumes:
|
||||
- filestore-public-files:/overleaf/services/filestore/public_files
|
||||
- filestore-template-files:/overleaf/services/filestore/template_files
|
||||
- filestore-uploads:/overleaf/services/filestore/uploads
|
||||
- filestore-user-files:/overleaf/services/filestore/user_files
|
||||
|
||||
history-v1:
|
||||
build:
|
||||
context: ..
|
||||
dockerfile: services/history-v1/Dockerfile
|
||||
env_file:
|
||||
- dev.env
|
||||
environment:
|
||||
OVERLEAF_EDITOR_ANALYTICS_BUCKET: "/buckets/analytics"
|
||||
OVERLEAF_EDITOR_BLOBS_BUCKET: "/buckets/blobs"
|
||||
OVERLEAF_EDITOR_CHUNKS_BUCKET: "/buckets/chunks"
|
||||
OVERLEAF_EDITOR_PROJECT_BLOBS_BUCKET: "/buckets/project_blobs"
|
||||
OVERLEAF_EDITOR_ZIPS_BUCKET: "/buckets/zips"
|
||||
PERSISTOR_BACKEND: fs
|
||||
volumes:
|
||||
- history-v1-buckets:/buckets
|
||||
|
||||
mongo:
|
||||
image: mongo:6.0
|
||||
command: --replSet overleaf
|
||||
ports:
|
||||
- "127.0.0.1:27017:27017" # for debugging
|
||||
volumes:
|
||||
- mongo-data:/data/db
|
||||
- ../bin/shared/mongodb-init-replica-set.js:/docker-entrypoint-initdb.d/mongodb-init-replica-set.js
|
||||
environment:
|
||||
MONGO_INITDB_DATABASE: sharelatex
|
||||
extra_hosts:
|
||||
# Required when using the automatic database setup for initializing the
|
||||
# replica set. This override is not needed when running the setup after
|
||||
# starting up mongo.
|
||||
- mongo:127.0.0.1
|
||||
|
||||
notifications:
|
||||
build:
|
||||
context: ..
|
||||
dockerfile: services/notifications/Dockerfile
|
||||
env_file:
|
||||
- dev.env
|
||||
|
||||
project-history:
|
||||
build:
|
||||
context: ..
|
||||
dockerfile: services/project-history/Dockerfile
|
||||
env_file:
|
||||
- dev.env
|
||||
|
||||
real-time:
|
||||
build:
|
||||
context: ..
|
||||
dockerfile: services/real-time/Dockerfile
|
||||
env_file:
|
||||
- dev.env
|
||||
|
||||
redis:
|
||||
image: redis:5
|
||||
ports:
|
||||
- "127.0.0.1:6379:6379" # for debugging
|
||||
volumes:
|
||||
- redis-data:/data
|
||||
|
||||
references:
|
||||
build:
|
||||
context: ..
|
||||
dockerfile: services/references/Dockerfile
|
||||
env_file:
|
||||
- dev.env
|
||||
|
||||
web:
|
||||
build:
|
||||
context: ..
|
||||
dockerfile: services/web/Dockerfile
|
||||
target: dev
|
||||
env_file:
|
||||
- dev.env
|
||||
environment:
|
||||
- APP_NAME=Overleaf Community Edition
|
||||
- ENABLED_LINKED_FILE_TYPES=project_file,project_output_file,url
|
||||
- EMAIL_CONFIRMATION_DISABLED=true
|
||||
- NODE_ENV=development
|
||||
- OVERLEAF_ALLOW_PUBLIC_ACCESS=true
|
||||
command: ["node", "app.mjs"]
|
||||
volumes:
|
||||
- sharelatex-data:/var/lib/overleaf
|
||||
- web-data:/overleaf/services/web/data
|
||||
depends_on:
|
||||
- mongo
|
||||
- redis
|
||||
- chat
|
||||
- clsi
|
||||
- contacts
|
||||
- docstore
|
||||
- document-updater
|
||||
- filestore
|
||||
- history-v1
|
||||
- notifications
|
||||
- project-history
|
||||
- real-time
|
||||
- references
|
||||
|
||||
webpack:
|
||||
build:
|
||||
context: ..
|
||||
dockerfile: services/web/Dockerfile
|
||||
target: webpack
|
||||
command: ["npx", "webpack", "serve", "--config", "webpack.config.dev-env.js"]
|
||||
ports:
|
||||
- "127.0.0.1:80:3808"
|
||||
volumes:
|
||||
- ./webpack.config.dev-env.js:/overleaf/services/web/webpack.config.dev-env.js
|
8
develop/texlive/Dockerfile
Normal file
8
develop/texlive/Dockerfile
Normal file
|
@ -0,0 +1,8 @@
|
|||
FROM debian:testing-slim
|
||||
|
||||
RUN apt-get update
|
||||
RUN apt-cache depends texlive-full | grep "Depends: " | grep -v -- "-doc" | grep -v -- "-lang-" | sed 's/Depends: //' | xargs apt-get install -y --no-install-recommends
|
||||
RUN apt-get install -y --no-install-recommends fontconfig inkscape pandoc python3-pygments
|
||||
|
||||
RUN useradd tex
|
||||
USER tex
|
23
develop/webpack.config.dev-env.js
Normal file
23
develop/webpack.config.dev-env.js
Normal file
|
@ -0,0 +1,23 @@
|
|||
const { merge } = require('webpack-merge')
|
||||
|
||||
const base = require('./webpack.config.dev')
|
||||
|
||||
module.exports = merge(base, {
|
||||
devServer: {
|
||||
allowedHosts: 'auto',
|
||||
devMiddleware: {
|
||||
index: false,
|
||||
},
|
||||
proxy: [
|
||||
{
|
||||
context: '/socket.io/**',
|
||||
target: 'http://real-time:3026',
|
||||
ws: true,
|
||||
},
|
||||
{
|
||||
context: ['!**/*.js', '!**/*.css', '!**/*.json'],
|
||||
target: 'http://web:3000',
|
||||
},
|
||||
],
|
||||
},
|
||||
})
|
BIN
doc/logo.png
Normal file
BIN
doc/logo.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 71 KiB |
BIN
doc/screenshot.png
Normal file
BIN
doc/screenshot.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1 MiB |
23
docker-compose.debug.yml
Normal file
23
docker-compose.debug.yml
Normal file
|
@ -0,0 +1,23 @@
|
|||
version: '2.2'
|
||||
services:
|
||||
sharelatex:
|
||||
ports:
|
||||
- 30000:30000
|
||||
- 30150:30150
|
||||
- 30120:30120
|
||||
- 30050:30050
|
||||
- 30420:30420
|
||||
- 30030:30030
|
||||
- 30160:30160
|
||||
- 30360:30360
|
||||
- 30130:30130
|
||||
- 30100:30100
|
||||
- 30540:30540
|
||||
- 30640:30640
|
||||
- 40000:40000
|
||||
|
||||
# Server Pro
|
||||
- 30070:30070
|
||||
- 30400:30400
|
||||
environment:
|
||||
DEBUG_NODE: 'true'
|
144
docker-compose.yml
Normal file
144
docker-compose.yml
Normal file
|
@ -0,0 +1,144 @@
|
|||
version: '2.2'
|
||||
services:
|
||||
sharelatex:
|
||||
restart: always
|
||||
# Server Pro users:
|
||||
# image: quay.io/sharelatex/sharelatex-pro
|
||||
image: sharelatex/sharelatex
|
||||
container_name: sharelatex
|
||||
depends_on:
|
||||
mongo:
|
||||
condition: service_healthy
|
||||
redis:
|
||||
condition: service_started
|
||||
ports:
|
||||
- 80:80
|
||||
stop_grace_period: 60s
|
||||
volumes:
|
||||
- ~/sharelatex_data:/var/lib/overleaf
|
||||
########################################################################
|
||||
#### Server Pro: Uncomment the following line to mount the docker ####
|
||||
#### socket, required for Sibling Containers to work ####
|
||||
########################################################################
|
||||
# - /var/run/docker.sock:/var/run/docker.sock
|
||||
environment:
|
||||
|
||||
OVERLEAF_APP_NAME: Overleaf Community Edition
|
||||
|
||||
OVERLEAF_MONGO_URL: mongodb://mongo/sharelatex
|
||||
|
||||
# Same property, unfortunately with different names in
|
||||
# different locations
|
||||
OVERLEAF_REDIS_HOST: redis
|
||||
REDIS_HOST: redis
|
||||
|
||||
ENABLED_LINKED_FILE_TYPES: 'project_file,project_output_file,url'
|
||||
|
||||
# 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
|
||||
|
||||
# OVERLEAF_SITE_URL: http://overleaf.example.com
|
||||
# OVERLEAF_NAV_TITLE: Overleaf Community Edition
|
||||
# OVERLEAF_HEADER_IMAGE_URL: http://example.com/mylogo.png
|
||||
# OVERLEAF_ADMIN_EMAIL: support@it.com
|
||||
|
||||
# OVERLEAF_LEFT_FOOTER: '[{"text": "Another page I want to link to can be found <a href=\"here\">here</a>"} ]'
|
||||
# OVERLEAF_RIGHT_FOOTER: '[{"text": "Hello I am on the Right"} ]'
|
||||
|
||||
# OVERLEAF_EMAIL_FROM_ADDRESS: "hello@example.com"
|
||||
|
||||
# OVERLEAF_EMAIL_AWS_SES_ACCESS_KEY_ID:
|
||||
# OVERLEAF_EMAIL_AWS_SES_SECRET_KEY:
|
||||
|
||||
# OVERLEAF_EMAIL_SMTP_HOST: smtp.example.com
|
||||
# OVERLEAF_EMAIL_SMTP_PORT: 587
|
||||
# OVERLEAF_EMAIL_SMTP_SECURE: false
|
||||
# OVERLEAF_EMAIL_SMTP_USER:
|
||||
# OVERLEAF_EMAIL_SMTP_PASS:
|
||||
# OVERLEAF_EMAIL_SMTP_TLS_REJECT_UNAUTH: true
|
||||
# OVERLEAF_EMAIL_SMTP_IGNORE_TLS: false
|
||||
# OVERLEAF_EMAIL_SMTP_NAME: '127.0.0.1'
|
||||
# OVERLEAF_EMAIL_SMTP_LOGGER: true
|
||||
# OVERLEAF_CUSTOM_EMAIL_FOOTER: "This system is run by department x"
|
||||
|
||||
# ENABLE_CRON_RESOURCE_DELETION: true
|
||||
|
||||
################
|
||||
## Server Pro ##
|
||||
################
|
||||
|
||||
## Sandboxed Compiles: https://github.com/overleaf/overleaf/wiki/Server-Pro:-Sandboxed-Compiles
|
||||
SANDBOXED_COMPILES: 'true'
|
||||
SANDBOXED_COMPILES_SIBLING_CONTAINERS: 'true'
|
||||
### Bind-mount source for /var/lib/overleaf/data/compiles inside the container.
|
||||
SANDBOXED_COMPILES_HOST_DIR: '/home/user/sharelatex_data/data/compiles'
|
||||
|
||||
## Works with test LDAP server shown at bottom of docker compose
|
||||
# OVERLEAF_LDAP_URL: 'ldap://ldap:389'
|
||||
# OVERLEAF_LDAP_SEARCH_BASE: 'ou=people,dc=planetexpress,dc=com'
|
||||
# OVERLEAF_LDAP_SEARCH_FILTER: '(uid={{username}})'
|
||||
# OVERLEAF_LDAP_BIND_DN: 'cn=admin,dc=planetexpress,dc=com'
|
||||
# OVERLEAF_LDAP_BIND_CREDENTIALS: 'GoodNewsEveryone'
|
||||
# OVERLEAF_LDAP_EMAIL_ATT: 'mail'
|
||||
# OVERLEAF_LDAP_NAME_ATT: 'cn'
|
||||
# OVERLEAF_LDAP_LAST_NAME_ATT: 'sn'
|
||||
# OVERLEAF_LDAP_UPDATE_USER_DETAILS_ON_LOGIN: 'true'
|
||||
|
||||
# OVERLEAF_TEMPLATES_USER_ID: "578773160210479700917ee5"
|
||||
# OVERLEAF_NEW_PROJECT_TEMPLATE_LINKS: '[ {"name":"All Templates","url":"/templates/all"}]'
|
||||
|
||||
|
||||
# OVERLEAF_PROXY_LEARN: "true"
|
||||
|
||||
mongo:
|
||||
restart: always
|
||||
image: mongo:6.0
|
||||
container_name: mongo
|
||||
command: '--replSet overleaf'
|
||||
volumes:
|
||||
- ~/mongo_data:/data/db
|
||||
- ./bin/shared/mongodb-init-replica-set.js:/docker-entrypoint-initdb.d/mongodb-init-replica-set.js
|
||||
environment:
|
||||
MONGO_INITDB_DATABASE: sharelatex
|
||||
extra_hosts:
|
||||
# Required when using the automatic database setup for initializing the replica set.
|
||||
# This override is not needed when running the setup after starting up mongo.
|
||||
- mongo:127.0.0.1
|
||||
healthcheck:
|
||||
test: echo 'db.stats().ok' | mongosh localhost:27017/test --quiet
|
||||
interval: 10s
|
||||
timeout: 10s
|
||||
retries: 5
|
||||
|
||||
redis:
|
||||
restart: always
|
||||
image: redis:6.2
|
||||
container_name: redis
|
||||
volumes:
|
||||
- ~/redis_data:/data
|
||||
|
||||
# ldap:
|
||||
# restart: always
|
||||
# image: rroemhild/test-openldap
|
||||
# container_name: ldap
|
||||
|
||||
# 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/overleaf/tmp:/etc/nginx/certs
|
5
install_unibremen/README.md
Normal file
5
install_unibremen/README.md
Normal file
|
@ -0,0 +1,5 @@
|
|||
```
|
||||
git clone git@git.fb1.uni-bremen.de:davrot/latex-ub.git
|
||||
cd latex-ub/server-ce
|
||||
make all
|
||||
```
|
25
install_unibremen/docker/compose_cep/check_users/Dockerfile
Normal file
25
install_unibremen/docker/compose_cep/check_users/Dockerfile
Normal file
|
@ -0,0 +1,25 @@
|
|||
FROM python:3.12.5
|
||||
|
||||
RUN apt-get update
|
||||
RUN apt -y install mc
|
||||
RUN apt -y install docker.io
|
||||
RUN pip install pymongo
|
||||
RUN pip install email_validator
|
||||
RUN pip install flask
|
||||
RUN pip install gunicorn
|
||||
RUN pip install requests
|
||||
RUN pip install BeautifulSoup4
|
||||
RUN apt -y install bash
|
||||
RUN pip install --upgrade pip
|
||||
RUN pip install flask_wtf
|
||||
RUN pip install wtforms
|
||||
RUN pip install flask_recaptcha
|
||||
RUN pip install Markup
|
||||
RUN pip install captcha Pillow
|
||||
RUN pip install argh
|
||||
|
||||
EXPOSE 80
|
||||
|
||||
ENTRYPOINT ["/bin/bash", "-c", "cd / && sleep infinity"]
|
||||
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
services:
|
||||
checkuser:
|
||||
image: "check_user_image"
|
||||
container_name: checkuser
|
||||
hostname: checkuser
|
||||
restart: always
|
||||
|
||||
volumes:
|
||||
- ./data:/data
|
||||
- /var/run/docker.sock:/var/run/docker.sock
|
||||
|
||||
networks:
|
||||
- overleaf-network
|
||||
|
||||
entrypoint: >
|
||||
/bin/sh -c "pip install argh && cd / && sleep infinity"
|
||||
|
||||
|
||||
networks:
|
||||
overleaf-network:
|
||||
external: true
|
82
install_unibremen/docker/compose_cep/check_users/data/add_user.py
Executable file
82
install_unibremen/docker/compose_cep/check_users/data/add_user.py
Executable file
|
@ -0,0 +1,82 @@
|
|||
import requests # type: ignore
|
||||
import json
|
||||
from requests.auth import HTTPBasicAuth # type: ignore
|
||||
|
||||
|
||||
def add_keycloak_user(username):
|
||||
|
||||
# print(f"Start to create user {username} via OIDC")
|
||||
|
||||
with open("config.json", "r") as file:
|
||||
config = json.load(file)
|
||||
|
||||
token_url = f"{config['keycloak_url']}/realms/master/protocol/openid-connect/token"
|
||||
token_data = {
|
||||
"grant_type": "password",
|
||||
"username": config["admin_username"],
|
||||
"password": config["admin_password"],
|
||||
}
|
||||
users_url = f"{config['keycloak_url']}/admin/realms/master/users"
|
||||
|
||||
# print("-- Get token")
|
||||
# Get token
|
||||
try:
|
||||
response = requests.post(
|
||||
token_url,
|
||||
data=token_data,
|
||||
auth=HTTPBasicAuth(config["client_id"], config["client_secret"]),
|
||||
)
|
||||
response.raise_for_status()
|
||||
|
||||
except requests.exceptions.HTTPError:
|
||||
return False
|
||||
|
||||
access_token = response.json()["access_token"]
|
||||
headers = {
|
||||
"Authorization": f"Bearer {access_token}",
|
||||
"Content-Type": "application/json",
|
||||
}
|
||||
|
||||
# Check if user exists
|
||||
params = {"username": username, "exact": "true"}
|
||||
|
||||
# print("-- Check if user exists")
|
||||
|
||||
try:
|
||||
response = requests.get(users_url, headers=headers, params=params)
|
||||
response.raise_for_status()
|
||||
|
||||
# Response is a list of users matching the criteria
|
||||
users = response.json()
|
||||
|
||||
# If we found any users with exact username match, the user exists
|
||||
if len(users) > 0:
|
||||
return False
|
||||
|
||||
except requests.exceptions.HTTPError:
|
||||
return False
|
||||
|
||||
# print("-- Make new user")
|
||||
|
||||
# Make new user
|
||||
new_user = {
|
||||
"username": username,
|
||||
"enabled": True,
|
||||
"emailVerified": False,
|
||||
"firstName": " ",
|
||||
"lastName": " ",
|
||||
"email": username,
|
||||
"requiredActions": ["UPDATE_PASSWORD"],
|
||||
}
|
||||
|
||||
try:
|
||||
# Create the user
|
||||
response = requests.post(users_url, headers=headers, data=json.dumps(new_user))
|
||||
response.raise_for_status()
|
||||
|
||||
except requests.exceptions.HTTPError:
|
||||
return False
|
||||
|
||||
print(username,"-- DONE")
|
||||
|
||||
return True
|
|
@ -0,0 +1,17 @@
|
|||
import pymongo
|
||||
from add_user import add_keycloak_user
|
||||
|
||||
container_name: str = "overleafmongo"
|
||||
port: int = 27017
|
||||
|
||||
client = pymongo.MongoClient(container_name, port)
|
||||
db = client.sharelatex
|
||||
users = db.projectInvites
|
||||
|
||||
cursor = users.find()
|
||||
|
||||
for user in cursor:
|
||||
# print(user["email"])
|
||||
add_keycloak_user(user["email"])
|
||||
|
||||
client.close()
|
8
install_unibremen/docker/compose_cep/check_users/data/config.json
Executable file
8
install_unibremen/docker/compose_cep/check_users/data/config.json
Executable file
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"keycloak_url": "https://sso.fb1.uni-bremen.de/sso",
|
||||
"keycloak_login": "https://overleaf.neuro.uni-bremen.de/login/oidc",
|
||||
"admin_username": "automation@non.no",
|
||||
"admin_password": "REDACTED",
|
||||
"client_id": "admin-cli",
|
||||
"client_secret": "REDACTED"
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
import pymongo
|
||||
|
||||
container_name:str = "overleafmongo"
|
||||
port: int = 27017
|
||||
|
||||
client = pymongo.MongoClient(container_name, port)
|
||||
db = client.sharelatex
|
||||
projects = db.projects
|
||||
|
||||
cursor = projects.find()
|
||||
|
||||
for project in cursor:
|
||||
print(project['imageName'])
|
||||
|
||||
client.close()
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
import pymongo
|
||||
|
||||
container_name:str = "overleafmongo"
|
||||
port: int = 27017
|
||||
|
||||
client = pymongo.MongoClient(container_name, port)
|
||||
db = client.sharelatex
|
||||
users = db.projectInvites
|
||||
|
||||
cursor = users.find()
|
||||
|
||||
for user in cursor:
|
||||
print(user['email'])
|
||||
|
||||
client.close()
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
import pymongo
|
||||
|
||||
container_name:str = "overleafmongo"
|
||||
port: int = 27017
|
||||
|
||||
client = pymongo.MongoClient(container_name, port)
|
||||
db = client.sharelatex
|
||||
users = db.users
|
||||
|
||||
cursor = users.find()
|
||||
|
||||
for user in cursor:
|
||||
print(user['email'])
|
||||
|
||||
client.close()
|
||||
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
import pymongo
|
||||
import argh
|
||||
|
||||
def main(email_to_find: str,container_name:str = "overleafmongo", port: int = 27017) -> bool:
|
||||
print(f"User name: {email_to_find}" )
|
||||
client = pymongo.MongoClient(container_name, port)
|
||||
db = client.sharelatex
|
||||
users = db.users
|
||||
search_result = users.find_one({"email": email_to_find})
|
||||
|
||||
if search_result is None:
|
||||
print("User not found")
|
||||
return
|
||||
else:
|
||||
print(f"User status was: {search_result['isAdmin']}")
|
||||
users.update_one(
|
||||
{"email": email_to_find},
|
||||
{"$set": {"isAdmin": True}}
|
||||
)
|
||||
print("User status changed")
|
||||
return
|
||||
|
||||
client.close()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
argh.dispatch_command(main)
|
|
@ -0,0 +1,9 @@
|
|||
#!/bin/bash
|
||||
|
||||
if [ -z "$1" ]; then
|
||||
echo "Error: Email address not provided"
|
||||
echo "Usage: $0 <email_address>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
docker exec overleafserver /bin/bash -ce "cd /overleaf/services/web && node modules/server-ce-scripts/scripts/delete-user.mjs --email=$1"
|
1
install_unibremen/docker/compose_cep/check_users/exec.sh
Normal file
1
install_unibremen/docker/compose_cep/check_users/exec.sh
Normal file
|
@ -0,0 +1 @@
|
|||
docker exec -it checkuser bash
|
1
install_unibremen/docker/compose_cep/check_users/exec_autoadd_invited.sh
Executable file
1
install_unibremen/docker/compose_cep/check_users/exec_autoadd_invited.sh
Executable file
|
@ -0,0 +1 @@
|
|||
docker exec checkuser bash -c "cd /data ; python autoadd_invited.py"
|
|
@ -0,0 +1 @@
|
|||
docker exec -it checkuser bash -c "cd /data ; python list_invited.py"
|
|
@ -0,0 +1 @@
|
|||
docker exec -it checkuser bash -c "cd /data ; python list_user.py"
|
|
@ -0,0 +1 @@
|
|||
docker exec -it checkuser bash -c "cd /data ; python make_admin.py $1"
|
|
@ -0,0 +1 @@
|
|||
docker build --network host -t check_user_image .
|
49
install_unibremen/docker/compose_cep/compose.yaml
Normal file
49
install_unibremen/docker/compose_cep/compose.yaml
Normal file
|
@ -0,0 +1,49 @@
|
|||
services:
|
||||
overleafredis:
|
||||
extends:
|
||||
file: ./overleafredis/compose.yaml
|
||||
service: overleafredis
|
||||
|
||||
overleafmongo:
|
||||
extends:
|
||||
file: ./overleafmongo/compose.yaml
|
||||
service: overleafmongo
|
||||
|
||||
overleafserver:
|
||||
extends:
|
||||
file: ./overleafserver/compose.yaml
|
||||
service: overleafserver
|
||||
depends_on:
|
||||
overleafredis:
|
||||
condition: service_healthy
|
||||
overleafmongo:
|
||||
condition: service_healthy
|
||||
|
||||
checkuser:
|
||||
extends:
|
||||
file: ./check_users/compose.yaml
|
||||
service: checkuser
|
||||
depends_on:
|
||||
overleafserver:
|
||||
condition: service_healthy
|
||||
|
||||
nginx:
|
||||
extends:
|
||||
file: ./nginx/compose.yaml
|
||||
service: nginx
|
||||
depends_on:
|
||||
overleafserver:
|
||||
condition: service_healthy
|
||||
|
||||
gitbridge:
|
||||
extends:
|
||||
file: ./gitbridge/compose.yaml
|
||||
service: gitbridge
|
||||
depends_on:
|
||||
overleafserver:
|
||||
condition: service_healthy
|
||||
|
||||
networks:
|
||||
overleaf-network:
|
||||
external: true
|
||||
|
2
install_unibremen/docker/compose_cep/down.sh
Normal file
2
install_unibremen/docker/compose_cep/down.sh
Normal file
|
@ -0,0 +1,2 @@
|
|||
docker compose down
|
||||
|
2
install_unibremen/docker/compose_cep/down_gitbridge.sh
Normal file
2
install_unibremen/docker/compose_cep/down_gitbridge.sh
Normal file
|
@ -0,0 +1,2 @@
|
|||
docker compose down gitbridge
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
docker compose down overleafserver
|
||||
|
1
install_unibremen/docker/compose_cep/exec_checkuser.sh
Normal file
1
install_unibremen/docker/compose_cep/exec_checkuser.sh
Normal file
|
@ -0,0 +1 @@
|
|||
docker exec -it checkuser bash
|
1
install_unibremen/docker/compose_cep/exec_gitbridge.sh
Normal file
1
install_unibremen/docker/compose_cep/exec_gitbridge.sh
Normal file
|
@ -0,0 +1 @@
|
|||
docker exec -it gitbridge bash
|
1
install_unibremen/docker/compose_cep/exec_nginx.sh
Normal file
1
install_unibremen/docker/compose_cep/exec_nginx.sh
Normal file
|
@ -0,0 +1 @@
|
|||
docker exec -it nginx sh
|
|
@ -0,0 +1 @@
|
|||
docker exec -it overleafmongo bash
|
|
@ -0,0 +1 @@
|
|||
docker exec -it overleafredis sh
|
|
@ -0,0 +1 @@
|
|||
docker exec -it overleafserver bash
|
41
install_unibremen/docker/compose_cep/gitbridge/Dockerfile
Normal file
41
install_unibremen/docker/compose_cep/gitbridge/Dockerfile
Normal file
|
@ -0,0 +1,41 @@
|
|||
FROM ubuntu:24.04
|
||||
|
||||
# Ensure non-interactive installation
|
||||
ENV DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
# Update and install packages
|
||||
RUN apt update
|
||||
RUN apt -y install mc
|
||||
RUN apt -y install bash
|
||||
RUN apt -y install openssh-server
|
||||
RUN apt -y install python3-pip
|
||||
RUN apt -y install python3-argh
|
||||
RUN apt -y install git-all
|
||||
RUN apt -y install golang-go
|
||||
RUN apt -y install curl
|
||||
RUN apt -y install openssl
|
||||
RUN apt -y install libpam-script
|
||||
RUN apt -y install sudo
|
||||
RUN apt -y install rush
|
||||
RUN apt -y install inetutils-syslogd
|
||||
RUN apt -y install python3-docker
|
||||
RUN apt -y install ncat
|
||||
RUN apt -y install python3-pymongo
|
||||
|
||||
RUN cp -a /etc /etc_original
|
||||
RUN rm -f /etc_original/hostname
|
||||
RUN rm -f /etc_original/hosts
|
||||
RUN rm -f /etc_original/resolv.conf
|
||||
|
||||
# Copy initialization script
|
||||
COPY files/init.sh /init.sh
|
||||
RUN chmod +x /init.sh
|
||||
|
||||
# Expose SSH port
|
||||
EXPOSE 22
|
||||
|
||||
ENTRYPOINT ["/init.sh"]
|
||||
|
||||
|
||||
|
||||
|
156
install_unibremen/docker/compose_cep/gitbridge/README.md
Normal file
156
install_unibremen/docker/compose_cep/gitbridge/README.md
Normal file
|
@ -0,0 +1,156 @@
|
|||
If the user logs in via git (in the moment on port 993, please don't forget to allow port 993 via ufw allow 993), the projects for that user are automatically updated.
|
||||
|
||||
Every 5 minutes, cron checks the userdata base of overleaf and new user from the database are created.
|
||||
|
||||
## Get the ssh keys for a user
|
||||
|
||||
```
|
||||
git clone ssh://[USERNAME]@[FQDN]:[PORT]/sshkey.git
|
||||
```
|
||||
|
||||
e.g.
|
||||
|
||||
```
|
||||
git clone ssh://davrot@uni-bremen.de@psintern.neuro.uni-bremen.de:993/sshkey.git
|
||||
```
|
||||
|
||||
## Get the project list for a user
|
||||
|
||||
```
|
||||
git clone ssh://[USERNAME]@[FQDN]:[PORT]/projects.git
|
||||
```
|
||||
|
||||
e.g.
|
||||
|
||||
```
|
||||
git clone ssh://davrot@uni-bremen.de@psintern.neuro.uni-bremen.de:993/projects.git
|
||||
```
|
||||
|
||||
## Get a project
|
||||
|
||||
```
|
||||
git clone ssh://[USERNAME]@[FQDN]:[PORT]/[PROJECT_ID].git
|
||||
```
|
||||
|
||||
e.g.
|
||||
|
||||
|
||||
```
|
||||
git clone ssh://davrot@uni-bremen.de@psintern.neuro.uni-bremen.de:993/6759fdf66ca7b8bc5b81b184.git
|
||||
```
|
||||
|
||||
On the one side this backup container communicates with the user via git and with the overleaf server via docker socket.
|
||||
|
||||
Don't forget the crontab entry for host:
|
||||
|
||||
```
|
||||
# m h dom mon dow command
|
||||
*/5 * * * * sh /docker/compose/hajtex_sshd/exec_update_userlist.sh
|
||||
```
|
||||
|
||||
Otherwise, login will fail without the user directories. You can also run it manually:
|
||||
```
|
||||
sh /docker/compose/hajtex_sshd/exec_update_userlist.sh
|
||||
```
|
||||
|
||||
# Port 993
|
||||
|
||||
If you don't like port 993 you can change the compose.yaml
|
||||
```
|
||||
ports:
|
||||
- 993:22
|
||||
```
|
||||
accordingly. But don't forget you firewall:
|
||||
|
||||
```
|
||||
ufw allow 993:22
|
||||
```
|
||||
|
||||
# ssh / scp / git-shell authentification against KeyCloak
|
||||
|
||||
## Create the client in keycloak:
|
||||
|
||||
```
|
||||
urn:ietf:wg:oauth:2.0:oob
|
||||
```
|
||||
|
||||

|
||||
|
||||
---
|
||||
|
||||

|
||||
|
||||
---
|
||||
|
||||

|
||||
|
||||
---
|
||||
|
||||
|
||||
## Update files/config.toml
|
||||
|
||||
Change clientsecret and the endpoint.
|
||||
|
||||
```
|
||||
realm = "master"
|
||||
endpoint = "https://psintern.neuro.uni-bremen.de/sso/"
|
||||
clientid = "linux-ssh"
|
||||
clientsecret = "REDACTED"
|
||||
clientscope = "openid"
|
||||
```
|
||||
|
||||
## Create image:
|
||||
|
||||
```
|
||||
>> make_image.sh
|
||||
```
|
||||
|
||||
## Change the name of the HajTex server container:
|
||||
|
||||
Default is "/overleafserver"
|
||||
|
||||
If your installation is different then change in the files download_files.py, auth_against_docker.py and update_userlist.py modifiy the line accordingly:
|
||||
|
||||
```
|
||||
container_name: str = "/overleafserver",
|
||||
```
|
||||
|
||||
|
||||
# Files
|
||||
|
||||
* Dockerfile
|
||||
|
||||
Dockerfile for creating the container image
|
||||
|
||||
* compose.yaml
|
||||
|
||||
Compose file to start the container
|
||||
|
||||
* crontab_host.txt
|
||||
|
||||
This needs to be placed into the crontab of the host
|
||||
|
||||
* down.sh
|
||||
|
||||
For stoping the container
|
||||
|
||||
* exec.sh
|
||||
|
||||
For entering the container for an interactive session
|
||||
|
||||
* init.sh
|
||||
|
||||
Init script that is ran during starting the container. The make_image.sh places it into the container.
|
||||
|
||||
* logs.sh
|
||||
|
||||
Shows the logs of the running container
|
||||
|
||||
* make_image.sh
|
||||
|
||||
Needs to be run for generating the container image
|
||||
|
||||
* exec_update_userlist.sh
|
||||
|
||||
Is run by the cron to update the user basis in the container based on the overleaf user database
|
||||
|
51
install_unibremen/docker/compose_cep/gitbridge/compose.yaml
Normal file
51
install_unibremen/docker/compose_cep/gitbridge/compose.yaml
Normal file
|
@ -0,0 +1,51 @@
|
|||
services:
|
||||
gitbridge:
|
||||
image: gitbridge_image
|
||||
container_name: gitbridge
|
||||
hostname: gitbridge
|
||||
restart: always
|
||||
volumes:
|
||||
- ./downloads:/downloads
|
||||
- ./etc:/etc
|
||||
- ./log:/var/log
|
||||
- /var/run/docker.sock:/var/run/docker.sock
|
||||
|
||||
- ./files/sshd_config:/etc/ssh/sshd_config:ro
|
||||
- ./files/rush.rc:/etc/rush.rc:ro
|
||||
- ./files/pre-rush.sh:/pre-rush.sh:ro
|
||||
|
||||
- ./files/get_project.py:/get_project.py:ro
|
||||
- ./files/get_project_list.py:/get_project_list.py:ro
|
||||
- ./files/check_and_create_new_users.py:/check_and_create_new_users.py:ro
|
||||
|
||||
- ./files/set_key_overleaf.py:/set_key_overleaf.py:ro
|
||||
- ./files/get_key_overleaf.py:/get_key_overleaf.py:ro
|
||||
# - ./files/make_new_user.sh:/make_new_user.sh:ro
|
||||
|
||||
# This is just for my multi server installation
|
||||
- ./files_special/get_key_keycloak.py:/get_key_keycloak.py:ro
|
||||
- ./files_special/set_key_keycloak.py:/set_key_keycloak.py:ro
|
||||
- ./files_special/config.json:/config.json:ro
|
||||
- ./files_special/make_new_user.sh:/make_new_user.sh:ro
|
||||
|
||||
|
||||
ports:
|
||||
- 22:22
|
||||
environment:
|
||||
PUID: 1000
|
||||
PGID: 1000
|
||||
TZ: Etc/UTC
|
||||
networks:
|
||||
- overleaf-network
|
||||
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "ncat -zv localhost 22 > /dev/null 2>&1 && exit 0 || exit 1"]
|
||||
interval: 30s
|
||||
timeout: 10s
|
||||
retries: 5
|
||||
start_period: 60s
|
||||
|
||||
networks:
|
||||
overleaf-network:
|
||||
external: true
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
# m h dom mon dow command
|
||||
*/5 * * * * sh /docker/compose_cep/gitbridge/exec_check_and_create_new_users.sh
|
|
@ -0,0 +1 @@
|
|||
docker exec gitbridge bash -c "cd / ; python3 check_and_create_new_users.py"
|
|
@ -0,0 +1,29 @@
|
|||
import pwd
|
||||
import subprocess
|
||||
import pymongo
|
||||
|
||||
container_name:str = "overleafmongo"
|
||||
port: int = 27017
|
||||
|
||||
client = pymongo.MongoClient(container_name, port)
|
||||
db = client.sharelatex
|
||||
users = db.users
|
||||
|
||||
cursor = users.find()
|
||||
|
||||
for user in cursor:
|
||||
username:str = user['email']
|
||||
create_new_user: bool = False
|
||||
try:
|
||||
pwd.getpwnam(username)
|
||||
create_new_user = False
|
||||
except KeyError:
|
||||
create_new_user = True
|
||||
|
||||
if create_new_user:
|
||||
subprocess.run([f"sh /make_new_user.sh {username}"], shell=True)
|
||||
|
||||
client.close()
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,82 @@
|
|||
import pymongo
|
||||
import argh
|
||||
import os
|
||||
import stat
|
||||
|
||||
def read_keys(username: str, container_name: str = "overleafmongo", port: int = 27017,
|
||||
output_path: str = "/downloads") -> bool:
|
||||
"""
|
||||
Read SSH public and private keys for a user from MongoDB and save to filesystem.
|
||||
|
||||
Args:
|
||||
username: Username for SSH key files
|
||||
container_name: MongoDB container name
|
||||
port: MongoDB port
|
||||
output_path: Base path to save user SSH keys
|
||||
"""
|
||||
print(f"Looking up user: {username}")
|
||||
|
||||
# Connect to MongoDB
|
||||
client = pymongo.MongoClient(container_name, port)
|
||||
db = client.sharelatex
|
||||
users = db.users
|
||||
|
||||
# Check if user exists and retrieve keys
|
||||
user_data = users.find_one({"email": username})
|
||||
if user_data is None:
|
||||
print("User not found")
|
||||
client.close()
|
||||
exit(1)
|
||||
|
||||
# Check if SSH keys exist in the user document
|
||||
if "sshPublicKey" not in user_data or "sshPrivateKey" not in user_data:
|
||||
print("SSH keys not found for this user")
|
||||
client.close()
|
||||
exit(1)
|
||||
|
||||
public_key = user_data["sshPublicKey"]
|
||||
private_key = user_data["sshPrivateKey"]
|
||||
|
||||
# Save keys to filesystem if path and username are provided
|
||||
if output_path and username:
|
||||
try:
|
||||
# Create .ssh directory if it doesn't exist
|
||||
ssh_dir = os.path.join(output_path, username, ".ssh")
|
||||
os.makedirs(ssh_dir, exist_ok=True)
|
||||
|
||||
# Define key file paths
|
||||
public_key_path = os.path.join(ssh_dir, "overleafcep.pub")
|
||||
private_key_path = os.path.join(ssh_dir, "overleafcep")
|
||||
authorized_keys_path = os.path.join(ssh_dir, "authorized_keys")
|
||||
|
||||
# Write authorized keys
|
||||
with open(authorized_keys_path, 'w') as file:
|
||||
file.write(public_key)
|
||||
os.chmod(authorized_keys_path, 0o644) # rw-r--r--
|
||||
|
||||
# Write public key
|
||||
with open(public_key_path, 'w') as file:
|
||||
file.write(public_key)
|
||||
os.chmod(public_key_path, 0o644) # rw-r--r--
|
||||
|
||||
# Write private key with restricted permissions
|
||||
with open(private_key_path, 'w') as file:
|
||||
file.write(private_key)
|
||||
os.chmod(private_key_path, 0o600) # rw-------
|
||||
|
||||
print(f"SSH keys saved to {ssh_dir}")
|
||||
print(f"Public key: {public_key_path}")
|
||||
print(f"Private key: {private_key_path}")
|
||||
print(f"Authorized key: {authorized_keys_path}")
|
||||
|
||||
except Exception as e:
|
||||
print(f"Error saving SSH keys: {e}")
|
||||
client.close()
|
||||
exit(1)
|
||||
|
||||
client.close()
|
||||
exit(0)
|
||||
|
||||
if __name__ == "__main__":
|
||||
argh.dispatch_command(read_keys)
|
||||
|
|
@ -0,0 +1,242 @@
|
|||
import argh # type: ignore
|
||||
import shutil
|
||||
import os
|
||||
import subprocess
|
||||
import glob
|
||||
import docker # type: ignore
|
||||
import pymongo
|
||||
import bson
|
||||
|
||||
|
||||
def get_user_id(
|
||||
username: str, container_mongo_name: str = "overleafmongo", port: int = 27017
|
||||
) -> bson.objectid.ObjectId | None:
|
||||
|
||||
# Establish connection to MongoDB
|
||||
client = pymongo.MongoClient(container_mongo_name, port)
|
||||
|
||||
try:
|
||||
# Access the 'sharelatex' database
|
||||
db = client.sharelatex
|
||||
|
||||
user_query_filter = {"email": username}
|
||||
|
||||
# Use find_one() to get a single document that matches the query
|
||||
selected_user = db.users.find_one(user_query_filter)
|
||||
|
||||
if selected_user:
|
||||
client.close()
|
||||
return selected_user["_id"]
|
||||
|
||||
finally:
|
||||
# Close the connection regardless of the outcome (success or failure in finding the user)
|
||||
client.close()
|
||||
|
||||
return None
|
||||
|
||||
|
||||
def check_project_access(
|
||||
user_id: bson.objectid.ObjectId,
|
||||
project_id: str,
|
||||
container_mongo_name: str = "overleafmongo",
|
||||
port: int = 27017,
|
||||
) -> bool:
|
||||
"""
|
||||
Check if a user has access to a specific project.
|
||||
|
||||
Args:
|
||||
user_id: The ObjectId of the user
|
||||
project_id: The string representation of the project's _id
|
||||
container_name: MongoDB container name
|
||||
port: MongoDB port
|
||||
|
||||
Returns:
|
||||
bool: True if the user has access to the project, False otherwise
|
||||
"""
|
||||
# Establish connection to MongoDB
|
||||
client = pymongo.MongoClient(container_mongo_name, port)
|
||||
try:
|
||||
# Access the 'sharelatex' database
|
||||
db = client.sharelatex
|
||||
|
||||
# Convert project_id string to ObjectId
|
||||
project_object_id = bson.objectid.ObjectId(project_id)
|
||||
|
||||
# Create query filter to check if the specific project exists
|
||||
# and if the user has access to it
|
||||
project_query_filter = {
|
||||
"_id": project_object_id, # Specific project ID
|
||||
"$or": [
|
||||
{"owner_ref": user_id}, # User is the owner
|
||||
{"collaberator_refs": user_id}, # User is a collaborator
|
||||
{"readOnly_refs": user_id}, # User has read-only access
|
||||
],
|
||||
}
|
||||
|
||||
# Check if any matching document exists
|
||||
# Using count_documents with limit=1 is efficient for just checking existence
|
||||
has_access = db.projects.count_documents(project_query_filter, limit=1) > 0
|
||||
|
||||
return has_access
|
||||
except Exception:
|
||||
return False
|
||||
finally:
|
||||
# Close the connection regardless of the outcome
|
||||
client.close()
|
||||
|
||||
|
||||
def get_container(container_name: str) -> None | docker.models.containers.Container:
|
||||
|
||||
client = docker.from_env()
|
||||
|
||||
# Find our overleaf container (name is defined in config.json)
|
||||
running_containers = client.containers.list()
|
||||
locate_containers = []
|
||||
for running_container in running_containers:
|
||||
if running_container.attrs["Name"] == container_name:
|
||||
locate_containers.append(running_container)
|
||||
|
||||
if len(locate_containers) != 1:
|
||||
return None
|
||||
|
||||
return locate_containers[0]
|
||||
|
||||
|
||||
def clean_directory_except_git(directory_path):
|
||||
"""
|
||||
Remove all files and subdirectories in the given directory except for the .git directory
|
||||
|
||||
Args:
|
||||
directory_path: Path to the directory to clean
|
||||
"""
|
||||
# Make sure the directory exists
|
||||
if not os.path.exists(directory_path):
|
||||
return
|
||||
|
||||
# List all entries in the directory
|
||||
for entry in os.listdir(directory_path):
|
||||
entry_path = os.path.join(directory_path, entry)
|
||||
|
||||
# Skip .git directory
|
||||
if entry == ".git" and os.path.isdir(entry_path):
|
||||
continue
|
||||
|
||||
# Remove file or directory
|
||||
if os.path.isfile(entry_path) or os.path.islink(entry_path):
|
||||
os.unlink(entry_path)
|
||||
elif os.path.isdir(entry_path):
|
||||
shutil.rmtree(entry_path)
|
||||
|
||||
|
||||
def main(
|
||||
username: str,
|
||||
project_id: str,
|
||||
container_mongo_name: str = "overleafmongo",
|
||||
container_overleaf_name: str = "overleafserver",
|
||||
overleaf_path: str = "/var/lib/overleaf/",
|
||||
host_path: str = "/downloads/",
|
||||
port: int = 27017,
|
||||
) -> None:
|
||||
|
||||
if len(project_id) == 0:
|
||||
exit(1)
|
||||
|
||||
if username is None:
|
||||
exit(1)
|
||||
|
||||
if len(username) == 0:
|
||||
exit(1)
|
||||
|
||||
# Find user
|
||||
user_id: bson.objectid.ObjectId | None = get_user_id(
|
||||
username=username, container_mongo_name=container_mongo_name, port=port
|
||||
)
|
||||
|
||||
if user_id is None:
|
||||
exit(1)
|
||||
|
||||
if (
|
||||
check_project_access(
|
||||
user_id=user_id,
|
||||
project_id=project_id,
|
||||
container_mongo_name=container_mongo_name,
|
||||
port=port,
|
||||
)
|
||||
is False
|
||||
):
|
||||
exit(1)
|
||||
|
||||
docker_container: None | docker.models.containers.Container = get_container(
|
||||
"/" + container_overleaf_name
|
||||
)
|
||||
|
||||
if docker_container is None:
|
||||
exit(1)
|
||||
|
||||
filename: str = f"{user_id}_{project_id}.zip"
|
||||
fullpath_container: str = os.path.join(overleaf_path, filename)
|
||||
fullpath_host: str = os.path.join(
|
||||
host_path,
|
||||
username,
|
||||
f"{project_id}.git",
|
||||
filename,
|
||||
)
|
||||
onlypath_host: str = os.path.join(
|
||||
host_path,
|
||||
username,
|
||||
f"{project_id}.git",
|
||||
)
|
||||
|
||||
# Create the archive of the project
|
||||
result: docker.models.containers.ExecResult = docker_container.exec_run(
|
||||
(
|
||||
"/bin/bash -c '"
|
||||
"cd /overleaf/services/web && "
|
||||
"node modules/server-ce-scripts/scripts/export-user-projects.mjs "
|
||||
f"--project-id {project_id} "
|
||||
f"--output {fullpath_container} "
|
||||
"'"
|
||||
)
|
||||
)
|
||||
if result.exit_code != 0:
|
||||
exit(1)
|
||||
# At this point the file with the project is waiting for us.
|
||||
|
||||
# It gives us a tar file... I am not a fan but have to live with it.
|
||||
bits, _ = docker_container.get_archive(fullpath_container)
|
||||
|
||||
os.makedirs(f"{onlypath_host}", mode=0o700, exist_ok=True)
|
||||
|
||||
# Delete everything except the .git dir
|
||||
clean_directory_except_git(onlypath_host)
|
||||
|
||||
# Write the file to the host
|
||||
with open(f"{fullpath_host}.tar", "wb") as f:
|
||||
for chunk in bits:
|
||||
f.write(chunk)
|
||||
subprocess.run([f"tar -xf {fullpath_host}.tar "], shell=True, cwd=onlypath_host)
|
||||
os.unlink(f"{fullpath_host}.tar")
|
||||
subprocess.run(
|
||||
[f"/usr/bin/unzip -qq -o {fullpath_host} "], shell=True, cwd=onlypath_host
|
||||
)
|
||||
os.unlink(f"{fullpath_host}")
|
||||
|
||||
subprocess.run(
|
||||
[f"chmod -R 0755 {onlypath_host} "],
|
||||
shell=True,
|
||||
)
|
||||
|
||||
if not os.path.isdir(f"{onlypath_host}/.git"):
|
||||
subprocess.run(["/usr/bin/git init -q "], shell=True, cwd=onlypath_host)
|
||||
|
||||
subprocess.run(["/usr/bin/git add --all "], shell=True, cwd=onlypath_host)
|
||||
|
||||
subprocess.run(
|
||||
["/usr/bin/git commit -q -m 'by Overleaf CEP' "], shell=True, cwd=onlypath_host
|
||||
)
|
||||
|
||||
return
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
argh.dispatch_command(main)
|
|
@ -0,0 +1,147 @@
|
|||
import argh # type: ignore
|
||||
import pymongo
|
||||
import bson
|
||||
import os
|
||||
import subprocess
|
||||
|
||||
|
||||
def get_user_id(
|
||||
username: str, container_name: str = "overleafmongo", port: int = 27017
|
||||
) -> bson.objectid.ObjectId | None:
|
||||
|
||||
# Establish connection to MongoDB
|
||||
client = pymongo.MongoClient(container_name, port)
|
||||
|
||||
try:
|
||||
# Access the 'sharelatex' database
|
||||
db = client.sharelatex
|
||||
|
||||
user_query_filter = {"email": username}
|
||||
|
||||
# Use find_one() to get a single document that matches the query
|
||||
selected_user = db.users.find_one(user_query_filter)
|
||||
|
||||
if selected_user:
|
||||
client.close()
|
||||
return selected_user["_id"]
|
||||
|
||||
finally:
|
||||
# Close the connection regardless of the outcome (success or failure in finding the user)
|
||||
client.close()
|
||||
|
||||
return None
|
||||
|
||||
|
||||
def get_project_list(
|
||||
user_id: bson.objectid.ObjectId,
|
||||
container_name: str = "overleafmongo",
|
||||
port: int = 27017,
|
||||
) -> list[dict] | None:
|
||||
# Establish connection to MongoDB
|
||||
client = pymongo.MongoClient(container_name, port)
|
||||
|
||||
try:
|
||||
# Access the 'sharelatex' database
|
||||
db = client.sharelatex
|
||||
|
||||
project_query_filter = {
|
||||
"$or": [
|
||||
{"owner_ref": user_id}, # User is the owner
|
||||
{"collaberator_refs": user_id}, # User is a collaborator
|
||||
{"readOnly_refs": user_id}, # User has read-only access
|
||||
]
|
||||
}
|
||||
|
||||
# Fetch all projects for a given userId
|
||||
projects_cursor = db.projects.find(
|
||||
project_query_filter,
|
||||
{
|
||||
"name": 1,
|
||||
"lastUpdated": 1,
|
||||
"publicAccessLevel": 1,
|
||||
"archived": 1,
|
||||
"trashed": 1,
|
||||
"_id": 1,
|
||||
},
|
||||
)
|
||||
|
||||
# Filter and map projects based on conditions
|
||||
filtered_projects = [
|
||||
{
|
||||
"_id": str(project["_id"]),
|
||||
"name": project["name"],
|
||||
}
|
||||
for project in projects_cursor
|
||||
if not (project.get("archived") or project.get("trashed"))
|
||||
]
|
||||
|
||||
return filtered_projects
|
||||
|
||||
finally:
|
||||
# Close the connection regardless of the outcome (success or failure in finding the user)
|
||||
client.close()
|
||||
|
||||
return None
|
||||
|
||||
|
||||
def main(
|
||||
username: str,
|
||||
container_name: str = "overleafmongo",
|
||||
port: int = 27017,
|
||||
):
|
||||
|
||||
if username is None:
|
||||
exit(1)
|
||||
|
||||
if len(username) == 0:
|
||||
exit(1)
|
||||
|
||||
user_id: bson.objectid.ObjectId | None = get_user_id(
|
||||
username=username, container_name=container_name, port=port
|
||||
)
|
||||
|
||||
if user_id is None:
|
||||
exit(1)
|
||||
|
||||
projectlist = get_project_list(
|
||||
user_id=user_id, container_name=container_name, port=port
|
||||
)
|
||||
|
||||
os.makedirs(f"/downloads/{username}/projects.git", mode=0o700, exist_ok=True)
|
||||
|
||||
with open(
|
||||
os.path.join("/downloads/", f"{username}", "projects.git", "projects.txt"),
|
||||
"w",
|
||||
) as file:
|
||||
if projectlist is not None:
|
||||
for entry in projectlist:
|
||||
file.write(f'{entry["_id"]} ; "{entry["name"]}"\n')
|
||||
|
||||
if not os.path.isdir("/downloads/{username}/projects.git/.git"):
|
||||
|
||||
subprocess.run(
|
||||
[f"cd /downloads/{username}/projects.git && /usr/bin/git init -q "],
|
||||
shell=True,
|
||||
)
|
||||
|
||||
subprocess.run(
|
||||
[f"cd /downloads/{username}/projects.git && /usr/bin/git add --all "],
|
||||
shell=True,
|
||||
)
|
||||
subprocess.run(
|
||||
[
|
||||
f"cd /downloads/{username}/projects.git && /usr/bin/git commit -q -m 'by HajTex' "
|
||||
],
|
||||
shell=True,
|
||||
)
|
||||
|
||||
subprocess.run(
|
||||
[f"chmod -R 0700 /downloads/{username}/projects.git "],
|
||||
shell=True,
|
||||
)
|
||||
|
||||
exit(0)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
argh.dispatch_command(main)
|
81
install_unibremen/docker/compose_cep/gitbridge/files/init.sh
Normal file
81
install_unibremen/docker/compose_cep/gitbridge/files/init.sh
Normal file
|
@ -0,0 +1,81 @@
|
|||
#!/bin/bash
|
||||
|
||||
# If mounted /etc is empty, copy from backup
|
||||
if [ ! -d /etc/skel ]; then
|
||||
cp -a /etc_original/* /etc/
|
||||
mkdir -p /etc/skel/
|
||||
chmod 0700 /etc/skel/.ssh
|
||||
rm -f /etc/skel/.profile
|
||||
rm -f /etc/skel/.bashrc
|
||||
rm -f /etc/skel/.bash_logout
|
||||
rm -rf /etc_original
|
||||
fi
|
||||
|
||||
|
||||
# Create minimal system groups and users
|
||||
if ! getent group nogroup >/dev/null 2>&1; then
|
||||
groupadd -r nogroup
|
||||
fi
|
||||
|
||||
# Create a minimal system user for SSH and SSSD
|
||||
if ! id -u sshd >/dev/null 2>&1; then
|
||||
useradd -r -g nogroup -s /bin/false sshd
|
||||
fi
|
||||
|
||||
if [ ! -d /run/sshd ]; then
|
||||
mkdir -p /run/sshd
|
||||
chmod -R 0700 /run/sshd
|
||||
fi
|
||||
|
||||
chmod 644 /etc/passwd
|
||||
chmod 644 /etc/group
|
||||
chmod 600 /etc/shadow
|
||||
|
||||
# Ensure overleafcep group exists
|
||||
if ! getent group overleafcep >/dev/null 2>&1; then
|
||||
groupadd -r overleafcep
|
||||
fi
|
||||
|
||||
echo "root ALL=(ALL) ALL" > /etc/sudoers
|
||||
|
||||
chown root:root /downloads
|
||||
chmod 755 /downloads
|
||||
|
||||
/usr/sbin/syslogd
|
||||
|
||||
mkdir -p /master_jail/lib
|
||||
mkdir -p /master_jail/lib64
|
||||
mkdir -p /master_jail/lib/x86_64-linux-gnu
|
||||
mkdir -p /master_jail/lib64
|
||||
mkdir -p /master_jail/usr/lib/git-core
|
||||
mkdir -p /master_jail/etc
|
||||
|
||||
cp /usr/lib/git-core/git-submodule /master_jail/usr/lib/git-core/
|
||||
cp /usr/lib/git-core/git /master_jail/usr/lib/git-core/
|
||||
cp /usr/lib/git-core/git-upload-pack /master_jail/usr/lib/git-core/
|
||||
chmod +x /master_jail/usr/lib/git-core/*
|
||||
|
||||
# Lets extract which libs we need
|
||||
cd /master_jail/usr/lib/git-core
|
||||
ldd git | grep "=> " | awk {'print $3'} > /master_jail/ldd_list
|
||||
ldd git-submodule | grep "=> " | awk {'print $3'} >> /master_jail/ldd_list
|
||||
|
||||
cd /master_jail
|
||||
cat ldd_list | sort -u > ldd_list_nodups
|
||||
\rm ldd_list
|
||||
mv ldd_list_nodups ldd_list
|
||||
|
||||
for file in $(cat ldd_list)
|
||||
do
|
||||
\cp $file /master_jail/lib/x86_64-linux-gnu
|
||||
done
|
||||
\rm ldd_list
|
||||
|
||||
\cp /lib64/ld-linux-x86-64.so.* /master_jail/lib64/
|
||||
|
||||
# The users need to access docker before they are put into jail.
|
||||
chmod 666 /var/run/docker.sock
|
||||
|
||||
/usr/sbin/sshd -D &
|
||||
|
||||
sleep infinity
|
|
@ -0,0 +1,62 @@
|
|||
#!/bin/bash
|
||||
if [ -z "$1" ]; then
|
||||
echo "Error: Argument 1 is missing." >&2 # Send error to stderr
|
||||
exit 1 # Exit with a non-zero status code to indicate failure
|
||||
fi
|
||||
|
||||
USERNAME=$1
|
||||
|
||||
# Create user
|
||||
/usr/sbin/useradd ${USERNAME} -g overleafcep -k /etc/skel -m -d /downloads/${USERNAME}
|
||||
chown -R ${USERNAME}:overleafcep /downloads/${USERNAME}
|
||||
chmod -R 0755 /downloads/${USERNAME}
|
||||
|
||||
cp -rfa /master_jail/* /downloads/${USERNAME}
|
||||
chown -R ${USERNAME}:overleafcep /downloads/${USERNAME}
|
||||
chmod 0755 /downloads/${USERNAME}
|
||||
cat /etc/passwd | grep ${USERNAME} > /downloads/${USERNAME}/etc/passwd
|
||||
|
||||
# Make devs for the jail
|
||||
mkdir -p /downloads/${USERNAME}/dev
|
||||
mknod -m 666 /downloads/${USERNAME}/dev/null c 1 3
|
||||
mknod -m 666 /downloads/${USERNAME}/dev/zero c 1 5
|
||||
mknod -m 666 /downloads/${USERNAME}/dev/random c 1 8
|
||||
mknod -m 666 /downloads/${USERNAME}/dev/urandom c 1 9
|
||||
mknod -m 666 /downloads/${USERNAME}/dev/tty c 5 0
|
||||
|
||||
# Make new ssh key
|
||||
mkdir -p /downloads/${USERNAME}/.ssh
|
||||
chmod 700 /downloads/${USERNAME}/.ssh
|
||||
|
||||
cd /
|
||||
python3 get_key_overleaf.py ${USERNAME}
|
||||
# Check exit code of get_key_overleaf.py
|
||||
if [ $? -eq 1 ]; then
|
||||
# Only execute these commands if get_key_overleaf.py returned 1
|
||||
ssh-keygen -t ed25519 -f /downloads/${USERNAME}/.ssh/overleafcep -N ""
|
||||
python3 set_key_overleaf.py ${USERNAME}
|
||||
fi
|
||||
|
||||
cat /downloads/${USERNAME}/.ssh/overleafcep.pub > /downloads/${USERNAME}/.ssh/authorized_keys
|
||||
chmod 600 /downloads/${USERNAME}/.ssh/overleafcep
|
||||
chmod 700 /downloads/${USERNAME}/.ssh
|
||||
chmod 600 /downloads/${USERNAME}/.ssh/authorized_keys
|
||||
chown -R ${USERNAME}:overleafcep /downloads/${USERNAME}/.ssh
|
||||
|
||||
chmod 777 /downloads/${USERNAME}
|
||||
sudo -u ${USERNAME} /usr/bin/git config --global user.email ${USERNAME}
|
||||
sudo -u ${USERNAME} /usr/bin/git config --global user.name ${USERNAME}
|
||||
|
||||
mkdir -p /downloads/${USERNAME}/projects.git
|
||||
echo "" > /downloads/${USERNAME}/projects.git/projects.txt
|
||||
chown -R ${USERNAME}:overleafcep /downloads/${USERNAME}/projects.git
|
||||
|
||||
cd /downloads/${USERNAME}/projects.git && sudo -u ${USERNAME} /usr/bin/git init -q
|
||||
cd /downloads/${USERNAME}/projects.git && sudo -u ${USERNAME} /usr/bin/git add --all
|
||||
cd /downloads/${USERNAME}/projects.git && sudo -u ${USERNAME} /usr/bin/git commit -m 'by overleafcep'
|
||||
chown -R ${USERNAME}:overleafcep /downloads/${USERNAME}/projects.git
|
||||
chmod -R 0755 /downloads/${USERNAME}/projects.git
|
||||
|
||||
|
||||
chmod 755 /downloads/${USERNAME}
|
||||
|
74
install_unibremen/docker/compose_cep/gitbridge/files/pre-rush.sh
Executable file
74
install_unibremen/docker/compose_cep/gitbridge/files/pre-rush.sh
Executable file
|
@ -0,0 +1,74 @@
|
|||
#!/bin/bash
|
||||
# List of repos to be ignored
|
||||
IGNORE_REPOS=(
|
||||
"projects"
|
||||
)
|
||||
|
||||
# Function to check if a string contains any repos to be ignored
|
||||
check_repos_to_be_ignored() {
|
||||
local input="$1"
|
||||
for word in "${IGNORE_REPOS[@]}"; do
|
||||
if [[ "$input" == *"$word"* ]]; then
|
||||
return 1 # found repo to be ignored
|
||||
fi
|
||||
done
|
||||
return 0 # No repos to be ignored found
|
||||
}
|
||||
|
||||
# Function to validate the command format and extract the repository ID
|
||||
validate_and_extract() {
|
||||
local command="$1"
|
||||
|
||||
# Check if command starts with "git-upload-pack '/" and ends with ".git'"
|
||||
if [[ ! "$command" =~ ^git-upload-pack\ \'/.+\.git\'$ ]]
|
||||
then
|
||||
echo "Invalid command format" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Extract the string between "git-upload-pack '/" and ".git'"
|
||||
# Using parameter expansion to remove prefix and suffix
|
||||
local temp="${command#git-upload-pack \'/}" # Remove prefix
|
||||
local repo_id="${temp%%.git\'}" # Remove suffix
|
||||
|
||||
# Validate that we actually extracted something
|
||||
if [ -z "$repo_id" ]; then
|
||||
echo "Failed to extract repository ID" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Return the extracted repository ID
|
||||
echo "$repo_id"
|
||||
}
|
||||
|
||||
# Main execution
|
||||
if [ -z "$SSH_ORIGINAL_COMMAND" ]; then
|
||||
echo "SSH_ORIGINAL_COMMAND is empty" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Validate and extract the repository ID
|
||||
REPO_ID=$(validate_and_extract "$SSH_ORIGINAL_COMMAND")
|
||||
|
||||
|
||||
if [ -n "$REPO_ID" ]
|
||||
then
|
||||
|
||||
if check_repos_to_be_ignored "$REPO_ID"
|
||||
then
|
||||
# Run your post-login scripts
|
||||
python3 /get_project.py ${USER} ${REPO_ID} > /dev/null 2>&1
|
||||
fi
|
||||
|
||||
# Check if REPO_ID is equal to "projects"
|
||||
if [ "$REPO_ID" == "projects" ]
|
||||
then
|
||||
# Run your post-login scripts if condition is met
|
||||
python3 /get_project_list.py ${USER} > /dev/null 2>&1
|
||||
|
||||
fi
|
||||
fi
|
||||
|
||||
# Finally, execute rush with chroot inside
|
||||
/usr/sbin/rush
|
||||
|
10
install_unibremen/docker/compose_cep/gitbridge/files/rush.rc
Normal file
10
install_unibremen/docker/compose_cep/gitbridge/files/rush.rc
Normal file
|
@ -0,0 +1,10 @@
|
|||
rush 2.0
|
||||
|
||||
rule git-upload-pack
|
||||
match $command ~ "^/bin/sh"
|
||||
match $SSH_ORIGINAL_COMMAND ~ "git-upload-pack '(.+)'"
|
||||
set[0] = "/usr/lib/git-core/git-upload-pack"
|
||||
set[1] = %1
|
||||
interactive true
|
||||
umask 022
|
||||
chroot "~"
|
|
@ -0,0 +1,72 @@
|
|||
import pymongo
|
||||
import argh
|
||||
import os
|
||||
|
||||
def main(username: str, container_name: str = "overleafmongo", port: int = 27017,
|
||||
path: str = "/downloads/", ) -> None:
|
||||
"""
|
||||
Store SSH public and private keys for a user in MongoDB.
|
||||
|
||||
Args:
|
||||
username: Username for SSH key files
|
||||
container_name: MongoDB container name
|
||||
port: MongoDB port
|
||||
path: Base path containing user SSH directories
|
||||
"""
|
||||
print(f"User email: {username}")
|
||||
|
||||
# Connect to MongoDB
|
||||
client = pymongo.MongoClient(container_name, port)
|
||||
db = client.sharelatex
|
||||
users = db.users
|
||||
|
||||
# Check if user exists
|
||||
search_result = users.find_one({"email": username})
|
||||
if search_result is None:
|
||||
print("User not found")
|
||||
client.close()
|
||||
exit(1)
|
||||
|
||||
# Get SSH keys from files
|
||||
if path and username:
|
||||
try:
|
||||
public_keys_name = os.path.join(path, username, ".ssh", "overleafcep.pub")
|
||||
private_keys_name = os.path.join(path, username, ".ssh", "overleafcep")
|
||||
|
||||
# Verify directories and files exist
|
||||
assert os.path.isdir(os.path.join(path, username, ".ssh"))
|
||||
assert os.path.isfile(public_keys_name)
|
||||
assert os.path.isfile(private_keys_name)
|
||||
|
||||
# Read key files
|
||||
with open(public_keys_name, 'r') as file:
|
||||
public_key = file.read()
|
||||
with open(private_keys_name, 'r') as file:
|
||||
private_key = file.read()
|
||||
|
||||
# Update user with SSH keys
|
||||
users.update_one(
|
||||
{"email": username},
|
||||
{"$set": {"sshPublicKey": public_key, "sshPrivateKey": private_key}}
|
||||
)
|
||||
print("SSH keys stored successfully")
|
||||
|
||||
except AssertionError:
|
||||
print("Error: SSH directory or key files not found")
|
||||
client.close()
|
||||
exit(1)
|
||||
except Exception as e:
|
||||
print(f"Error reading SSH keys: {e}")
|
||||
client.close()
|
||||
exit(1)
|
||||
else:
|
||||
print("Path and username are required to store SSH keys")
|
||||
client.close()
|
||||
exit(1)
|
||||
|
||||
client.close()
|
||||
exit(0)
|
||||
|
||||
if __name__ == "__main__":
|
||||
argh.dispatch_command(main)
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
PasswordAuthentication no
|
||||
PermitEmptyPasswords no
|
||||
KbdInteractiveAuthentication no
|
||||
UsePAM yes
|
||||
X11Forwarding no
|
||||
PrintMotd no
|
||||
AcceptEnv LANG LC_*
|
||||
PubkeyAuthentication yes
|
||||
AuthorizedKeysFile .ssh/authorized_keys
|
||||
|
||||
Match Group overleafcep
|
||||
ForceCommand /pre-rush.sh
|
||||
AllowTcpForwarding no
|
||||
X11Forwarding no
|
||||
PasswordAuthentication no
|
||||
PubkeyAuthentication yes
|
||||
AuthorizedKeysFile .ssh/authorized_keys
|
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
"keycloak_url": "https://sso.fb1.uni-bremen.de/sso",
|
||||
"keycloak_login": "https://sso.fb1.uni-bremen.de/sso",
|
||||
"admin_username": "automation@non.no",
|
||||
"admin_password": "REDACTED",
|
||||
"client_id": "admin-cli",
|
||||
"client_secret": "REDACTED"
|
||||
}
|
||||
|
|
@ -0,0 +1,137 @@
|
|||
import glob
|
||||
import os
|
||||
import requests # type: ignore
|
||||
import json
|
||||
from requests.auth import HTTPBasicAuth # type: ignore
|
||||
import argh # type: ignore
|
||||
|
||||
def get_ssh_keys(username:str) -> tuple[bool, str, list[str]|None, list[str]|None]:
|
||||
|
||||
with open("config.json", "r") as file:
|
||||
config = json.load(file)
|
||||
|
||||
token_url = f"{config['keycloak_url']}/realms/master/protocol/openid-connect/token"
|
||||
token_data = {
|
||||
"grant_type": "password",
|
||||
"username": config["admin_username"],
|
||||
"password": config["admin_password"],
|
||||
}
|
||||
users_url = f"{config['keycloak_url']}/admin/realms/master/users"
|
||||
|
||||
# Get token
|
||||
try:
|
||||
response = requests.post(
|
||||
token_url,
|
||||
data=token_data,
|
||||
auth=HTTPBasicAuth(config["client_id"], config["client_secret"]),
|
||||
)
|
||||
response.raise_for_status()
|
||||
|
||||
except requests.exceptions.HTTPError:
|
||||
return False, "SSO connection broken. No token.", None, None
|
||||
|
||||
access_token = response.json()["access_token"]
|
||||
headers = {
|
||||
"Authorization": f"Bearer {access_token}",
|
||||
"Content-Type": "application/json",
|
||||
}
|
||||
|
||||
# Check if user exists
|
||||
params = {"username": username, "exact": "true"}
|
||||
|
||||
try:
|
||||
response = requests.get(users_url, headers=headers, params=params)
|
||||
response.raise_for_status()
|
||||
|
||||
# Response is a list of users matching the criteria
|
||||
users = response.json()
|
||||
|
||||
if len(users) == 0:
|
||||
return False, f"User {username} does not exists.", None, None
|
||||
|
||||
if len(users) > 1:
|
||||
return False, f"User {username} can not be identified.", None, None
|
||||
|
||||
except requests.exceptions.HTTPError:
|
||||
return False, "Communication with SSO server failed.", None, None
|
||||
|
||||
user_id = users[0]["id"]
|
||||
|
||||
# Get user details
|
||||
user_url = f"{users_url}/{user_id}"
|
||||
try:
|
||||
response = requests.get(user_url, headers=headers)
|
||||
response.raise_for_status()
|
||||
user_data = response.json()
|
||||
except requests.exceptions.HTTPError as e:
|
||||
return False, f"Failed to get user details: {str(e)}", None, None
|
||||
|
||||
if "attributes" not in user_data:
|
||||
user_data["attributes"] = dict()
|
||||
|
||||
if "Overleaf_SSH_Public_Key" not in user_data["attributes"]:
|
||||
return True, "No keys in SSO", None, None
|
||||
|
||||
if "Overleaf_SSH_Private_Key" not in user_data["attributes"]:
|
||||
return True, "No keys in SSO", None, None
|
||||
|
||||
if user_data["attributes"]["Overleaf_SSH_Public_Key"] is None or user_data["attributes"]["Overleaf_SSH_Private_Key"] is None:
|
||||
return True, "No keys in SSO", None, None
|
||||
|
||||
return True, "OK", user_data["attributes"]["Overleaf_SSH_Public_Key"], user_data["attributes"]["Overleaf_SSH_Private_Key"]
|
||||
|
||||
|
||||
|
||||
def main(username:str, path:str = "/downloads"):
|
||||
|
||||
if len(username) == 0:
|
||||
exit(1)
|
||||
|
||||
public_key_sso = None
|
||||
private_key_sso = None
|
||||
|
||||
status, info_string, public_key_sso, private_key_sso = get_ssh_keys(username=username)
|
||||
|
||||
if status is False:
|
||||
print(username)
|
||||
print(info_string)
|
||||
exit(1)
|
||||
|
||||
if public_key_sso is None or private_key_sso is None:
|
||||
exit(1)
|
||||
|
||||
if status:
|
||||
if len(public_key_sso) != 1:
|
||||
exit(1)
|
||||
if len(private_key_sso) != 1:
|
||||
exit(1)
|
||||
|
||||
public_key_sso = public_key_sso[0].strip()
|
||||
private_key_sso = private_key_sso[0].strip()
|
||||
|
||||
assert os.path.isdir(os.path.join(path, username, ".ssh"))
|
||||
assert os.path.isfile(os.path.join(path, username, ".ssh", "overleafcep.pub")) is False
|
||||
assert os.path.isfile(os.path.join(path, username, ".ssh", "overleafcep")) is False
|
||||
|
||||
public_keys_name:str = os.path.join(path, username, ".ssh", "overleafcep.pub")
|
||||
private_keys_name:str = os.path.join(path, username, ".ssh", "overleafcep")
|
||||
with open(public_keys_name, 'w') as file:
|
||||
file.write(public_key_sso)
|
||||
if not public_key_sso.endswith('\n'):
|
||||
file.write('\n')
|
||||
|
||||
with open(private_keys_name, 'w') as file:
|
||||
file.write(private_key_sso)
|
||||
if not private_key_sso.endswith('\n'):
|
||||
file.write('\n')
|
||||
exit(0)
|
||||
|
||||
else:
|
||||
print(username)
|
||||
print(info_string)
|
||||
exit(1)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
argh.dispatch_command(main)
|
||||
|
|
@ -0,0 +1,64 @@
|
|||
#!/bin/bash
|
||||
if [ -z "$1" ]; then
|
||||
echo "Error: Argument 1 is missing." >&2 # Send error to stderr
|
||||
exit 1 # Exit with a non-zero status code to indicate failure
|
||||
fi
|
||||
|
||||
USERNAME=$1
|
||||
|
||||
# Create user
|
||||
/usr/sbin/useradd ${USERNAME} -g overleafcep -k /etc/skel -m -d /downloads/${USERNAME}
|
||||
chown -R ${USERNAME}:overleafcep /downloads/${USERNAME}
|
||||
chmod -R 0755 /downloads/${USERNAME}
|
||||
|
||||
cp -rfa /master_jail/* /downloads/${USERNAME}
|
||||
chown -R ${USERNAME}:overleafcep /downloads/${USERNAME}
|
||||
chmod 0755 /downloads/${USERNAME}
|
||||
cat /etc/passwd | grep ${USERNAME} > /downloads/${USERNAME}/etc/passwd
|
||||
|
||||
# Make devs for the jail
|
||||
mkdir -p /downloads/${USERNAME}/dev
|
||||
mknod -m 666 /downloads/${USERNAME}/dev/null c 1 3
|
||||
mknod -m 666 /downloads/${USERNAME}/dev/zero c 1 5
|
||||
mknod -m 666 /downloads/${USERNAME}/dev/random c 1 8
|
||||
mknod -m 666 /downloads/${USERNAME}/dev/urandom c 1 9
|
||||
mknod -m 666 /downloads/${USERNAME}/dev/tty c 5 0
|
||||
|
||||
# Make new ssh key
|
||||
mkdir -p /downloads/${USERNAME}/.ssh
|
||||
chmod 700 /downloads/${USERNAME}/.ssh
|
||||
|
||||
cd /
|
||||
python3 get_key_keycloak.py ${USERNAME}
|
||||
|
||||
# Check exit code of get_key_keycloak.py
|
||||
if [ $? -eq 1 ]; then
|
||||
# Only execute these commands if get_key_overleaf.py returned 1
|
||||
ssh-keygen -t ed25519 -f /downloads/${USERNAME}/.ssh/overleafcep -N ""
|
||||
python3 set_key_keycloak.py ${USERNAME}
|
||||
fi
|
||||
python3 set_key_overleaf.py ${USERNAME}
|
||||
|
||||
cat /downloads/${USERNAME}/.ssh/overleafcep.pub > /downloads/${USERNAME}/.ssh/authorized_keys
|
||||
chmod 600 /downloads/${USERNAME}/.ssh/overleafcep
|
||||
chmod 700 /downloads/${USERNAME}/.ssh
|
||||
chmod 600 /downloads/${USERNAME}/.ssh/authorized_keys
|
||||
chown -R ${USERNAME}:overleafcep /downloads/${USERNAME}/.ssh
|
||||
|
||||
chmod 777 /downloads/${USERNAME}
|
||||
sudo -u ${USERNAME} /usr/bin/git config --global user.email ${USERNAME}
|
||||
sudo -u ${USERNAME} /usr/bin/git config --global user.name ${USERNAME}
|
||||
|
||||
mkdir -p /downloads/${USERNAME}/projects.git
|
||||
echo "" > /downloads/${USERNAME}/projects.git/projects.txt
|
||||
chown -R ${USERNAME}:overleafcep /downloads/${USERNAME}/projects.git
|
||||
|
||||
cd /downloads/${USERNAME}/projects.git && sudo -u ${USERNAME} /usr/bin/git init -q
|
||||
cd /downloads/${USERNAME}/projects.git && sudo -u ${USERNAME} /usr/bin/git add --all
|
||||
cd /downloads/${USERNAME}/projects.git && sudo -u ${USERNAME} /usr/bin/git commit -m 'by overleafcep'
|
||||
chown -R ${USERNAME}:overleafcep /downloads/${USERNAME}/projects.git
|
||||
chmod -R 0755 /downloads/${USERNAME}/projects.git
|
||||
|
||||
|
||||
chmod 755 /downloads/${USERNAME}
|
||||
|
|
@ -0,0 +1,120 @@
|
|||
import glob
|
||||
import os
|
||||
import requests # type: ignore
|
||||
import json
|
||||
from requests.auth import HTTPBasicAuth # type: ignore
|
||||
import argh # type: ignore
|
||||
|
||||
def set_ssh_keys(username:str, public_key:str, private_key:str, overwrite:bool=False) -> tuple[bool, str]:
|
||||
|
||||
if public_key is None and private_key is None:
|
||||
return False, "No SSH keys provided to set."
|
||||
|
||||
with open("config.json", "r") as file:
|
||||
config = json.load(file)
|
||||
|
||||
token_url = f"{config['keycloak_url']}/realms/master/protocol/openid-connect/token"
|
||||
token_data = {
|
||||
"grant_type": "password",
|
||||
"username": config["admin_username"],
|
||||
"password": config["admin_password"],
|
||||
}
|
||||
users_url = f"{config['keycloak_url']}/admin/realms/master/users"
|
||||
|
||||
# Get token
|
||||
try:
|
||||
response = requests.post(
|
||||
token_url,
|
||||
data=token_data,
|
||||
auth=HTTPBasicAuth(config["client_id"], config["client_secret"]),
|
||||
)
|
||||
response.raise_for_status()
|
||||
|
||||
except requests.exceptions.HTTPError:
|
||||
return False, "SSO connection broken. No token."
|
||||
|
||||
access_token = response.json()["access_token"]
|
||||
headers = {
|
||||
"Authorization": f"Bearer {access_token}",
|
||||
"Content-Type": "application/json",
|
||||
}
|
||||
|
||||
# Check if user exists
|
||||
params = {"username": username, "exact": "true"}
|
||||
|
||||
try:
|
||||
response = requests.get(users_url, headers=headers, params=params)
|
||||
response.raise_for_status()
|
||||
|
||||
# Response is a list of users matching the criteria
|
||||
users = response.json()
|
||||
|
||||
if len(users) == 0:
|
||||
return False, f"User {username} does not exists."
|
||||
|
||||
if len(users) > 1:
|
||||
return False, f"User {username} can not be identified."
|
||||
|
||||
except requests.exceptions.HTTPError:
|
||||
return False, "Communication with SSO server failed."
|
||||
|
||||
user_id = users[0]["id"]
|
||||
|
||||
# Get user details
|
||||
user_url = f"{users_url}/{user_id}"
|
||||
try:
|
||||
response = requests.get(user_url, headers=headers)
|
||||
response.raise_for_status()
|
||||
user_data = response.json()
|
||||
except requests.exceptions.HTTPError as e:
|
||||
return False, f"Failed to get user details: {str(e)}"
|
||||
|
||||
if "attributes" not in user_data:
|
||||
user_data["attributes"] = dict()
|
||||
|
||||
if "Overleaf_SSH_Public_Key" in user_data["attributes"] and user_data["attributes"]["Overleaf_SSH_Public_Key"] is not None:
|
||||
if len(user_data["attributes"]["Overleaf_SSH_Public_Key"]) > 0 and overwrite is False:
|
||||
print("== SKIPPED (OVERWRITE DISABLED) ==")
|
||||
return True, ""
|
||||
|
||||
user_data["attributes"]["Overleaf_SSH_Public_Key"] = [public_key]
|
||||
user_data["attributes"]["Overleaf_SSH_Private_Key"] = [private_key]
|
||||
|
||||
# Modify user attributes
|
||||
try:
|
||||
response = requests.put(user_url, headers=headers, json=user_data)
|
||||
response.raise_for_status()
|
||||
except requests.exceptions.HTTPError as e:
|
||||
return False, f"Failed to update user attributes: {str(e)}"
|
||||
|
||||
return True, "OK"
|
||||
|
||||
def main(username:str, path:str = "/downloads"):
|
||||
|
||||
if len(username) == 0:
|
||||
exit(1)
|
||||
|
||||
print(username)
|
||||
|
||||
public_keys_name:str = os.path.join(path, username, ".ssh", "overleafcep.pub")
|
||||
private_keys_name:str = os.path.join(path, username, ".ssh", "overleafcep")
|
||||
|
||||
assert os.path.isdir(os.path.join(path, username, ".ssh"))
|
||||
assert os.path.isfile(public_keys_name)
|
||||
assert os.path.isfile(private_keys_name)
|
||||
|
||||
with open(public_keys_name,'r') as file:
|
||||
public_key = file.read()
|
||||
|
||||
with open(private_keys_name,'r') as file:
|
||||
private_key = file.read()
|
||||
|
||||
status, info_string = set_ssh_keys(username=username, public_key=public_key, private_key=private_key)
|
||||
|
||||
if status:
|
||||
exit(0)
|
||||
else:
|
||||
exit(1)
|
||||
|
||||
if __name__ == "__main__":
|
||||
argh.dispatch_command(main)
|
|
@ -0,0 +1,2 @@
|
|||
chmod +x ./files/pre-rush.sh
|
||||
docker build --network host -t gitbridge_image .
|
1
install_unibremen/docker/compose_cep/inspect_texlive_2023.sh
Executable file
1
install_unibremen/docker/compose_cep/inspect_texlive_2023.sh
Executable file
|
@ -0,0 +1 @@
|
|||
docker run -it texlive/texlive:TL2023-historic /bin/bash
|
1
install_unibremen/docker/compose_cep/inspect_texlive_2024.sh
Executable file
1
install_unibremen/docker/compose_cep/inspect_texlive_2024.sh
Executable file
|
@ -0,0 +1 @@
|
|||
docker run -it texlive/texlive:TL2024-historic /bin/bash
|
1
install_unibremen/docker/compose_cep/inspect_texlive_latest.sh
Executable file
1
install_unibremen/docker/compose_cep/inspect_texlive_latest.sh
Executable file
|
@ -0,0 +1 @@
|
|||
docker run -it texlive/texlive:latest-full /bin/bash
|
2
install_unibremen/docker/compose_cep/logs_all.sh
Executable file
2
install_unibremen/docker/compose_cep/logs_all.sh
Executable file
|
@ -0,0 +1,2 @@
|
|||
docker compose logs -f
|
||||
|
2
install_unibremen/docker/compose_cep/logs_checkuser.sh
Executable file
2
install_unibremen/docker/compose_cep/logs_checkuser.sh
Executable file
|
@ -0,0 +1,2 @@
|
|||
docker compose logs -f checkuser
|
||||
|
2
install_unibremen/docker/compose_cep/logs_gitbridge.sh
Executable file
2
install_unibremen/docker/compose_cep/logs_gitbridge.sh
Executable file
|
@ -0,0 +1,2 @@
|
|||
docker compose logs -f gitbridge
|
||||
|
2
install_unibremen/docker/compose_cep/logs_nginx.sh
Executable file
2
install_unibremen/docker/compose_cep/logs_nginx.sh
Executable file
|
@ -0,0 +1,2 @@
|
|||
docker compose logs -f nginx
|
||||
|
2
install_unibremen/docker/compose_cep/logs_overleafmongo.sh
Executable file
2
install_unibremen/docker/compose_cep/logs_overleafmongo.sh
Executable file
|
@ -0,0 +1,2 @@
|
|||
docker compose logs -f overleafmongo
|
||||
|
2
install_unibremen/docker/compose_cep/logs_overleafredis.sh
Executable file
2
install_unibremen/docker/compose_cep/logs_overleafredis.sh
Executable file
|
@ -0,0 +1,2 @@
|
|||
docker compose logs -f overleafredis
|
||||
|
2
install_unibremen/docker/compose_cep/logs_overleafserver.sh
Executable file
2
install_unibremen/docker/compose_cep/logs_overleafserver.sh
Executable file
|
@ -0,0 +1,2 @@
|
|||
docker compose logs -f overleafserver
|
||||
|
31
install_unibremen/docker/compose_cep/nginx/compose.yaml
Normal file
31
install_unibremen/docker/compose_cep/nginx/compose.yaml
Normal file
|
@ -0,0 +1,31 @@
|
|||
services:
|
||||
nginx:
|
||||
image: nginx:stable-alpine
|
||||
container_name: nginx
|
||||
hostname: nginx
|
||||
restart: always
|
||||
volumes:
|
||||
- "./key.pem:/certs/nginx_key.pem:ro"
|
||||
- "./ca.pem:/certs/nginx_certificate.pem:ro"
|
||||
- "./nginx.conf:/etc/nginx/nginx.conf:ro"
|
||||
ports:
|
||||
- "0.0.0.0:443:443"
|
||||
- "0.0.0.0:80:80"
|
||||
- ":::443:443"
|
||||
- ":::80:80"
|
||||
environment:
|
||||
NGINX_WORKER_PROCESSES: "4"
|
||||
NGINX_WORKER_CONNECTIONS: "768"
|
||||
networks:
|
||||
- overleaf-network
|
||||
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "curl -fsI --connect-timeout 10 http://localhost || exit 1"]
|
||||
interval: 30s
|
||||
timeout: 10s
|
||||
retries: 5
|
||||
start_period: 60s
|
||||
|
||||
networks:
|
||||
overleaf-network:
|
||||
external: true
|
39
install_unibremen/docker/compose_cep/nginx/nginx.conf
Normal file
39
install_unibremen/docker/compose_cep/nginx/nginx.conf
Normal file
|
@ -0,0 +1,39 @@
|
|||
events {}
|
||||
http {
|
||||
server {
|
||||
listen 80 default_server;
|
||||
listen [::]:80 default_server;
|
||||
server_name _;
|
||||
return 301 https://$host$request_uri;
|
||||
}
|
||||
|
||||
server {
|
||||
listen 443 ssl;
|
||||
listen [::]:443 ssl;
|
||||
ssl_certificate /certs/nginx_certificate.pem;
|
||||
ssl_certificate_key /certs/nginx_key.pem;
|
||||
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
|
||||
ssl_prefer_server_ciphers on;
|
||||
ssl_ciphers EECDH+CHACHA20:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5;
|
||||
add_header Strict-Transport-Security "max-age=31536000; includeSubdomains;";
|
||||
server_tokens off;
|
||||
client_max_body_size 50M;
|
||||
|
||||
location / {
|
||||
proxy_pass http://overleafserver:80;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "upgrade";
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_read_timeout 3m;
|
||||
proxy_send_timeout 3m;
|
||||
}
|
||||
|
||||
location /register {
|
||||
return 301 https://sso.fb1.uni-bremen.de;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
services:
|
||||
overleafmongo:
|
||||
image: "mongo:6.0"
|
||||
container_name: overleafmongo
|
||||
hostname: overleafmongo
|
||||
restart: always
|
||||
healthcheck:
|
||||
test: "mongosh --quiet --eval 'rs.hello().setName ? rs.hello().setName : rs.initiate({_id: \"overleaf\",members:[{_id: 0, host:\"overleafmongo:27017\"}]})'"
|
||||
interval: 10s
|
||||
timeout: 10s
|
||||
retries: 5
|
||||
command: "--replSet overleaf"
|
||||
|
||||
volumes:
|
||||
- ./data_db:/data/db
|
||||
- ./data_configdb:/data/configdb
|
||||
- ./backup:/backup
|
||||
- /var/run/docker.sock:/var/run/docker.sock
|
||||
networks:
|
||||
- overleaf-network
|
||||
expose:
|
||||
- 27017
|
||||
extra_hosts:
|
||||
- "mongo:127.0.0.1"
|
||||
- "overleafmongo:127.0.0.1"
|
||||
|
||||
networks:
|
||||
overleaf-network:
|
||||
external: true
|
|
@ -0,0 +1,27 @@
|
|||
# docker network create overleaf-network
|
||||
services:
|
||||
overleafredis:
|
||||
image: "redis:6.2-alpine"
|
||||
container_name: overleafredis
|
||||
hostname: overleafredis
|
||||
restart: always
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "redis-cli ping | grep PONG"]
|
||||
start_period: 20s
|
||||
interval: 30s
|
||||
retries: 5
|
||||
timeout: 3s
|
||||
command: --save 60 1 --loglevel warning
|
||||
volumes:
|
||||
- ./data:/data
|
||||
- /var/run/docker.sock:/var/run/docker.sock
|
||||
expose:
|
||||
- 6379
|
||||
networks:
|
||||
- overleaf-network
|
||||
environment:
|
||||
REDIS_AOF_PERSISTENCE: "true"
|
||||
|
||||
networks:
|
||||
overleaf-network:
|
||||
external: true
|
114
install_unibremen/docker/compose_cep/overleafserver/compose.yaml
Normal file
114
install_unibremen/docker/compose_cep/overleafserver/compose.yaml
Normal file
|
@ -0,0 +1,114 @@
|
|||
services:
|
||||
overleafserver:
|
||||
image: sharelatex/sharelatex:5.4.0.2
|
||||
container_name: overleafserver
|
||||
hostname: overleafserver
|
||||
restart: always
|
||||
volumes:
|
||||
- ./data:/var/lib/overleaf
|
||||
- /var/run/docker.sock:/var/run/docker.sock
|
||||
ports:
|
||||
- 80
|
||||
environment:
|
||||
GIT_BRIDGE_ENABLED: false
|
||||
GIT_BRIDGE_HOST: git-bridge
|
||||
GIT_BRIDGE_PORT: 8000
|
||||
REDIS_HOST: overleafredis
|
||||
REDIS_PORT: 6379
|
||||
OVERLEAF_REDIS_HOST: overleafredis
|
||||
V1_HISTORY_URL: http://127.0.0.1:3100/api
|
||||
OVERLEAF_MONGO_URL: mongodb://overleafmongo/sharelatex
|
||||
OVERLEAF_APP_NAME: ${OVERLEAF_APP_NAME}
|
||||
ENABLED_LINKED_FILE_TYPES: project_file,project_output_file
|
||||
ENABLE_CONVERSIONS: true
|
||||
EMAIL_CONFIRMATION_DISABLED: true
|
||||
OVERLEAF_BEHIND_PROXY: true
|
||||
OVERLEAF_SECURE_COOKIE: true
|
||||
OVERLEAF_SITE_URL: ${OVERLEAF_SITE_URL}
|
||||
OVERLEAF_NAV_TITLE: ${OVERLEAF_NAV_TITLE}
|
||||
NAV_HIDE_POWERED_BY: true
|
||||
OVERLEAF_ADMIN_EMAIL: ${OVERLEAF_ADMIN_EMAIL}
|
||||
OVERLEAF_EMAIL_FROM_ADDRESS: ${OVERLEAF_EMAIL_FROM_ADDRESS}
|
||||
OVERLEAF_EMAIL_SMTP_HOST: ${OVERLEAF_EMAIL_SMTP_HOST}
|
||||
OVERLEAF_EMAIL_SMTP_PORT: ${OVERLEAF_EMAIL_SMTP_PORT}
|
||||
OVERLEAF_EMAIL_SMTP_SECURE: ${OVERLEAF_EMAIL_SMTP_SECURE}
|
||||
OVERLEAF_EMAIL_SMTP_USER: ${OVERLEAF_EMAIL_SMTP_USER}
|
||||
OVERLEAF_EMAIL_SMTP_PASS: ${OVERLEAF_EMAIL_PASSWORD}
|
||||
OVERLEAF_EMAIL_SMTP_LOGGER: true
|
||||
OVERLEAF_CUSTOM_EMAIL_FOOTER: ${OVERLEAF_CUSTOM_EMAIL_FOOTER}
|
||||
|
||||
########################
|
||||
## OIDC ##
|
||||
########################
|
||||
|
||||
EXTERNAL_AUTH: oidc
|
||||
OVERLEAF_OIDC_PROVIDER_ID: oidc
|
||||
OVERLEAF_OIDC_ISSUER: ${OVERLEAF_OIDC_ISSUER}
|
||||
OVERLEAF_OIDC_AUTHORIZATION_URL: ${OVERLEAF_OIDC_ISSUER}/protocol/openid-connect/auth
|
||||
OVERLEAF_OIDC_TOKEN_URL: ${OVERLEAF_OIDC_ISSUER}/protocol/openid-connect/token
|
||||
OVERLEAF_OIDC_USERINFO_URL: ${OVERLEAF_OIDC_ISSUER}/protocol/openid-connect/userinfo
|
||||
OVERLEAF_OIDC_LOGOUT_URL: ${OVERLEAF_OIDC_ISSUER}/protocol/openid-connect/logout
|
||||
OVERLEAF_OIDC_IDENTITY_SERVICE_NAME: ${OVERLEAF_OIDC_IDENTITY_SERVICE_NAME}
|
||||
OVERLEAF_OIDC_CLIENT_ID: ${OVERLEAF_OIDC_CLIENT_ID}
|
||||
OVERLEAF_OIDC_CLIENT_SECRET: ${OVERLEAF_OIDC_CLIENT_SECRET}
|
||||
OVERLEAF_OIDC_UPDATE_USER_DETAILS_ON_LOGIN: true
|
||||
|
||||
LOCAL_LOGIN_ENABLED: false
|
||||
LOGIN_PAGE_LOGO_URL: "https://git.fb1.uni-bremen.de/assets/img/logo_full.svg"
|
||||
SIMPLIFIED_SSO_SETTING_PAGE: true
|
||||
DISABLE_THIRD_PARTY_IDENTITY_MANAGER_EMAIL: true
|
||||
|
||||
OVERLEAF_LEFT_FOOTER: '[{"text": "<img src=\"https://git.fb1.uni-bremen.de/assets/img/logo.svg\"> University of Bremen Overleaf Wiki", "url": "https://psintern.neuro.uni-bremen.de/register"}]'
|
||||
OVERLEAF_RIGHT_FOOTER: '[{"text":"Powered by Overleaf", "url":"https://github.com/yu-i-i/overleaf-cep"}]'
|
||||
|
||||
########################
|
||||
## Sandboxed Compiles ##
|
||||
########################
|
||||
|
||||
SERVER_PRO: true
|
||||
DOCKER_RUNNER: true
|
||||
|
||||
SIBLING_CONTAINERS_ENABLED: true
|
||||
DOCKER_SOCKET_PATH: /var/run/docker.sock
|
||||
|
||||
SANDBOXED_COMPILES: true
|
||||
SANDBOXED_COMPILES_SIBLING_CONTAINERS: true
|
||||
|
||||
# WARNING: CHANGE DIR!!!!
|
||||
SANDBOXED_COMPILES_HOST_DIR: /docker/compose_cep/overleafserver/data/data/compiles
|
||||
COMPILES_HOST_DIR: /docker/compose_cep/overleafserver/data/data/compiles
|
||||
|
||||
ALL_TEX_LIVE_DOCKER_IMAGES: texlive/texlive:latest-full, texlive/texlive:TL2024-historic, texlive/texlive:TL2023-historic
|
||||
ALL_TEX_LIVE_DOCKER_IMAGE_NAMES: TeXLive 2025, TeXLive 2024, TeXLive 2023
|
||||
TEX_LIVE_DOCKER_IMAGE: texlive/texlive:latest-full
|
||||
TEX_COMPILER_EXTRA_FLAGS: -shell-escape
|
||||
TEXLIVE_IMAGE_USER: www-data
|
||||
|
||||
#################
|
||||
# TEMPLATES #
|
||||
#################
|
||||
OVERLEAF_TEMPLATE_GALLERY: true
|
||||
OVERLEAF_NON_ADMIN_CAN_PUBLISH_TEMPLATES: false
|
||||
OVERLEAF_TEMPLATE_CATEGORIES: presentation thesis
|
||||
|
||||
TEMPLATE_PRESENTATION_NAME: Presentations
|
||||
TEMPLATE_PRESENTATION_DESCRIPTION: Templates for Beamer and other presentation formats, tailored for academic talks and lectures.
|
||||
|
||||
TEMPLATE_THESIS_NAME: Theses
|
||||
TEMPLATE_THESIS_DESCRIPTION: Templates for writing theses and dissertations, following institutional formatting and citation guidelines.
|
||||
|
||||
TEMPLATE_ALL_NAME: All templates
|
||||
TEMPLATE_ALL_DESCRIPTION: Browse a collection of all available LaTeX templates, categorized by document type, style, and purpose.
|
||||
|
||||
networks:
|
||||
- overleaf-network
|
||||
healthcheck:
|
||||
test: bash -c "curl -fsI --connect-timeout 10 http://localhost || exit 1"
|
||||
interval: 30s
|
||||
timeout: 10s
|
||||
retries: 5
|
||||
start_period: 600s
|
||||
|
||||
networks:
|
||||
overleaf-network:
|
||||
external: true
|
6
install_unibremen/docker/compose_cep/pull_other_containers.sh
Executable file
6
install_unibremen/docker/compose_cep/pull_other_containers.sh
Executable file
|
@ -0,0 +1,6 @@
|
|||
docker pull texlive/texlive:latest-full
|
||||
docker pull texlive/texlive:TL2024-historic
|
||||
docker pull texlive/texlive:TL2023-historic
|
||||
docker pull nginx:stable-alpine
|
||||
docker pull mongo:6.0
|
||||
docker pull redis:6.2-alpine
|
15
install_unibremen/docker/compose_cep/up.sh
Normal file
15
install_unibremen/docker/compose_cep/up.sh
Normal file
|
@ -0,0 +1,15 @@
|
|||
docker compose down
|
||||
|
||||
docker network create overleaf-network
|
||||
snetz=`docker network inspect overleaf-network | grep "Subnet" | sed s/" "/""/g | sed s/"\,"/""/g | sed s/":"/"\n"/g | grep -v "Subnet" | sed s/'"'/''/g`
|
||||
nid=`docker network ls | grep overleaf-network | awk '{print $1}'`
|
||||
|
||||
ufw allow in on br-$nid
|
||||
ufw route allow in on br-$nid
|
||||
ufw route allow out on br-$nid
|
||||
iptables -t nat -A POSTROUTING ! -o br-$nid -s $snetz -j MASQUERADE
|
||||
|
||||
cd /docker/compose_cep/
|
||||
sysctl vm.overcommit_memory=1
|
||||
docker compose up -d
|
||||
|
2
install_unibremen/docker/compose_cep/up_gitbridge.sh
Normal file
2
install_unibremen/docker/compose_cep/up_gitbridge.sh
Normal file
|
@ -0,0 +1,2 @@
|
|||
docker compose up -d gitbridge
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
docker compose up -d overleafserver
|
||||
|
2
install_unibremen/install.sh
Normal file
2
install_unibremen/install.sh
Normal file
|
@ -0,0 +1,2 @@
|
|||
cp -r server-ce/* ../server-ce
|
||||
cp -r services/* ../services
|
91
install_unibremen/server-ce/Dockerfile-base
Normal file
91
install_unibremen/server-ce/Dockerfile-base
Normal file
|
@ -0,0 +1,91 @@
|
|||
# --------------------------------------------------
|
||||
# Overleaf Base Image (sharelatex/sharelatex-base)
|
||||
# --------------------------------------------------
|
||||
|
||||
FROM phusion/baseimage:noble-1.0.0
|
||||
|
||||
# Makes sure LuaTex cache is writable
|
||||
# -----------------------------------
|
||||
ENV TEXMFVAR=/var/lib/overleaf/tmp/texmf-var
|
||||
|
||||
# Update to ensure dependencies are updated
|
||||
# ------------------------------------------
|
||||
ENV REBUILT_AFTER="2025-03-27"
|
||||
|
||||
# Install dependencies
|
||||
# --------------------
|
||||
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
|
||||
# Technically, we are using potentially stale package-lists with the below line.
|
||||
# Practically, apt refreshes the lists as needed and release builds run in fresh CI VMs without the cache.
|
||||
--mount=type=cache,target=/var/lib/apt/lists,sharing=locked true \
|
||||
# Enable caching: https://docs.docker.com/reference/dockerfile/#example-cache-apt-packages
|
||||
&& rm -f /etc/apt/apt.conf.d/docker-clean && echo 'Binary::apt::APT::Keep-Downloaded-Packages "true";' > /etc/apt/apt.conf.d/keep-cache \
|
||||
&& apt-get update \
|
||||
&& apt-get install -y \
|
||||
unattended-upgrades \
|
||||
build-essential wget net-tools unzip time imagemagick optipng strace nginx git python3 python-is-python3 zlib1g-dev libpcre3-dev gettext-base libwww-perl ca-certificates curl gnupg \
|
||||
qpdf mc lynx micro telnet\
|
||||
# upgrade base-image, batch all the upgrades together, rather than installing them on-by-one (which is slow!)
|
||||
&& unattended-upgrade --verbose --no-minimal-upgrade-steps \
|
||||
# install Node.js https://github.com/nodesource/distributions#nodejs
|
||||
&& mkdir -p /etc/apt/keyrings \
|
||||
&& curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg \
|
||||
&& echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_20.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list \
|
||||
&& apt-get update \
|
||||
&& apt-get install -y nodejs \
|
||||
\
|
||||
&& rm -rf \
|
||||
# We are adding a custom nginx config in the main Dockerfile.
|
||||
/etc/nginx/nginx.conf \
|
||||
/etc/nginx/sites-enabled/default
|
||||
|
||||
# Install TexLive
|
||||
# ---------------
|
||||
# CTAN mirrors occasionally fail, in that case install TexLive using a
|
||||
# different server, for example https://ctan.crest.fr
|
||||
#
|
||||
# # docker build \
|
||||
# --build-arg TEXLIVE_MIRROR=https://ctan.crest.fr/tex-archive/systems/texlive/tlnet \
|
||||
# -f Dockerfile-base -t sharelatex/sharelatex-base .
|
||||
ARG TEXLIVE_MIRROR=https://mirror.ox.ac.uk/sites/ctan.org/systems/texlive/tlnet
|
||||
|
||||
RUN mkdir /install-tl-unx \
|
||||
&& wget --quiet https://tug.org/texlive/files/texlive.asc \
|
||||
&& gpg --import texlive.asc \
|
||||
&& rm texlive.asc \
|
||||
&& wget --quiet ${TEXLIVE_MIRROR}/install-tl-unx.tar.gz \
|
||||
&& wget --quiet ${TEXLIVE_MIRROR}/install-tl-unx.tar.gz.sha512 \
|
||||
&& wget --quiet ${TEXLIVE_MIRROR}/install-tl-unx.tar.gz.sha512.asc \
|
||||
&& gpg --verify install-tl-unx.tar.gz.sha512.asc \
|
||||
&& sha512sum -c install-tl-unx.tar.gz.sha512 \
|
||||
&& tar -xz -C /install-tl-unx --strip-components=1 -f install-tl-unx.tar.gz \
|
||||
&& rm install-tl-unx.tar.gz* \
|
||||
&& echo "tlpdbopt_autobackup 0" >> /install-tl-unx/texlive.profile \
|
||||
&& echo "tlpdbopt_install_docfiles 0" >> /install-tl-unx/texlive.profile \
|
||||
&& echo "tlpdbopt_install_srcfiles 0" >> /install-tl-unx/texlive.profile \
|
||||
&& echo "selected_scheme scheme-basic" >> /install-tl-unx/texlive.profile \
|
||||
\
|
||||
&& /install-tl-unx/install-tl \
|
||||
-profile /install-tl-unx/texlive.profile \
|
||||
-repository ${TEXLIVE_MIRROR} \
|
||||
\
|
||||
&& $(find /usr/local/texlive -name tlmgr) path add \
|
||||
&& tlmgr install --repository ${TEXLIVE_MIRROR} \
|
||||
latexmk \
|
||||
texcount \
|
||||
synctex \
|
||||
etoolbox \
|
||||
xetex \
|
||||
&& tlmgr path add \
|
||||
&& rm -rf /install-tl-unx
|
||||
|
||||
|
||||
# Set up overleaf user and home directory
|
||||
# -----------------------------------------
|
||||
RUN adduser --system --group --home /overleaf --no-create-home overleaf && \
|
||||
mkdir -p /var/lib/overleaf && \
|
||||
chown www-data:www-data /var/lib/overleaf && \
|
||||
mkdir -p /var/log/overleaf && \
|
||||
chown www-data:www-data /var/log/overleaf && \
|
||||
mkdir -p /var/lib/overleaf/data/template_files && \
|
||||
chown www-data:www-data /var/lib/overleaf/data/template_files
|
67
install_unibremen/server-ce/Makefile
Normal file
67
install_unibremen/server-ce/Makefile
Normal file
|
@ -0,0 +1,67 @@
|
|||
# Makefile
|
||||
|
||||
MONOREPO_ROOT := ../
|
||||
HERE=$(shell pwd)
|
||||
export MONOREPO_REVISION := $(shell git rev-parse HEAD)
|
||||
export BRANCH_NAME ?= $(shell git rev-parse --abbrev-ref HEAD)
|
||||
export OVERLEAF_BASE_BRANCH ?= sharelatex/sharelatex-base:$(BRANCH_NAME)
|
||||
export OVERLEAF_BASE_LATEST ?= sharelatex/sharelatex-base
|
||||
export OVERLEAF_BASE_TAG ?= sharelatex/sharelatex-base:$(BRANCH_NAME)-$(MONOREPO_REVISION)
|
||||
export OVERLEAF_BRANCH ?= sharelatex/sharelatex:$(BRANCH_NAME)
|
||||
export OVERLEAF_LATEST ?= sharelatex/sharelatex
|
||||
export OVERLEAF_TAG ?= sharelatex/sharelatex:$(BRANCH_NAME)-$(MONOREPO_REVISION)
|
||||
|
||||
all: build-base build-community
|
||||
|
||||
build-base:
|
||||
cp .dockerignore $(MONOREPO_ROOT)
|
||||
docker build \
|
||||
--build-arg BUILDKIT_INLINE_CACHE=1 \
|
||||
--progress=plain \
|
||||
--file Dockerfile-base \
|
||||
--pull \
|
||||
--cache-from $(OVERLEAF_BASE_LATEST) \
|
||||
--cache-from $(OVERLEAF_BASE_BRANCH) \
|
||||
--tag $(OVERLEAF_BASE_TAG) \
|
||||
--tag $(OVERLEAF_BASE_BRANCH) \
|
||||
--network=host \
|
||||
$(MONOREPO_ROOT)
|
||||
|
||||
|
||||
build-community:
|
||||
cp .dockerignore $(MONOREPO_ROOT)
|
||||
docker build \
|
||||
--build-arg BUILDKIT_INLINE_CACHE=1 \
|
||||
--progress=plain \
|
||||
--build-arg OVERLEAF_BASE_TAG \
|
||||
--build-arg MONOREPO_REVISION \
|
||||
--cache-from $(OVERLEAF_LATEST) \
|
||||
--cache-from $(OVERLEAF_BRANCH) \
|
||||
--file Dockerfile \
|
||||
--tag $(OVERLEAF_TAG) \
|
||||
--tag $(OVERLEAF_BRANCH) \
|
||||
--network=host \
|
||||
$(MONOREPO_ROOT)
|
||||
|
||||
SHELLCHECK_OPTS = \
|
||||
--shell=bash \
|
||||
--external-sources \
|
||||
--exclude=SC1091
|
||||
SHELLCHECK_COLOR := $(if $(CI),--color=never,--color)
|
||||
SHELLCHECK_FILES := { git ls-files "*.sh" -z; git grep -Plz "\A\#\!.*bash"; } | sort -zu
|
||||
|
||||
shellcheck:
|
||||
@$(SHELLCHECK_FILES) | xargs -0 -r docker run --rm -v $(HERE):/mnt -w /mnt \
|
||||
koalaman/shellcheck:stable $(SHELLCHECK_OPTS) $(SHELLCHECK_COLOR)
|
||||
|
||||
shellcheck_fix:
|
||||
@$(SHELLCHECK_FILES) | while IFS= read -r -d '' file; do \
|
||||
diff=$$(docker run --rm -v $(HERE):/mnt -w /mnt koalaman/shellcheck:stable $(SHELLCHECK_OPTS) --format=diff "$$file" 2>/dev/null); \
|
||||
if [ -n "$$diff" ] && ! echo "$$diff" | patch -p1 >/dev/null 2>&1; then echo "\033[31m$$file\033[0m"; \
|
||||
elif [ -n "$$diff" ]; then echo "$$file"; \
|
||||
else echo "\033[2m$$file\033[0m"; fi \
|
||||
done
|
||||
|
||||
.PHONY: all \
|
||||
build-base build-community \
|
||||
shellcheck shellcheck_fix
|
628
install_unibremen/services/clsi/app/js/DockerRunner.js
Normal file
628
install_unibremen/services/clsi/app/js/DockerRunner.js
Normal file
|
@ -0,0 +1,628 @@
|
|||
const { promisify } = require('node:util')
|
||||
const Settings = require('@overleaf/settings')
|
||||
const logger = require('@overleaf/logger')
|
||||
const Docker = require('dockerode')
|
||||
const dockerode = new Docker()
|
||||
const crypto = require('node:crypto')
|
||||
const async = require('async')
|
||||
const LockManager = require('./DockerLockManager')
|
||||
const fs = require('node:fs')
|
||||
const Path = require('node:path')
|
||||
const _ = require('lodash')
|
||||
|
||||
const ONE_HOUR_IN_MS = 60 * 60 * 1000
|
||||
logger.debug('using docker runner')
|
||||
|
||||
function usingSiblingContainers() {
|
||||
return (
|
||||
Settings != null &&
|
||||
Settings.path != null &&
|
||||
Settings.path.sandboxedCompilesHostDir != null
|
||||
)
|
||||
}
|
||||
|
||||
let containerMonitorTimeout
|
||||
let containerMonitorInterval
|
||||
|
||||
const DockerRunner = {
|
||||
run(
|
||||
projectId,
|
||||
command,
|
||||
directory,
|
||||
image,
|
||||
timeout,
|
||||
environment,
|
||||
compileGroup,
|
||||
callback
|
||||
) {
|
||||
if (usingSiblingContainers()) {
|
||||
const _newPath = Settings.path.sandboxedCompilesHostDir
|
||||
logger.debug(
|
||||
{ path: _newPath },
|
||||
'altering bind path for sibling containers'
|
||||
)
|
||||
// Server Pro, example:
|
||||
// '/var/lib/overleaf/data/compiles/<project-id>'
|
||||
// ... becomes ...
|
||||
// '/opt/overleaf_data/data/compiles/<project-id>'
|
||||
directory = Path.join(
|
||||
Settings.path.sandboxedCompilesHostDir,
|
||||
Path.basename(directory)
|
||||
)
|
||||
}
|
||||
|
||||
const volumes = { [directory]: '/compile' }
|
||||
|
||||
command = command.map(arg =>
|
||||
arg.toString().replace('$COMPILE_DIR', '/compile')
|
||||
)
|
||||
if (image == null) {
|
||||
image = Settings.clsi.docker.image
|
||||
}
|
||||
|
||||
if (
|
||||
Settings.clsi.docker.allowedImages &&
|
||||
!Settings.clsi.docker.allowedImages.includes(image)
|
||||
) {
|
||||
return callback(new Error('image not allowed'))
|
||||
}
|
||||
|
||||
if (Settings.texliveImageNameOveride != null) {
|
||||
const img = image.split('/')
|
||||
image = `${Settings.texliveImageNameOveride}/${img[2]}`
|
||||
}
|
||||
|
||||
if (compileGroup === 'synctex' || compileGroup === 'wordcount') {
|
||||
volumes[directory] += ':ro'
|
||||
}
|
||||
|
||||
const options = DockerRunner._getContainerOptions(
|
||||
command,
|
||||
image,
|
||||
volumes,
|
||||
timeout,
|
||||
environment,
|
||||
compileGroup
|
||||
)
|
||||
const fingerprint = DockerRunner._fingerprintContainer(options)
|
||||
const name = `project-${projectId}-${fingerprint}`
|
||||
options.name = name
|
||||
|
||||
// logOptions = _.clone(options)
|
||||
// logOptions?.HostConfig?.SecurityOpt = "secomp used, removed in logging"
|
||||
logger.debug({ projectId }, 'running docker container')
|
||||
DockerRunner._runAndWaitForContainer(
|
||||
options,
|
||||
volumes,
|
||||
timeout,
|
||||
(error, output) => {
|
||||
if (error && error.statusCode === 500) {
|
||||
logger.debug(
|
||||
{ err: error, projectId },
|
||||
'error running container so destroying and retrying'
|
||||
)
|
||||
DockerRunner.destroyContainer(name, null, true, error => {
|
||||
if (error != null) {
|
||||
return callback(error)
|
||||
}
|
||||
DockerRunner._runAndWaitForContainer(
|
||||
options,
|
||||
volumes,
|
||||
timeout,
|
||||
callback
|
||||
)
|
||||
})
|
||||
} else {
|
||||
callback(error, output)
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
// pass back the container name to allow it to be killed
|
||||
return name
|
||||
},
|
||||
|
||||
kill(containerId, callback) {
|
||||
logger.debug({ containerId }, 'sending kill signal to container')
|
||||
const container = dockerode.getContainer(containerId)
|
||||
container.kill(error => {
|
||||
if (
|
||||
error != null &&
|
||||
error.message != null &&
|
||||
error.message.match(/Cannot kill container .* is not running/)
|
||||
) {
|
||||
logger.warn(
|
||||
{ err: error, containerId },
|
||||
'container not running, continuing'
|
||||
)
|
||||
error = null
|
||||
}
|
||||
if (error != null) {
|
||||
logger.error({ err: error, containerId }, 'error killing container')
|
||||
callback(error)
|
||||
} else {
|
||||
callback()
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
_runAndWaitForContainer(options, volumes, timeout, _callback) {
|
||||
const callback = _.once(_callback)
|
||||
const { name } = options
|
||||
|
||||
let streamEnded = false
|
||||
let containerReturned = false
|
||||
let output = {}
|
||||
|
||||
function callbackIfFinished() {
|
||||
if (streamEnded && containerReturned) {
|
||||
callback(null, output)
|
||||
}
|
||||
}
|
||||
|
||||
function attachStreamHandler(error, _output) {
|
||||
if (error != null) {
|
||||
return callback(error)
|
||||
}
|
||||
output = _output
|
||||
streamEnded = true
|
||||
callbackIfFinished()
|
||||
}
|
||||
|
||||
DockerRunner.startContainer(
|
||||
options,
|
||||
volumes,
|
||||
attachStreamHandler,
|
||||
(error, containerId) => {
|
||||
if (error != null) {
|
||||
return callback(error)
|
||||
}
|
||||
|
||||
DockerRunner.waitForContainer(name, timeout, (error, exitCode) => {
|
||||
if (error != null) {
|
||||
return callback(error)
|
||||
}
|
||||
if (exitCode === 137) {
|
||||
// exit status from kill -9
|
||||
const err = new Error('terminated')
|
||||
err.terminated = true
|
||||
return callback(err)
|
||||
}
|
||||
if (exitCode === 1) {
|
||||
// exit status from chktex
|
||||
const err = new Error('exited')
|
||||
err.code = exitCode
|
||||
return callback(err)
|
||||
}
|
||||
containerReturned = true
|
||||
if (options != null && options.HostConfig != null) {
|
||||
options.HostConfig.SecurityOpt = null
|
||||
}
|
||||
logger.debug({ exitCode, options }, 'docker container has exited')
|
||||
callbackIfFinished()
|
||||
})
|
||||
}
|
||||
)
|
||||
},
|
||||
|
||||
_getContainerOptions(
|
||||
command,
|
||||
image,
|
||||
volumes,
|
||||
timeout,
|
||||
environment,
|
||||
compileGroup
|
||||
) {
|
||||
const timeoutInSeconds = timeout / 1000
|
||||
|
||||
const dockerVolumes = {}
|
||||
for (const hostVol in volumes) {
|
||||
const dockerVol = volumes[hostVol]
|
||||
dockerVolumes[dockerVol] = {}
|
||||
|
||||
if (volumes[hostVol].slice(-3).indexOf(':r') === -1) {
|
||||
volumes[hostVol] = `${dockerVol}:rw`
|
||||
}
|
||||
}
|
||||
|
||||
// merge settings and environment parameter
|
||||
const env = {}
|
||||
for (const src of [Settings.clsi.docker.env, environment || {}]) {
|
||||
for (const key in src) {
|
||||
const value = src[key]
|
||||
env[key] = value
|
||||
}
|
||||
}
|
||||
// set the path based on the image year
|
||||
const match = image.match(/:([0-9]+)\.[0-9]+|:TL([0-9]+)/)
|
||||
const year = match ? match[1] || match[2] : '2025'
|
||||
env.PATH = `/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/texlive/${year}/bin/x86_64-linux/`
|
||||
const options = {
|
||||
Cmd: command,
|
||||
Image: image,
|
||||
Volumes: dockerVolumes,
|
||||
WorkingDir: '/compile',
|
||||
NetworkDisabled: true,
|
||||
Memory: 1024 * 1024 * 1024 * 1024, // 1 Gb
|
||||
User: Settings.clsi.docker.user,
|
||||
Env: Object.entries(env).map(([key, value]) => `${key}=${value}`),
|
||||
HostConfig: {
|
||||
Binds: Object.entries(volumes).map(
|
||||
([hostVol, dockerVol]) => `${hostVol}:${dockerVol}`
|
||||
),
|
||||
LogConfig: { Type: 'none', Config: {} },
|
||||
Ulimits: [
|
||||
{
|
||||
Name: 'cpu',
|
||||
Soft: timeoutInSeconds + 5,
|
||||
Hard: timeoutInSeconds + 10,
|
||||
},
|
||||
],
|
||||
CapDrop: 'ALL',
|
||||
SecurityOpt: ['no-new-privileges'],
|
||||
},
|
||||
}
|
||||
|
||||
if (Settings.clsi.docker.seccomp_profile != null) {
|
||||
options.HostConfig.SecurityOpt.push(
|
||||
`seccomp=${Settings.clsi.docker.seccomp_profile}`
|
||||
)
|
||||
}
|
||||
|
||||
if (Settings.clsi.docker.apparmor_profile != null) {
|
||||
options.HostConfig.SecurityOpt.push(
|
||||
`apparmor=${Settings.clsi.docker.apparmor_profile}`
|
||||
)
|
||||
}
|
||||
|
||||
if (Settings.clsi.docker.runtime) {
|
||||
options.HostConfig.Runtime = Settings.clsi.docker.runtime
|
||||
}
|
||||
|
||||
if (Settings.clsi.docker.Readonly) {
|
||||
options.HostConfig.ReadonlyRootfs = true
|
||||
options.HostConfig.Tmpfs = { '/tmp': 'rw,noexec,nosuid,size=65536k' }
|
||||
options.Volumes['/home/tex'] = {}
|
||||
}
|
||||
|
||||
// Allow per-compile group overriding of individual settings
|
||||
if (
|
||||
Settings.clsi.docker.compileGroupConfig &&
|
||||
Settings.clsi.docker.compileGroupConfig[compileGroup]
|
||||
) {
|
||||
const override = Settings.clsi.docker.compileGroupConfig[compileGroup]
|
||||
for (const key in override) {
|
||||
_.set(options, key, override[key])
|
||||
}
|
||||
}
|
||||
|
||||
return options
|
||||
},
|
||||
|
||||
_fingerprintContainer(containerOptions) {
|
||||
// Yay, Hashing!
|
||||
const json = JSON.stringify(containerOptions)
|
||||
return crypto.createHash('md5').update(json).digest('hex')
|
||||
},
|
||||
|
||||
startContainer(options, volumes, attachStreamHandler, callback) {
|
||||
LockManager.runWithLock(
|
||||
options.name,
|
||||
releaseLock =>
|
||||
// Check that volumes exist before starting the container.
|
||||
// When a container is started with volume pointing to a
|
||||
// non-existent directory then docker creates the directory but
|
||||
// with root ownership.
|
||||
DockerRunner._checkVolumes(options, volumes, err => {
|
||||
if (err != null) {
|
||||
return releaseLock(err)
|
||||
}
|
||||
DockerRunner._startContainer(
|
||||
options,
|
||||
volumes,
|
||||
attachStreamHandler,
|
||||
releaseLock
|
||||
)
|
||||
}),
|
||||
|
||||
callback
|
||||
)
|
||||
},
|
||||
|
||||
// Check that volumes exist and are directories
|
||||
_checkVolumes(options, volumes, callback) {
|
||||
if (usingSiblingContainers()) {
|
||||
// Server Pro, with sibling-containers active, skip checks
|
||||
return callback(null)
|
||||
}
|
||||
|
||||
const checkVolume = (path, cb) =>
|
||||
fs.stat(path, (err, stats) => {
|
||||
if (err != null) {
|
||||
return cb(err)
|
||||
}
|
||||
if (!stats.isDirectory()) {
|
||||
return cb(new Error('not a directory'))
|
||||
}
|
||||
cb()
|
||||
})
|
||||
const jobs = []
|
||||
for (const vol in volumes) {
|
||||
jobs.push(cb => checkVolume(vol, cb))
|
||||
}
|
||||
async.series(jobs, callback)
|
||||
},
|
||||
|
||||
_startContainer(options, volumes, attachStreamHandler, callback) {
|
||||
callback = _.once(callback)
|
||||
const { name } = options
|
||||
|
||||
logger.debug({ containerName: name }, 'starting container')
|
||||
const container = dockerode.getContainer(name)
|
||||
|
||||
function createAndStartContainer() {
|
||||
dockerode.createContainer(options, (error, container) => {
|
||||
if (error != null) {
|
||||
return callback(error)
|
||||
}
|
||||
startExistingContainer()
|
||||
})
|
||||
}
|
||||
|
||||
function startExistingContainer() {
|
||||
DockerRunner.attachToContainer(
|
||||
options.name,
|
||||
attachStreamHandler,
|
||||
error => {
|
||||
if (error != null) {
|
||||
return callback(error)
|
||||
}
|
||||
container.start(error => {
|
||||
if (error != null && error.statusCode !== 304) {
|
||||
callback(error)
|
||||
} else {
|
||||
// already running
|
||||
callback()
|
||||
}
|
||||
})
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
container.inspect((error, stats) => {
|
||||
if (error != null && error.statusCode === 404) {
|
||||
createAndStartContainer()
|
||||
} else if (error != null) {
|
||||
logger.err(
|
||||
{ containerName: name, error },
|
||||
'unable to inspect container to start'
|
||||
)
|
||||
callback(error)
|
||||
} else {
|
||||
startExistingContainer()
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
attachToContainer(containerId, attachStreamHandler, attachStartCallback) {
|
||||
const container = dockerode.getContainer(containerId)
|
||||
container.attach({ stdout: 1, stderr: 1, stream: 1 }, (error, stream) => {
|
||||
if (error != null) {
|
||||
logger.error(
|
||||
{ err: error, containerId },
|
||||
'error attaching to container'
|
||||
)
|
||||
return attachStartCallback(error)
|
||||
} else {
|
||||
attachStartCallback()
|
||||
}
|
||||
|
||||
logger.debug({ containerId }, 'attached to container')
|
||||
|
||||
const MAX_OUTPUT = 1024 * 1024 * 2 // limit output to 2MB
|
||||
function createStringOutputStream(name) {
|
||||
return {
|
||||
data: '',
|
||||
overflowed: false,
|
||||
write(data) {
|
||||
if (this.overflowed) {
|
||||
return
|
||||
}
|
||||
if (this.data.length < MAX_OUTPUT) {
|
||||
this.data += data
|
||||
} else {
|
||||
logger.info(
|
||||
{
|
||||
containerId,
|
||||
length: this.data.length,
|
||||
maxLen: MAX_OUTPUT,
|
||||
},
|
||||
`${name} exceeds max size`
|
||||
)
|
||||
this.data += `(...truncated at ${MAX_OUTPUT} chars...)`
|
||||
this.overflowed = true
|
||||
}
|
||||
},
|
||||
// kill container if too much output
|
||||
// docker.containers.kill(containerId, () ->)
|
||||
}
|
||||
}
|
||||
|
||||
const stdout = createStringOutputStream('stdout')
|
||||
const stderr = createStringOutputStream('stderr')
|
||||
|
||||
container.modem.demuxStream(stream, stdout, stderr)
|
||||
|
||||
stream.on('error', err =>
|
||||
logger.error(
|
||||
{ err, containerId },
|
||||
'error reading from container stream'
|
||||
)
|
||||
)
|
||||
|
||||
stream.on('end', () =>
|
||||
attachStreamHandler(null, { stdout: stdout.data, stderr: stderr.data })
|
||||
)
|
||||
})
|
||||
},
|
||||
|
||||
waitForContainer(containerId, timeout, _callback) {
|
||||
const callback = _.once(_callback)
|
||||
|
||||
const container = dockerode.getContainer(containerId)
|
||||
|
||||
let timedOut = false
|
||||
const timeoutId = setTimeout(() => {
|
||||
timedOut = true
|
||||
logger.debug({ containerId }, 'timeout reached, killing container')
|
||||
container.kill(err => {
|
||||
logger.warn({ err, containerId }, 'failed to kill container')
|
||||
})
|
||||
}, timeout)
|
||||
|
||||
logger.debug({ containerId }, 'waiting for docker container')
|
||||
container.wait((error, res) => {
|
||||
if (error != null) {
|
||||
clearTimeout(timeoutId)
|
||||
logger.warn({ err: error, containerId }, 'error waiting for container')
|
||||
return callback(error)
|
||||
}
|
||||
if (timedOut) {
|
||||
logger.debug({ containerId }, 'docker container timed out')
|
||||
error = new Error('container timed out')
|
||||
error.timedout = true
|
||||
callback(error)
|
||||
} else {
|
||||
clearTimeout(timeoutId)
|
||||
logger.debug(
|
||||
{ containerId, exitCode: res.StatusCode },
|
||||
'docker container returned'
|
||||
)
|
||||
callback(null, res.StatusCode)
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
destroyContainer(containerName, containerId, shouldForce, callback) {
|
||||
// We want the containerName for the lock and, ideally, the
|
||||
// containerId to delete. There is a bug in the docker.io module
|
||||
// where if you delete by name and there is an error, it throws an
|
||||
// async exception, but if you delete by id it just does a normal
|
||||
// error callback. We fall back to deleting by name if no id is
|
||||
// supplied.
|
||||
LockManager.runWithLock(
|
||||
containerName,
|
||||
releaseLock =>
|
||||
DockerRunner._destroyContainer(
|
||||
containerId || containerName,
|
||||
shouldForce,
|
||||
releaseLock
|
||||
),
|
||||
callback
|
||||
)
|
||||
},
|
||||
|
||||
_destroyContainer(containerId, shouldForce, callback) {
|
||||
logger.debug({ containerId }, 'destroying docker container')
|
||||
const container = dockerode.getContainer(containerId)
|
||||
container.remove({ force: shouldForce === true, v: true }, error => {
|
||||
if (error != null && error.statusCode === 404) {
|
||||
logger.warn(
|
||||
{ err: error, containerId },
|
||||
'container not found, continuing'
|
||||
)
|
||||
error = null
|
||||
}
|
||||
if (error != null) {
|
||||
logger.error({ err: error, containerId }, 'error destroying container')
|
||||
} else {
|
||||
logger.debug({ containerId }, 'destroyed container')
|
||||
}
|
||||
callback(error)
|
||||
})
|
||||
},
|
||||
|
||||
// handle expiry of docker containers
|
||||
|
||||
MAX_CONTAINER_AGE: Settings.clsi.docker.maxContainerAge || ONE_HOUR_IN_MS,
|
||||
|
||||
examineOldContainer(container, callback) {
|
||||
const name = container.Name || (container.Names && container.Names[0])
|
||||
const created = container.Created * 1000 // creation time is returned in seconds
|
||||
const now = Date.now()
|
||||
const age = now - created
|
||||
const maxAge = DockerRunner.MAX_CONTAINER_AGE
|
||||
const ttl = maxAge - age
|
||||
logger.debug(
|
||||
{ containerName: name, created, now, age, maxAge, ttl },
|
||||
'checking whether to destroy container'
|
||||
)
|
||||
return { name, id: container.Id, ttl }
|
||||
},
|
||||
|
||||
destroyOldContainers(callback) {
|
||||
dockerode.listContainers({ all: true }, (error, containers) => {
|
||||
if (error != null) {
|
||||
return callback(error)
|
||||
}
|
||||
const jobs = []
|
||||
for (const container of containers) {
|
||||
const { name, id, ttl } = DockerRunner.examineOldContainer(container)
|
||||
if (name.slice(0, 9) === '/project-' && ttl <= 0) {
|
||||
// strip the / prefix
|
||||
// the LockManager uses the plain container name
|
||||
const plainName = name.slice(1)
|
||||
jobs.push(cb =>
|
||||
DockerRunner.destroyContainer(plainName, id, false, () => cb())
|
||||
)
|
||||
}
|
||||
}
|
||||
// Ignore errors because some containers get stuck but
|
||||
// will be destroyed next time
|
||||
async.series(jobs, callback)
|
||||
})
|
||||
},
|
||||
|
||||
startContainerMonitor() {
|
||||
logger.debug(
|
||||
{ maxAge: DockerRunner.MAX_CONTAINER_AGE },
|
||||
'starting container expiry'
|
||||
)
|
||||
|
||||
// guarantee only one monitor is running
|
||||
DockerRunner.stopContainerMonitor()
|
||||
|
||||
// randomise the start time
|
||||
const randomDelay = Math.floor(Math.random() * 5 * 60 * 1000)
|
||||
containerMonitorTimeout = setTimeout(() => {
|
||||
containerMonitorInterval = setInterval(
|
||||
() =>
|
||||
DockerRunner.destroyOldContainers(err => {
|
||||
if (err) {
|
||||
logger.error({ err }, 'failed to destroy old containers')
|
||||
}
|
||||
}),
|
||||
ONE_HOUR_IN_MS
|
||||
)
|
||||
}, randomDelay)
|
||||
},
|
||||
|
||||
stopContainerMonitor() {
|
||||
if (containerMonitorTimeout) {
|
||||
clearTimeout(containerMonitorTimeout)
|
||||
containerMonitorTimeout = undefined
|
||||
}
|
||||
if (containerMonitorInterval) {
|
||||
clearInterval(containerMonitorInterval)
|
||||
containerMonitorInterval = undefined
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
DockerRunner.startContainerMonitor()
|
||||
|
||||
module.exports = DockerRunner
|
||||
module.exports.promises = {
|
||||
run: promisify(DockerRunner.run),
|
||||
kill: promisify(DockerRunner.kill),
|
||||
}
|
852
install_unibremen/services/clsi/seccomp/clsi-profile.json
Normal file
852
install_unibremen/services/clsi/seccomp/clsi-profile.json
Normal file
|
@ -0,0 +1,852 @@
|
|||
{
|
||||
"defaultAction": "SCMP_ACT_ERRNO",
|
||||
"architectures": [
|
||||
"SCMP_ARCH_X86_64",
|
||||
"SCMP_ARCH_X86",
|
||||
"SCMP_ARCH_X32"
|
||||
],
|
||||
"syscalls": [
|
||||
{
|
||||
"name": "getrandom",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "access",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "arch_prctl",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "brk",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "chdir",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "chmod",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "clock_getres",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "clock_gettime",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "clock_nanosleep",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "clone",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": [
|
||||
{
|
||||
"index": 0,
|
||||
"value": 2080505856,
|
||||
"valueTwo": 0,
|
||||
"op": "SCMP_CMP_MASKED_EQ"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "close",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "copy_file_range",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "creat",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "dup",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "dup2",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "dup3",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "execve",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "execveat",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "exit",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "exit_group",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "faccessat",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "fadvise64",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "fadvise64_64",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "fallocate",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "fchdir",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "fchmod",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "fchmodat",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "fcntl",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "fcntl64",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "fdatasync",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "fork",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "fstat",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "fstat64",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "fstatat64",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "fstatfs",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "fstatfs64",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "fsync",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "ftruncate",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "ftruncate64",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "futex",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "futimesat",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "getcpu",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "getcwd",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "getdents",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "getdents64",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "getegid",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "getegid32",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "geteuid",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "geteuid32",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "getgid",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "getgid32",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "getgroups",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "getgroups32",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "getpgid",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "getpgrp",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "getpid",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "getppid",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "getpriority",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "getresgid",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "getresgid32",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "getresuid",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "getresuid32",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "getrlimit",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "get_robust_list",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "getrusage",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "getsid",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "gettid",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "getuid",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "getuid32",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "ioctl",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "kill",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "_llseek",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "lseek",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "lstat",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "lstat64",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "madvise",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "mkdir",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "mkdirat",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "mmap",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "mmap2",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "mprotect",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "mremap",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "munmap",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "newfstatat",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "open",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "openat",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "pause",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "pipe",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "pipe2",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "prctl",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "pread64",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "preadv",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "prlimit64",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "pwrite64",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "pwritev",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "read",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "readlink",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "readlinkat",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "readv",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "rename",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "renameat",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "renameat2",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "restart_syscall",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "rmdir",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "rt_sigaction",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "rt_sigpending",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "rt_sigprocmask",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "rt_sigqueueinfo",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "rt_sigreturn",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "rt_sigsuspend",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "rt_sigtimedwait",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "rt_tgsigqueueinfo",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "sched_getaffinity",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "sched_getparam",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "sched_get_priority_max",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "sched_get_priority_min",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "sched_getscheduler",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "sched_rr_get_interval",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "sched_yield",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "sendfile",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "sendfile64",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "setgroups",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "setgroups32",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "set_robust_list",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "set_tid_address",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "sigaltstack",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "stat",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "stat64",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "statfs",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "statfs64",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "sync",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "sync_file_range",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "syncfs",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "sysinfo",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "tgkill",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "timer_create",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "timer_delete",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "timer_getoverrun",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "timer_gettime",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "timer_settime",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "times",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "tkill",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "truncate",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "truncate64",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "umask",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "uname",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "unlink",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "unlinkat",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "utime",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "utimensat",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "utimes",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "vfork",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "vhangup",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "wait4",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "waitid",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "write",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "writev",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "pread",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "setgid",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "setuid",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "capget",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "capset",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "fchown",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "gettimeofday",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "epoll_pwait",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "poll",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "epoll_create1",
|
||||
"action": "SCMP_ACT_ALLOW",
|
||||
"args": []
|
||||
}
|
||||
]
|
||||
}
|
|
@ -0,0 +1,222 @@
|
|||
const UserAuditLogHandler = require('../../../../app/src/Features/User/UserAuditLogHandler')
|
||||
const EmailHandler = require('../../../../app/src/Features/Email/EmailHandler')
|
||||
const EmailOptionsHelper = require('../../../../app/src/Features/Email/EmailOptionsHelper')
|
||||
const Errors = require('../Errors/Errors')
|
||||
const _ = require('lodash')
|
||||
const logger = require('@overleaf/logger')
|
||||
const settings = require('@overleaf/settings')
|
||||
const { User } = require('../../../../app/src/models/User')
|
||||
const { callbackify } = require('@overleaf/promise-utils')
|
||||
const OError = require('@overleaf/o-error')
|
||||
|
||||
const oauthProviders = settings.oauthProviders || {}
|
||||
|
||||
async function getUser(providerId, externalUserId) {
|
||||
if (providerId == null || externalUserId == null) {
|
||||
throw new OError('invalid SSO arguments', {
|
||||
externalUserId,
|
||||
providerId,
|
||||
})
|
||||
}
|
||||
|
||||
const query = _getUserQuery(providerId, externalUserId)
|
||||
const user = await User.findOne(query).exec()
|
||||
if (!user) {
|
||||
throw new Errors.ThirdPartyUserNotFoundError()
|
||||
}
|
||||
return user
|
||||
}
|
||||
|
||||
async function login(providerId, externalUserId, externalData) {
|
||||
const user = await ThirdPartyIdentityManager.promises.getUser(
|
||||
providerId,
|
||||
externalUserId
|
||||
)
|
||||
if (!externalData) {
|
||||
return user
|
||||
}
|
||||
const query = _getUserQuery(providerId, externalUserId)
|
||||
const update = _thirdPartyIdentifierUpdate(
|
||||
user,
|
||||
providerId,
|
||||
externalUserId,
|
||||
externalData
|
||||
)
|
||||
return await User.findOneAndUpdate(query, update, { new: true }).exec()
|
||||
}
|
||||
|
||||
async function link(
|
||||
userId,
|
||||
providerId,
|
||||
externalUserId,
|
||||
externalData,
|
||||
auditLog,
|
||||
retry
|
||||
) {
|
||||
const accountLinked = true
|
||||
if (!oauthProviders[providerId]) {
|
||||
throw new Error('Not a valid provider')
|
||||
}
|
||||
|
||||
await UserAuditLogHandler.promises.addEntry(
|
||||
userId,
|
||||
'link-sso',
|
||||
auditLog.initiatorId,
|
||||
auditLog.ipAddress,
|
||||
{
|
||||
providerId,
|
||||
}
|
||||
)
|
||||
|
||||
const query = {
|
||||
_id: userId,
|
||||
'thirdPartyIdentifiers.providerId': {
|
||||
$ne: providerId,
|
||||
},
|
||||
}
|
||||
const update = {
|
||||
$push: {
|
||||
thirdPartyIdentifiers: {
|
||||
externalUserId,
|
||||
externalData,
|
||||
providerId,
|
||||
},
|
||||
},
|
||||
}
|
||||
// add new tpi only if an entry for the provider does not exist
|
||||
// projection includes thirdPartyIdentifiers for tests
|
||||
let res
|
||||
try {
|
||||
res = await User.findOneAndUpdate(query, update, { new: 1 }).exec()
|
||||
} catch (err) {
|
||||
if (err.code === 11000) {
|
||||
throw new Errors.ThirdPartyIdentityExistsError({
|
||||
info: { externalUserId },
|
||||
})
|
||||
}
|
||||
throw err
|
||||
}
|
||||
|
||||
if (res) {
|
||||
_sendSecurityAlert(accountLinked, providerId, res, userId)
|
||||
return res
|
||||
}
|
||||
|
||||
if (retry) {
|
||||
// if already retried then throw error
|
||||
throw new Error('update failed')
|
||||
}
|
||||
|
||||
// attempt to clear existing entry then retry
|
||||
await ThirdPartyIdentityManager.promises.unlink(userId, providerId, auditLog)
|
||||
return await ThirdPartyIdentityManager.promises.link(
|
||||
userId,
|
||||
providerId,
|
||||
externalUserId,
|
||||
externalData,
|
||||
auditLog,
|
||||
true
|
||||
)
|
||||
}
|
||||
|
||||
async function unlink(userId, providerId, auditLog) {
|
||||
const accountLinked = false
|
||||
if (!oauthProviders[providerId]) {
|
||||
throw new Error('Not a valid provider')
|
||||
}
|
||||
|
||||
await UserAuditLogHandler.promises.addEntry(
|
||||
userId,
|
||||
'unlink-sso',
|
||||
auditLog.initiatorId,
|
||||
auditLog.ipAddress,
|
||||
{
|
||||
...(auditLog.extraInfo || {}),
|
||||
providerId,
|
||||
}
|
||||
)
|
||||
|
||||
const query = {
|
||||
_id: userId,
|
||||
}
|
||||
const update = {
|
||||
$pull: {
|
||||
thirdPartyIdentifiers: {
|
||||
providerId,
|
||||
},
|
||||
},
|
||||
}
|
||||
// projection includes thirdPartyIdentifiers for tests
|
||||
const res = await User.findOneAndUpdate(query, update, { new: 1 })
|
||||
if (!res) {
|
||||
throw new Error('update failed')
|
||||
}
|
||||
_sendSecurityAlert(accountLinked, providerId, res, userId)
|
||||
return res
|
||||
}
|
||||
|
||||
function _getUserQuery(providerId, externalUserId) {
|
||||
externalUserId = externalUserId.toString()
|
||||
providerId = providerId.toString()
|
||||
const query = {
|
||||
'thirdPartyIdentifiers.externalUserId': externalUserId,
|
||||
'thirdPartyIdentifiers.providerId': providerId,
|
||||
}
|
||||
return query
|
||||
}
|
||||
|
||||
function _sendSecurityAlert(accountLinked, providerId, user, userId) {
|
||||
const providerName = oauthProviders[providerId].name
|
||||
const emailOptions = EmailOptionsHelper.linkOrUnlink(
|
||||
accountLinked,
|
||||
providerName,
|
||||
user.email
|
||||
)
|
||||
|
||||
const disableThirdPartyIdentityManagerEMail = settings.disableThirdPartyIdentityManagerEMail
|
||||
if (!disableThirdPartyIdentityManagerEMail) {
|
||||
|
||||
EmailHandler.promises
|
||||
.sendEmail('securityAlert', emailOptions)
|
||||
.catch(error => {
|
||||
logger.error(
|
||||
{ err: error, userId },
|
||||
`could not send security alert email when ${emailOptions.action.toLowerCase()}`
|
||||
)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
function _thirdPartyIdentifierUpdate(
|
||||
user,
|
||||
providerId,
|
||||
externalUserId,
|
||||
externalData
|
||||
) {
|
||||
providerId = providerId.toString()
|
||||
// get third party identifier object from array
|
||||
const thirdPartyIdentifier = user.thirdPartyIdentifiers.find(
|
||||
tpi =>
|
||||
tpi.externalUserId === externalUserId && tpi.providerId === providerId
|
||||
)
|
||||
// do recursive merge of new data over existing data
|
||||
_.merge(thirdPartyIdentifier.externalData, externalData)
|
||||
const update = { 'thirdPartyIdentifiers.$': thirdPartyIdentifier }
|
||||
return update
|
||||
}
|
||||
|
||||
const ThirdPartyIdentityManager = {
|
||||
getUser: callbackify(getUser),
|
||||
login: callbackify(login),
|
||||
link: callbackify(link),
|
||||
unlink: callbackify(unlink),
|
||||
}
|
||||
|
||||
ThirdPartyIdentityManager.promises = {
|
||||
getUser,
|
||||
login,
|
||||
link,
|
||||
unlink,
|
||||
}
|
||||
|
||||
module.exports = ThirdPartyIdentityManager
|
|
@ -0,0 +1,355 @@
|
|||
import UserGetter from './UserGetter.js'
|
||||
import OError from '@overleaf/o-error'
|
||||
import UserSessionsManager from './UserSessionsManager.js'
|
||||
import logger from '@overleaf/logger'
|
||||
import Settings from '@overleaf/settings'
|
||||
import AuthenticationController from '../Authentication/AuthenticationController.js'
|
||||
import SessionManager from '../Authentication/SessionManager.js'
|
||||
import NewsletterManager from '../Newsletter/NewsletterManager.js'
|
||||
import SubscriptionLocator from '../Subscription/SubscriptionLocator.js'
|
||||
import _ from 'lodash'
|
||||
import { expressify } from '@overleaf/promise-utils'
|
||||
import Features from '../../infrastructure/Features.js'
|
||||
import SplitTestHandler from '../SplitTests/SplitTestHandler.js'
|
||||
import Modules from '../../infrastructure/Modules.js'
|
||||
|
||||
async function settingsPage(req, res) {
|
||||
const userId = SessionManager.getLoggedInUserId(req.session)
|
||||
const reconfirmationRemoveEmail = req.query.remove
|
||||
// SSO
|
||||
const ssoError = req.session.ssoError
|
||||
if (ssoError) {
|
||||
delete req.session.ssoError
|
||||
}
|
||||
const ssoErrorMessage = req.session.ssoErrorMessage
|
||||
if (ssoErrorMessage) {
|
||||
delete req.session.ssoErrorMessage
|
||||
}
|
||||
const projectSyncSuccessMessage = req.session.projectSyncSuccessMessage
|
||||
if (projectSyncSuccessMessage) {
|
||||
delete req.session.projectSyncSuccessMessage
|
||||
}
|
||||
// Institution SSO
|
||||
let institutionLinked = _.get(req.session, ['saml', 'linked'])
|
||||
if (institutionLinked) {
|
||||
// copy object if exists because _.get does not
|
||||
institutionLinked = Object.assign(
|
||||
{
|
||||
hasEntitlement: _.get(req.session, ['saml', 'hasEntitlement']),
|
||||
},
|
||||
institutionLinked
|
||||
)
|
||||
}
|
||||
const samlError = _.get(req.session, ['saml', 'error'])
|
||||
const institutionEmailNonCanonical = _.get(req.session, [
|
||||
'saml',
|
||||
'emailNonCanonical',
|
||||
])
|
||||
const institutionRequestedEmail = _.get(req.session, [
|
||||
'saml',
|
||||
'requestedEmail',
|
||||
])
|
||||
|
||||
const reconfirmedViaSAML = _.get(req.session, ['saml', 'reconfirmed'])
|
||||
delete req.session.saml
|
||||
let shouldAllowEditingDetails = true
|
||||
const externalAuth = req.user.externalAuth
|
||||
if (externalAuth && Settings[externalAuth].updateUserDetailsOnLogin) {
|
||||
shouldAllowEditingDetails = false
|
||||
}
|
||||
const oauthProviders = Settings.oauthProviders || {}
|
||||
|
||||
const user = await UserGetter.promises.getUser(userId)
|
||||
if (!user) {
|
||||
// The user has just deleted their account.
|
||||
return UserSessionsManager.removeSessionsFromRedis(
|
||||
{ _id: userId },
|
||||
null,
|
||||
() => res.redirect('/')
|
||||
)
|
||||
}
|
||||
|
||||
let personalAccessTokens
|
||||
try {
|
||||
const results = await Modules.promises.hooks.fire(
|
||||
'listPersonalAccessTokens',
|
||||
user._id
|
||||
)
|
||||
personalAccessTokens = results?.[0] ?? []
|
||||
} catch (error) {
|
||||
const err = OError.tag(error, 'listPersonalAccessTokens hook failed')
|
||||
logger.error({ err, userId }, err.message)
|
||||
}
|
||||
|
||||
let currentManagedUserAdminEmail
|
||||
try {
|
||||
currentManagedUserAdminEmail =
|
||||
await SubscriptionLocator.promises.getAdminEmail(req.managedBy)
|
||||
} catch (err) {
|
||||
logger.error({ err }, 'error getting subscription admin email')
|
||||
}
|
||||
|
||||
let memberOfSSOEnabledGroups = []
|
||||
try {
|
||||
memberOfSSOEnabledGroups =
|
||||
(
|
||||
await Modules.promises.hooks.fire(
|
||||
'getUserGroupsSSOEnrollmentStatus',
|
||||
user._id,
|
||||
{ teamName: 1 },
|
||||
['email']
|
||||
)
|
||||
)?.[0] || []
|
||||
memberOfSSOEnabledGroups = memberOfSSOEnabledGroups.map(group => {
|
||||
return {
|
||||
groupId: group._id.toString(),
|
||||
linked: group.linked,
|
||||
groupName: group.teamName,
|
||||
adminEmail: group.admin_id?.email,
|
||||
}
|
||||
})
|
||||
} catch (error) {
|
||||
logger.error(
|
||||
{ err: error },
|
||||
'error fetching groups with Group SSO enabled the user may be member of'
|
||||
)
|
||||
}
|
||||
|
||||
// Get the users write-and-cite assignment to switch between translation strings
|
||||
await SplitTestHandler.promises.getAssignment(req, res, 'write-and-cite')
|
||||
// Get the users papers-integration assignment to show the linking widget
|
||||
await SplitTestHandler.promises.getAssignment(req, res, 'papers-integration')
|
||||
|
||||
res.render('user/settings', {
|
||||
title: 'account_settings',
|
||||
user: {
|
||||
id: user._id,
|
||||
isAdmin: user.isAdmin,
|
||||
email: user.email,
|
||||
allowedFreeTrial: user.allowedFreeTrial,
|
||||
first_name: user.first_name,
|
||||
last_name: user.last_name,
|
||||
alphaProgram: user.alphaProgram,
|
||||
betaProgram: user.betaProgram,
|
||||
labsProgram: user.labsProgram,
|
||||
features: {
|
||||
dropbox: user.features.dropbox,
|
||||
github: user.features.github,
|
||||
mendeley: user.features.mendeley,
|
||||
zotero: user.features.zotero,
|
||||
papers: user.features.papers,
|
||||
references: user.features.references,
|
||||
},
|
||||
refProviders: {
|
||||
mendeley: Boolean(user.refProviders?.mendeley),
|
||||
zotero: Boolean(user.refProviders?.zotero),
|
||||
papers: Boolean(user.refProviders?.papers),
|
||||
},
|
||||
writefull: {
|
||||
enabled: Boolean(user.writefull?.enabled),
|
||||
},
|
||||
aiErrorAssistant: {
|
||||
enabled: Boolean(user.aiErrorAssistant?.enabled),
|
||||
},
|
||||
sshkeys: {
|
||||
Public: user.sshPublicKey,
|
||||
Private: user.sshPrivateKey,
|
||||
},
|
||||
},
|
||||
hasPassword: !!user.hashedPassword,
|
||||
shouldAllowEditingDetails,
|
||||
oauthProviders: UserPagesController._translateProviderDescriptions(
|
||||
oauthProviders,
|
||||
req
|
||||
),
|
||||
institutionLinked,
|
||||
samlError,
|
||||
institutionEmailNonCanonical:
|
||||
institutionEmailNonCanonical && institutionRequestedEmail
|
||||
? institutionEmailNonCanonical
|
||||
: undefined,
|
||||
reconfirmedViaSAML,
|
||||
reconfirmationRemoveEmail,
|
||||
samlBeta: req.session.samlBeta,
|
||||
ssoErrorMessage,
|
||||
thirdPartyIds: UserPagesController._restructureThirdPartyIds(user),
|
||||
projectSyncSuccessMessage,
|
||||
personalAccessTokens,
|
||||
emailAddressLimit: Settings.emailAddressLimit,
|
||||
isManagedAccount: !!req.managedBy,
|
||||
userRestrictions: Array.from(req.userRestrictions || []),
|
||||
currentManagedUserAdminEmail,
|
||||
gitBridgeEnabled: Settings.enableGitBridge,
|
||||
isSaas: Features.hasFeature('saas'),
|
||||
memberOfSSOEnabledGroups,
|
||||
})
|
||||
}
|
||||
|
||||
async function accountSuspended(req, res) {
|
||||
if (SessionManager.isUserLoggedIn(req.session)) {
|
||||
return res.redirect('/project')
|
||||
}
|
||||
res.render('user/accountSuspended', {
|
||||
title: 'your_account_is_suspended',
|
||||
})
|
||||
}
|
||||
|
||||
async function reconfirmAccountPage(req, res) {
|
||||
const pageData = {
|
||||
reconfirm_email: req.session.reconfirm_email,
|
||||
}
|
||||
const { variant } = await SplitTestHandler.promises.getAssignment(
|
||||
req,
|
||||
res,
|
||||
'auth-pages-bs5'
|
||||
)
|
||||
|
||||
const template =
|
||||
variant === 'enabled' ? 'user/reconfirm-bs5' : 'user/reconfirm'
|
||||
|
||||
res.render(template, pageData)
|
||||
}
|
||||
|
||||
const UserPagesController = {
|
||||
accountSuspended: expressify(accountSuspended),
|
||||
|
||||
registerPage(req, res) {
|
||||
const sharedProjectData = req.session.sharedProjectData || {}
|
||||
|
||||
const newTemplateData = {}
|
||||
if (req.session.templateData != null) {
|
||||
newTemplateData.templateName = req.session.templateData.templateName
|
||||
}
|
||||
|
||||
res.render('user/register', {
|
||||
title: 'register',
|
||||
sharedProjectData,
|
||||
newTemplateData,
|
||||
samlBeta: req.session.samlBeta,
|
||||
})
|
||||
},
|
||||
|
||||
loginPage(req, res) {
|
||||
// if user is being sent to /login with explicit redirect (redir=/foo),
|
||||
// such as being sent from the editor to /login, then set the redirect explicitly
|
||||
if (
|
||||
req.query.redir != null &&
|
||||
AuthenticationController.getRedirectFromSession(req) == null
|
||||
) {
|
||||
AuthenticationController.setRedirectInSession(req, req.query.redir)
|
||||
}
|
||||
res.render('user/login', {
|
||||
title: Settings.nav?.login_support_title || 'login',
|
||||
login_support_title: Settings.nav?.login_support_title,
|
||||
login_support_text: Settings.nav?.login_support_text,
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Landing page for users who may have received one-time login
|
||||
* tokens from the read-only maintenance site.
|
||||
*
|
||||
* We tell them that Overleaf is back up and that they can login normally.
|
||||
*/
|
||||
oneTimeLoginPage(req, res, next) {
|
||||
res.render('user/one_time_login')
|
||||
},
|
||||
|
||||
renderReconfirmAccountPage: expressify(reconfirmAccountPage),
|
||||
|
||||
settingsPage: expressify(settingsPage),
|
||||
|
||||
sessionsPage(req, res, next) {
|
||||
const user = SessionManager.getSessionUser(req.session)
|
||||
logger.debug({ userId: user._id }, 'loading sessions page')
|
||||
const currentSession = {
|
||||
ip_address: user.ip_address,
|
||||
session_created: user.session_created,
|
||||
}
|
||||
UserSessionsManager.getAllUserSessions(
|
||||
user,
|
||||
[req.sessionID],
|
||||
(err, sessions) => {
|
||||
if (err != null) {
|
||||
OError.tag(err, 'error getting all user sessions', {
|
||||
userId: user._id,
|
||||
})
|
||||
return next(err)
|
||||
}
|
||||
res.render('user/sessions', {
|
||||
title: 'sessions',
|
||||
currentSession,
|
||||
sessions,
|
||||
})
|
||||
}
|
||||
)
|
||||
},
|
||||
|
||||
emailPreferencesPage(req, res, next) {
|
||||
const userId = SessionManager.getLoggedInUserId(req.session)
|
||||
UserGetter.getUser(
|
||||
userId,
|
||||
{ _id: 1, email: 1, first_name: 1, last_name: 1 },
|
||||
(err, user) => {
|
||||
if (err != null) {
|
||||
return next(err)
|
||||
}
|
||||
NewsletterManager.subscribed(user, (err, subscribed) => {
|
||||
if (err != null) {
|
||||
OError.tag(err, 'error getting newsletter subscription status')
|
||||
return next(err)
|
||||
}
|
||||
res.render('user/email-preferences', {
|
||||
title: 'newsletter_info_title',
|
||||
subscribed,
|
||||
})
|
||||
})
|
||||
}
|
||||
)
|
||||
},
|
||||
|
||||
async compromisedPasswordPage(req, res) {
|
||||
// Populates splitTestVariants with a value for the split test name and allows
|
||||
// Pug to read it
|
||||
await SplitTestHandler.promises.getAssignment(
|
||||
req,
|
||||
res,
|
||||
'bs5-misc-pages-platform'
|
||||
)
|
||||
|
||||
res.render('user/compromised_password')
|
||||
},
|
||||
|
||||
_restructureThirdPartyIds(user) {
|
||||
// 3rd party identifiers are an array of objects
|
||||
// this turn them into a single object, which
|
||||
// makes data easier to use in template
|
||||
if (
|
||||
!user.thirdPartyIdentifiers ||
|
||||
user.thirdPartyIdentifiers.length === 0
|
||||
) {
|
||||
return null
|
||||
}
|
||||
return user.thirdPartyIdentifiers.reduce((obj, identifier) => {
|
||||
obj[identifier.providerId] = identifier.externalUserId
|
||||
return obj
|
||||
}, {})
|
||||
},
|
||||
|
||||
_translateProviderDescriptions(providers, req) {
|
||||
const result = {}
|
||||
if (providers) {
|
||||
for (const provider in providers) {
|
||||
const data = providers[provider]
|
||||
data.description = req.i18n.translate(
|
||||
data.descriptionKey,
|
||||
Object.assign({}, data.descriptionOptions)
|
||||
)
|
||||
result[provider] = data
|
||||
}
|
||||
}
|
||||
return result
|
||||
},
|
||||
}
|
||||
|
||||
export default UserPagesController
|
246
install_unibremen/services/web/app/src/models/User.js
Normal file
246
install_unibremen/services/web/app/src/models/User.js
Normal file
|
@ -0,0 +1,246 @@
|
|||
const Settings = require('@overleaf/settings')
|
||||
const mongoose = require('../infrastructure/Mongoose')
|
||||
const TokenGenerator = require('../Features/TokenGenerator/TokenGenerator')
|
||||
const { Schema } = mongoose
|
||||
const { ObjectId } = Schema
|
||||
|
||||
// See https://stackoverflow.com/questions/386294/what-is-the-maximum-length-of-a-valid-email-address/574698#574698
|
||||
const MAX_EMAIL_LENGTH = 254
|
||||
const MAX_NAME_LENGTH = 255
|
||||
|
||||
const UserSchema = new Schema(
|
||||
{
|
||||
email: { type: String, default: '', maxlength: MAX_EMAIL_LENGTH },
|
||||
emails: [
|
||||
{
|
||||
email: { type: String, default: '', maxlength: MAX_EMAIL_LENGTH },
|
||||
reversedHostname: { type: String, default: '' },
|
||||
createdAt: {
|
||||
type: Date,
|
||||
default() {
|
||||
return new Date()
|
||||
},
|
||||
},
|
||||
confirmedAt: { type: Date },
|
||||
samlProviderId: { type: String },
|
||||
affiliationUnchecked: { type: Boolean },
|
||||
reconfirmedAt: { type: Date },
|
||||
},
|
||||
],
|
||||
first_name: {
|
||||
type: String,
|
||||
default: '',
|
||||
maxlength: MAX_NAME_LENGTH,
|
||||
},
|
||||
last_name: {
|
||||
type: String,
|
||||
default: '',
|
||||
maxlength: MAX_NAME_LENGTH,
|
||||
},
|
||||
role: { type: String, default: '' },
|
||||
institution: { type: String, default: '' },
|
||||
hashedPassword: String,
|
||||
enrollment: {
|
||||
sso: [
|
||||
{
|
||||
groupId: {
|
||||
type: ObjectId,
|
||||
ref: 'Subscription',
|
||||
},
|
||||
linkedAt: Date,
|
||||
primary: { type: Boolean, default: false },
|
||||
},
|
||||
],
|
||||
managedBy: {
|
||||
type: ObjectId,
|
||||
ref: 'Subscription',
|
||||
},
|
||||
enrolledAt: { type: Date },
|
||||
},
|
||||
isAdmin: { type: Boolean, default: false },
|
||||
staffAccess: {
|
||||
publisherMetrics: { type: Boolean, default: false },
|
||||
publisherManagement: { type: Boolean, default: false },
|
||||
institutionMetrics: { type: Boolean, default: false },
|
||||
institutionManagement: { type: Boolean, default: false },
|
||||
groupMetrics: { type: Boolean, default: false },
|
||||
groupManagement: { type: Boolean, default: false },
|
||||
adminMetrics: { type: Boolean, default: false },
|
||||
splitTestMetrics: { type: Boolean, default: false },
|
||||
splitTestManagement: { type: Boolean, default: false },
|
||||
},
|
||||
signUpDate: {
|
||||
type: Date,
|
||||
default() {
|
||||
return new Date()
|
||||
},
|
||||
},
|
||||
loginEpoch: { type: Number },
|
||||
lastActive: { type: Date },
|
||||
lastFailedLogin: { type: Date },
|
||||
lastLoggedIn: { type: Date },
|
||||
lastLoginIp: { type: String, default: '' },
|
||||
lastPrimaryEmailCheck: { type: Date },
|
||||
lastTrial: { type: Date },
|
||||
loginCount: { type: Number, default: 0 },
|
||||
holdingAccount: { type: Boolean, default: false },
|
||||
ace: {
|
||||
mode: { type: String, default: 'none' },
|
||||
theme: { type: String, default: 'textmate' },
|
||||
overallTheme: { type: String, default: '' },
|
||||
fontSize: { type: Number, default: '12' },
|
||||
autoComplete: { type: Boolean, default: true },
|
||||
autoPairDelimiters: { type: Boolean, default: true },
|
||||
spellCheckLanguage: { type: String, default: 'en' },
|
||||
pdfViewer: { type: String, default: 'pdfjs' },
|
||||
syntaxValidation: { type: Boolean },
|
||||
fontFamily: { type: String },
|
||||
lineHeight: { type: String },
|
||||
mathPreview: { type: Boolean, default: true },
|
||||
referencesSearchMode: { type: String, default: 'advanced' }, // 'advanced' or 'simple'
|
||||
enableNewEditor: { type: Boolean },
|
||||
},
|
||||
features: {
|
||||
collaborators: {
|
||||
type: Number,
|
||||
default: Settings.defaultFeatures.collaborators,
|
||||
},
|
||||
versioning: {
|
||||
type: Boolean,
|
||||
default: Settings.defaultFeatures.versioning,
|
||||
},
|
||||
dropbox: { type: Boolean, default: Settings.defaultFeatures.dropbox },
|
||||
github: { type: Boolean, default: Settings.defaultFeatures.github },
|
||||
gitBridge: { type: Boolean, default: Settings.defaultFeatures.gitBridge },
|
||||
compileTimeout: {
|
||||
type: Number,
|
||||
default: Settings.defaultFeatures.compileTimeout,
|
||||
},
|
||||
compileGroup: {
|
||||
type: String,
|
||||
default: Settings.defaultFeatures.compileGroup,
|
||||
},
|
||||
references: {
|
||||
type: Boolean,
|
||||
default: Settings.defaultFeatures.references,
|
||||
},
|
||||
trackChanges: {
|
||||
type: Boolean,
|
||||
default: Settings.defaultFeatures.trackChanges,
|
||||
},
|
||||
mendeley: { type: Boolean, default: Settings.defaultFeatures.mendeley },
|
||||
zotero: { type: Boolean, default: Settings.defaultFeatures.zotero },
|
||||
papers: { type: Boolean, default: Settings.defaultFeatures.papers },
|
||||
referencesSearch: {
|
||||
type: Boolean,
|
||||
default: Settings.defaultFeatures.referencesSearch,
|
||||
},
|
||||
symbolPalette: {
|
||||
type: Boolean,
|
||||
default: Settings.defaultFeatures.symbolPalette,
|
||||
},
|
||||
aiErrorAssistant: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
},
|
||||
featuresOverrides: [
|
||||
{
|
||||
createdAt: {
|
||||
type: Date,
|
||||
default() {
|
||||
return new Date()
|
||||
},
|
||||
},
|
||||
expiresAt: { type: Date },
|
||||
note: { type: String },
|
||||
features: {
|
||||
aiErrorAssistant: { type: Boolean },
|
||||
collaborators: { type: Number },
|
||||
versioning: { type: Boolean },
|
||||
dropbox: { type: Boolean },
|
||||
github: { type: Boolean },
|
||||
gitBridge: { type: Boolean },
|
||||
compileTimeout: { type: Number },
|
||||
compileGroup: { type: String },
|
||||
templates: { type: Boolean },
|
||||
trackChanges: { type: Boolean },
|
||||
mendeley: { type: Boolean },
|
||||
papers: { type: Boolean },
|
||||
zotero: { type: Boolean },
|
||||
referencesSearch: { type: Boolean },
|
||||
symbolPalette: { type: Boolean },
|
||||
},
|
||||
},
|
||||
],
|
||||
featuresUpdatedAt: { type: Date },
|
||||
featuresEpoch: {
|
||||
type: String,
|
||||
},
|
||||
must_reconfirm: { type: Boolean, default: false },
|
||||
referal_id: {
|
||||
type: String,
|
||||
default() {
|
||||
return TokenGenerator.generateReferralId()
|
||||
},
|
||||
},
|
||||
refered_users: [{ type: ObjectId, ref: 'User' }],
|
||||
refered_user_count: { type: Number, default: 0 },
|
||||
refProviders: {
|
||||
// The actual values are managed by third-party-references.
|
||||
mendeley: Schema.Types.Mixed,
|
||||
zotero: Schema.Types.Mixed,
|
||||
papers: Schema.Types.Mixed,
|
||||
},
|
||||
writefull: {
|
||||
enabled: { type: Boolean, default: null },
|
||||
autoCreatedAccount: { type: Boolean, default: false },
|
||||
isPremium: { type: Boolean, default: false },
|
||||
},
|
||||
aiErrorAssistant: {
|
||||
enabled: { type: Boolean, default: true },
|
||||
},
|
||||
alphaProgram: { type: Boolean, default: false }, // experimental features
|
||||
betaProgram: { type: Boolean, default: false },
|
||||
labsProgram: { type: Boolean, default: false },
|
||||
overleaf: {
|
||||
id: { type: Number },
|
||||
accessToken: { type: String },
|
||||
refreshToken: { type: String },
|
||||
},
|
||||
awareOfV2: { type: Boolean, default: false },
|
||||
samlIdentifiers: { type: Array, default: [] },
|
||||
thirdPartyIdentifiers: { type: Array, default: [] },
|
||||
migratedAt: { type: Date },
|
||||
twoFactorAuthentication: {
|
||||
createdAt: { type: Date },
|
||||
enrolledAt: { type: Date },
|
||||
secretEncrypted: { type: String },
|
||||
},
|
||||
onboardingEmailSentAt: { type: Date },
|
||||
splitTests: Schema.Types.Mixed,
|
||||
analyticsId: { type: String },
|
||||
completedTutorials: Schema.Types.Mixed,
|
||||
suspended: { type: Boolean },
|
||||
sshPublicKey: { type: String, default: "" },
|
||||
sshPrivateKey: { type: String, default: "" },
|
||||
},
|
||||
{ minimize: false }
|
||||
)
|
||||
|
||||
function formatSplitTestsSchema(next) {
|
||||
if (this.splitTests) {
|
||||
for (const splitTestKey of Object.keys(this.splitTests)) {
|
||||
for (const variantIndex in this.splitTests[splitTestKey]) {
|
||||
this.splitTests[splitTestKey][variantIndex].assignedAt = new Date(
|
||||
this.splitTests[splitTestKey][variantIndex].assignedAt
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
next()
|
||||
}
|
||||
UserSchema.pre('save', formatSplitTestsSchema)
|
||||
|
||||
exports.User = mongoose.model('User', UserSchema)
|
||||
exports.UserSchema = UserSchema
|
74
install_unibremen/services/web/app/views/user/login.pug
Normal file
74
install_unibremen/services/web/app/views/user/login.pug
Normal file
|
@ -0,0 +1,74 @@
|
|||
extends ../layout-marketing
|
||||
|
||||
block vars
|
||||
- bootstrap5PageStatus = 'disabled'
|
||||
|
||||
block content
|
||||
main.content.content-alt#main-content
|
||||
.container
|
||||
.row
|
||||
.col-md-6.col-md-offset-3.col-lg-4.col-lg-offset-4
|
||||
.card
|
||||
.page-header
|
||||
if login_support_title
|
||||
h1 !{login_support_title}
|
||||
else
|
||||
h1 #{translate("log_in")}
|
||||
if settings.loginPageEnableLogo
|
||||
img(src=settings.loginPagelogoUrl style='width:300px;')
|
||||
p
|
||||
if settings.localLoginEnable
|
||||
form(data-ol-async-form, name="loginForm", action='/login', method="POST")
|
||||
input(name='_csrf', type='hidden', value=csrfToken)
|
||||
+formMessages()
|
||||
+customFormMessage('invalid-password-retry-or-reset', 'danger')
|
||||
| !{translate('email_or_password_wrong_try_again_or_reset', {}, [{ name: 'a', attrs: { href: '/user/password/reset', 'aria-describedby': 'resetPasswordDescription' } }])}
|
||||
span.sr-only(id='resetPasswordDescription')
|
||||
| #{translate('reset_password_link')}
|
||||
+customValidationMessage('password-compromised')
|
||||
| !{translate('password_compromised_try_again_or_use_known_device_or_reset', {}, [{name: 'a', attrs: {href: 'https://haveibeenpwned.com/passwords', rel: 'noopener noreferrer', target: '_blank'}}, {name: 'a', attrs: {href: '/user/password/reset', target: '_blank'}}])}.
|
||||
.form-group
|
||||
input.form-control(
|
||||
type=(settings.ldap && settings.ldap.enable) ? 'text' : 'email',
|
||||
name='email',
|
||||
required,
|
||||
placeholder=(settings.ldap && settings.ldap.enable) ? settings.ldap.placeholder : 'email@example.com',
|
||||
autofocus="true"
|
||||
)
|
||||
.form-group
|
||||
input.form-control(
|
||||
type='password',
|
||||
name='password',
|
||||
required,
|
||||
placeholder='********',
|
||||
)
|
||||
.actions
|
||||
button.btn-primary.btn(
|
||||
type='submit',
|
||||
data-ol-disabled-inflight
|
||||
)
|
||||
span(data-ol-inflight="idle") #{translate("login")}
|
||||
span(hidden data-ol-inflight="pending") #{translate("logging_in")}…
|
||||
a.pull-right(href='/user/password/reset') #{translate("forgot_your_password")}?
|
||||
if login_support_text
|
||||
hr
|
||||
p.text-center !{login_support_text}
|
||||
|
||||
if settings.saml && settings.saml.enable
|
||||
form(data-ol-async-form, name="samlLoginForm")
|
||||
.actions(style='margin-top: 30px;')
|
||||
a.btn.btn-secondary.btn-block(
|
||||
href='/saml/login',
|
||||
data-ol-disabled-inflight
|
||||
)
|
||||
span(data-ol-inflight="idle") #{settings.saml.identityServiceName}
|
||||
span(hidden data-ol-inflight="pending") #{translate("logging_in")}…
|
||||
if settings.oidc && settings.oidc.enable
|
||||
form(data-ol-async-form, name="oidcLoginForm")
|
||||
.actions(style='margin-top: 30px;')
|
||||
a.btn.btn-secondary.btn-block(
|
||||
href='/oidc/login',
|
||||
data-ol-disabled-inflight
|
||||
)
|
||||
span(data-ol-inflight="idle") #{settings.oidc.identityServiceName}
|
||||
span(hidden data-ol-inflight="pending") #{translate("logging_in")}…
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue