Add all repos
This commit is contained in:
parent
faa12c60bc
commit
8a91c9b89b
369 changed files with 29047 additions and 28 deletions
6
zammad-addon-pgp/.gitignore
vendored
Normal file
6
zammad-addon-pgp/.gitignore
vendored
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
dist/
|
||||
.env*
|
||||
node_modules/
|
||||
npm-debug.log*
|
||||
*.szpm
|
||||
.DS_Store
|
||||
25
zammad-addon-pgp/.gitlab-ci.yml
Normal file
25
zammad-addon-pgp/.gitlab-ci.yml
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
---
|
||||
image: registry.gitlab.com/guardianproject-ops/docker-python-node:python3.8-nodejs12
|
||||
|
||||
stages:
|
||||
- test
|
||||
- build
|
||||
- trigger
|
||||
|
||||
before_script:
|
||||
- apt-get update && apt-get install -y make ruby
|
||||
- gem install rufo -v 0.12.0
|
||||
- pip install inflection
|
||||
|
||||
test:
|
||||
stage: test
|
||||
script:
|
||||
- echo "Skipping tests" # make test
|
||||
|
||||
build:
|
||||
stage: build
|
||||
artifacts:
|
||||
paths:
|
||||
- dist/*.szpm
|
||||
script:
|
||||
- make
|
||||
1
zammad-addon-pgp/.ruby-version
Normal file
1
zammad-addon-pgp/.ruby-version
Normal file
|
|
@ -0,0 +1 @@
|
|||
2.6.6
|
||||
10
zammad-addon-pgp/Gemfile
Normal file
10
zammad-addon-pgp/Gemfile
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
source 'https://rubygems.org'
|
||||
# git_source(:git) { |repo| "https://github.com/#{repo}.git" }
|
||||
|
||||
ruby '2.6.5'
|
||||
|
||||
# Use Sequoia for PGP encryption
|
||||
# gem "sequoia-ruby-ffi", git: "https://gitlab.com/dorle/sequoia-ruby-ffi"
|
||||
|
||||
# Use ruby_openpgp implementation of Sequoia for PGP encryption
|
||||
gem 'ruby_openpgp', git: "https://github.com/throneless-tech/ruby_openpgp"
|
||||
60
zammad-addon-pgp/Gemfile.lock
Normal file
60
zammad-addon-pgp/Gemfile.lock
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
PATH
|
||||
remote: /Users/rae/Sites/Throneless/ruby_openpgp
|
||||
specs:
|
||||
ruby_openpgp (0.1.0)
|
||||
ffi (~> 1)
|
||||
rake (~> 13)
|
||||
rspec (~> 3)
|
||||
rubocop (~> 1.7)
|
||||
|
||||
GEM
|
||||
remote: https://rubygems.org/
|
||||
specs:
|
||||
ast (2.4.2)
|
||||
diff-lcs (1.4.4)
|
||||
ffi (1.15.0)
|
||||
parallel (1.20.1)
|
||||
parser (3.0.1.1)
|
||||
ast (~> 2.4.1)
|
||||
rainbow (3.0.0)
|
||||
rake (13.0.3)
|
||||
regexp_parser (2.1.1)
|
||||
rexml (3.2.5)
|
||||
rspec (3.10.0)
|
||||
rspec-core (~> 3.10.0)
|
||||
rspec-expectations (~> 3.10.0)
|
||||
rspec-mocks (~> 3.10.0)
|
||||
rspec-core (3.10.1)
|
||||
rspec-support (~> 3.10.0)
|
||||
rspec-expectations (3.10.1)
|
||||
diff-lcs (>= 1.2.0, < 2.0)
|
||||
rspec-support (~> 3.10.0)
|
||||
rspec-mocks (3.10.2)
|
||||
diff-lcs (>= 1.2.0, < 2.0)
|
||||
rspec-support (~> 3.10.0)
|
||||
rspec-support (3.10.2)
|
||||
rubocop (1.14.0)
|
||||
parallel (~> 1.10)
|
||||
parser (>= 3.0.0.0)
|
||||
rainbow (>= 2.2.2, < 4.0)
|
||||
regexp_parser (>= 1.8, < 3.0)
|
||||
rexml
|
||||
rubocop-ast (>= 1.5.0, < 2.0)
|
||||
ruby-progressbar (~> 1.7)
|
||||
unicode-display_width (>= 1.4.0, < 3.0)
|
||||
rubocop-ast (1.5.0)
|
||||
parser (>= 3.0.1.1)
|
||||
ruby-progressbar (1.11.0)
|
||||
unicode-display_width (2.0.0)
|
||||
|
||||
PLATFORMS
|
||||
x86_64-darwin-18
|
||||
|
||||
DEPENDENCIES
|
||||
ruby_openpgp!
|
||||
|
||||
RUBY VERSION
|
||||
ruby 2.6.5p114
|
||||
|
||||
BUNDLED WITH
|
||||
2.2.9
|
||||
616
zammad-addon-pgp/LICENSE.md
Normal file
616
zammad-addon-pgp/LICENSE.md
Normal file
|
|
@ -0,0 +1,616 @@
|
|||
### GNU AFFERO GENERAL PUBLIC LICENSE
|
||||
|
||||
Version 3, 19 November 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc.
|
||||
<https://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
|
||||
28
zammad-addon-pgp/Makefile
Normal file
28
zammad-addon-pgp/Makefile
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
.PHONY: prep clean
|
||||
|
||||
build: prep
|
||||
@./package.py
|
||||
@find dist/ -iname "*szpm"
|
||||
|
||||
prep:
|
||||
@mkdir -p dist
|
||||
|
||||
clean: prep
|
||||
@rm -rf dist/*
|
||||
|
||||
fmt:
|
||||
rufo src
|
||||
|
||||
new-migration:
|
||||
@./new-migration.py
|
||||
|
||||
init:
|
||||
@echo "Give your addon a name. No spaces."
|
||||
@echo "Addon name?: "; \
|
||||
read NAME; \
|
||||
mkdir -p "src/db/addon/$${NAME}"; \
|
||||
sed -i "s/NAME/$${NAME}/" base.szpm.template; \
|
||||
mv base.szpm.template "$${NAME}.szpm.template"
|
||||
|
||||
test:
|
||||
@echo "there are no tests yet"
|
||||
51
zammad-addon-pgp/README.md
Normal file
51
zammad-addon-pgp/README.md
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
# zammad-addon-pgp
|
||||
|
||||
Adds PGP integration into [Zammad](https://zammad.org) via [Sequoia](https://sequoia-pgp.org).
|
||||
|
||||
## Configuration
|
||||
|
||||
Once PGP addon has been successfully installed, there are a few steps required to set it up for use. This is also assuming that Zammad has already been correctly configured for sending and receiving email, and that you have command-line access to a system with the [gnupg](https://gnupg.org) client installed for generating and manipulating keys.
|
||||
|
||||
### For Thunderbird users
|
||||
|
||||
If you generated and manage your key through a current version of Thunderbird (see [here](https://support.mozilla.org/en-US/kb/openpgp-thunderbird-howto-and-faq) for general information on how to generate keys and use PGP in versions of Thunderbird 78 and above), you will need to use the following steps to prepare for the instructions below assuming you already have a key:
|
||||
|
||||
1. Go to `Account Settings -> End-To-End Encryption` for the relevant account and click the 'OpenPGP Key Manager' button to access the key manager.
|
||||
2. Click the relevant key and select `File -> Backup Secret Key(s) to File` and select a place to save the key file.
|
||||
3. It will ask you to set a passphrase for the key, make sure to note this down for use below.
|
||||
4. After the key has been saved to a file, go to that file in a terminal and run `gpg --import <key file>`. It will ask you for the passphrase you just set.
|
||||
5. Go to #2 below and continue with the instructions.
|
||||
|
||||
### Generate helpdesk key
|
||||
|
||||
In order to receive encrypted email, the Zammad helpdesk must have a PGP key associated with its email address. You can follow the instructions [here](https://docs.github.com/en/authentication/managing-commit-signature-verification/generating-a-new-gpg-key) in order to generate such a key if you do not already have one; when you get to the step where you enter your email address, use the email address associated with your Zammad installation.
|
||||
|
||||
1. Generate the key, using the instructions above. Make a note of the corresponding keyid.
|
||||
2. You'll need to remove the passphrase from the private key before adding it to Zammad. To do this, edit the key: `gpg --edit-key <keyid>`
|
||||
3. In the resulting prompt, type `passwd`. Enter the passphrasse you set during key generation, and when you are prompted for a new passphrase just leave it blank and hit 'enter' twice and confirm.
|
||||
4. As an admin user, go to the Zammad settings panel and under `Channels -> PGP Support` and click the `Add Key` button at the top.
|
||||
5. In your terminal, export the private key with `gpg --export-secret-key --armor <keyid>` and paste the entire resulting text block including the header and footer into the box for the private key. Do the same for the public key box by exporting with `gpg --export --armor <keyid>`. Select the group the key is associated with ('Users' by default).
|
||||
6. Submit the changes
|
||||
|
||||
Now your helpdesk is configured to accept encrypted email!
|
||||
|
||||
### Set user keys
|
||||
|
||||
In order to send an encrypted reply to a user who has submitted a ticket, they must have a public key configured. Either that user or an admin can go to settings under `Manage -> Users`, select the user account, and paste their public key in the `PGP Public Key` box. The key can be exported by the user by running `gpg --export --armor <keyid>`, where <keyid> is the keyid of the key associated with the email address with which they are sending an email to the helpdesk. Then submit the changes.
|
||||
|
||||
The helpdesk can now send encrypted email to that user!
|
||||
|
||||
## Help and Support
|
||||
|
||||
Join us in our public matrix channel [#cdr-link-dev-support:matrix.org](https://matrix.to/#/#cdr-link-dev-support:matrix.org?via=matrix.org&via=neo.keanu.im).
|
||||
|
||||
## License
|
||||
|
||||
[](https://gitlab.com/digiresilience/link/zamamd-addon-sigarillo/blob/master/LICENSE.md)
|
||||
|
||||
This is a free software project licensed under the GNU Affero General
|
||||
Public License v3.0 (GNU AGPLv3) by [The Center for Digital
|
||||
Resilience](https://digiresilience.org) and [Guardian
|
||||
Project](https://guardianproject.info).
|
||||
|
||||
🤸
|
||||
0
zammad-addon-pgp/Rakefile
Normal file
0
zammad-addon-pgp/Rakefile
Normal file
43
zammad-addon-pgp/new-migration.py
Normal file
43
zammad-addon-pgp/new-migration.py
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
#!/usr/bin/env python3
|
||||
import os
|
||||
import json
|
||||
import glob
|
||||
import inflection
|
||||
from datetime import datetime
|
||||
from collections import OrderedDict
|
||||
|
||||
migration_template = """class {} < ActiveRecord::Migration[5.2]
|
||||
def self.up
|
||||
# add your code here
|
||||
end
|
||||
|
||||
def self.down
|
||||
# add your code here
|
||||
end
|
||||
end
|
||||
"""
|
||||
|
||||
|
||||
def load_skeleton():
|
||||
t = glob.glob('*.szpm.template')
|
||||
if len(t) != 1:
|
||||
raise Exception("Cannot find szpm template")
|
||||
with open(t[0], 'r', encoding='utf-8') as f:
|
||||
skeleton = json.load(f, object_pairs_hook=OrderedDict)
|
||||
return skeleton
|
||||
|
||||
|
||||
def main():
|
||||
skeleton = load_skeleton()
|
||||
name = skeleton["name"].lower()
|
||||
raw_name = input("Enter migration name: ")
|
||||
migration_base_name = "{}_{}".format(name, inflection.underscore(raw_name))
|
||||
migration_name = inflection.camelize(migration_base_name, uppercase_first_letter=True)
|
||||
contents = migration_template.format(migration_name)
|
||||
time = datetime.utcnow().strftime("%Y%m%d%H%M%S")
|
||||
migration_file_name = "{}_{}.rb".format(time, migration_base_name)
|
||||
with open(os.path.join("src/db/addon/", skeleton["name"], migration_file_name), 'w') as f:
|
||||
f.write(contents)
|
||||
|
||||
|
||||
main()
|
||||
75
zammad-addon-pgp/package.py
Executable file
75
zammad-addon-pgp/package.py
Executable file
|
|
@ -0,0 +1,75 @@
|
|||
#!/usr/bin/env python3
|
||||
import os
|
||||
import base64
|
||||
import json
|
||||
import datetime
|
||||
import platform
|
||||
import glob
|
||||
import re
|
||||
from collections import OrderedDict
|
||||
|
||||
# files matching this pattern are not included in the package
|
||||
ignored_patterns = [
|
||||
"\.gitkeep"
|
||||
]
|
||||
|
||||
|
||||
def encode(fname):
|
||||
data = open(fname, "r", encoding='utf-8').read().encode('utf-8')
|
||||
return base64.b64encode(data).decode('utf-8')
|
||||
|
||||
|
||||
def read_perm(fname):
|
||||
return int(oct(os.stat(fname).st_mode & 0o777)[-3:])
|
||||
|
||||
|
||||
def format_file(content, pkg_path, permission):
|
||||
return OrderedDict(
|
||||
location=pkg_path,
|
||||
permission=permission,
|
||||
encode="base64",
|
||||
content=content)
|
||||
|
||||
|
||||
def pkg_file(actual_path):
|
||||
print(" Packaging: {}".format(actual_path))
|
||||
pkg_path = actual_path[6:]
|
||||
contents = encode(actual_path)
|
||||
res = format_file(contents, pkg_path, read_perm(actual_path))
|
||||
return res
|
||||
|
||||
|
||||
def pkg_files():
|
||||
pkged_files = []
|
||||
for root, dirs, files in os.walk("./src/"):
|
||||
for f in files:
|
||||
if any(re.search(r, f) for r in ignored_patterns):
|
||||
continue
|
||||
actual_path = os.path.join(root, f)
|
||||
pkged_files.append(pkg_file(actual_path))
|
||||
return pkged_files
|
||||
|
||||
|
||||
def load_skeleton():
|
||||
t = glob.glob('*.szpm.template')
|
||||
if len(t) != 1:
|
||||
raise Exception("Cannot find szpm template")
|
||||
with open(t[0], 'r', encoding='utf-8') as f:
|
||||
skeleton = json.load(f, object_pairs_hook=OrderedDict)
|
||||
return skeleton
|
||||
|
||||
|
||||
def main():
|
||||
files = pkg_files()
|
||||
skeleton = load_skeleton()
|
||||
skeleton["files"] = files
|
||||
skeleton["builddate"] = datetime.datetime.utcnow().isoformat()
|
||||
skeleton["buildhost"] = platform.node()
|
||||
name = skeleton["name"].lower()
|
||||
version = skeleton["version"]
|
||||
pkg = json.dumps(skeleton, indent=2)
|
||||
with open("dist/{}-v{}.szpm".format(name, version), "w", encoding='utf-8') as f:
|
||||
f.write(pkg)
|
||||
|
||||
|
||||
main()
|
||||
|
|
@ -0,0 +1,256 @@
|
|||
class Index extends App.ControllerIntegrationBase
|
||||
featureIntegration: 'pgp_integration'
|
||||
featureName: 'PGP'
|
||||
featureConfig: 'pgp_config'
|
||||
description: [
|
||||
['PGP (Pretty Good Privacy) is a widely accepted method (or more precisely, a protocol) for sending digitally signed and encrypted messages.']
|
||||
]
|
||||
events:
|
||||
'change .js-switch input': 'switch'
|
||||
|
||||
render: =>
|
||||
super
|
||||
new Form(
|
||||
el: @$('.js-form')
|
||||
)
|
||||
|
||||
new App.HttpLog(
|
||||
el: @$('.js-log')
|
||||
facility: 'PGP'
|
||||
)
|
||||
|
||||
class Form extends App.Controller
|
||||
events:
|
||||
'click .js-addPublicKey': 'addPublicKey'
|
||||
'click .js-addPrivateKey': 'addPrivateKey'
|
||||
'click .js-updateGroup': 'updateGroup'
|
||||
|
||||
constructor: ->
|
||||
super
|
||||
@render()
|
||||
|
||||
currentConfig: ->
|
||||
App.Setting.get('pgp_config')
|
||||
|
||||
setConfig: (value) ->
|
||||
App.Setting.set('pgp_config', value, {notify: true})
|
||||
|
||||
render: =>
|
||||
@config = @currentConfig()
|
||||
|
||||
@html App.view('integration/pgp')(
|
||||
config: @config
|
||||
)
|
||||
@keyList()
|
||||
@groupList()
|
||||
|
||||
keyList: =>
|
||||
new List(el: @$('.js-keyList'))
|
||||
|
||||
groupList: =>
|
||||
new Group(
|
||||
el: @$('.js-groupList')
|
||||
config: @config
|
||||
)
|
||||
|
||||
addPublicKey: =>
|
||||
new PublicKey(
|
||||
callback: @keyList
|
||||
)
|
||||
|
||||
addPrivateKey: =>
|
||||
new PrivateKey(
|
||||
callback: @keyList
|
||||
)
|
||||
|
||||
updateGroup: (e) =>
|
||||
params = App.ControllerForm.params(e)
|
||||
@setConfig(params)
|
||||
|
||||
class PublicKey extends App.ControllerModal
|
||||
buttonClose: true
|
||||
buttonCancel: true
|
||||
buttonSubmit: 'Add'
|
||||
autoFocusOnFirstInput: false
|
||||
head: 'Add Public Key'
|
||||
large: true
|
||||
|
||||
content: ->
|
||||
|
||||
# show start dialog
|
||||
content = $(App.view('integration/pgp_public_key_add')(
|
||||
head: 'Add Public Key'
|
||||
))
|
||||
content
|
||||
|
||||
onSubmit: (e) =>
|
||||
params = new FormData($(e.currentTarget).closest('form').get(0))
|
||||
params.set('try', true)
|
||||
if _.isEmpty(params.get('data'))
|
||||
params.delete('data')
|
||||
@formDisable(e)
|
||||
|
||||
@ajax(
|
||||
id: 'pgp-public_key-add'
|
||||
type: 'POST'
|
||||
url: "#{@apiPath}/integration/pgp/public_key"
|
||||
processData: false
|
||||
contentType: false
|
||||
cache: false
|
||||
data: params
|
||||
success: (data, status, xhr) =>
|
||||
@close()
|
||||
@callback()
|
||||
error: (data) =>
|
||||
@close()
|
||||
details = data.responseJSON || {}
|
||||
@notify
|
||||
type: 'error'
|
||||
msg: App.i18n.translateContent(details.error_human || details.error || 'The import failed.')
|
||||
timeout: 6000
|
||||
)
|
||||
|
||||
class PrivateKey extends App.ControllerModal
|
||||
buttonClose: true
|
||||
buttonCancel: true
|
||||
buttonSubmit: 'Add'
|
||||
autoFocusOnFirstInput: false
|
||||
head: 'Add Private Key'
|
||||
large: true
|
||||
|
||||
content: ->
|
||||
|
||||
# show start dialog
|
||||
content = $(App.view('integration/pgp_private_key_add')(
|
||||
head: 'Add Private Key'
|
||||
))
|
||||
content
|
||||
|
||||
onSubmit: (e) =>
|
||||
params = new FormData($(e.currentTarget).closest('form').get(0))
|
||||
params.set('try', true)
|
||||
if _.isEmpty(params.get('data'))
|
||||
params.delete('data')
|
||||
@formDisable(e)
|
||||
|
||||
@ajax(
|
||||
id: 'pgp-private_key-add'
|
||||
type: 'POST'
|
||||
url: "#{@apiPath}/integration/pgp/private_key"
|
||||
processData: false
|
||||
contentType: false
|
||||
cache: false
|
||||
data: params
|
||||
success: (data, status, xhr) =>
|
||||
@close()
|
||||
@callback()
|
||||
error: (data) =>
|
||||
@close()
|
||||
details = data.responseJSON || {}
|
||||
@notify
|
||||
type: 'error'
|
||||
msg: App.i18n.translateContent(details.error_human || details.error || 'The import failed.')
|
||||
timeout: 6000
|
||||
)
|
||||
|
||||
|
||||
class List extends App.Controller
|
||||
events:
|
||||
'click .js-remove': 'remove'
|
||||
|
||||
constructor: ->
|
||||
super
|
||||
@load()
|
||||
|
||||
load: =>
|
||||
@ajax(
|
||||
id: 'pgp-list'
|
||||
type: 'GET'
|
||||
url: "#{@apiPath}/integration/pgp/public_key"
|
||||
success: (data, status, xhr) =>
|
||||
@render(data)
|
||||
|
||||
error: (data, status) =>
|
||||
|
||||
# do not close window if request is aborted
|
||||
return if status is 'abort'
|
||||
|
||||
details = data.responseJSON || {}
|
||||
@notify(
|
||||
type: 'error'
|
||||
msg: App.i18n.translateContent(details.error_human || details.error || 'Loading failed.')
|
||||
)
|
||||
|
||||
# do something
|
||||
)
|
||||
|
||||
render: (data) =>
|
||||
@html App.view('integration/pgp_list')(
|
||||
keyPairs: data
|
||||
)
|
||||
|
||||
remove: (e) =>
|
||||
e.preventDefault()
|
||||
id = $(e.currentTarget).parents('tr').data('id')
|
||||
return if !id
|
||||
|
||||
@ajax(
|
||||
id: 'pgp-list'
|
||||
type: 'DELETE'
|
||||
url: "#{@apiPath}/integration/pgp/public_key"
|
||||
data: JSON.stringify(id: id)
|
||||
success: (data, status, xhr) =>
|
||||
@load()
|
||||
|
||||
error: (data, status) =>
|
||||
|
||||
# do not close window if request is aborted
|
||||
return if status is 'abort'
|
||||
|
||||
details = data.responseJSON || {}
|
||||
@notify(
|
||||
type: 'error'
|
||||
msg: App.i18n.translateContent(details.error_human || details.error || 'Server operation failed.')
|
||||
)
|
||||
)
|
||||
|
||||
class Group extends App.Controller
|
||||
constructor: ->
|
||||
super
|
||||
@render()
|
||||
|
||||
render: (data) =>
|
||||
groups = App.Group.search(sortBy: 'name', filter: active: true)
|
||||
@html App.view('integration/pgp_group')(
|
||||
groups: groups
|
||||
)
|
||||
for group in groups
|
||||
for type, selector of { default_sign: 'js-signDefault', default_encryption: 'js-encryptionDefault' }
|
||||
selected = true
|
||||
if @config?.group_id && @config.group_id[type]
|
||||
selected = @config.group_id[type][group.id.toString()]
|
||||
selection = App.UiElement.boolean.render(
|
||||
name: "group_id::#{type}::#{group.id}"
|
||||
multiple: false
|
||||
null: false
|
||||
nulloption: false
|
||||
value: selected
|
||||
class: 'form-control--small'
|
||||
)
|
||||
@$("[data-id=#{group.id}] .#{selector}").html(selection)
|
||||
|
||||
class State
|
||||
@current: ->
|
||||
App.Setting.get('pgp_integration')
|
||||
|
||||
App.Config.set(
|
||||
'Integrationpgp'
|
||||
{
|
||||
name: 'PGP'
|
||||
target: '#system/integration/pgp'
|
||||
description: 'PGP enables you to send digitally signed and encrypted messages.'
|
||||
controller: Index
|
||||
state: State
|
||||
}
|
||||
'NavBarIntegrations'
|
||||
)
|
||||
|
|
@ -0,0 +1,614 @@
|
|||
# coffeelint: disable=camel_case_classes
|
||||
class App.UiElement.ticket_perform_action
|
||||
@defaults: (attribute) ->
|
||||
defaults = ['ticket.state_id']
|
||||
|
||||
groups =
|
||||
ticket:
|
||||
name: 'Ticket'
|
||||
model: 'Ticket'
|
||||
article:
|
||||
name: 'Article'
|
||||
model: 'Article'
|
||||
|
||||
if attribute.notification
|
||||
groups.notification =
|
||||
name: 'Notification'
|
||||
model: 'Notification'
|
||||
|
||||
# merge config
|
||||
elements = {}
|
||||
for groupKey, groupMeta of groups
|
||||
if !groupMeta.model || !App[groupMeta.model]
|
||||
if groupKey is 'notification'
|
||||
elements["#{groupKey}.email"] = { name: 'email', display: 'Email' }
|
||||
elements["#{groupKey}.sms"] = { name: 'sms', display: 'SMS' }
|
||||
elements["#{groupKey}.webhook"] = { name: 'webhook', display: 'Webhook' }
|
||||
else if groupKey is 'article'
|
||||
elements["#{groupKey}.note"] = { name: 'note', display: 'Note' }
|
||||
else
|
||||
|
||||
for row in App[groupMeta.model].configure_attributes
|
||||
|
||||
# ignore passwords and relations
|
||||
if row.type isnt 'password' && row.name.substr(row.name.length-4,4) isnt '_ids'
|
||||
|
||||
# ignore readonly attributes
|
||||
if !row.readonly
|
||||
config = _.clone(row)
|
||||
|
||||
switch config.tag
|
||||
when 'datetime'
|
||||
config.operator = ['static', 'relative']
|
||||
when 'tag'
|
||||
config.operator = ['add', 'remove']
|
||||
|
||||
elements["#{groupKey}.#{config.name}"] = config
|
||||
|
||||
# add ticket deletion action
|
||||
if attribute.ticket_delete
|
||||
elements['ticket.action'] =
|
||||
name: 'action'
|
||||
display: 'Action'
|
||||
tag: 'select'
|
||||
null: false
|
||||
translate: true
|
||||
options:
|
||||
delete: 'Delete'
|
||||
|
||||
[defaults, groups, elements]
|
||||
|
||||
@placeholder: (elementFull, attribute, params, groups, elements) ->
|
||||
item = $( App.view('generic/ticket_perform_action/row')( attribute: attribute ) )
|
||||
selector = @buildAttributeSelector(elementFull, groups, elements)
|
||||
item.find('.js-attributeSelector').prepend(selector)
|
||||
item
|
||||
|
||||
@render: (attribute, params = {}) ->
|
||||
|
||||
[defaults, groups, elements] = @defaults(attribute)
|
||||
|
||||
# return item
|
||||
item = $( App.view('generic/ticket_perform_action/index')( attribute: attribute ) )
|
||||
|
||||
# add filter
|
||||
item.on('click', '.js-rowActions .js-add', (e) =>
|
||||
element = $(e.target).closest('.js-filterElement')
|
||||
placeholder = @placeholder(item, attribute, params, groups, elements)
|
||||
if element.get(0)
|
||||
element.after(placeholder)
|
||||
else
|
||||
item.append(placeholder)
|
||||
placeholder.find('.js-attributeSelector select').trigger('change')
|
||||
@updateAttributeSelectors(item)
|
||||
)
|
||||
|
||||
# remove filter
|
||||
item.on('click', '.js-rowActions .js-remove', (e) =>
|
||||
return if $(e.currentTarget).hasClass('is-disabled')
|
||||
$(e.target).closest('.js-filterElement').remove()
|
||||
@updateAttributeSelectors(item)
|
||||
)
|
||||
|
||||
# change attribute selector
|
||||
item.on('change', '.js-attributeSelector select', (e) =>
|
||||
elementRow = $(e.target).closest('.js-filterElement')
|
||||
groupAndAttribute = elementRow.find('.js-attributeSelector option:selected').attr('value')
|
||||
@rebuildAttributeSelectors(item, elementRow, groupAndAttribute, elements, {}, attribute)
|
||||
@updateAttributeSelectors(item)
|
||||
)
|
||||
|
||||
# change operator selector
|
||||
item.on('change', '.js-operator select', (e) =>
|
||||
elementRow = $(e.target).closest('.js-filterElement')
|
||||
groupAndAttribute = elementRow.find('.js-attributeSelector option:selected').attr('value')
|
||||
@buildOperator(item, elementRow, groupAndAttribute, elements, {}, attribute)
|
||||
)
|
||||
|
||||
# build initial params
|
||||
if _.isEmpty(params[attribute.name])
|
||||
|
||||
for groupAndAttribute in defaults
|
||||
|
||||
# build and append
|
||||
element = @placeholder(item, attribute, params, groups, elements)
|
||||
item.append(element)
|
||||
@rebuildAttributeSelectors(item, element, groupAndAttribute, elements, {}, attribute)
|
||||
|
||||
else
|
||||
|
||||
for groupAndAttribute, meta of params[attribute.name]
|
||||
|
||||
# build and append
|
||||
element = @placeholder(item, attribute, params, groups, elements)
|
||||
@rebuildAttributeSelectors(item, element, groupAndAttribute, elements, meta, attribute)
|
||||
item.append(element)
|
||||
|
||||
@disableRemoveForOneAttribute(item)
|
||||
item
|
||||
|
||||
@buildAttributeSelector: (elementFull, groups, elements) ->
|
||||
|
||||
# find first possible attribute
|
||||
selectedValue = ''
|
||||
elementFull.find('.js-attributeSelector select option').each(->
|
||||
if !selectedValue && !$(@).prop('disabled')
|
||||
selectedValue = $(@).val()
|
||||
)
|
||||
|
||||
selection = $('<select class="form-control"></select>')
|
||||
for groupKey, groupMeta of groups
|
||||
displayName = App.i18n.translateInline(groupMeta.name)
|
||||
selection.closest('select').append("<optgroup label=\"#{displayName}\" class=\"js-#{groupKey}\"></optgroup>")
|
||||
optgroup = selection.find("optgroup.js-#{groupKey}")
|
||||
for elementKey, elementGroup of elements
|
||||
spacer = elementKey.split(/\./)
|
||||
if spacer[0] is groupKey
|
||||
attributeConfig = elements[elementKey]
|
||||
displayName = App.i18n.translateInline(attributeConfig.display)
|
||||
|
||||
selected = ''
|
||||
if elementKey is selectedValue
|
||||
selected = 'selected="selected"'
|
||||
optgroup.append("<option value=\"#{elementKey}\" #{selected}>#{displayName}</option>")
|
||||
selection
|
||||
|
||||
# disable - if we only have one attribute
|
||||
@disableRemoveForOneAttribute: (elementFull) ->
|
||||
if elementFull.find('.js-attributeSelector select').length > 1
|
||||
elementFull.find('.js-remove').removeClass('is-disabled')
|
||||
else
|
||||
elementFull.find('.js-remove').addClass('is-disabled')
|
||||
|
||||
@updateAttributeSelectors: (elementFull) ->
|
||||
|
||||
# enable all
|
||||
elementFull.find('.js-attributeSelector select option').prop('disabled', false)
|
||||
|
||||
# disable all used attributes
|
||||
elementFull.find('.js-attributeSelector select').each(->
|
||||
keyLocal = $(@).val()
|
||||
elementFull.find('.js-attributeSelector select option[value="' + keyLocal + '"]').attr('disabled', true)
|
||||
)
|
||||
|
||||
# disable - if we only have one attribute
|
||||
@disableRemoveForOneAttribute(elementFull)
|
||||
|
||||
@rebuildAttributeSelectors: (elementFull, elementRow, groupAndAttribute, elements, meta, attribute) ->
|
||||
|
||||
# set attribute
|
||||
if groupAndAttribute
|
||||
elementRow.find('.js-attributeSelector select').val(groupAndAttribute)
|
||||
|
||||
notificationTypeMatch = groupAndAttribute.match(/^notification.([\w]+)$/)
|
||||
articleTypeMatch = groupAndAttribute.match(/^article.([\w]+)$/)
|
||||
|
||||
if _.isArray(notificationTypeMatch) && notificationType = notificationTypeMatch[1]
|
||||
elementRow.find('.js-setAttribute').html('').addClass('hide')
|
||||
elementRow.find('.js-setArticle').html('').addClass('hide')
|
||||
@buildNotificationArea(notificationType, elementFull, elementRow, groupAndAttribute, elements, meta, attribute)
|
||||
else if _.isArray(articleTypeMatch) && articleType = articleTypeMatch[1]
|
||||
elementRow.find('.js-setAttribute').html('').addClass('hide')
|
||||
elementRow.find('.js-setNotification').html('').addClass('hide')
|
||||
@buildArticleArea(articleType, elementFull, elementRow, groupAndAttribute, elements, meta, attribute)
|
||||
else
|
||||
elementRow.find('.js-setNotification').html('').addClass('hide')
|
||||
elementRow.find('.js-setArticle').html('').addClass('hide')
|
||||
if !elementRow.find('.js-setAttribute div').get(0)
|
||||
attributeSelectorElement = $( App.view('generic/ticket_perform_action/attribute_selector')(
|
||||
attribute: attribute
|
||||
name: name
|
||||
meta: meta || {}
|
||||
))
|
||||
elementRow.find('.js-setAttribute').html(attributeSelectorElement).removeClass('hide')
|
||||
@buildOperator(elementFull, elementRow, groupAndAttribute, elements, meta, attribute)
|
||||
|
||||
@buildOperator: (elementFull, elementRow, groupAndAttribute, elements, meta, attribute) ->
|
||||
currentOperator = elementRow.find('.js-operator option:selected').attr('value')
|
||||
|
||||
if !meta.operator
|
||||
meta.operator = currentOperator
|
||||
|
||||
name = "#{attribute.name}::#{groupAndAttribute}::operator"
|
||||
|
||||
selection = $("<select class=\"form-control\" name=\"#{name}\"></select>")
|
||||
attributeConfig = elements[groupAndAttribute]
|
||||
if !attributeConfig || !attributeConfig.operator
|
||||
elementRow.find('.js-operator').parent().addClass('hide')
|
||||
else
|
||||
elementRow.find('.js-operator').parent().removeClass('hide')
|
||||
if attributeConfig && attributeConfig.operator
|
||||
for operator in attributeConfig.operator
|
||||
operatorName = App.i18n.translateInline(operator)
|
||||
selected = ''
|
||||
if meta.operator is operator
|
||||
selected = 'selected="selected"'
|
||||
selection.append("<option value=\"#{operator}\" #{selected}>#{operatorName}</option>")
|
||||
selection
|
||||
|
||||
elementRow.find('.js-operator select').replaceWith(selection)
|
||||
|
||||
@buildPreCondition(elementFull, elementRow, groupAndAttribute, elements, meta, attribute)
|
||||
|
||||
@buildPreCondition: (elementFull, elementRow, groupAndAttribute, elements, meta, attributeConfig) ->
|
||||
currentOperator = elementRow.find('.js-operator option:selected').attr('value')
|
||||
currentPreCondition = elementRow.find('.js-preCondition option:selected').attr('value')
|
||||
|
||||
if !meta.pre_condition
|
||||
meta.pre_condition = currentPreCondition
|
||||
|
||||
toggleValue = =>
|
||||
preCondition = elementRow.find('.js-preCondition option:selected').attr('value')
|
||||
if preCondition isnt 'specific'
|
||||
elementRow.find('.js-value select').html('')
|
||||
elementRow.find('.js-value').addClass('hide')
|
||||
else
|
||||
elementRow.find('.js-value').removeClass('hide')
|
||||
@buildValue(elementFull, elementRow, groupAndAttribute, elements, meta, attribute)
|
||||
|
||||
# force to use auto complition on user lookup
|
||||
attribute = _.clone(attributeConfig)
|
||||
|
||||
name = "#{attribute.name}::#{groupAndAttribute}::value"
|
||||
attributeSelected = elements[groupAndAttribute]
|
||||
|
||||
preCondition = false
|
||||
if attributeSelected.relation is 'User'
|
||||
preCondition = 'user'
|
||||
attribute.tag = 'user_autocompletion'
|
||||
if attributeSelected.relation is 'Organization'
|
||||
preCondition = 'org'
|
||||
attribute.tag = 'autocompletion_ajax'
|
||||
if !preCondition
|
||||
elementRow.find('.js-preCondition select').html('')
|
||||
elementRow.find('.js-preCondition').closest('.controls').addClass('hide')
|
||||
toggleValue()
|
||||
@buildValue(elementFull, elementRow, groupAndAttribute, elements, meta, attribute)
|
||||
return
|
||||
|
||||
elementRow.find('.js-preCondition').closest('.controls').removeClass('hide')
|
||||
name = "#{attribute.name}::#{groupAndAttribute}::pre_condition"
|
||||
|
||||
selection = $("<select class=\"form-control\" name=\"#{name}\" ></select>")
|
||||
options = {}
|
||||
if preCondition is 'user'
|
||||
options =
|
||||
'current_user.id': App.i18n.translateInline('current user')
|
||||
'specific': App.i18n.translateInline('specific user')
|
||||
|
||||
if attributeSelected.null is true
|
||||
options['not_set'] = App.i18n.translateInline('unassign user')
|
||||
|
||||
else if preCondition is 'org'
|
||||
options =
|
||||
'current_user.organization_id': App.i18n.translateInline('current user organization')
|
||||
'specific': App.i18n.translateInline('specific organization')
|
||||
|
||||
for key, value of options
|
||||
selected = ''
|
||||
if key is meta.pre_condition
|
||||
selected = 'selected="selected"'
|
||||
selection.append("<option value=\"#{key}\" #{selected}>#{App.i18n.translateInline(value)}</option>")
|
||||
elementRow.find('.js-preCondition').closest('.controls').removeClass('hide')
|
||||
elementRow.find('.js-preCondition select').replaceWith(selection)
|
||||
|
||||
elementRow.find('.js-preCondition select').on('change', (e) ->
|
||||
toggleValue()
|
||||
)
|
||||
|
||||
@buildValue(elementFull, elementRow, groupAndAttribute, elements, meta, attribute)
|
||||
toggleValue()
|
||||
|
||||
@buildValue: (elementFull, elementRow, groupAndAttribute, elements, meta, attribute) ->
|
||||
name = "#{attribute.name}::#{groupAndAttribute}::value"
|
||||
|
||||
# build new item
|
||||
attributeConfig = elements[groupAndAttribute]
|
||||
config = _.clone(attributeConfig)
|
||||
|
||||
if config.relation is 'User'
|
||||
config.tag = 'user_autocompletion'
|
||||
if config.relation is 'Organization'
|
||||
config.tag = 'autocompletion_ajax'
|
||||
|
||||
# render ui element
|
||||
item = ''
|
||||
if config && App.UiElement[config.tag]
|
||||
config['name'] = name
|
||||
if attribute.value && attribute.value[groupAndAttribute]
|
||||
config['value'] = _.clone(attribute.value[groupAndAttribute]['value'])
|
||||
config.multiple = false
|
||||
config.nulloption = config.null
|
||||
if config.tag is 'checkbox'
|
||||
config.tag = 'select'
|
||||
tagSearch = "#{config.tag}_search"
|
||||
if config.tag is 'datetime'
|
||||
config.validationContainer = 'self'
|
||||
if App.UiElement[tagSearch]
|
||||
item = App.UiElement[tagSearch].render(config, {})
|
||||
else
|
||||
item = App.UiElement[config.tag].render(config, {})
|
||||
|
||||
relative_operators = [
|
||||
'before (relative)',
|
||||
'within next (relative)',
|
||||
'within last (relative)',
|
||||
'after (relative)',
|
||||
'till (relative)',
|
||||
'from (relative)',
|
||||
'relative'
|
||||
]
|
||||
|
||||
upcoming_operator = meta.operator
|
||||
|
||||
if !_.include(config.operator, upcoming_operator)
|
||||
if Array.isArray(config.operator)
|
||||
upcoming_operator = config.operator[0]
|
||||
else
|
||||
upcoming_operator = null
|
||||
|
||||
if _.include(relative_operators, upcoming_operator)
|
||||
config['name'] = "#{attribute.name}::#{groupAndAttribute}"
|
||||
if attribute.value && attribute.value[groupAndAttribute]
|
||||
config['value'] = _.clone(attribute.value[groupAndAttribute])
|
||||
item = App.UiElement['time_range'].render(config, {})
|
||||
|
||||
elementRow.find('.js-setAttribute > .flex > .js-value').removeClass('hide').html(item)
|
||||
|
||||
@buildNotificationArea: (notificationType, elementFull, elementRow, groupAndAttribute, elements, meta, attribute) ->
|
||||
|
||||
return if elementRow.find(".js-setNotification .js-body-#{notificationType}").get(0)
|
||||
|
||||
elementRow.find('.js-setNotification').empty()
|
||||
|
||||
options =
|
||||
'article_last_sender': 'Sender of last article'
|
||||
'ticket_owner': 'Owner'
|
||||
'ticket_customer': 'Customer'
|
||||
'ticket_agents': 'All agents'
|
||||
|
||||
name = "#{attribute.name}::notification.#{notificationType}"
|
||||
|
||||
messageLength = switch notificationType
|
||||
when 'sms' then 160
|
||||
else 200000
|
||||
|
||||
# meta.recipient was a string in the past (single-select) so we convert it to array if needed
|
||||
if !_.isArray(meta.recipient)
|
||||
meta.recipient = [meta.recipient]
|
||||
|
||||
columnSelectOptions = []
|
||||
for key, value of options
|
||||
selected = undefined
|
||||
for recipient in meta.recipient
|
||||
if key is recipient
|
||||
selected = true
|
||||
columnSelectOptions.push({ value: key, name: App.i18n.translatePlain(value), selected: selected })
|
||||
|
||||
columnSelectRecipientUserOptions = []
|
||||
for user in App.User.all()
|
||||
key = "userid_#{user.id}"
|
||||
selected = undefined
|
||||
for recipient in meta.recipient
|
||||
if key is recipient
|
||||
selected = true
|
||||
columnSelectRecipientUserOptions.push({ value: key, name: "#{user.firstname} #{user.lastname}", selected: selected })
|
||||
|
||||
columnSelectRecipient = new App.ColumnSelect
|
||||
attribute:
|
||||
name: "#{name}::recipient"
|
||||
options: [
|
||||
{
|
||||
label: 'Variables',
|
||||
group: columnSelectOptions
|
||||
},
|
||||
{
|
||||
label: 'User',
|
||||
group: columnSelectRecipientUserOptions
|
||||
},
|
||||
]
|
||||
|
||||
selectionRecipient = columnSelectRecipient.element()
|
||||
|
||||
if notificationType is 'webhook'
|
||||
notificationElement = $( App.view('generic/ticket_perform_action/webhook')(
|
||||
attribute: attribute
|
||||
name: name
|
||||
notificationType: notificationType
|
||||
meta: meta || {}
|
||||
))
|
||||
|
||||
notificationElement.find('.js-recipient select').replaceWith(selectionRecipient)
|
||||
|
||||
|
||||
if App.Webhook.search(filter: { active: true }).length isnt 0 || !_.isEmpty(meta.webhook_id)
|
||||
webhookSelection = App.UiElement.select.render(
|
||||
name: "#{name}::webhook_id"
|
||||
multiple: false
|
||||
null: false
|
||||
relation: 'Webhook'
|
||||
value: meta.webhook_id
|
||||
translate: false
|
||||
nulloption: true
|
||||
)
|
||||
else
|
||||
webhookSelection = App.view('generic/ticket_perform_action/webhook_not_available')( attribute: attribute )
|
||||
|
||||
notificationElement.find('.js-webhooks').html(webhookSelection)
|
||||
|
||||
else
|
||||
notificationElement = $( App.view('generic/ticket_perform_action/notification')(
|
||||
attribute: attribute
|
||||
name: name
|
||||
notificationType: notificationType
|
||||
meta: meta || {}
|
||||
))
|
||||
|
||||
notificationElement.find('.js-recipient select').replaceWith(selectionRecipient)
|
||||
|
||||
visibilitySelection = App.UiElement.select.render(
|
||||
name: "#{name}::internal"
|
||||
multiple: false
|
||||
null: false
|
||||
options: { true: 'internal', false: 'public' }
|
||||
value: meta.internal || 'false'
|
||||
translate: true
|
||||
)
|
||||
|
||||
includeAttachmentsCheckbox = App.UiElement.select.render(
|
||||
name: "#{name}::include_attachments"
|
||||
multiple: false
|
||||
null: false
|
||||
options: { true: 'Yes', false: 'No' }
|
||||
value: meta.include_attachments || 'false'
|
||||
translate: true
|
||||
)
|
||||
|
||||
notificationElement.find('.js-internal').html(visibilitySelection)
|
||||
notificationElement.find('.js-include_attachments').html(includeAttachmentsCheckbox)
|
||||
|
||||
notificationElement.find('.js-body div[contenteditable="true"]').ce(
|
||||
mode: 'richtext'
|
||||
placeholder: 'message'
|
||||
maxlength: messageLength
|
||||
)
|
||||
new App.WidgetPlaceholder(
|
||||
el: notificationElement.find('.js-body div[contenteditable="true"]').parent()
|
||||
objects: [
|
||||
{
|
||||
prefix: 'ticket'
|
||||
object: 'Ticket'
|
||||
display: 'Ticket'
|
||||
},
|
||||
{
|
||||
prefix: 'article'
|
||||
object: 'TicketArticle'
|
||||
display: 'Article'
|
||||
},
|
||||
{
|
||||
prefix: 'user'
|
||||
object: 'User'
|
||||
display: 'Current User'
|
||||
},
|
||||
]
|
||||
)
|
||||
|
||||
elementRow.find('.js-setNotification').html(notificationElement).removeClass('hide')
|
||||
|
||||
if App.Config.get('smime_integration') == true || App.Config.get('pgp_integration') == true
|
||||
selection = App.UiElement.select.render(
|
||||
name: "#{name}::sign"
|
||||
multiple: false
|
||||
options: {
|
||||
'no': 'Do not sign email'
|
||||
'discard': 'Sign email (if not possible, discard notification)'
|
||||
'always': 'Sign email (if not possible, send notification anyway)'
|
||||
}
|
||||
value: meta.sign
|
||||
translate: true
|
||||
)
|
||||
|
||||
elementRow.find('.js-sign').html(selection)
|
||||
|
||||
selection = App.UiElement.select.render(
|
||||
name: "#{name}::encryption"
|
||||
multiple: false
|
||||
options: {
|
||||
'no': 'Do not encrypt email'
|
||||
'discard': 'Encrypt email (if not possible, discard notification)'
|
||||
'always': 'Encrypt email (if not possible, send notification anyway)'
|
||||
}
|
||||
value: meta.encryption
|
||||
translate: true
|
||||
)
|
||||
|
||||
elementRow.find('.js-encryption').html(selection)
|
||||
|
||||
@buildArticleArea: (articleType, elementFull, elementRow, groupAndAttribute, elements, meta, attribute) ->
|
||||
|
||||
return if elementRow.find(".js-setArticle .js-body-#{articleType}").get(0)
|
||||
|
||||
elementRow.find('.js-setArticle').empty()
|
||||
|
||||
name = "#{attribute.name}::article.#{articleType}"
|
||||
selection = App.UiElement.select.render(
|
||||
name: "#{name}::internal"
|
||||
multiple: false
|
||||
null: false
|
||||
label: 'Visibility'
|
||||
options: { true: 'internal', false: 'public' }
|
||||
value: meta.internal
|
||||
translate: true
|
||||
)
|
||||
articleElement = $( App.view('generic/ticket_perform_action/article')(
|
||||
attribute: attribute
|
||||
name: name
|
||||
articleType: articleType
|
||||
meta: meta || {}
|
||||
))
|
||||
articleElement.find('.js-internal').html(selection)
|
||||
articleElement.find('.js-body div[contenteditable="true"]').ce(
|
||||
mode: 'richtext'
|
||||
placeholder: 'message'
|
||||
maxlength: 200000
|
||||
)
|
||||
new App.WidgetPlaceholder(
|
||||
el: articleElement.find('.js-body div[contenteditable="true"]').parent()
|
||||
objects: [
|
||||
{
|
||||
prefix: 'ticket'
|
||||
object: 'Ticket'
|
||||
display: 'Ticket'
|
||||
},
|
||||
{
|
||||
prefix: 'article'
|
||||
object: 'TicketArticle'
|
||||
display: 'Article'
|
||||
},
|
||||
{
|
||||
prefix: 'user'
|
||||
object: 'User'
|
||||
display: 'Current User'
|
||||
},
|
||||
]
|
||||
)
|
||||
|
||||
elementRow.find('.js-setArticle').html(articleElement).removeClass('hide')
|
||||
|
||||
@humanText: (condition) ->
|
||||
none = App.i18n.translateContent('No filter.')
|
||||
return [none] if _.isEmpty(condition)
|
||||
[defaults, groups, operators, elements] = @defaults()
|
||||
rules = []
|
||||
for attribute, value of condition
|
||||
|
||||
objectAttribute = attribute.split(/\./)
|
||||
|
||||
# get stored params
|
||||
if meta && objectAttribute[1]
|
||||
model = toCamelCase(objectAttribute[0])
|
||||
config = elements[attribute]
|
||||
|
||||
valueHuman = []
|
||||
if _.isArray(value)
|
||||
for data in value
|
||||
r = @humanTextLookup(config, data)
|
||||
valueHuman.push r
|
||||
else
|
||||
valueHuman.push @humanTextLookup(config, value)
|
||||
|
||||
if valueHuman.join
|
||||
valueHuman = valueHuman.join(', ')
|
||||
rules.push "#{App.i18n.translateContent('Set')} <b>#{App.i18n.translateContent(model)} -> #{App.i18n.translateContent(config.display)}</b> #{App.i18n.translateContent('to')} <b>#{valueHuman}</b>."
|
||||
|
||||
return [none] if _.isEmpty(rules)
|
||||
rules
|
||||
|
||||
@humanTextLookup: (config, value) ->
|
||||
return value if !App[config.relation]
|
||||
return value if !App[config.relation].exists(value)
|
||||
data = App[config.relation].fullLocal(value)
|
||||
return value if !data
|
||||
if data.displayName
|
||||
return App.i18n.translateContent( data.displayName() )
|
||||
valueHuman.push App.i18n.translateContent( data.name )
|
||||
|
|
@ -0,0 +1,99 @@
|
|||
# Methods for displaying security ui elements and to get security params
|
||||
|
||||
App.SecurityOptions =
|
||||
|
||||
securityOptionsShow: ->
|
||||
@$('.js-securityOptions').removeClass('hide')
|
||||
|
||||
securityOptionsHide: ->
|
||||
@$('.js-securityOptions').addClass('hide')
|
||||
|
||||
securityOptionsShown: ->
|
||||
!@$('.js-securityOptions').hasClass('hide')
|
||||
|
||||
securityEnabled: ->
|
||||
App.Config.get('smime_integration') || App.Config.get('pgp_integration')
|
||||
|
||||
paramsSecurity: =>
|
||||
if @$('.js-securityOptions').hasClass('hide')
|
||||
return {}
|
||||
|
||||
security = {}
|
||||
security.encryption ||= {}
|
||||
security.sign ||= {}
|
||||
if App.Config.get('pgp_integration')
|
||||
security.type = 'PGP'
|
||||
else
|
||||
security.type = 'S/MIME'
|
||||
if @$('.js-securityEncrypt').hasClass('btn--active')
|
||||
security.encryption.success = true
|
||||
if @$('.js-securitySign').hasClass('btn--active')
|
||||
security.sign.success = true
|
||||
security
|
||||
|
||||
updateSecurityOptionsRemote: (key, ticket, article, securityOptions) ->
|
||||
if securityOptions.type == 'PGP'
|
||||
id = "pgp-check-#{key}"
|
||||
url = "#{@apiPath}/integration/pgp"
|
||||
securityConfig = App.Config.get('pgp_config')
|
||||
else
|
||||
id = "smime-check-#{key}"
|
||||
url = "#{@apiPath}/integration/smime"
|
||||
securityConfig = App.Config.get('smime_config')
|
||||
callback = =>
|
||||
@ajax(
|
||||
id: id
|
||||
type: 'POST'
|
||||
url: url
|
||||
data: JSON.stringify(ticket: ticket, article: article)
|
||||
processData: true
|
||||
success: (data, status, xhr) =>
|
||||
|
||||
# get default selected security options
|
||||
selected =
|
||||
encryption: true
|
||||
sign: true
|
||||
for type, selector of { default_sign: 'sign', default_encryption: 'encryption' }
|
||||
if securityConfig?.group_id?[type] && ticket.group_id
|
||||
if securityConfig.group_id[type][ticket.group_id.toString()] == false
|
||||
selected[selector] = false
|
||||
|
||||
@$('.js-securityEncryptComment').attr('title', data.encryption.comment)
|
||||
|
||||
# if encryption is possible
|
||||
if data.encryption.success is true
|
||||
@$('.js-securityEncrypt').attr('disabled', false)
|
||||
|
||||
# overrule current selection with Group configuration
|
||||
if selected.encryption
|
||||
@$('.js-securityEncrypt').addClass('btn--active')
|
||||
else
|
||||
@$('.js-securityEncrypt').removeClass('btn--active')
|
||||
|
||||
# if encryption is not possible
|
||||
else
|
||||
@$('.js-securityEncrypt').attr('disabled', true)
|
||||
@$('.js-securityEncrypt').removeClass('btn--active')
|
||||
|
||||
@$('.js-securitySignComment').attr('title', data.sign.comment)
|
||||
|
||||
# if sign is possible
|
||||
if data.sign.success is true
|
||||
@$('.js-securitySign').attr('disabled', false)
|
||||
|
||||
# overrule current selection with Group configuration
|
||||
if selected.sign
|
||||
@$('.js-securitySign').addClass('btn--active')
|
||||
else
|
||||
@$('.js-securitySign').removeClass('btn--active')
|
||||
|
||||
# if sign is possible
|
||||
else
|
||||
@$('.js-securitySign').attr('disabled', true)
|
||||
@$('.js-securitySign').removeClass('btn--active')
|
||||
|
||||
error: (data) ->
|
||||
details = data.responseJSON || {}
|
||||
console.log(details)
|
||||
)
|
||||
@delay(callback, 200, 'security-check')
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
<form>
|
||||
<h2><%- @T('Public & Private Keys') %></h2>
|
||||
<div class="settings-entry settings-entry--stretched js-keyList"></div>
|
||||
|
||||
<div class="btn btn--primary js-addPublicKey"><%- @T('Add Public Key') %></div>
|
||||
<div class="btn js-addPrivateKey"><%- @T('Add Private Key') %></div>
|
||||
|
||||
<hr>
|
||||
|
||||
<h2><%- @T('Default Behavior') %></h2>
|
||||
<p>Choose the default behavior of the PGP integration on per group basis. If signing or encrypting is not possible, the setting has no effect. Agents call always manually alter the behavior for each article.</p>
|
||||
<div class="settings-entry settings-entry--stretched js-groupList"></div>
|
||||
<div class="btn btn--primary js-updateGroup"><%- @T('Update') %></div>
|
||||
</form>
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
<table class="settings-list">
|
||||
<thead>
|
||||
<tr>
|
||||
<th width="55%"><%- @T('Group') %>
|
||||
<th><%- @T('Sign') %>
|
||||
<th><%- @T('Encryption') %>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% if _.isEmpty(@groups): %>
|
||||
<tr>
|
||||
<td colspan="6">
|
||||
<%- @T('No Entries') %>
|
||||
</td>
|
||||
</tr>
|
||||
<% else: %>
|
||||
<% for group in @groups: %>
|
||||
<tr data-id="<%= group.id %>">
|
||||
<td><%= group.name %>
|
||||
<td class="js-signDefault">
|
||||
<td class="js-encryptionDefault">
|
||||
<% end %>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
<table class="settings-list settings-list--stretch">
|
||||
<thead>
|
||||
<tr>
|
||||
<th width="35%"><%- @T('Email') %>
|
||||
<th width="60%"><%- @T('Fingerprint') %>
|
||||
<th width="5%"><%- @T('Actions') %>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% if _.isEmpty(@keyPairs): %>
|
||||
<tr>
|
||||
<td colspan="6">
|
||||
<%- @T('No Entries') %>
|
||||
</td>
|
||||
</tr>
|
||||
<% else: %>
|
||||
<% for keyPair in @keyPairs: %>
|
||||
<tr data-id="<%= keyPair.id %>">
|
||||
<td><% if !_.isEmpty(keyPair.email_addresses): %><%= keyPair.email_addresses.toString() %><% end %>
|
||||
<% if keyPair.private_key: %><br><i><%- @T('Including private key.') %></i><% end %>
|
||||
<td title="<%= keyPair.fingerprint %>"><%= keyPair.fingerprint %>
|
||||
<td>
|
||||
<div class="dropdown dropdown--actions">
|
||||
<div class="btn btn--table btn--text btn--secondary js-action" data-toggle="dropdown">
|
||||
<%- @Icon('overflow-button') %>
|
||||
</div>
|
||||
<ul class="dropdown-menu dropdown-menu-right js-table-action-menu" role="menu">
|
||||
<% if keyPair.private_key: %>
|
||||
<li role="presentation" data-table-action="download-private">
|
||||
<a href="<%= @C('http_type') %>://<%= @C('fqdn')%>/api/v1/integration/pgp/private_key_download/<%= keyPair.id %>" download><%- @Icon('download') %> <%- @T('Download Private Key') %></a>
|
||||
</li>
|
||||
<% end %>
|
||||
<li role="presentation" data-table-action="download-public">
|
||||
<a href="<%= @C('http_type') %>://<%= @C('fqdn')%>/api/v1/integration/pgp/public_key_download/<%= keyPair.id %>"%download><%- @Icon('download') %> <%- @T('Download Public Key') %></a>
|
||||
</li>
|
||||
<li role="presentation" class="danger js-remove" data-table-action="remove">
|
||||
<%- @Icon('trash') %> <%- @T('Delete') %>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</td>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
<div>
|
||||
<p class="alert alert--danger js-error hide"></p>
|
||||
|
||||
<div class="form-field-group">
|
||||
<div class="form-group">
|
||||
<div class="formGroup-label">
|
||||
<label for="private_key-upload"><%- @T('Upload Private Key') %></label>
|
||||
</div>
|
||||
<div class="controls">
|
||||
<input name="file" type="file" id="private_key-upload">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="or-divider">
|
||||
<span><%- @T('or') %></span>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<div class="formGroup-label">
|
||||
<label for="private_key-paste"><%- @T('Paste Private Key') %></label>
|
||||
</div>
|
||||
<div class="controls">
|
||||
<textarea cols="25" rows="20" name="data" style="height: 200px;"
|
||||
id="private_key-paste"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<div class="formGroup-label">
|
||||
<label for="private_key-secret"><%- @T('Enter Private Key Secret') %></label>
|
||||
</div>
|
||||
<div class="controls">
|
||||
<input class="form-control" name="secret" type="password" id="private_key-secret">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
<div>
|
||||
<p class="alert alert--danger js-error hide"></p>
|
||||
|
||||
<div class="form-group">
|
||||
<div class="formGroup-label">
|
||||
<label for="public_key-upload"><%- @T('Upload Public Key') %></label>
|
||||
</div>
|
||||
<div class="controls">
|
||||
<input name="file" type="file" id="public_key-upload">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="or-divider">
|
||||
<span><%- @T('or') %></span>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<div class="formGroup-label">
|
||||
<label for="public_key-paste"><%- @T('Paste Public Key') %></label>
|
||||
</div>
|
||||
<div class="controls">
|
||||
<textarea cols="25" rows="20" name="data" style="height: 200px;"
|
||||
id="public_key-paste"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
|
@ -0,0 +1 @@
|
|||
.icon-pgp { width:17px; height: 17px; }
|
||||
|
|
@ -0,0 +1,154 @@
|
|||
# Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/
|
||||
|
||||
class Integration::PGPController < ApplicationController
|
||||
prepend_before_action { authentication_check && authorize! }
|
||||
|
||||
def public_key_download
|
||||
cert = PGPKeypair.find(params[:id])
|
||||
|
||||
send_data(
|
||||
cert.public_key,
|
||||
filename: "#{cert.fingerprint}.asc",
|
||||
type: 'text/plain',
|
||||
disposition: 'attachment'
|
||||
)
|
||||
end
|
||||
|
||||
def private_key_download
|
||||
cert = PGPKeypair.find(params[:id])
|
||||
|
||||
send_data(
|
||||
cert.private_key,
|
||||
filename: "#{cert.fingerprint}-private.asc",
|
||||
type: 'text/plain',
|
||||
disposition: 'attachment'
|
||||
)
|
||||
end
|
||||
|
||||
def public_key_list
|
||||
render json: PGPKeypair.all, methods: :email_addresses
|
||||
end
|
||||
|
||||
def public_key_delete
|
||||
PGPKeypair.find(params[:id]).destroy!
|
||||
render json: {
|
||||
result: 'ok'
|
||||
}
|
||||
end
|
||||
|
||||
def public_key_add
|
||||
string = params[:data]
|
||||
string = params[:file].read.force_encoding('utf-8') if string.blank? && params[:file].present?
|
||||
|
||||
items = PGPKeypair.create_public_keys(string)
|
||||
|
||||
render json: {
|
||||
result: 'ok',
|
||||
response: items
|
||||
}
|
||||
rescue StandardError => e
|
||||
unprocessable_entity(e)
|
||||
end
|
||||
|
||||
def private_key_delete
|
||||
PGPKeypair.find(params[:id]).update!(
|
||||
private_key: nil,
|
||||
private_key_secret: nil
|
||||
)
|
||||
|
||||
render json: {
|
||||
result: 'ok'
|
||||
}
|
||||
end
|
||||
|
||||
def private_key_add
|
||||
string = params[:data]
|
||||
string = params[:file].read.force_encoding('utf-8') if string.blank? && params[:file].present?
|
||||
|
||||
raise "Parameter 'data' or 'file' required." if string.blank?
|
||||
|
||||
PGPKeypair.create_private_keys(string, params[:secret])
|
||||
|
||||
render json: {
|
||||
result: 'ok'
|
||||
}
|
||||
rescue StandardError => e
|
||||
unprocessable_entity(e)
|
||||
end
|
||||
|
||||
def search
|
||||
result = {
|
||||
type: 'PGP'
|
||||
}
|
||||
|
||||
result[:encryption] = article_encryption(params[:article])
|
||||
result[:sign] = article_sign(params[:ticket])
|
||||
|
||||
render json: result
|
||||
end
|
||||
|
||||
def article_encryption(article)
|
||||
result = {
|
||||
success: false,
|
||||
comment: 'no recipient found'
|
||||
}
|
||||
|
||||
return result if article.blank?
|
||||
return result if article[:to].blank? && article[:cc].blank?
|
||||
|
||||
recipient = [article[:to], article[:cc]].compact.join(',').to_s
|
||||
recipients = []
|
||||
begin
|
||||
list = Mail::AddressList.new(recipient)
|
||||
list.addresses.each do |address|
|
||||
recipients.push address.address
|
||||
end
|
||||
rescue StandardError # rubocop:disable Lint/SuppressedException
|
||||
end
|
||||
|
||||
return result if recipients.blank?
|
||||
|
||||
begin
|
||||
keys = PGPKeypair.for_recipient_email_addresses!(recipients)
|
||||
|
||||
if keys
|
||||
result[:success] = true
|
||||
result[:comment] = "keys found for #{recipients.join(',')}"
|
||||
end
|
||||
rescue StandardError => e
|
||||
result[:comment] = e.message
|
||||
end
|
||||
|
||||
result
|
||||
end
|
||||
|
||||
def article_sign(ticket)
|
||||
result = {
|
||||
success: false,
|
||||
comment: 'key not found'
|
||||
}
|
||||
|
||||
return result if ticket.blank? || !ticket[:group_id]
|
||||
|
||||
group = Group.find_by(id: ticket[:group_id])
|
||||
return result unless group
|
||||
|
||||
email_address = group.email_address
|
||||
begin
|
||||
list = Mail::AddressList.new(email_address.email)
|
||||
from = list.addresses.first.to_s
|
||||
key = PGPKeypair.for_sender_email_address(from)
|
||||
if key
|
||||
result[:success] = true
|
||||
result[:comment] = "key for #{email_address.email} found"
|
||||
else
|
||||
result[:success] = false
|
||||
result[:comment] = "no key for #{email_address.email} found"
|
||||
end
|
||||
rescue StandardError => e
|
||||
result[:comment] = e.message
|
||||
end
|
||||
|
||||
result
|
||||
end
|
||||
end
|
||||
64
zammad-addon-pgp/src/app/models/pgp_keypair.rb
Normal file
64
zammad-addon-pgp/src/app/models/pgp_keypair.rb
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
# Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/
|
||||
|
||||
class PGPKeypair < ApplicationModel
|
||||
validates :fingerprint, uniqueness: { case_sensitive: true }
|
||||
|
||||
def self.create_private_keys(raw, secret)
|
||||
Sequoia.emails_of(keys: raw).each do |address|
|
||||
downcased_address = address.downcase
|
||||
public_key = find_each.detect do |certificate|
|
||||
certificate.email_addresses.include?(downcased_address)
|
||||
end
|
||||
|
||||
unless public_key
|
||||
raise Exceptions::UnprocessableEntity,
|
||||
'The public key for this private key could not be found.'
|
||||
end
|
||||
|
||||
public_key.update!(private_key: raw, private_key_secret: secret)
|
||||
end
|
||||
end
|
||||
|
||||
def self.create_public_keys(raw)
|
||||
create!(public_key: raw)
|
||||
end
|
||||
|
||||
def self.for_sender_email_address(address)
|
||||
downcased_address = address.downcase
|
||||
where.not(private_key: nil).find_each.detect do |certificate|
|
||||
certificate.email_addresses.include?(downcased_address)
|
||||
end
|
||||
end
|
||||
|
||||
def self.for_recipient_email_addresses!(addresses)
|
||||
certificates = []
|
||||
remaining_addresses = addresses.map(&:downcase)
|
||||
find_each do |certificate|
|
||||
# intersection of both lists
|
||||
certificate_for = certificate.email_addresses & remaining_addresses
|
||||
next if certificate_for.blank?
|
||||
|
||||
certificates.push(certificate)
|
||||
|
||||
# subtract found recipient(s)
|
||||
remaining_addresses -= certificate_for
|
||||
|
||||
# end loop if no addresses are remaining
|
||||
break if remaining_addresses.blank?
|
||||
end
|
||||
|
||||
return certificates if remaining_addresses.blank?
|
||||
|
||||
raise ActiveRecord::RecordNotFound,
|
||||
"Can't find PGP encryption certificates for: #{remaining_addresses.join(', ')}"
|
||||
end
|
||||
|
||||
def public_key=(string)
|
||||
self.fingerprint = Sequoia.fingerprints_of(keys: string).first
|
||||
self[:public_key] = string
|
||||
end
|
||||
|
||||
def email_addresses
|
||||
@email_addresses ||= Sequoia.emails_of(keys: public_key)
|
||||
end
|
||||
end
|
||||
1909
zammad-addon-pgp/src/app/models/ticket.rb
Normal file
1909
zammad-addon-pgp/src/app/models/ticket.rb
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -0,0 +1,6 @@
|
|||
# Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/
|
||||
|
||||
class Controllers::Integration::PGPControllerPolicy < Controllers::ApplicationControllerPolicy
|
||||
permit! :search, to: 'ticket.agent'
|
||||
default_permit!('admin.integration.pgp')
|
||||
end
|
||||
29
zammad-addon-pgp/src/config/initializers/inflections.rb
Normal file
29
zammad-addon-pgp/src/config/initializers/inflections.rb
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
# Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/
|
||||
|
||||
# Be sure to restart your server when you modify this file.
|
||||
|
||||
# Add new inflection rules using the following format. Inflections
|
||||
# are locale specific, and you may define rules for as many different
|
||||
# locales as you wish. All of these examples are active by default:
|
||||
# ActiveSupport::Inflector.inflections(:en) do |inflect|
|
||||
# inflect.plural /^(ox)$/i, '\1en'
|
||||
# inflect.singular /^(ox)en/i, '\1'
|
||||
# inflect.irregular 'person', 'people'
|
||||
# inflect.uncountable %w( fish sheep )
|
||||
# end
|
||||
|
||||
# These inflection rules are supported but not enabled by default:
|
||||
# ActiveSupport::Inflector.inflections(:en) do |inflect|
|
||||
# inflect.acronym 'RESTful'
|
||||
# end
|
||||
|
||||
ActiveSupport::Inflector.inflections(:en) do |inflect|
|
||||
|
||||
# Rails thinks the singularized version of knowledge_bases is knowledge_basis?!
|
||||
# see: KnowledgeBase.table_name.singularize
|
||||
inflect.irregular 'base', 'bases'
|
||||
inflect.acronym 'SMIME'
|
||||
inflect.acronym 'PGP'
|
||||
inflect.acronym 'GitLab'
|
||||
inflect.acronym 'GitHub'
|
||||
end
|
||||
18
zammad-addon-pgp/src/config/initializers/pgp_support.rb
Normal file
18
zammad-addon-pgp/src/config/initializers/pgp_support.rb
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
require 'ruby_openpgp'
|
||||
|
||||
Rails.application.config.before_configuration do
|
||||
#FIXME need icon
|
||||
icon = File.read("public/assets/images/icons/pgp.svg")
|
||||
doc = File.open("public/assets/images/icons.svg") { |f| Nokogiri::XML(f) }
|
||||
if !doc.at_css('#icon-pgp')
|
||||
doc.at('svg').add_child(icon)
|
||||
Rails.logger.debug "PGP support icon added to icon set"
|
||||
else
|
||||
Rails.logger.debug "PGP support icon already in icon set"
|
||||
end
|
||||
File.write("public/assets/images/icons.svg", doc.to_xml)
|
||||
end
|
||||
|
||||
# Rails.application.config.after_initialize do
|
||||
# Ticket::Article.add_observer Observer::Ticket::Article::CommunicatePgpSupport.instance
|
||||
# end
|
||||
14
zammad-addon-pgp/src/config/routes/integration_pgp.rb
Normal file
14
zammad-addon-pgp/src/config/routes/integration_pgp.rb
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
# Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/
|
||||
|
||||
Zammad::Application.routes.draw do
|
||||
api_path = Rails.configuration.api_path
|
||||
|
||||
match api_path + '/integration/pgp', to: 'integration/pgp#search', via: :post
|
||||
match api_path + '/integration/pgp/public_key', to: 'integration/pgp#public_key_add', via: :post
|
||||
match api_path + '/integration/pgp/public_key', to: 'integration/pgp#public_key_delete', via: :delete
|
||||
match api_path + '/integration/pgp/public_key', to: 'integration/pgp#public_key_list', via: :get
|
||||
match api_path + '/integration/pgp/private_key', to: 'integration/pgp#private_key_add', via: :post
|
||||
match api_path + '/integration/pgp/private_key', to: 'integration/pgp#private_key_delete', via: :delete
|
||||
match api_path + '/integration/pgp/public_key_download/:id', to: 'integration/pgp#public_key_download', via: :get
|
||||
match api_path + '/integration/pgp/private_key_download/:id', to: 'integration/pgp#private_key_download', via: :get
|
||||
end
|
||||
|
|
@ -0,0 +1,65 @@
|
|||
class PGPSupport < ActiveRecord::Migration[5.2]
|
||||
def up
|
||||
# return if it's a new setup
|
||||
# return unless Setting.exists?(name: 'system_init_done')
|
||||
|
||||
Setting.create_if_not_exists(
|
||||
title: 'PGP integration',
|
||||
name: 'pgp_integration',
|
||||
area: 'Integration::Switch',
|
||||
description: 'Defines if PGP encryption is enabled or not.',
|
||||
options: {
|
||||
form: [
|
||||
{
|
||||
display: '',
|
||||
null: true,
|
||||
name: 'pgp_integration',
|
||||
tag: 'boolean',
|
||||
options: {
|
||||
true => 'yes',
|
||||
false => 'no'
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
state: false,
|
||||
preferences: {
|
||||
prio: 1,
|
||||
authentication: true,
|
||||
permission: ['admin.integration']
|
||||
},
|
||||
frontend: true
|
||||
)
|
||||
Setting.create_if_not_exists(
|
||||
title: 'PGP config',
|
||||
name: 'pgp_config',
|
||||
area: 'Integration::PGP',
|
||||
description: 'Defines the PGP config.',
|
||||
options: {},
|
||||
state: {},
|
||||
preferences: {
|
||||
prio: 2,
|
||||
permission: ['admin.integration']
|
||||
},
|
||||
frontend: true
|
||||
)
|
||||
Setting.create_if_not_exists(
|
||||
title: 'Defines postmaster filter.',
|
||||
name: '0016_postmaster_filter_smime',
|
||||
area: 'Postmaster::PreFilter',
|
||||
description: 'Defines postmaster filter to handle secure mailing.',
|
||||
options: {},
|
||||
state: 'Channel::Filter::SecureMailing',
|
||||
frontend: false
|
||||
)
|
||||
|
||||
create_table :pgp_keypairs do |t|
|
||||
t.string :fingerprint, limit: 250, null: false
|
||||
t.binary :public_key, limit: 10.megabytes, null: false
|
||||
t.binary :private_key, limit: 10.megabytes, null: true
|
||||
t.string :private_key_secret, limit: 500, null: true
|
||||
t.timestamps limit: 3, null: false
|
||||
end
|
||||
add_index :pgp_keypairs, [:fingerprint], unique: true
|
||||
end
|
||||
end
|
||||
4832
zammad-addon-pgp/src/db/seeds/settings.rb
Normal file
4832
zammad-addon-pgp/src/db/seeds/settings.rb
Normal file
File diff suppressed because it is too large
Load diff
7
zammad-addon-pgp/src/lib/secure_mailing/pgp.rb
Normal file
7
zammad-addon-pgp/src/lib/secure_mailing/pgp.rb
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
# Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/
|
||||
|
||||
class SecureMailing::PGP < SecureMailing::Backend
|
||||
def self.active?
|
||||
Setting.get('pgp_integration')
|
||||
end
|
||||
end
|
||||
170
zammad-addon-pgp/src/lib/secure_mailing/pgp/incoming.rb
Normal file
170
zammad-addon-pgp/src/lib/secure_mailing/pgp/incoming.rb
Normal file
|
|
@ -0,0 +1,170 @@
|
|||
# Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/
|
||||
|
||||
class SecureMailing::PGP::Incoming < SecureMailing::Backend::Handler
|
||||
attr_accessor :mail, :content_type
|
||||
|
||||
EXPRESSION_ENCRYPTED = %r{application/pgp-encrypted}i.freeze
|
||||
EXPRESSION_SIGNATURE = %r{application/pgp-signature}i.freeze
|
||||
|
||||
def initialize(mail)
|
||||
super()
|
||||
|
||||
@mail = mail
|
||||
@content_type = mail[:mail_instance].content_type
|
||||
end
|
||||
|
||||
def process
|
||||
return unless process?
|
||||
|
||||
initialize_article_preferences
|
||||
decrypt
|
||||
verify_signature
|
||||
log
|
||||
end
|
||||
|
||||
def initialize_article_preferences
|
||||
article_preferences[:security] = {
|
||||
type: 'PGP',
|
||||
sign: {
|
||||
success: false,
|
||||
comment: nil
|
||||
},
|
||||
encryption: {
|
||||
success: false,
|
||||
comment: nil
|
||||
}
|
||||
}
|
||||
end
|
||||
|
||||
def article_preferences
|
||||
@article_preferences ||= begin
|
||||
key = :'x-zammad-article-preferences'
|
||||
mail[key] ||= {}
|
||||
mail[key]
|
||||
end
|
||||
end
|
||||
|
||||
def process?
|
||||
signed? || encrypted?
|
||||
end
|
||||
|
||||
def signed?(check_content_type = content_type)
|
||||
EXPRESSION_SIGNATURE.match?(check_content_type)
|
||||
end
|
||||
|
||||
def encrypted?(check_content_type = content_type)
|
||||
EXPRESSION_ENCRYPTED.match?(check_content_type)
|
||||
end
|
||||
|
||||
def decrypt
|
||||
return unless encrypted?
|
||||
|
||||
success = false
|
||||
comment = 'Private key for decryption could not be found.'
|
||||
::PGPKeypair.where.not(private_key: [nil, '']).find_each do |cert|
|
||||
begin
|
||||
index = mail[:attachments].index { |file| file[:preferences]['Content-Type'] == 'application/pgp-encrypted' }
|
||||
data = mail[:attachments][index + 1][:data]
|
||||
decrypted_data = Sequoia.decrypt_for(ciphertext: data.chop, recipient: cert.private_key,
|
||||
password: cert.private_key_secret)
|
||||
rescue StandardError
|
||||
next
|
||||
end
|
||||
|
||||
parse_new_mail(decrypted_data)
|
||||
|
||||
success = true
|
||||
comment = cert.email_addresses.join(', ')
|
||||
|
||||
# overwrite content_type for signature checking
|
||||
@content_type = mail[:mail_instance].content_type
|
||||
break
|
||||
end
|
||||
|
||||
article_preferences[:security][:encryption] = {
|
||||
success: success,
|
||||
comment: comment
|
||||
}
|
||||
end
|
||||
|
||||
def verify_signature
|
||||
return unless signed?
|
||||
|
||||
success = false
|
||||
comment = 'Certificate for verification could not be found.'
|
||||
|
||||
::PGPKeypair.where.not(public_key: [nil, '']).find_each do |cert|
|
||||
next unless cert.email_addresses.include? mail[:from_email]
|
||||
|
||||
begin
|
||||
index = mail[:attachments].index { |file| file[:preferences]['Mime-Type'] == 'application/pgp-signature' }
|
||||
data = mail[:attachments][index][:data]
|
||||
verified_data = Sequoia.verify_detached_from(plaintext: mail[:mail_instance].body.encoded, signature: data.chop,
|
||||
sender: cert.public_key)
|
||||
rescue StandardError
|
||||
next
|
||||
end
|
||||
|
||||
parse_new_mail(verified_data)
|
||||
|
||||
success = true
|
||||
comment = cert.email_addresses.join(', ')
|
||||
|
||||
# overwrite content_type for signature checking
|
||||
@content_type = mail[:mail_instance].content_type
|
||||
break
|
||||
end
|
||||
|
||||
article_preferences[:security][:sign] = {
|
||||
success: success,
|
||||
comment: comment
|
||||
}
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def log
|
||||
%i[sign encryption].each do |action|
|
||||
result = article_preferences[:security][action]
|
||||
next if result.blank?
|
||||
|
||||
if result[:success]
|
||||
status = 'success'
|
||||
elsif result[:comment].blank?
|
||||
# means not performed
|
||||
next
|
||||
else
|
||||
status = 'failed'
|
||||
end
|
||||
|
||||
HttpLog.create(
|
||||
direction: 'in',
|
||||
facility: 'PGP',
|
||||
url: "#{mail[:from_email]} -> #{mail[:to]}",
|
||||
status: status,
|
||||
ip: nil,
|
||||
request: {
|
||||
message_id: mail[:message_id]
|
||||
},
|
||||
response: article_preferences[:security],
|
||||
method: action,
|
||||
created_by_id: 1,
|
||||
updated_by_id: 1
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
def parse_new_mail(new_mail)
|
||||
mail[:mail_instance].header['Content-Type'] = nil
|
||||
mail[:mail_instance].header['Content-Disposition'] = nil
|
||||
mail[:mail_instance].header['Content-Transfer-Encoding'] = nil
|
||||
mail[:mail_instance].header['Content-Description'] = nil
|
||||
|
||||
new_raw_mail = "#{mail[:mail_instance].header}#{new_mail}"
|
||||
|
||||
mail_new = Channel::EmailParser.new.parse(new_raw_mail)
|
||||
mail_new.each do |local_key, local_value|
|
||||
mail[local_key] = local_value
|
||||
end
|
||||
end
|
||||
end
|
||||
120
zammad-addon-pgp/src/lib/secure_mailing/pgp/outgoing.rb
Normal file
120
zammad-addon-pgp/src/lib/secure_mailing/pgp/outgoing.rb
Normal file
|
|
@ -0,0 +1,120 @@
|
|||
# Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/
|
||||
|
||||
class SecureMailing::PGP::Outgoing < SecureMailing::Backend::Handler
|
||||
def initialize(mail, security)
|
||||
super()
|
||||
|
||||
@mail = mail
|
||||
@security = security
|
||||
end
|
||||
|
||||
def process
|
||||
return unless process?
|
||||
|
||||
if @security[:sign][:success]
|
||||
sign
|
||||
log('sign', 'success')
|
||||
end
|
||||
if @security[:encryption][:success]
|
||||
encrypt
|
||||
log('encryption', 'success')
|
||||
end
|
||||
end
|
||||
|
||||
def process?
|
||||
return false if @security.blank?
|
||||
return false if @security[:type] != 'PGP'
|
||||
|
||||
@security[:sign][:success] || @security[:encryption][:success]
|
||||
end
|
||||
|
||||
def cleanup(mail)
|
||||
part = Mail::Part.new
|
||||
if mail.multipart?
|
||||
if mail.content_type =~ /^(multipart[^;]+)/
|
||||
part.content_type Regexp.last_match(1)
|
||||
else
|
||||
part.content_type 'multipart/mixed'
|
||||
end
|
||||
mail.body.parts.each do |p|
|
||||
part.add_part cleanup(p)
|
||||
end
|
||||
else
|
||||
# retain important headers if present
|
||||
part.content_type mail.content_type
|
||||
part.content_id mail.header['Content-ID'] if mail.header['Content-ID']
|
||||
part.content_disposition mail.content_disposition if mail.content_disposition
|
||||
|
||||
# force base64 encoding
|
||||
part.body Mail::Encodings::Base64.encode(mail.body.to_s)
|
||||
part.body.encoding = 'base64'
|
||||
end
|
||||
part
|
||||
end
|
||||
|
||||
def sign
|
||||
from = @mail.from.first
|
||||
cert = PGPKeypair.for_sender_email_address(from)
|
||||
raise "Unable to find PGP private key for '#{from}'" unless cert
|
||||
|
||||
signature = Sequoia.sign_detached_with(plaintext: @mail.body.encoded, sender: cert.private_key,
|
||||
password: cert.private_key_secret)
|
||||
|
||||
signature_part = Mail::Part.new do
|
||||
content_type 'application/pgp-signature; name="signature.asc"'
|
||||
content_disposition 'attachment; filename="signature.asc"'
|
||||
content_description 'OpenPGP signature'
|
||||
body signature
|
||||
end
|
||||
@mail.add_part signature_part
|
||||
@mail.content_type "multipart/signed; protocol=\"application/pgp-signature\"; micalg=\"pgp-sha512\"; boundary=\"#{@mail.boundary}\""
|
||||
rescue StandardError => e
|
||||
log('sign', 'failed', e.message)
|
||||
raise
|
||||
end
|
||||
|
||||
def encrypt
|
||||
recipients = []
|
||||
recipients += @mail.to if @mail.to
|
||||
recipients += @mail.cc if @mail.cc
|
||||
recipients += @mail.bcc if @mail.bcc
|
||||
|
||||
certificates = PGPKeypair.for_recipient_email_addresses!(recipients)
|
||||
|
||||
encrypted_control = Mail::Part.new do
|
||||
content_type 'application/pgp-encrypted'
|
||||
content_description 'OpenPGP version'
|
||||
body 'Version: 1'
|
||||
end
|
||||
|
||||
plaintext = @mail.encoded
|
||||
encrypted_part = Mail::Part.new do
|
||||
content_type 'application/octet-stream; name="encrypted.asc"'
|
||||
content_disposition 'inline; filename="encrypted.asc"'
|
||||
content_description 'OpenPGP encrypted message'
|
||||
body Sequoia.encrypt_for(plaintext: plaintext, recipients: certificates.map(&:public_key))
|
||||
end
|
||||
@mail.body = nil
|
||||
@mail.add_part encrypted_control
|
||||
@mail.add_part encrypted_part
|
||||
@mail.content_type "multipart/encrypted; protocol=\"application/pgp-encrypted\"; boundary=\"#{@mail.boundary}\""
|
||||
rescue StandardError => e
|
||||
log('encryption', 'failed', e.message)
|
||||
raise
|
||||
end
|
||||
|
||||
def log(action, status, error = nil)
|
||||
HttpLog.create(
|
||||
direction: 'out',
|
||||
facility: 'PGP',
|
||||
url: "#{@mail[:from_email]} -> #{@mail[:to]}",
|
||||
status: status,
|
||||
ip: nil,
|
||||
request: @security,
|
||||
response: { error: error },
|
||||
method: action,
|
||||
created_by_id: 1,
|
||||
updated_by_id: 1
|
||||
)
|
||||
end
|
||||
end
|
||||
93
zammad-addon-pgp/src/lib/secure_mailing/pgp/retry.rb
Normal file
93
zammad-addon-pgp/src/lib/secure_mailing/pgp/retry.rb
Normal file
|
|
@ -0,0 +1,93 @@
|
|||
# Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/
|
||||
|
||||
class SecureMailing::PGP::Retry < SecureMailing::Backend::Handler
|
||||
def initialize(article)
|
||||
super()
|
||||
@article = article
|
||||
end
|
||||
|
||||
def process
|
||||
return existing_result if already_processed?
|
||||
|
||||
save_result if retry_succeeded?
|
||||
retry_result
|
||||
end
|
||||
|
||||
def signature_checked?
|
||||
@signature_checked ||= existing_result&.dig('sign', 'success') || false
|
||||
end
|
||||
|
||||
def decrypted?
|
||||
@decrypted ||= existing_result&.dig('encryption', 'success') || false
|
||||
end
|
||||
|
||||
def already_processed?
|
||||
signature_checked? && decrypted?
|
||||
end
|
||||
|
||||
def existing_result
|
||||
@article.preferences['security']
|
||||
end
|
||||
|
||||
def mail
|
||||
@mail ||= begin
|
||||
raw_mail = @article.as_raw.store_file.content
|
||||
Channel::EmailParser.new.parse(raw_mail).tap do |parsed|
|
||||
SecureMailing.incoming(parsed)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def retry_result
|
||||
@retry_result ||= mail['x-zammad-article-preferences']['security']
|
||||
end
|
||||
|
||||
def signature_found?
|
||||
return false if signature_checked?
|
||||
|
||||
retry_result['sign']['success']
|
||||
end
|
||||
|
||||
def decryption_succeeded?
|
||||
return false if decrypted?
|
||||
|
||||
retry_result['encryption']['success']
|
||||
end
|
||||
|
||||
def retry_succeeded?
|
||||
return true if signature_found?
|
||||
|
||||
decryption_succeeded?
|
||||
end
|
||||
|
||||
def save_result
|
||||
save_decrypted if decryption_succeeded?
|
||||
@article.preferences['security'] = retry_result
|
||||
@article.save!
|
||||
end
|
||||
|
||||
def save_decrypted
|
||||
@article.content_type = mail['content_type']
|
||||
@article.body = mail['body']
|
||||
|
||||
Store.remove(
|
||||
object: 'Ticket::Article',
|
||||
o_id: @article.id
|
||||
)
|
||||
|
||||
mail[:attachments]&.each do |attachment|
|
||||
filename = attachment[:filename].force_encoding('utf-8')
|
||||
unless filename.force_encoding('UTF-8').valid_encoding?
|
||||
filename = filename.utf8_encode(fallback: :read_as_sanitized_binary)
|
||||
end
|
||||
Store.add(
|
||||
object: 'Ticket::Article',
|
||||
o_id: @article.id,
|
||||
data: attachment[:data],
|
||||
filename: filename,
|
||||
preferences: attachment[:preferences],
|
||||
created_by_id: @article.created_by_id
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
1
zammad-addon-pgp/src/public/assets/images/icons/pgp.svg
Normal file
1
zammad-addon-pgp/src/public/assets/images/icons/pgp.svg
Normal file
|
|
@ -0,0 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path d="M512 176a176 176 0 01-208.8 173l-24 27a24 24 0 01-18 8H224v40a24 24 0 01-24 24h-40v40a24 24 0 01-24 24H24a24 24 0 01-24-24v-78a24 24 0 017-17l161.8-161.8A176 176 0 11512 176zm-176-48a48 48 0 1096 0 48 48 0 00-96 0z"/><script/></svg>
|
||||
|
After Width: | Height: | Size: 304 B |
24
zammad-addon-pgp/zammad-addon-pgp.szpm.template
Normal file
24
zammad-addon-pgp/zammad-addon-pgp.szpm.template
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
{
|
||||
"name": "PGPSupport",
|
||||
"version": "0.0.1",
|
||||
"vendor": "Center for Digital Resilience",
|
||||
"license": "AGPL-v3+",
|
||||
"url": "https://gitlab.com/digiresilience/link/zammad-addon-pgp",
|
||||
"buildhost": "",
|
||||
"builddate": "",
|
||||
"change_log": [
|
||||
{
|
||||
"version": "0.0.1",
|
||||
"date": "",
|
||||
"log": "Initial version."
|
||||
}
|
||||
],
|
||||
"description": [
|
||||
{
|
||||
"language": "en",
|
||||
"text": "An addon for Zammad to include PGP integration."
|
||||
}
|
||||
],
|
||||
"files": [
|
||||
]
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue