Compare commits
No commits in common. "master" and "v0.8.10" have entirely different histories.
449 changed files with 32789 additions and 36693 deletions
26
.env.example
26
.env.example
|
@ -1,9 +1,9 @@
|
|||
APP_NAME=addy.io
|
||||
APP_NAME=AnonAddy
|
||||
APP_ENV=production
|
||||
APP_KEY=
|
||||
APP_DEBUG=false
|
||||
APP_LOG_LEVEL=debug
|
||||
# The URL of the addy.io instance, can be anything you like e.g. https://aa.example.com, or just https://example.com, if using a non-standard port you must include it e.g. https://example.test:8000. Do not include a trailing slash '/'
|
||||
# The URL of the AnonAddy instance, can be anything you like e.g. aa.example.com, or just example.com
|
||||
APP_URL=https://app.example.com
|
||||
|
||||
LOG_CHANNEL=stack
|
||||
|
@ -11,8 +11,8 @@ LOG_CHANNEL=stack
|
|||
DB_CONNECTION=mysql
|
||||
DB_HOST=127.0.0.1
|
||||
DB_PORT=3306
|
||||
DB_DATABASE=addy_database
|
||||
DB_USERNAME=addy
|
||||
DB_DATABASE=anonaddy_database
|
||||
DB_USERNAME=anonaddy
|
||||
DB_PASSWORD=secret
|
||||
|
||||
BROADCAST_DRIVER=log
|
||||
|
@ -28,16 +28,14 @@ REDIS_HOST=127.0.0.1
|
|||
REDIS_PASSWORD=null
|
||||
REDIS_PORT=6379
|
||||
|
||||
# The from name to be used for outgoing email notifications from addy.io
|
||||
# The from name to be used for outgoing email notifications from AnonAddy
|
||||
MAIL_FROM_NAME=Example
|
||||
# The from address to be used for outgoing email notifications from addy.io
|
||||
# The from address to be used for outgoing email notifications from AnonAddy
|
||||
MAIL_FROM_ADDRESS=mailer@example.com
|
||||
MAIL_DRIVER=smtp
|
||||
MAIL_HOST=mail.example.com
|
||||
MAIL_HOST=localhost
|
||||
MAIL_PORT=25
|
||||
MAIL_ENCRYPTION=tls
|
||||
MAIL_EHLO_DOMAIN=mail.example.com
|
||||
MAIL_VERIFY_PEER=true
|
||||
MAIL_ENCRYPTION=null
|
||||
|
||||
# The SMTP FROM address to be used if the alias address cannot be, e.g. for a custom domain that is not verified for sending
|
||||
ANONADDY_RETURN_PATH=mailer@example.com
|
||||
|
@ -48,7 +46,7 @@ ANONADDY_DOMAIN=example.com
|
|||
ANONADDY_HOSTNAME=mail.example.com
|
||||
ANONADDY_DNS_RESOLVER=127.0.0.1
|
||||
ANONADDY_ALL_DOMAINS=example.com,example2.com
|
||||
# Used for verifying custom domains and variable envelope return paths, can be anything e.g. 64U64QcpgWHAZPyr4nN58kDGvwj9TkKMGyuXcjMFA7CdhTDy2f
|
||||
# Used for verifying custom domains, can be anything e.g. 64U64QcpgWHAZPyr4nN58kDGvwj9TkKMGyuXcjMFA7CdhTDy2f
|
||||
ANONADDY_SECRET=long-random-string
|
||||
# Number of emails that can be forwarded through the service per hour by any one user
|
||||
ANONADDY_LIMIT=200
|
||||
|
@ -62,4 +60,8 @@ ANONADDY_ADDITIONAL_USERNAME_LIMIT=10
|
|||
ANONADDY_SIGNING_KEY_FINGERPRINT=
|
||||
# This is only needed if you will be adding any custom domains. If you do not need it then leave it blank. ANONADDY_DKIM_SIGNING_KEY=/etc/opendkim/keys/example.com/default.private
|
||||
ANONADDY_DKIM_SIGNING_KEY=
|
||||
ANONADDY_DKIM_SELECTOR=default
|
||||
ANONADDY_DKIM_SELECTOR=default
|
||||
|
||||
# These details will be displayed after you run php artisan passport:install, you should update accordingly
|
||||
PASSPORT_PERSONAL_ACCESS_CLIENT_ID=client-id-value
|
||||
PASSPORT_PERSONAL_ACCESS_CLIENT_SECRET=unhashed-client-secret-value
|
9
.gitignore
vendored
9
.gitignore
vendored
|
@ -1,4 +1,3 @@
|
|||
/.phpunit.cache
|
||||
/node_modules
|
||||
/public/hot
|
||||
/public/storage
|
||||
|
@ -7,22 +6,14 @@
|
|||
/public/js
|
||||
/public/mix-manifest.json
|
||||
/storage/*.key
|
||||
/storage/debugbar
|
||||
/vendor
|
||||
/postfix/vendor
|
||||
/.fleet
|
||||
/.idea
|
||||
/.vscode
|
||||
/.vagrant
|
||||
Homestead.json
|
||||
Homestead.yaml
|
||||
auth.json
|
||||
npm-debug.log
|
||||
yarn-error.log
|
||||
.env
|
||||
.env.backup
|
||||
.env.production
|
||||
.php-cs-fixer.cache
|
||||
.phpunit.result.cache
|
||||
ray.php
|
||||
.husky/pre-commit
|
||||
|
|
|
@ -1,12 +1,10 @@
|
|||
#!/usr/bin/env sh
|
||||
#!/bin/sh
|
||||
if [ -z "$husky_skip_init" ]; then
|
||||
debug () {
|
||||
if [ "$HUSKY_DEBUG" = "1" ]; then
|
||||
echo "husky (debug) - $1"
|
||||
fi
|
||||
[ "$HUSKY_DEBUG" = "1" ] && echo "husky (debug) - $1"
|
||||
}
|
||||
|
||||
readonly hook_name="$(basename -- "$0")"
|
||||
readonly hook_name="$(basename "$0")"
|
||||
debug "starting $hook_name..."
|
||||
|
||||
if [ "$HUSKY" = "0" ]; then
|
||||
|
@ -19,18 +17,14 @@ if [ -z "$husky_skip_init" ]; then
|
|||
. ~/.huskyrc
|
||||
fi
|
||||
|
||||
readonly husky_skip_init=1
|
||||
export husky_skip_init
|
||||
export readonly husky_skip_init=1
|
||||
sh -e "$0" "$@"
|
||||
exitCode="$?"
|
||||
|
||||
if [ $exitCode != 0 ]; then
|
||||
echo "husky - $hook_name hook exited with code $exitCode (error)"
|
||||
exit $exitCode
|
||||
fi
|
||||
|
||||
if [ $exitCode = 127 ]; then
|
||||
echo "husky - command not found in PATH=$PATH"
|
||||
fi
|
||||
|
||||
exit $exitCode
|
||||
exit 0
|
||||
fi
|
||||
|
|
4
.husky/pre-commit
Executable file
4
.husky/pre-commit
Executable file
|
@ -0,0 +1,4 @@
|
|||
#!/bin/sh
|
||||
. "$(dirname "$0")/_/husky.sh"
|
||||
|
||||
npm run pre-commit
|
21
.php-cs-fixer.php
Normal file
21
.php-cs-fixer.php
Normal file
|
@ -0,0 +1,21 @@
|
|||
<?php
|
||||
|
||||
$finder = Symfony\Component\Finder\Finder::create()
|
||||
->notPath('vendor')
|
||||
->notPath('bootstrap')
|
||||
->notPath('storage')
|
||||
->in(__DIR__)
|
||||
->name('*.php')
|
||||
->notName('*.blade.php')
|
||||
->ignoreDotFiles(true)
|
||||
->ignoreVCS(true);
|
||||
|
||||
$config = new PhpCsFixer\Config();
|
||||
|
||||
return $config->setRules([
|
||||
'@PSR2' => true,
|
||||
'array_syntax' => ['syntax' => 'short'],
|
||||
'ordered_imports' => ['sort_algorithm' => 'alpha'],
|
||||
'no_unused_imports' => true,
|
||||
])
|
||||
->setFinder($finder);
|
673
LICENSE.md
673
LICENSE.md
|
@ -1,661 +1,22 @@
|
|||
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.
|
||||
MIT License
|
||||
|
||||
Preamble
|
||||
Copyright (c) 2019 anonaddy
|
||||
|
||||
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.
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
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.
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
Developers that use our General Public Licenses protect your rights
|
||||
with two steps: (1) assert copyright on the software, and (2) offer
|
||||
you this License which gives you legal permission to copy, distribute
|
||||
and/or modify the software.
|
||||
|
||||
A secondary benefit of defending all users' freedom is that
|
||||
improvements made in alternate versions of the program, if they
|
||||
receive widespread use, become available for other developers to
|
||||
incorporate. Many developers of free software are heartened and
|
||||
encouraged by the resulting cooperation. However, in the case of
|
||||
software used on network servers, this result may fail to come about.
|
||||
The GNU General Public License permits making a modified version and
|
||||
letting the public access it on a server without ever releasing its
|
||||
source code to the public.
|
||||
|
||||
The GNU Affero General Public License is designed specifically to
|
||||
ensure that, in such cases, the modified source code becomes available
|
||||
to the community. It requires the operator of a network server to
|
||||
provide the source code of the modified version running there to the
|
||||
users of that server. Therefore, public use of a modified version, on
|
||||
a publicly accessible server, gives the public access to the source
|
||||
code of the modified version.
|
||||
|
||||
An older license, called the Affero General Public License and
|
||||
published by Affero, was designed to accomplish similar goals. This is
|
||||
a different license, not a version of the Affero GPL, but Affero has
|
||||
released a new version of the Affero GPL which permits relicensing under
|
||||
this license.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU Affero General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Remote Network Interaction; Use with the GNU General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, if you modify the
|
||||
Program, your modified version must prominently offer all users
|
||||
interacting with it remotely through a computer network (if your version
|
||||
supports such interaction) an opportunity to receive the Corresponding
|
||||
Source of your version by providing access to the Corresponding Source
|
||||
from a network server at no charge, through some standard or customary
|
||||
means of facilitating copying of software. This Corresponding Source
|
||||
shall include the Corresponding Source for any work covered by version 3
|
||||
of the GNU General Public License that is incorporated pursuant to the
|
||||
following paragraph.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the work with which it is combined will remain governed by version
|
||||
3 of the GNU General Public License.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU Affero General Public License from time to time. Such new versions
|
||||
will be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU Affero General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU Affero General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU Affero General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published
|
||||
by the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If your software can interact with users remotely through a computer
|
||||
network, you should also make sure that it provides a way for users to
|
||||
get its source. For example, if your program is a web application, its
|
||||
interface could display a "Source" link that leads users to an archive
|
||||
of the code. There are many ways you could offer source, and different
|
||||
solutions will be better for different programs; see section 13 for the
|
||||
specific requirements.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU AGPL, see
|
||||
<https://www.gnu.org/licenses/>.
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
|
193
README.md
193
README.md
|
@ -1,12 +1,12 @@
|
|||
# Anonymous Email Forwarding
|
||||
|
||||
This is the source code for self-hosting addy.io.
|
||||
This is the source code for self-hosting AnonAddy.
|
||||
|
||||
## FAQ
|
||||
|
||||
- [Why is it called addy.io?](#why-is-it-called-addyio)
|
||||
- [Why is it called AnonAddy?](#why-is-it-called-anonaddy)
|
||||
- [Why did you make this site?](#why-did-you-make-this-site)
|
||||
- [Why should I use addy.io?](#why-should-i-use-addyio)
|
||||
- [Why should I use AnonAddy?](#why-should-i-use-anonaddy)
|
||||
- [Do you store emails?](#do-you-store-emails)
|
||||
- [What is a shared domain alias?](#what-is-a-shared-domain-alias)
|
||||
- [What is a standard alias?](#what-is-a-standard-alias)
|
||||
|
@ -17,15 +17,9 @@ This is the source code for self-hosting addy.io.
|
|||
- [Is there a browser extension?](#is-there-a-browser-extension)
|
||||
- [Is there an Android app?](#is-there-an-android-app)
|
||||
- [Is there an iOS app?](#is-there-an-ios-app)
|
||||
- [Is there a Raycast extension?](#is-there-a-raycast-extension)
|
||||
- [How do I add my own GPG/OpenPGP key for encryption?](#how-do-i-add-my-own-gpgopenpgp-key-for-encryption)
|
||||
- [Are attachments encrypted too?](#are-attachments-encrypted-too)
|
||||
- [Are forwarded emails signed when encryption is enabled?](#are-forwarded-emails-signed-when-encryption-is-enabled)
|
||||
- [Can I reply/send from aliases using encryption?](#can-i-replysend-from-aliases-using-encryption)
|
||||
- [Is my public GPG/OpenPGP key removed when I reply/send from an alias?](#is-my-public-gpgopenpgp-key-removed-when-i-replysend-from-an-alias)
|
||||
- [Can I mark emails forwarded to me by addy.io as spam?](#can-i-mark-emails-forwarded-to-me-by-addyio-as-spam)
|
||||
- [Can I use aliases to create multiple accounts on other websites and services?](#can-i-use-aliases-to-create-multiple-accounts-on-other-websites-and-services)
|
||||
- [Can I have multiple Free accounts?](#can-i-have-multiple-free-accounts)
|
||||
- [What if I don't want anyone to link ownership of my aliases together?](#what-if-i-dont-want-anyone-to-link-ownership-of-my-aliases-together)
|
||||
- [Where is the server located?](#where-is-the-server-located)
|
||||
- [What if I don't trust you?](#what-if-i-dont-trust-you)
|
||||
|
@ -35,15 +29,13 @@ This is the source code for self-hosting addy.io.
|
|||
- [How do I reply to a forwarded email?](#how-do-i-reply-to-a-forwarded-email)
|
||||
- [I'm trying to reply/send from an alias but the email keeps coming back to me, what's wrong?](#im-trying-to-replysend-from-an-alias-but-the-email-keeps-coming-back-to-me-whats-wrong)
|
||||
- [I'm trying to reply/send from an alias but it is rejected, what's wrong?](#im-trying-to-replysend-from-an-alias-but-it-is-rejected-whats-wrong)
|
||||
- [I've been forwarded an email with a red warning banner saying it may have been spoofed, what does it mean?](#ive-been-forwarded-an-email-with-a-red-warning-banner-saying-it-may-have-been-spoofed-what-does-it-mean)
|
||||
- [Does addy.io strip out the banner information when I reply to an email?](#does-addyio-strip-out-the-banner-information-when-i-reply-to-an-email)
|
||||
- [Does AnonAddy strip out the banner information when I reply to an email?](#does-anonaddy-strip-out-the-banner-information-when-i-reply-to-an-email)
|
||||
- [How do I send email from an alias?](#how-do-i-send-email-from-an-alias)
|
||||
- [Will people see my real email if I reply to a forwarded one?](#will-people-see-my-real-email-if-i-reply-to-a-forwarded-one)
|
||||
- [Can emails have attachments?](#can-emails-have-attachments)
|
||||
- [What is the max email size limit?](#what-is-the-max-email-size-limit)
|
||||
- [What happens if I have a subscription but then cancel it?](#what-happens-if-i-have-a-subscription-but-then-cancel-it)
|
||||
- [If I subscribe will Stripe see my real email address?](#if-i-subscribe-will-stripe-see-my-real-email-address)
|
||||
- [Do you offer student discount?](#do-you-offer-student-discount)
|
||||
- [How do you prevent spammers?](#how-do-you-prevent-spammers)
|
||||
- [What do you use to do DNS lookups on domain names?](#what-do-you-use-to-do-dns-lookups-on-domain-names)
|
||||
- [Is there a limit to how many emails I can forward?](#is-there-a-limit-to-how-many-emails-i-can-forward)
|
||||
|
@ -55,15 +47,15 @@ This is the source code for self-hosting addy.io.
|
|||
- [I'm not receiving any emails, what's wrong?](#im-not-receiving-any-emails-whats-wrong)
|
||||
- [I'm having trouble logging in, what's wrong?](#im-having-trouble-logging-in-whats-wrong)
|
||||
- [How do I know this site won't disappear next month?](#how-do-i-know-this-site-wont-disappear-next-month)
|
||||
- [What happens to addy.io if you die?](#what-happens-to-addyio-if-you-die)
|
||||
- [What happens to AnonAddy if you die?](#what-happens-to-anonaddy-if-you-die)
|
||||
- [Is the application tested?](#is-the-appliction-tested)
|
||||
- [How do I host this myself?](#how-do-i-host-this-myself)
|
||||
- [Who's behind addy.io?](#whos-behind-addyio)
|
||||
- [Who's behind AnonAddy?](#whos-behind-anonaddy)
|
||||
- [I couldn't find an answer to my question, how can I contact you?](#i-couldnt-find-an-answer-to-my-question-how-can-i-contact-you)
|
||||
|
||||
## Why is it called addy.io?
|
||||
## Why is it called AnonAddy?
|
||||
|
||||
Addy is short for "Address". The word "Addy" is internet slang for an email address, e.g.
|
||||
AnonAddy is short for "Anonymous Email Address". The word "Addy" is internet slang for email address, e.g.
|
||||
|
||||
> "My addy is being spammed. I should've kept it private."
|
||||
|
||||
|
@ -82,7 +74,7 @@ I made the code open-source to show everyone what was going on behind the scenes
|
|||
|
||||
I use this service myself for the vast majority of sites I'm signed up to.
|
||||
|
||||
## Why should I use addy.io?
|
||||
## Why should I use AnonAddy?
|
||||
|
||||
There are a number of reasons you should consider using this service:
|
||||
|
||||
|
@ -95,7 +87,7 @@ There are a number of reasons you should consider using this service:
|
|||
|
||||
## Do you store emails?
|
||||
|
||||
Emails are only ever stored in the event of a failed delivery, and only if you have this option enabled in your account settings.
|
||||
No I definitely do not store/save any emails that pass through the server.
|
||||
|
||||
## What is a shared domain alias?
|
||||
|
||||
|
@ -103,7 +95,7 @@ A shared domain alias is any alias that has a domain name that is also shared wi
|
|||
|
||||
## What is a standard alias?
|
||||
|
||||
A standard alias is any alias that can be created on-the-fly. Automatic on-the-fly alias creation is only available for domains that are unique to you. For example, your unique username subdomain, any additional usernames or any custom domains. So if you signed up with the username "johndoe", any alias you create using @johndoe.anonaddy.com would be a standard alias (even if you've generated a Random Character/Random Word one).
|
||||
A standard alias is any alias that can be created on-the-fly. Automatic on-the-fly alias creation is only available for domains that are unique to you. For example, your unique username subdomain, any additional usernames or any custom domains. So if you signed up with the username "johndoe", any alias you create using @johndoe.anonaddy.com would be a standard alias (even if you've generated a UUID/Random Word one).
|
||||
|
||||
## Can I use my own domain?
|
||||
|
||||
|
@ -111,24 +103,24 @@ Yes you can use your own domain name so you can also have *@example.com as your
|
|||
|
||||
## Can I add a domain and also use it as a recipient?
|
||||
|
||||
No, you cannot use the same domain as a custom domain and also for a recipient on addy.io.
|
||||
No, you cannot use the same domain as a custom domain and also for a recipient on AnonAddy.
|
||||
|
||||
e.g if you add "example.com" as a custom domain, you cannot then add "xyz@example.com" as a recipient. This is because a domain cannot direct email to multiple locations simultaneously using MX records. So your email would arrive for "example.com" and then attempt to be forwarded to "xyz@example.com" which would create a loop.
|
||||
|
||||
You can instead use a subdomain for your custom domain, e.g. "mail.example.com" instead of "example.com", this would allow you to create *@mail.example.com for your aliases. More details can be found [here](https://addy.io/help/adding-a-custom-domain/).
|
||||
You can instead use a subdomain for your custom domain, e.g. "mail.example.com" instead of "example.com", this would allow you to create *@mail.example.com for your aliases. More details can be found [here](https://anonaddy.com/help/adding-a-custom-domain/).
|
||||
|
||||
## Can I add a domain if I'm already using it for email somewhere else?
|
||||
|
||||
If you have a custom domain say **example.com** and you are already using it for email somewhere else e.g. ProtonMail or Namecheap then you cannot also use it simultaneously with addy.io.
|
||||
If you have a custom domain say **example.com** and you are already using it for email somewhere else e.g. ProtonMail or Namecheap then you cannot also use it simultaneously with AnonAddy.
|
||||
|
||||
This is because emails cannot be handled by multiple different mail servers at the same time, even if they have the same priority MX records. It can only be delivered to one mail server at a time which will typically be the MX record with the smallest number since this has the highest priority.
|
||||
|
||||
You can either:
|
||||
|
||||
- Migrate your domain to addy.io by removing the current provider's MX records and adding addy.io's.
|
||||
- Or, if you would like to keep using your domain with your current email provider then I would recommend instead adding a subdomain of it to addy.io such as **mail.example.com**.
|
||||
- Migrate your domain to AnonAddy by removing the current provider's MX records and adding AnonAddy's.
|
||||
- Or, if you would like to keep using your domain with your current email provider then I would recommend instead adding a subdomain of it to AnonAddy such as **mail.example.com**.
|
||||
|
||||
Using a subdomain will not interfere with your current email setup and you'll be able to create aliases ***@mail.example.com** through addy.io.
|
||||
Using a subdomain will not interfere with your current email setup and you'll be able to create aliases ***@mail.example.com** through AnonAddy.
|
||||
|
||||
## Why should I use this instead of a similar service?
|
||||
|
||||
|
@ -141,14 +133,14 @@ Here are a few reasons I can think of:
|
|||
* Open-source application code
|
||||
* No limitation on the number of aliases that can be created
|
||||
* Generous monthly bandwidth
|
||||
* Multiple domains to choose for aliases (currently anonaddy.com, anonaddy.me and more for paid plan users)
|
||||
* Ability to generate random character and random word aliases at shared domains
|
||||
* Multiple domains to choose for aliases (currently anonaddy.com, anonaddy.me and another 3 for paid plan users)
|
||||
* Ability to generate UUID and random word aliases at shared domains
|
||||
* Ability to add additional usernames to compartmentalise aliases
|
||||
* New features added regularly
|
||||
|
||||
## Is there a browser extension?
|
||||
|
||||
Yes there is an [open-source](https://github.com/anonaddy/browser-extension) browser extension available to download for [Firefox](https://addons.mozilla.org/en-GB/firefox/addon/addy_io/) and [Chrome](https://chrome.google.com/webstore/detail/addyio-anonymous-email-fo/iadbdpnoknmbdeolbapdackdcogdmjpe) (also available on other chromium based browsers such as Brave and Vivaldi). You can use the extension to generate new aliases remotely.
|
||||
Yes there is an [open-source](https://github.com/anonaddy/browser-extension) browser extension available to download for [Firefox](https://addons.mozilla.org/en-GB/firefox/addon/anonaddy/) and [Chrome](https://chrome.google.com/webstore/detail/anonaddy/iadbdpnoknmbdeolbapdackdcogdmjpe) (also available on other chromium based browsers such as Brave and Vivaldi). You can use the extension to generate new aliases remotely.
|
||||
|
||||
## Is there an Android app?
|
||||
|
||||
|
@ -160,13 +152,9 @@ There is also another [open-source](https://github.com/KhalidWar/anonaddy) Andro
|
|||
|
||||
Yes, [KhalidWar's](https://github.com/KhalidWar) [open-source](https://github.com/KhalidWar/anonaddy) app from above is also available on the [App Store](https://apps.apple.com/us/app/addymanager/id1547461270).
|
||||
|
||||
## Is there a Raycast extension?
|
||||
|
||||
Yes, [http.james'](https://httpjames.space/) [open-source](https://github.com/raycast/extensions/tree/cceffa51046266f25819f800316561b783c52663/extensions/anonaddy/) extension is available on the [Raycast Store](https://www.raycast.com/http.james/anonaddy).
|
||||
|
||||
## How do I add my own GPG/OpenPGP key for encryption?
|
||||
|
||||
On the recipients page you simply need to click "Add public key" and paste in your **public** key data. Now all emails forwarded to you will be encrypted with your key. You can even hide and encrypt the subject as addy.io supports protected headers.
|
||||
On the recipients page you simply need to click "Add public key" and paste in your **public** key data. Now all emails forwarded to you will be encrypted with your key. You should also replace the subject line of forwarded messages in your account settings as this cannot be encrypted.
|
||||
|
||||
## Are attachments encrypted too?
|
||||
|
||||
|
@ -174,44 +162,18 @@ Yes attachments are part of the email body and are also encrypted if you have it
|
|||
|
||||
## Are forwarded emails signed when encryption is enabled?
|
||||
|
||||
Yes when you have encryption enabled all forwarded emails are signed using our no-reply@addy.io private key.
|
||||
Yes when you have encryption enabled all forwarded emails are signed using our mailer@anonaddy.me private key.
|
||||
|
||||
You can add this key to your own keyring so that you can verify emails have come from us.
|
||||
|
||||
The fingerprint of the no-reply@addy.io key is "26A987650243B28802524E2F809FD0D502E2F695" you can find the key on [https://keys.openpgp.org](https://keys.openpgp.org/search?q=26A987650243B28802524E2F809FD0D502E2F695).
|
||||
|
||||
## Can I reply/send from aliases using encryption?
|
||||
|
||||
1. If the person you are sending your message to **already uses GPG/OpenPGP encryption** then you can simply encrypt your reply/send from your alias using their public key.
|
||||
|
||||
2. If the person you are sending your message to **does not use GPG/OpenPGP encryption** then you can instead encrypt your reply/send with the `no-reply@addy.io` [public key](https://keys.openpgp.org/search?q=26A987650243B28802524E2F809FD0D502E2F695) (<span class="break-words">"26A987650243B28802524E2F809FD0D502E2F695"</span>). Your reply/send will then be **automatically decrypted** on the addy.io server before being sent on to the correct destination in clear text. This is useful if you wish to hide your replies/sends from your email provider such as Gmail.
|
||||
|
||||
## Is my public GPG/OpenPGP key removed when I reply/send from an alias?
|
||||
|
||||
Yes, any attached GPG/OpenPGP public keys or GPG/OpenPGP signatures are automatically removed when replying or sending from an alias. This is to prevent you accidentally revealing your real email address which is usually shown as an identity in your public key.
|
||||
|
||||
## Can I mark emails forwarded to me by addy.io as spam?
|
||||
|
||||
No, you must not mark messages forwarded to you by addy.io as spam as this can damage the reputation of the mail servers and is against the [terms and conditions](https://addy.io/terms/).
|
||||
|
||||
If an alias is receiving spam messages then please deactivate it or delete it.
|
||||
|
||||
addy.io is signed up to multiple feedback loops (FBLs) that trigger a notification when any messages are marked as spam. Repeatedly marking messages as spam will result in your account being disabled.
|
||||
|
||||
## Can I use aliases to create multiple accounts on other websites and services?
|
||||
|
||||
No, you must not use addy.io to create large numbers of accounts on other websites/services as this is against the [terms and conditions](https://addy.io/terms/).
|
||||
|
||||
## Can I have multiple Free accounts?
|
||||
|
||||
Having multiple Free accounts is not considered an acceptable use of our service. Any users found to be abusing this rule may have their accounts disabled. This does not apply to those with a paid subscription.
|
||||
The fingerprint of the mailer@anonaddy.me key is "26A987650243B28802524E2F809FD0D502E2F695" you can find the key on [https://keys.openpgp.org](https://keys.openpgp.org/search?q=26A987650243B28802524E2F809FD0D502E2F695).
|
||||
|
||||
## What if I don't want anyone to link ownership of my aliases together?
|
||||
|
||||
If you're concerned that your aliases are all linked by your username e.g. @johndoe.anonaddy.com, then you have a couple of options:
|
||||
|
||||
1. You can generate random character or random word aliases instead, these are all under a shared domain and cannot be linked to a user.
|
||||
2. You can add additional usernames and separate your aliases under each of them. e.g. you could have one username for personal stuff, another for work, another for hobbies etc.
|
||||
1. You can generate UUID or random word aliases instead, these are all under a shared domain and cannot be linked to a user.
|
||||
2. You can add additional usernames and separate your aliases under your these. e.g. you could have one username for personal stuff, another for work, another for hobbies etc.
|
||||
|
||||
## Where is the server located?
|
||||
|
||||
|
@ -230,7 +192,7 @@ The limit is currently set to 10 which should suffice in the vast majority of si
|
|||
When you delete your account the following happens:
|
||||
|
||||
* All of your recipients are deleted from the database
|
||||
* All of your aliases that use a shared domain e.g. @anonaddy.me are soft deleted from the database (this is to prevent any chance of another user generating the same alias in the future) any identifying information e.g the alias description is removed
|
||||
* All of your aliases that use a shared domain e.g. @anonaddy.me are soft deleted from the database (this is to prevent any chance of another user generating the same alias in the future)
|
||||
* All of your other aliases are deleted from the database
|
||||
* All of your custom domains are deleted from the database
|
||||
* Your user details are deleted from the database
|
||||
|
@ -253,11 +215,11 @@ All you need to do is click reply in your email client or web interface and it w
|
|||
|
||||
To check if a reply has worked properly check in your dashboard if the reply count has been incremented for that alias.
|
||||
|
||||
For further details please see this help article - [Replying to email using an alias](https://addy.io/help/replying-to-email-using-an-alias/).
|
||||
For further details please see this help article - [Replying to email using an alias](https://anonaddy.com/help/replying-to-email-using-an-alias/).
|
||||
|
||||
## I'm trying to reply/send from an alias but the email keeps coming back to me, what's wrong?
|
||||
|
||||
If you are trying to reply or send from an alias but the email keeps coming back to yourself then it is most likely because you are not sending the message from an email address that **is not listed as a verified recipient** on your addy.io account.
|
||||
If you are tying to reply or send from an alias but the email keeps coming back to yourself then it is most likely because you are not sending the message from an email address that **is not listed as a verified recipient** on your AnonAddy account.
|
||||
|
||||
If you try to reply or send from an alias using an unverified email address then the message will simply be forwarded to you as it would be if it was sent by any other sender.
|
||||
|
||||
|
@ -265,15 +227,17 @@ Please double check that you are indeed sending from a verified recipient email
|
|||
|
||||
## I'm trying to reply/send from an alias but it is rejected, what's wrong?
|
||||
|
||||
If you see the rejection message `550 5.1.1 Recipient address rejected: Address does not exist` then this means that the alias has either been deleted or does not yet exist (and you do not have catch-all enabled), you must restore (or create) it before you can send/reply from it.
|
||||
If you see the rejection message `5.7.1 Recipient address rejected: Address does not exist` then this means that the alias has either been deleted or does not yet exist (and you do not have catch-all enabled), you must restore (or create) it before you can send/reply from it.
|
||||
|
||||
If you receive an email notification with the subject "Attempted reply/send from alias has failed" then it is usually because you have a verified recipient that is using your own domain which does not have a DMARC policy.
|
||||
If you see the rejection message `5.7.1 Rejected due to missing/failed DMARC policy...` then it is because your AnonAddy recipient's domain either does not have a DMARC policy or it has failed DMARC checks.
|
||||
|
||||
> Note: This is referring to **your verified recipient address** on your addy.io account **and not** any of your custom domains or the email address that you are replying / sending to
|
||||
This is usually because you have a verified recipient that is using your own domain which does not have a DMARC policy.
|
||||
|
||||
When replying or sending from an alias, **additional checks** are carried out to ensure it is not a spoofed email. Your addy.io recipient's email domain must pass DMARC checks in order to protect against spoofed emails and to make sure that the reply/send from attempt definitely came from your recipient.
|
||||
> Note: This is referring to **your verified recipient address** on your AnonAddy account **and not** any of your custom domains or the email address that you are replying / sending to
|
||||
|
||||
For example if the verified recipient on your addy.io account is `hello@example.com` and you get this email notification then it is because the domain "example.com" does not have a DMARC policy in place.
|
||||
When replying or sending from an alias, **additional checks** are carried out to ensure it is not a spoofed email. Your AnonAddy recipient's email domain must pass DMARC checks in order to protect against spoofed emails and to make sure that the reply/send from attempt definitely came from your recipient.
|
||||
|
||||
For example if the verified recipient on your AnonAddy account is `hello@example.com` and you get the "missing/failed DMARC policy" rejection message then it is because the domain "example.com" does not have a DMARC policy in place.
|
||||
|
||||
To resolve this you simply need to add a DMARC record, for example:
|
||||
|
||||
|
@ -286,21 +250,11 @@ You should also have SPF and DKIM records in place.
|
|||
|
||||
To learn more about DMARC please see this site - [https://dmarc.org/](https://dmarc.org/).
|
||||
|
||||
If your addy.io recipient is with a popular mail service provider for example: Gmail, Outlook, Tutanota, Mailbox.org, Protonmail etc. then they will already have a DMARC policy in place so you do not need to take any action.
|
||||
If your AnonAddy recipient is with a popular mail service provider for example: Gmail, Outlook, Tutanota, Mailbox.org, Protonmail etc. then they will already have a DMARC policy in place so you do not need to take any action.
|
||||
|
||||
## I've been forwarded an email with a red warning banner saying it may have been spoofed, what does it mean?
|
||||
## Does AnonAddy strip out the banner information when I reply to an email?
|
||||
|
||||
If an incoming email looks like spam (for example, because it has failed its [DMARC](https://dmarc.org/overview/) check) then a red warning banner is added by addy.io before forwarding the message on to you. This warning banner is added in order to help protect you from any potential phishing attempts, for example someone pretending to be your bank.
|
||||
|
||||
Most of the time this is nothing to worry about and is just because the sender has not correctly configured their DNS records.
|
||||
|
||||
To see why this banner was added you can view the headers of the received email and look for the header called 'X-AnonAddy-Authentication-Results'. This header shows the original email's authentication results and will show you why the email failed its DMARC checks.
|
||||
|
||||
## Does addy.io strip out the banner information when I reply to an email?
|
||||
|
||||
Yes, the email banner "This email was sent to..." will be automatically removed when you reply to any messages. You can test this by replying to yourself from one of your aliases.
|
||||
|
||||
Make sure not to alter or edit the email banner as this may cause issues when trying to match and remove it. You can still remove it manually from the quoted message of your reply if you wish.
|
||||
At the moment the site does not automatically strip out the "This email was sent to..." text from forwarded emails when you reply to them. You need to either remove this from the quoted text manually or set the banner information to "off" in your account settings.
|
||||
|
||||
## How do I send email from an alias?
|
||||
|
||||
|
@ -330,7 +284,7 @@ If you need to send an email to an address with an extension e.g. **hello+whatev
|
|||
|
||||
Just enter the extension too!
|
||||
|
||||
For further details please see this help article - [Sending email from an alias](https://addy.io/help/sending-email-from-an-alias/).
|
||||
For further details please see this help article - [Sending email from an alias](https://anonaddy.com/help/sending-email-from-an-alias/).
|
||||
|
||||
## Will people see my real email if I reply to a forwarded one?
|
||||
|
||||
|
@ -342,7 +296,7 @@ Yes you can add attachments to emails forwarded and replies. Attachments count t
|
|||
|
||||
## What is the max email size limit?
|
||||
|
||||
The max email size is currently set to 25MB (including attachments).
|
||||
The max email size is currently set to 10MB (including attachments).
|
||||
|
||||
## What happens if I have a subscription but then cancel it?
|
||||
|
||||
|
@ -352,21 +306,17 @@ A few days before your billing cycle ends you will receive an email letting you
|
|||
|
||||
* Any custom domains will be **deactivated**
|
||||
* Any additional usernames will be **deactivated**
|
||||
* If you have any more than **1 recipient** they will be **deleted**
|
||||
* If you have any more than **2 recipients** they will be **deleted**
|
||||
* Paid account settings will be reverted to default values
|
||||
* Any aliases using paid plan only domains will be **deactivated**
|
||||
* If you have any more than 10 aliases using a shared domain e.g. anonaddy.me they will be **deactivated**
|
||||
* If you have any more than 20 aliases using a shared domain e.g. anonaddy.me they will be **deactivated**
|
||||
* If your account username has catch-all disabled then it will be enabled
|
||||
|
||||
You will not be able to activate any of the above again until you resubscribe.
|
||||
|
||||
## If I subscribe will Stripe see my real email address?
|
||||
|
||||
When you subscribe you can choose which email to provide to Stripe, feel free to use an alias. This email will be used for notifications from Stripe such as; if your card payment fails or if your card has expired.
|
||||
|
||||
## Do you offer student discount?
|
||||
|
||||
Currently, addy.io does not offer any student discounts.
|
||||
No, Stripe will instead be given an alias. This alias will only be created if Stripe sends an email to it, for example if your card payment fails or if your card has expired.
|
||||
|
||||
## How do you prevent spammers?
|
||||
|
||||
|
@ -397,25 +347,25 @@ Each time a new email is received Postfix calculates its size in bytes. A column
|
|||
|
||||
I don't use rolling 30 day total as the only way to do this would be to log the date and size of every single email received.
|
||||
|
||||
Blocked emails do not count towards your bandwidth (e.g. if an alias is inactive or deleted).
|
||||
Blocked emails do not count towards your bandwidth (e.g. an alias is inactive or deleted).
|
||||
|
||||
## How many emails can I receive before I go over my bandwidth limit?
|
||||
|
||||
The average email is about 76800 bytes (75KB), this is roughly equivalent to 7,000 words in plain text. So the 10MB monthly allowance would be around 140 emails and the Lite plan's 100MB would be almost 1,400 emails.
|
||||
The average email is about 76800 bytes (75KB), this is roughly equivalent to 7,000 words in plain text. So the 10MB monthly allowance would be around 140 emails and the Lite plan's 50MB would be almost 700 emails.
|
||||
|
||||
## What happens if I go over my bandwidth limit in a given month?
|
||||
|
||||
If you get close to your limit (over 80%) you'll be sent an email letting you know. If you continue and go over your limit the server will respond to any delivery attempts to your aliases with the following: `552 5.2.2 Recipient address rejected: User over quota` until your bandwidth resets the next month or you upgrade your plan.
|
||||
If you get close to your limit (over 80%) you'll be sent an email letting you know. If you continue and go over your limit the server will start discarding emails until your bandwidth resets the next month or you upgrade your plan.
|
||||
|
||||
## Can I login using an additional username?
|
||||
|
||||
Yes, you can login with any of your usernames. You can add 5 additional username as a Lite user and up to 20 additional usernames as a Pro user for totals of 6 and 21 respectively (including the one you signed up with).
|
||||
You can add 1 additional username as a Lite user and up to 3 additional usernames as a Pro user for totals of 2 and 4 respectively (including the one you signed up with). You can currently only login with the one that you originally signed up with.
|
||||
|
||||
## I'm not receiving any emails, what's wrong?
|
||||
|
||||
Please make sure to add no-reply@addy.io and any aliases you use to your address book and also to check your spam folder. Make sure to mark emails from addy.io as safe if they turn up in spam.
|
||||
Please make sure to add mailer@anonaddy.me, mailer@anonaddy.com and any other aliases you use to your address book and also to check your spam folder. Make sure to mark emails from AnonAddy as safe if they turn up in spam.
|
||||
|
||||
If an alias has been deleted and you try to send email to it, the emails will be rejected with an error message - "550 5.1.1 Recipient address rejected: Address does not exist".
|
||||
If an alias has been previously deleted and you try to send email to it, the emails will be rejected with an error message - "554 5.7.1 Recipient address rejected: Address does not exist".
|
||||
|
||||
Check that you have not deactivated the alias, custom domain or additional username. When any of these are deactivated, emails will be silently discarded, they will not be rejected or return any error message.
|
||||
|
||||
|
@ -427,15 +377,12 @@ For some reason Apple seems to think these emails are spam/phishing and returns
|
|||
|
||||
> Diagnostic-Code: smtp; 550 5.7.1 [CS01] Message rejected due to local policy.
|
||||
|
||||
I have contacted Apple multiple times about this but they have not yet responded.
|
||||
|
||||
If you are having issues with emails being rejected as "possibly spammy" by Google, iCloud or Microsoft then please try the following steps if you can:
|
||||
|
||||
1. **Replace the email subject** by going to your settings in addy.io
|
||||
2. Try adding a GPG key and **enabling encryption**. This will prevent the email's content being scanned and reduce the chance of it being rejected.
|
||||
3. Enable the option to hide and encrypt the email subject
|
||||
4. Try disabling the banner information on forwarded emails
|
||||
5. Try adding the alias email (and/or domain) to your contact list (address book) or safe senders list if possible
|
||||
|
||||
For Outlook, Hotmail or MSN you can find instructions on how to add a domain to your safe senders list [here](https://support.microsoft.com/en-gb/office/safe-senders-in-outlook-com-470d4ee6-e3b6-402b-8cd9-a6f00eda7339).
|
||||
1. **Replace the email subject** by going to your settings in AnonAddy
|
||||
2. Try adding a GPP key and **enabling encryption**. This will prevent the email's content being scanned and reduce the change of it being rejected.
|
||||
|
||||
I will also soon be adding an option to change the format of the display from part of the "From:" header.
|
||||
|
||||
|
@ -453,17 +400,17 @@ Please make sure you are using your account username (e.g. johndoe) and not your
|
|||
|
||||
2. Forgotten password
|
||||
|
||||
If you've forgotten your password you can reset it by entering your username here - https://app.addy.io/password/reset
|
||||
If you've forgotten your password you can reset it by entering your username here - https://app.anonaddy.com/password/reset
|
||||
|
||||
3. Forgotten username
|
||||
|
||||
If you've forgotten your username you can request a reminder by entering your email address here - https://app.addy.io/username/reminder
|
||||
If you've forgotten your username you can request a reminder by entering your email address here - https://app.anonaddy.com/username/reminder
|
||||
|
||||
4. Lost 2FA device
|
||||
|
||||
Please use the backup code that you were shown when you enabled 2FA.
|
||||
|
||||
5. Errors with hardware security key
|
||||
5. Errors with U2F device
|
||||
|
||||
If you have a YubiKey and are using Windows and have an issue with your personal password/PIN you may need to reset the key using the YubiKey manager software.
|
||||
|
||||
|
@ -471,15 +418,15 @@ If you have a YubiKey and are using Windows and have an issue with your personal
|
|||
|
||||
I am very passionate about this project. I use it myself every day and will be keeping it running indefinitely. The service also provides me with an income.
|
||||
|
||||
## What happens to addy.io if you die?
|
||||
## What happens to AnonAddy if you die?
|
||||
|
||||
I do have someone in place who can keep the service running in the event of me not being here. They are able to continue paying for the servers that host addy.io and the domains that it uses. All addy.io domains also always have over 5 years until they expire.
|
||||
I do have someone in place who can keep the service running in the event of me not being here. They are able to continue paying for the servers that host AnonAddy and the domains that it uses. All AnonAddy domains also always have over 5 years until they expire.
|
||||
|
||||
They would make a Twitter announcement informing all users that they would be keeping the service running. You would then be able to decide whether you'd like to continue using addy.io or start to update your email addresses.
|
||||
They would make a Twitter announcement informing all users that they would be keeping the service running. You would then be able to decide whether you'd like to continue using AnonAddy or start to update your email addresses.
|
||||
|
||||
## Is the application tested?
|
||||
|
||||
Yes it has over 200 automated PHPUnit tests written.
|
||||
Yes it has over 190 automated PHPUnit tests written.
|
||||
|
||||
## How do I host this myself?
|
||||
|
||||
|
@ -487,26 +434,26 @@ You will need to set up your own server with Postfix so that you can pipe the re
|
|||
|
||||
For those who prefer using Docker there is an image you can use here - [github.com/anonaddy/docker](https://github.com/anonaddy/docker).
|
||||
|
||||
## Who's behind addy.io?
|
||||
## Who's behind AnonAddy?
|
||||
|
||||
My name is Will Browning, I'm a web developer from the UK and an advocate for online privacy and open-source software. You can find me on [Twitter](https://twitter.com/willbrowningme) although I don't tweet that much!
|
||||
|
||||
## I couldn't find an answer to my question, how can I contact you?
|
||||
|
||||
For any other questions just send an email to - contact (at) help.addy.io ([GPG Key](https://addy.io/contact-public-key.asc))
|
||||
For any other questions just send an email to - [contact@anonaddy.com](mailto:contact@anonaddy.com) ([GPG Key](https://anonaddy.com/anonaddy-contact-public-key.asc))
|
||||
|
||||
## Self Hosting
|
||||
|
||||
## Software Requirements
|
||||
|
||||
* Postfix (3.0.0+) (plus postfix-mysql for database queries and postfix-pcre)
|
||||
* PHP (8.2+) and the [php-mailparse](https://pecl.php.net/package/mailparse) extension, the [php-gnupg](https://pecl.php.net/package/gnupg) extension if you plan to encrypt forwarded emails, the [php-imagick](https://pecl.php.net/package/imagick) extension for generating 2FA QR codes
|
||||
* PHP (8.0+) and the [php-mailparse](https://pecl.php.net/package/mailparse) extension, the [php-gnupg](https://pecl.php.net/package/gnupg) extension if you plan to encrypt forwarded emails, the [php-imagick](https://pecl.php.net/package/imagick) extension for generating 2FA QR codes
|
||||
* Port 25 unblocked and open
|
||||
* Redis (7.x+) for throttling and queues
|
||||
* Redis (4.x+) for throttling and queues
|
||||
* FQDN as hostname e.g. mail.anonaddy.me
|
||||
* MariaDB / MySQL
|
||||
* Nginx
|
||||
* Rspamd
|
||||
* (SpamAssassin, OpenDKIM, OpenDMARC, postfix-policyd-spf-python) OR Rspamd
|
||||
* DNS records - MX, SPF, DKIM, DMARC
|
||||
* Reverse DNS
|
||||
* SSL/TLS Encryption - you can install a free certificate from Let’s Encrypt.
|
||||
|
@ -515,16 +462,12 @@ For full details please see the [self-hosting instructions file](SELF-HOSTING.md
|
|||
|
||||
## My sponsors
|
||||
|
||||
Thanks to [Vlad Timofeev](https://github.com/vlad-timofeev), [Patrick Dobler](https://github.com/patrickdobler), [Luca Steeb](https://github.com/steebchen), [narolinus](https://github.com/narolinus) and [Lukas](https://github.com/lunibo) for supporting me by sponsoring the project on GitHub!
|
||||
|
||||
Also an extra special thanks to [CrazyMax](https://github.com/crazy-max) for sponsoring me and also creating and maintaining the awesome [addy.io Docker image](https://github.com/anonaddy/docker)!
|
||||
Thanks to [Vlad Timofeev](https://github.com/vlad-timofeev) and [Patrick Dobler](https://github.com/patrickdobler) for supporting me by sponsoring the project on GitHub!
|
||||
|
||||
## Thanks
|
||||
|
||||
Huge thank you to [Stjin](https://twitter.com/Stjinchan) and [KhalidWar](https://github.com/KhalidWar) for their amazing mobile apps.
|
||||
|
||||
Also to [https://gitlab.com/mailcare/mailcare](https://gitlab.com/mailcare/mailcare) and [https://github.com/niftylettuce/forward-email](https://github.com/niftylettuce/forward-email) for their awesome open-source projects that helped me along the way.
|
||||
Thanks to [https://gitlab.com/mailcare/mailcare](https://gitlab.com/mailcare/mailcare) and [https://github.com/niftylettuce/forward-email](https://github.com/niftylettuce/forward-email) for their awesome open-source projects that helped me along the way.
|
||||
|
||||
## License
|
||||
|
||||
GNU Affero General Public License v3.0. Please see [License File](LICENSE.md) for more information.
|
||||
The MIT License (MIT). Please see [License File](LICENSE.md) for more information.
|
||||
|
|
20
SECURITY.md
20
SECURITY.md
|
@ -1,4 +1,4 @@
|
|||
If you believe you've found a security issue in the addy.io product or service, I encourage you to
|
||||
If you believe you've found a security issue in the AnonAddy product or service, I encourage you to
|
||||
notify me. I welcome working with you to resolve the issue promptly. Thanks in advance!
|
||||
|
||||
# Disclosure Policy
|
||||
|
@ -11,27 +11,27 @@ notify me. I welcome working with you to resolve the issue promptly. Thanks in a
|
|||
degradation of the service. Only interact with accounts you own or with explicit permission of the
|
||||
account holder.
|
||||
- If you would like to encrypt your report, please use the PGP key with fingerprint
|
||||
`E652C2DB43859328F35575DEBF7B93C6497510D0` (available on the openpgp.org keyserver).
|
||||
`5FCAFD8A67D2A783CFF4D0E31AC6D923E6FB4EF7` (available on the openpgp.org keyserver).
|
||||
|
||||
# Reporting a Vulnerability
|
||||
|
||||
To report a vulnerability please send an email to contact (at) help.addy.io, you can use the PGP key above if you wish to encrypt it.
|
||||
To report a vulnerability please send an email to contact@anonaddy.com, you can use the PGP key above if you wish to encrypt it.
|
||||
|
||||
# In-scope
|
||||
|
||||
- Security issues in any current release of addy.io. This includes the web application, browser extension,
|
||||
- Security issues in any current release of AnonAddy. This includes the web application, browser extension,
|
||||
and landing page. Source code is available at https://github.com/anonaddy.
|
||||
|
||||
# Exclusions
|
||||
|
||||
The following bug classes are out-of scope:
|
||||
|
||||
- Bugs that are already reported on any of addy.io's issue trackers (https://github.com/anonaddy),
|
||||
- Bugs that are already reported on any of AnonAddy's issue trackers (https://github.com/anonaddy),
|
||||
or that I already know of.
|
||||
- Attacks requiring physical access to a user's device.
|
||||
- Self-XSS
|
||||
- Issues related to software or protocols not under addy.io's control
|
||||
- Vulnerabilities in outdated versions of addy.io
|
||||
- Issues related to software or protocols not under AnonAddy's control
|
||||
- Vulnerabilities in outdated versions of AnonAddy
|
||||
- Missing security best practices that do not directly lead to a vulnerability
|
||||
- Issues that do not have any impact on the general public
|
||||
|
||||
|
@ -39,7 +39,7 @@ While researching, I'd like to ask you to refrain from:
|
|||
|
||||
- Denial of service
|
||||
- Spamming
|
||||
- Social engineering (including phishing) of addy.io emails
|
||||
- Any physical attempts against addy.io property or data centers
|
||||
- Social engineering (including phishing) of AnonAddy emails
|
||||
- Any physical attempts against AnonAddy property or data centers
|
||||
|
||||
Thank you for helping keep addy.io and its users safe!
|
||||
Thank you for helping keep AnonAddy and its users safe!
|
706
SELF-HOSTING.md
706
SELF-HOSTING.md
File diff suppressed because it is too large
Load diff
|
@ -1,41 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Actions;
|
||||
|
||||
use App\Facades\Webauthn;
|
||||
use App\Models\WebauthnKey;
|
||||
use Exception;
|
||||
use Illuminate\Contracts\Auth\Authenticatable;
|
||||
use LaravelWebauthn\Actions\RegisterKeyStore as ActionsRegisterKeyStore;
|
||||
use LaravelWebauthn\Events\WebauthnRegister;
|
||||
use LaravelWebauthn\Services\Webauthn\CredentialAttestationValidator;
|
||||
use Webauthn\PublicKeyCredentialCreationOptions;
|
||||
|
||||
class RegisterKeyStore extends ActionsRegisterKeyStore
|
||||
{
|
||||
/**
|
||||
* Register a new key.
|
||||
*/
|
||||
public function __invoke(Authenticatable $user, PublicKeyCredentialCreationOptions $publicKey, string $data, string $keyName): ?WebauthnKey
|
||||
{
|
||||
if (! Webauthn::canRegister($user)) {
|
||||
$this->throwFailedRegisterException($user);
|
||||
}
|
||||
|
||||
try {
|
||||
$publicKeyCredentialSource = $this->app[CredentialAttestationValidator::class]($publicKey, $data);
|
||||
|
||||
$webauthnKey = Webauthn::create($user, $keyName, $publicKeyCredentialSource);
|
||||
|
||||
WebauthnRegister::dispatch($webauthnKey);
|
||||
|
||||
Webauthn::login();
|
||||
|
||||
return $webauthnKey;
|
||||
} catch (Exception $e) {
|
||||
$this->throwFailedRegisterException($user, $e);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -39,22 +39,21 @@ class CheckDomainsMxValidation extends Command
|
|||
*/
|
||||
public function handle()
|
||||
{
|
||||
Domain::with('user.defaultUsername')
|
||||
->get()
|
||||
->each(function ($domain) {
|
||||
try {
|
||||
if (! $domain->checkMxRecords()) {
|
||||
// Notify user via email only if domain's MX previously were valid
|
||||
if (! is_null($domain->domain_mx_validated_at)) {
|
||||
$domain->user->notify(new DomainMxRecordsInvalid($domain->domain));
|
||||
}
|
||||
|
||||
$domain->domain_mx_validated_at = null;
|
||||
$domain->save();
|
||||
Domain::all()
|
||||
->each(function ($domain) {
|
||||
try {
|
||||
if (! $domain->checkMxRecords()) {
|
||||
// Notify user via email only if domain's MX previously were valid
|
||||
if (!is_null($domain->domain_mx_validated_at)) {
|
||||
$domain->user->notify(new DomainMxRecordsInvalid($domain->domain));
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
//
|
||||
|
||||
$domain->domain_mx_validated_at = null;
|
||||
$domain->save();
|
||||
}
|
||||
});
|
||||
} catch (\Exception $e) {
|
||||
//
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,8 +39,7 @@ class CheckDomainsSendingVerification extends Command
|
|||
*/
|
||||
public function handle()
|
||||
{
|
||||
Domain::with('user.defaultUsername')
|
||||
->whereNotNull('domain_sending_verified_at')->get()
|
||||
Domain::whereNotNull('domain_sending_verified_at')->get()
|
||||
->each(function ($domain) {
|
||||
try {
|
||||
$result = $domain->checkVerificationForSending();
|
||||
|
|
|
@ -4,7 +4,6 @@ namespace App\Console\Commands;
|
|||
|
||||
use App\Models\FailedDelivery;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
class ClearFailedDeliveries extends Command
|
||||
{
|
||||
|
@ -39,14 +38,6 @@ class ClearFailedDeliveries extends Command
|
|||
*/
|
||||
public function handle()
|
||||
{
|
||||
FailedDelivery::where('created_at', '<=', now()->subDays(7))->delete();
|
||||
|
||||
// Delete any stored failed deliveries older than 7 days
|
||||
collect(Storage::disk('local')->listContents(''))
|
||||
->each(function ($file) {
|
||||
if ($file['type'] === 'file' && $file['lastModified'] < now()->subDays(7)->getTimestamp()) {
|
||||
Storage::disk('local')->delete($file['path']);
|
||||
}
|
||||
});
|
||||
FailedDelivery::where('created_at', '<=', now()->subDays(3))->delete();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,35 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Models\OutboundMessage;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class ClearOutboundMessages extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'anonaddy:clear-outbound-messages';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Clears outbound messages that are older than 7 days';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
OutboundMessage::where('created_at', '<', now()->subDays(7))->delete();
|
||||
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
}
|
|
@ -2,24 +2,24 @@
|
|||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Helpers\GitVersionHelper;
|
||||
use App\Models\PostfixQueueId;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class UpdateAppVersion extends Command
|
||||
class ClearPostfixQueueIds extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'anonaddy:update-app-version';
|
||||
protected $signature = 'anonaddy:clear-postfix-queue-ids';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Updates the cached app version';
|
||||
protected $description = 'Clears postfix queue ids that are older than 7 days';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
|
@ -38,9 +38,6 @@ class UpdateAppVersion extends Command
|
|||
*/
|
||||
public function handle()
|
||||
{
|
||||
$version = GitVersionHelper::cacheFreshVersion();
|
||||
$this->info("addy.io version: {$version}");
|
||||
|
||||
return 0;
|
||||
PostfixQueueId::where('created_at', '<=', now()->subDays(7))->delete();
|
||||
}
|
||||
}
|
|
@ -4,11 +4,9 @@ namespace App\Console\Commands;
|
|||
|
||||
use App\Models\Recipient;
|
||||
use App\Models\User;
|
||||
use App\Models\Username;
|
||||
use App\Rules\NotDeletedUsername;
|
||||
use App\Rules\NotLocalRecipient;
|
||||
use App\Rules\RegisterUniqueRecipient;
|
||||
use Illuminate\Auth\Events\Registered;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
|
@ -49,57 +47,50 @@ class CreateUser extends Command
|
|||
{
|
||||
$validator = Validator::make([
|
||||
'username' => $this->argument('username'),
|
||||
'email' => $this->argument('email'), ], [
|
||||
'username' => [
|
||||
'required',
|
||||
'regex:/^[a-zA-Z0-9]*$/',
|
||||
'max:20',
|
||||
'unique:usernames,username',
|
||||
new NotDeletedUsername,
|
||||
],
|
||||
'email' => [
|
||||
'required',
|
||||
'email:rfc,dns',
|
||||
'max:254',
|
||||
new RegisterUniqueRecipient,
|
||||
new NotLocalRecipient,
|
||||
],
|
||||
]);
|
||||
'email' => $this->argument('email')], [
|
||||
'username' => [
|
||||
'required',
|
||||
'regex:/^[a-zA-Z0-9]*$/',
|
||||
'max:20',
|
||||
'unique:users,username',
|
||||
'unique:additional_usernames,username',
|
||||
new NotDeletedUsername
|
||||
],
|
||||
'email' => [
|
||||
'required',
|
||||
'email:rfc,dns',
|
||||
'max:254',
|
||||
new RegisterUniqueRecipient,
|
||||
new NotLocalRecipient
|
||||
],
|
||||
]);
|
||||
|
||||
if ($validator->fails()) {
|
||||
$errors = $validator->errors();
|
||||
foreach ($errors->all() as $message) {
|
||||
$this->error($message);
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
$userId = Uuid::uuid4();
|
||||
|
||||
$recipient = Recipient::create([
|
||||
'email' => $this->argument('email'),
|
||||
'user_id' => $userId,
|
||||
]);
|
||||
|
||||
$username = Username::create([
|
||||
'username' => $this->argument('username'),
|
||||
'user_id' => $userId,
|
||||
'user_id' => $userId
|
||||
]);
|
||||
|
||||
$twoFactor = app('pragmarx.google2fa');
|
||||
|
||||
$user = User::create([
|
||||
'id' => $userId,
|
||||
'default_username_id' => $username->id,
|
||||
'username' => $this->argument('username'),
|
||||
'default_recipient_id' => $recipient->id,
|
||||
'password' => Hash::make($userId),
|
||||
'two_factor_secret' => $twoFactor->generateSecretKey(),
|
||||
'two_factor_secret' => $twoFactor->generateSecretKey()
|
||||
]);
|
||||
|
||||
event(new Registered($user));
|
||||
|
||||
$this->info('Created user: "'.$user->username.'" with user_id: "'.$user->id.'"');
|
||||
$this->info('This user can now reset their password (the default password is their user_id)');
|
||||
$this->info('Created user: '.$user->username.' with userid: '.$user->id);
|
||||
$this->info('This user can now reset their password (the default password is their guserid)');
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -41,14 +41,14 @@ class EmailUsersWithTokenExpiringSoon extends Command
|
|||
*/
|
||||
public function handle()
|
||||
{
|
||||
User::with(['defaultUsername', 'defaultRecipient', 'tokens'])
|
||||
->whereHas('tokens', function ($query) {
|
||||
$query->whereDate('expires_at', now()->addWeek());
|
||||
})
|
||||
->get()
|
||||
->each(function (User $user) {
|
||||
$this->sendTokenExpiringSoonMail($user);
|
||||
});
|
||||
User::whereHas('tokens', function ($query) {
|
||||
$query->whereDate('expires_at', now()->addWeek())
|
||||
->where('revoked', false);
|
||||
})
|
||||
->get()
|
||||
->each(function (User $user) {
|
||||
$this->sendTokenExpiringSoonMail($user);
|
||||
});
|
||||
}
|
||||
|
||||
protected function sendTokenExpiringSoonMail(User $user)
|
||||
|
|
|
@ -15,6 +15,7 @@ class ListUsers extends Command
|
|||
* @var string
|
||||
*/
|
||||
protected $signature = 'anonaddy:list-users
|
||||
{--columns=* : The columns to return}
|
||||
{--username= : The Username of the user}
|
||||
{--json : Output as JSON}
|
||||
{--sort= : The column to sort by}';
|
||||
|
@ -66,35 +67,27 @@ class ListUsers extends Command
|
|||
*/
|
||||
protected function getUsers()
|
||||
{
|
||||
$users = User::with('defaultUsername:id,user_id,username')
|
||||
->select(['id', 'default_username_id', 'bandwidth', 'created_at', 'updated_at']);
|
||||
if ($columns = $this->option('columns')) {
|
||||
$users = User::select($columns);
|
||||
} else {
|
||||
$users = User::select($this->getColumns());
|
||||
}
|
||||
|
||||
if ($username = $this->option('username')) {
|
||||
$users->whereHas('usernames', function ($query) use ($username) {
|
||||
$query->where('username', $username);
|
||||
});
|
||||
$users->where('username', $username);
|
||||
}
|
||||
|
||||
$users = $users->get()->map(function ($user) {
|
||||
return [
|
||||
'id' => $user->id,
|
||||
'username' => $user->defaultUsername->username,
|
||||
'bandwidth' => $user->bandwidth,
|
||||
'created_at' => $user->created_at,
|
||||
'updated_at' => $user->updated_at,
|
||||
];
|
||||
});
|
||||
|
||||
if ($sort = $this->option('sort')) {
|
||||
$users = $users->sortBy($sort);
|
||||
$users->orderBy($sort);
|
||||
}
|
||||
|
||||
return $users->toArray();
|
||||
return $users->get()->toArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the user information on the console.
|
||||
*
|
||||
* @param array $users
|
||||
* @return void
|
||||
*/
|
||||
protected function displayUsers(array $users)
|
||||
|
@ -125,8 +118,11 @@ class ListUsers extends Command
|
|||
*/
|
||||
protected function getColumns()
|
||||
{
|
||||
$availableColumns = collect($this->headers)
|
||||
->map(fn ($header) => strtolower($header))->toArray();
|
||||
$availableColumns = array_map('strtolower', $this->headers);
|
||||
|
||||
if ($columns = $this->option('columns')) {
|
||||
return array_intersect($availableColumns, $this->parseColumns($columns));
|
||||
}
|
||||
|
||||
return $availableColumns;
|
||||
}
|
||||
|
@ -134,6 +130,7 @@ class ListUsers extends Command
|
|||
/**
|
||||
* Parse the column list.
|
||||
*
|
||||
* @param array $columns
|
||||
* @return array
|
||||
*/
|
||||
protected function parseColumns(array $columns)
|
||||
|
|
|
@ -5,24 +5,21 @@ namespace App\Console\Commands;
|
|||
use App\Mail\ForwardEmail;
|
||||
use App\Mail\ReplyToEmail;
|
||||
use App\Mail\SendFromEmail;
|
||||
use App\Models\AdditionalUsername;
|
||||
use App\Models\Alias;
|
||||
use App\Models\Domain;
|
||||
use App\Models\EmailData;
|
||||
use App\Models\OutboundMessage;
|
||||
use App\Models\Username;
|
||||
use App\Notifications\DisallowedReplySendAttempt;
|
||||
use App\Models\PostfixQueueId;
|
||||
use App\Models\Recipient;
|
||||
use App\Models\User;
|
||||
use App\Notifications\FailedDeliveryNotification;
|
||||
use App\Notifications\NearBandwidthLimit;
|
||||
use App\Notifications\SpamReplySendAttempt;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Str;
|
||||
use ParagonIE\ConstantTime\Base32;
|
||||
use PhpMimeMailParser\Parser;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
|
||||
class ReceiveEmail extends Command
|
||||
{
|
||||
|
@ -46,15 +43,9 @@ class ReceiveEmail extends Command
|
|||
* @var string
|
||||
*/
|
||||
protected $description = 'Receive email from postfix pipe';
|
||||
|
||||
protected $parser;
|
||||
|
||||
protected $senderFrom;
|
||||
|
||||
protected $size;
|
||||
|
||||
protected $rawEmail;
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
|
@ -75,12 +66,11 @@ class ReceiveEmail extends Command
|
|||
try {
|
||||
$this->exitIfFromSelf();
|
||||
|
||||
$recipients = $this->getRecipients();
|
||||
|
||||
$file = $this->argument('file');
|
||||
|
||||
$this->parser = $this->getParser($file);
|
||||
$this->senderFrom = $this->getSenderFrom();
|
||||
|
||||
$recipients = $this->getRecipients();
|
||||
|
||||
// Divide the size of the email by the number of recipients (excluding any unsubscribe recipients) to prevent it being added multiple times.
|
||||
$recipientCount = $recipients->where('domain', '!=', 'unsubscribe.'.config('anonaddy.domain'))->count();
|
||||
|
@ -88,76 +78,45 @@ class ReceiveEmail extends Command
|
|||
$this->size = $this->option('size') / ($recipientCount ? $recipientCount : 1);
|
||||
|
||||
foreach ($recipients as $recipient) {
|
||||
// Check if VERP bounce
|
||||
if (substr($recipient['email'], 0, 2) === 'b_') {
|
||||
if ($outboundMessageId = $this->getIdFromVerp($recipient['email'])) {
|
||||
// Is a valid bounce
|
||||
$outboundMessage = OutboundMessage::with(['user', 'alias', 'recipient'])->find($outboundMessageId);
|
||||
|
||||
if (is_null($outboundMessage)) {
|
||||
// Must have been more than 7 days
|
||||
Log::info('VERP outboundMessage not found');
|
||||
|
||||
exit(0);
|
||||
}
|
||||
|
||||
$bouncedAlias = $outboundMessage->alias;
|
||||
|
||||
// If already bounced then forward to the user instead
|
||||
if (! $outboundMessage->bounced) {
|
||||
$this->handleBounce($outboundMessage);
|
||||
}
|
||||
|
||||
if (in_array(strtolower($this->parser->getHeader('Auto-Submitted')), ['auto-replied', 'auto-generated']) && ! in_array($outboundMessage->email_type, ['R', 'S'])) {
|
||||
Log::info('VERP auto-response to forward/notification, username: '.$outboundMessage->user?->username.' outboundMessageID: '.$outboundMessageId);
|
||||
|
||||
exit(0);
|
||||
}
|
||||
|
||||
// If it is a notification then there is no alias so exit and log, may be an auto-reply to a notification.
|
||||
if (is_null($bouncedAlias)) {
|
||||
Log::info('VERP previously bounced/auto-response to notification, username: '.$outboundMessage->user?->username.' outboundMessageID: '.$outboundMessageId);
|
||||
|
||||
exit(0);
|
||||
}
|
||||
|
||||
// If it is not a bounce (could be auto-reply) then redirect to alias
|
||||
$recipient['email'] = $bouncedAlias->email;
|
||||
$recipient['local_part'] = $bouncedAlias->local_part;
|
||||
$recipient['domain'] = $bouncedAlias->domain;
|
||||
}
|
||||
// Handle bounces
|
||||
if ($this->option('sender') === 'MAILER-DAEMON') {
|
||||
$this->handleBounce($recipient['email']);
|
||||
}
|
||||
|
||||
// First determine if the alias already exists in the database
|
||||
if ($alias = Alias::firstWhere('email', $recipient['local_part'].'@'.$recipient['domain'])) {
|
||||
if ($alias = Alias::firstWhere('email', $recipient['local_part'] . '@' . $recipient['domain'])) {
|
||||
$user = $alias->user;
|
||||
|
||||
if ($alias->aliasable_id) {
|
||||
$aliasable = $alias->aliasable;
|
||||
}
|
||||
} else {
|
||||
// Does not exist, must be a standard, username or custom domain alias
|
||||
// Does not exist, must be a standard, additional username or custom domain alias
|
||||
$parentDomain = collect(config('anonaddy.all_domains'))
|
||||
->filter(function ($name) use ($recipient) {
|
||||
return Str::endsWith($recipient['domain'], $name);
|
||||
})
|
||||
->first();
|
||||
->filter(function ($name) use ($recipient) {
|
||||
return Str::endsWith($recipient['domain'], $name);
|
||||
})
|
||||
->first();
|
||||
|
||||
if (! empty($parentDomain)) {
|
||||
// It is standard or username alias
|
||||
$subdomain = substr($recipient['domain'], 0, strrpos($recipient['domain'], '.'.$parentDomain)); // e.g. johndoe
|
||||
if (!empty($parentDomain)) {
|
||||
// It is standard or additional username alias
|
||||
$subdomain = substr($recipient['domain'], 0, strrpos($recipient['domain'], '.' . $parentDomain)); // e.g. johndoe
|
||||
|
||||
if ($subdomain === 'unsubscribe') {
|
||||
$this->handleUnsubscribe($recipient);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
// Check if this is an username or standard alias
|
||||
if (! empty($subdomain)) {
|
||||
$username = Username::where('username', $subdomain)->first();
|
||||
$user = $username->user;
|
||||
$aliasable = $username;
|
||||
// Check if this is an additional username or standard alias
|
||||
if (!empty($subdomain)) {
|
||||
$user = User::where('username', $subdomain)->first();
|
||||
|
||||
if (!isset($user)) {
|
||||
$additionalUsername = AdditionalUsername::where('username', $subdomain)->first();
|
||||
$user = $additionalUsername->user;
|
||||
$aliasable = $additionalUsername;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// It is a custom domain
|
||||
|
@ -167,13 +126,13 @@ class ReceiveEmail extends Command
|
|||
}
|
||||
}
|
||||
|
||||
if (! isset($user) && ! empty(config('anonaddy.admin_username'))) {
|
||||
$user = Username::where('username', config('anonaddy.admin_username'))->first()?->user;
|
||||
if (!isset($user) && !empty(config('anonaddy.admin_username'))) {
|
||||
$user = User::where('username', config('anonaddy.admin_username'))->first();
|
||||
}
|
||||
}
|
||||
|
||||
// If there is still no user or the user has no verified default recipient then continue.
|
||||
if (! isset($user) || ! $user->hasVerifiedDefaultRecipient()) {
|
||||
if (!isset($user) || !$user->hasVerifiedDefaultRecipient()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -182,43 +141,21 @@ class ReceiveEmail extends Command
|
|||
$this->checkRateLimit($user);
|
||||
|
||||
// Check whether this email is a reply/send from or a new email to be forwarded.
|
||||
$destination = Str::replaceLast('=', '@', $recipient['extension']);
|
||||
$validEmailDestination = filter_var($destination, FILTER_VALIDATE_EMAIL);
|
||||
if ($validEmailDestination) {
|
||||
$verifiedRecipient = $user->getVerifiedRecipientByEmail($this->senderFrom);
|
||||
} else {
|
||||
$verifiedRecipient = null;
|
||||
}
|
||||
|
||||
if ($verifiedRecipient?->can_reply_send) {
|
||||
// Check if the Dmarc allow or spam headers are present from Rspamd
|
||||
if (! $this->parser->getHeader('X-AnonAddy-Dmarc-Allow')) {
|
||||
// Notify user and exit
|
||||
$verifiedRecipient->notify(new SpamReplySendAttempt($recipient, $this->senderFrom, $this->parser->getHeader('X-AnonAddy-Authentication-Results')));
|
||||
|
||||
exit(0);
|
||||
}
|
||||
|
||||
if ($this->parser->getHeader('In-Reply-To') && $alias) {
|
||||
$this->handleReply($user, $alias, $validEmailDestination);
|
||||
if (filter_var(Str::replaceLast('=', '@', $recipient['extension']), FILTER_VALIDATE_EMAIL) && $user->isVerifiedRecipient($this->option('sender'))) {
|
||||
if ($this->parser->getHeader('In-Reply-To')) {
|
||||
$this->handleReply($user, $recipient);
|
||||
} else {
|
||||
$this->handleSendFrom($user, $recipient, $alias ?? null, $aliasable ?? null, $validEmailDestination);
|
||||
$this->handleSendFrom($user, $recipient, $aliasable ?? null);
|
||||
}
|
||||
} elseif ($verifiedRecipient?->can_reply_send === false) {
|
||||
// Notify user that they have not allowed this recipient to reply and send from aliases
|
||||
$verifiedRecipient->notify(new DisallowedReplySendAttempt($recipient, $this->senderFrom, $this->parser->getHeader('X-AnonAddy-Authentication-Results')));
|
||||
|
||||
exit(0);
|
||||
} else {
|
||||
// Check if the spam header is present from Rspamd
|
||||
$this->handleForward($user, $recipient, $alias ?? null, $aliasable ?? null, $this->parser->getHeader('X-AnonAddy-Spam') === 'Yes');
|
||||
$this->handleForward($user, $recipient, $aliasable ?? null);
|
||||
}
|
||||
}
|
||||
} catch (\Throwable $e) {
|
||||
$this->error('4.3.0 An error has occurred, please try again later.');
|
||||
|
||||
} catch (\Exception $e) {
|
||||
report($e);
|
||||
|
||||
$this->error('4.3.0 An error has occurred, please try again later.');
|
||||
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
@ -227,54 +164,65 @@ class ReceiveEmail extends Command
|
|||
{
|
||||
$alias = Alias::find($recipient['local_part']);
|
||||
|
||||
if ($alias && $alias->user->isVerifiedRecipient($this->senderFrom) && $this->parser->getHeader('X-AnonAddy-Dmarc-Allow')) {
|
||||
if (!is_null($alias) && $alias->user->isVerifiedRecipient($this->option('sender'))) {
|
||||
$alias->deactivate();
|
||||
}
|
||||
}
|
||||
|
||||
protected function handleReply($user, $alias, $destination)
|
||||
protected function handleReply($user, $recipient)
|
||||
{
|
||||
$emailData = new EmailData($this->parser, $this->option('sender'), $this->size, 'R');
|
||||
$alias = $user->aliases()->where('email', $recipient['local_part'] . '@' . $recipient['domain'])->first();
|
||||
|
||||
$message = new ReplyToEmail($user, $alias, $emailData);
|
||||
if ($alias) {
|
||||
$sendTo = Str::replaceLast('=', '@', $recipient['extension']);
|
||||
|
||||
Mail::to($destination)->queue($message);
|
||||
$emailData = new EmailData($this->parser, $this->size);
|
||||
|
||||
$message = new ReplyToEmail($user, $alias, $emailData);
|
||||
|
||||
Mail::to($sendTo)->queue($message);
|
||||
}
|
||||
}
|
||||
|
||||
protected function handleSendFrom($user, $recipient, $alias, $aliasable, $destination)
|
||||
protected function handleSendFrom($user, $recipient, $aliasable)
|
||||
{
|
||||
if (is_null($alias)) {
|
||||
$alias = $user->aliases()->create([
|
||||
'email' => $recipient['local_part'].'@'.$recipient['domain'],
|
||||
'local_part' => $recipient['local_part'],
|
||||
'domain' => $recipient['domain'],
|
||||
'aliasable_id' => $aliasable?->id,
|
||||
'aliasable_type' => $aliasable ? 'App\\Models\\'.class_basename($aliasable) : null,
|
||||
]);
|
||||
$alias = $user->aliases()->withTrashed()->firstOrNew([
|
||||
'email' => $recipient['local_part'] . '@' . $recipient['domain'],
|
||||
'local_part' => $recipient['local_part'],
|
||||
'domain' => $recipient['domain'],
|
||||
'aliasable_id' => $aliasable->id ?? null,
|
||||
'aliasable_type' => $aliasable ? 'App\\Models\\' . class_basename($aliasable) : null
|
||||
]);
|
||||
|
||||
// Hydrate all alias fields
|
||||
$alias->refresh();
|
||||
// This is a new alias but at a shared domain or the sender is not a verified recipient.
|
||||
if (!isset($alias->id) && in_array($recipient['domain'], config('anonaddy.all_domains'))) {
|
||||
exit(0);
|
||||
}
|
||||
|
||||
$emailData = new EmailData($this->parser, $this->option('sender'), $this->size, 'S');
|
||||
$alias->save();
|
||||
$alias->refresh();
|
||||
|
||||
$sendTo = Str::replaceLast('=', '@', $recipient['extension']);
|
||||
|
||||
$emailData = new EmailData($this->parser, $this->size);
|
||||
|
||||
$message = new SendFromEmail($user, $alias, $emailData);
|
||||
|
||||
Mail::to($destination)->queue($message);
|
||||
Mail::to($sendTo)->queue($message);
|
||||
}
|
||||
|
||||
protected function handleForward($user, $recipient, $alias, $aliasable, $isSpam)
|
||||
protected function handleForward($user, $recipient, $aliasable)
|
||||
{
|
||||
if (is_null($alias)) {
|
||||
// This is a new alias
|
||||
$alias = new Alias([
|
||||
'email' => $recipient['local_part'].'@'.$recipient['domain'],
|
||||
'local_part' => $recipient['local_part'],
|
||||
'domain' => $recipient['domain'],
|
||||
'aliasable_id' => $aliasable?->id,
|
||||
'aliasable_type' => $aliasable ? 'App\\Models\\'.class_basename($aliasable) : null,
|
||||
]);
|
||||
$alias = $user->aliases()->withTrashed()->firstOrNew([
|
||||
'email' => $recipient['local_part'] . '@' . $recipient['domain'],
|
||||
'local_part' => $recipient['local_part'],
|
||||
'domain' => $recipient['domain'],
|
||||
'aliasable_id' => $aliasable->id ?? null,
|
||||
'aliasable_type' => $aliasable ? 'App\\Models\\' . class_basename($aliasable) : null
|
||||
]);
|
||||
|
||||
if (!isset($alias->id)) {
|
||||
// This is a new alias.
|
||||
if ($user->hasExceededNewAliasLimit()) {
|
||||
$this->error('4.2.1 New aliases per hour limit exceeded for user.');
|
||||
|
||||
|
@ -287,38 +235,35 @@ class ReceiveEmail extends Command
|
|||
$keys = explode('.', $recipient['extension']);
|
||||
|
||||
$recipientIds = $user
|
||||
->recipients()
|
||||
->select(['id', 'email_verified_at'])
|
||||
->oldest()
|
||||
->get()
|
||||
->filter(function ($item, $key) use ($keys) {
|
||||
return in_array($key + 1, $keys) && ! is_null($item['email_verified_at']);
|
||||
})
|
||||
->pluck('id')
|
||||
->take(10)
|
||||
->toArray();
|
||||
}
|
||||
|
||||
$user->aliases()->save($alias);
|
||||
|
||||
// Hydrate all alias fields
|
||||
$alias->refresh();
|
||||
|
||||
if (isset($recipientIds)) {
|
||||
$alias->recipients()->sync($recipientIds);
|
||||
->recipients()
|
||||
->oldest()
|
||||
->get()
|
||||
->filter(function ($item, $key) use ($keys) {
|
||||
return in_array($key+1, $keys) && !is_null($item['email_verified_at']);
|
||||
})
|
||||
->pluck('id')
|
||||
->take(10)
|
||||
->toArray();
|
||||
}
|
||||
}
|
||||
|
||||
$emailData = new EmailData($this->parser, $this->option('sender'), $this->size);
|
||||
$alias->save();
|
||||
$alias->refresh();
|
||||
|
||||
$alias->verifiedRecipientsOrDefault()->each(function ($recipient) use ($alias, $emailData, $isSpam) {
|
||||
$message = (new ForwardEmail($alias, $emailData, $recipient, $isSpam));
|
||||
if (isset($recipientIds)) {
|
||||
$alias->recipients()->sync($recipientIds);
|
||||
}
|
||||
|
||||
$emailData = new EmailData($this->parser, $this->size);
|
||||
|
||||
$alias->verifiedRecipientsOrDefault()->each(function ($recipient) use ($alias, $emailData) {
|
||||
$message = new ForwardEmail($alias, $emailData, $recipient);
|
||||
|
||||
Mail::to($recipient->email)->queue($message);
|
||||
});
|
||||
}
|
||||
|
||||
protected function handleBounce($outboundMessage)
|
||||
protected function handleBounce($returnPath)
|
||||
{
|
||||
// Collect the attachments
|
||||
$attachments = collect($this->parser->getAttachments());
|
||||
|
@ -328,115 +273,112 @@ class ReceiveEmail extends Command
|
|||
return $attachment->getContentType() === 'message/delivery-status';
|
||||
})->first();
|
||||
|
||||
// Is not a bounce, may be an auto-reply so return
|
||||
if (! $deliveryReport) {
|
||||
return;
|
||||
}
|
||||
if ($deliveryReport) {
|
||||
$dsn = $this->parseDeliveryStatus($deliveryReport->getMimePartStr());
|
||||
|
||||
// Mark the outboundMessage as bounced
|
||||
$outboundMessage->markAsBounced();
|
||||
// Verify queue ID
|
||||
if (isset($dsn['X-postfix-queue-id'])) {
|
||||
|
||||
$dsn = $this->parseDeliveryStatus($deliveryReport->getMimePartStr());
|
||||
// First check in DB
|
||||
$postfixQueueId = PostfixQueueId::firstWhere('queue_id', strtoupper($dsn['X-postfix-queue-id']));
|
||||
|
||||
// Get the bounced email address
|
||||
$bouncedEmailAddress = isset($dsn['Final-recipient']) ? trim(Str::after($dsn['Final-recipient'], ';')) : null;
|
||||
|
||||
$remoteMta = isset($dsn['Remote-mta']) ? trim(Str::after($dsn['Remote-mta'], ';')) : '';
|
||||
|
||||
if (isset($dsn['Diagnostic-code']) && isset($dsn['Status'])) {
|
||||
// Try to determine the bounce type, HARD, SPAM, SOFT
|
||||
$bounceType = $this->getBounceType($dsn['Diagnostic-code'], $dsn['Status']);
|
||||
|
||||
$diagnosticCode = trim(Str::limit($dsn['Diagnostic-code'], 497));
|
||||
} else {
|
||||
$bounceType = null;
|
||||
$diagnosticCode = null;
|
||||
}
|
||||
|
||||
// To sort '5.7.1 (delivery not authorized, message refused)' as status
|
||||
if ($status = $dsn['Status'] ?? null) {
|
||||
|
||||
if (Str::length($status) > 5) {
|
||||
if (is_null($diagnosticCode)) {
|
||||
$diagnosticCode = trim(Str::substr($status, 5, 497));
|
||||
if (!$postfixQueueId) {
|
||||
exit(0);
|
||||
}
|
||||
|
||||
$status = trim(Str::substr($status, 0, 5));
|
||||
// If found then delete from DB
|
||||
$postfixQueueId->delete();
|
||||
} else {
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
// Get the undelivered message
|
||||
$undeliveredMessage = $attachments->filter(function ($attachment) {
|
||||
return in_array($attachment->getContentType(), ['text/rfc822-headers', 'message/rfc822']);
|
||||
})->first();
|
||||
// Get the bounced email address
|
||||
$bouncedEmailAddress = isset($dsn['Final-recipient']) ? trim(Str::after($dsn['Final-recipient'], ';')) : '';
|
||||
|
||||
$undeliveredMessageHeaders = [];
|
||||
$remoteMta = isset($dsn['Remote-mta']) ? trim(Str::after($dsn['Remote-mta'], ';')) : '';
|
||||
|
||||
if ($undeliveredMessage) {
|
||||
$undeliveredMessageHeaders = $this->parseDeliveryStatus($undeliveredMessage->getMimePartStr());
|
||||
}
|
||||
if (isset($dsn['Diagnostic-code']) && isset($dsn['Status'])) {
|
||||
// Try to determine the bounce type, HARD, SPAM, SOFT
|
||||
$bounceType = $this->getBounceType($dsn['Diagnostic-code'], $dsn['Status']);
|
||||
|
||||
// Get bounce user information
|
||||
$user = $outboundMessage->user;
|
||||
$alias = $outboundMessage->alias;
|
||||
$recipient = $outboundMessage->recipient;
|
||||
$emailType = $outboundMessage->getRawOriginal('email_type');
|
||||
$diagnosticCode = Str::limit($dsn['Diagnostic-code'], 497);
|
||||
} else {
|
||||
$bounceType = null;
|
||||
$diagnosticCode = null;
|
||||
}
|
||||
|
||||
if ($user) {
|
||||
$failedDeliveryId = Uuid::uuid4();
|
||||
// The return path is the alias except when it is from an unverified custom domain
|
||||
if ($returnPath !== config('anonaddy.return_path')) {
|
||||
$alias = Alias::withTrashed()->firstWhere('email', $returnPath);
|
||||
|
||||
if (isset($alias)) {
|
||||
$user = $alias->user;
|
||||
}
|
||||
}
|
||||
|
||||
// Try to find a user from the bounced email address
|
||||
if ($recipient = Recipient::select(['id', 'user_id', 'email', 'email_verified_at'])->get()->firstWhere('email', $bouncedEmailAddress)) {
|
||||
if (!isset($user)) {
|
||||
$user = $recipient->user;
|
||||
}
|
||||
}
|
||||
|
||||
// Get the undelivered message
|
||||
$undeliveredMessage = $attachments->filter(function ($attachment) {
|
||||
return in_array($attachment->getContentType(), ['text/rfc822-headers', 'message/rfc822']);
|
||||
})->first();
|
||||
|
||||
$undeliveredMessageHeaders = [];
|
||||
|
||||
if ($undeliveredMessage) {
|
||||
// Store the undelivered message if enabled by user. Do not store email verification notifications.
|
||||
if ($user->store_failed_deliveries && ! in_array($emailType, ['VR', 'VU'])) {
|
||||
$isStored = Storage::disk('local')->put("{$failedDeliveryId}.eml", $this->trimUndeliveredMessage($undeliveredMessage->getMimePartStr()));
|
||||
$undeliveredMessageHeaders = $this->parseDeliveryStatus($undeliveredMessage->getMimePartStr());
|
||||
|
||||
if (isset($undeliveredMessageHeaders['Feedback-id'])) {
|
||||
$parts = explode(':', $undeliveredMessageHeaders['Feedback-id']);
|
||||
|
||||
if (in_array($parts[0], ['F', 'R', 'S']) && !isset($alias)) {
|
||||
$alias = Alias::find($parts[1]);
|
||||
|
||||
// Find the user from the alias if we don't have it from the recipient
|
||||
if (!isset($user) && isset($alias)) {
|
||||
$user = $alias->user;
|
||||
}
|
||||
}
|
||||
|
||||
// Check if failed delivery notification or Alias deactivated notification and if so do not notify the user again
|
||||
if (! in_array($parts[0], ['FDN'])) {
|
||||
if (isset($recipient)) {
|
||||
// Notify recipient of failed delivery, check that $recipient address is verified
|
||||
if ($recipient->email_verified_at) {
|
||||
$recipient->notify(new FailedDeliveryNotification($alias->email ?? null, $undeliveredMessageHeaders['X-anonaddy-original-sender'] ?? null, $undeliveredMessageHeaders['Subject'] ?? null));
|
||||
}
|
||||
} elseif (in_array($parts[0], ['R', 'S']) && isset($user)) {
|
||||
if ($user->email_verified_at) {
|
||||
$user->defaultRecipient->notify(new FailedDeliveryNotification($alias->email ?? null, $undeliveredMessageHeaders['X-anonaddy-original-sender'] ?? null, $undeliveredMessageHeaders['Subject'] ?? null));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$failedDelivery = $user->failedDeliveries()->create([
|
||||
'id' => $failedDeliveryId,
|
||||
'recipient_id' => $recipient->id ?? null,
|
||||
'alias_id' => $alias->id ?? null,
|
||||
'is_stored' => $isStored ?? false,
|
||||
'bounce_type' => $bounceType,
|
||||
'remote_mta' => $remoteMta ?? null,
|
||||
'sender' => $undeliveredMessageHeaders['X-anonaddy-original-sender'] ?? null,
|
||||
'destination' => $bouncedEmailAddress,
|
||||
'email_type' => $emailType,
|
||||
'status' => $status ?? null,
|
||||
'code' => $diagnosticCode,
|
||||
'attempted_at' => $outboundMessage->created_at,
|
||||
]);
|
||||
|
||||
// Check the aliases failed deliveries
|
||||
if ($alias) {
|
||||
// Decrement the alias forward count due to failed delivery
|
||||
if ($failedDelivery->getRawOriginal('email_type') === 'F' && $alias->emails_forwarded > 0) {
|
||||
$alias->decrement('emails_forwarded');
|
||||
}
|
||||
|
||||
if ($failedDelivery->getRawOriginal('email_type') === 'R' && $alias->emails_replied > 0) {
|
||||
$alias->decrement('emails_replied');
|
||||
}
|
||||
|
||||
if ($failedDelivery->getRawOriginal('email_type') === 'S' && $alias->emails_sent > 0) {
|
||||
$alias->decrement('emails_sent');
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Log::info('User not found from outbound message, may have been deleted.');
|
||||
}
|
||||
|
||||
// Check if the bounce is a Failed delivery notification and if so do not notify the user again
|
||||
if (! in_array($emailType, ['FDN'])) {
|
||||
|
||||
$notifiable = $recipient?->email_verified_at ? $recipient : $user?->defaultRecipient;
|
||||
|
||||
// Notify user of failed delivery
|
||||
if ($notifiable?->email_verified_at) {
|
||||
|
||||
$notifiable->notify(new FailedDeliveryNotification($alias->email ?? null, $undeliveredMessageHeaders['X-anonaddy-original-sender'] ?? null, $undeliveredMessageHeaders['Subject'] ?? null, $failedDelivery?->is_stored, $user?->store_failed_deliveries, $recipient?->email));
|
||||
|
||||
Log::info('FDN '.$emailType.': '.$notifiable->email);
|
||||
if (isset($user)) {
|
||||
$user->failedDeliveries()->create([
|
||||
'recipient_id' => $recipient->id ?? null,
|
||||
'alias_id' => $alias->id ?? null,
|
||||
'bounce_type' => $bounceType,
|
||||
'remote_mta' => $remoteMta ?? null,
|
||||
'sender' => $undeliveredMessageHeaders['X-anonaddy-original-sender'] ?? null,
|
||||
'email_type' => $parts[0] ?? null,
|
||||
'status' => $dsn['Status'] ?? null,
|
||||
'code' => $diagnosticCode,
|
||||
'attempted_at' => $postfixQueueId->created_at
|
||||
]);
|
||||
} else {
|
||||
Log::info([
|
||||
'info' => 'user not found from bounce report',
|
||||
'deliveryReport' => $deliveryReport,
|
||||
'undeliveredMessage' => $undeliveredMessage,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -446,30 +388,27 @@ class ReceiveEmail extends Command
|
|||
protected function checkBandwidthLimit($user)
|
||||
{
|
||||
if ($user->hasReachedBandwidthLimit()) {
|
||||
$user->update(['reject_until' => now()->endOfMonth()]);
|
||||
|
||||
$this->error('4.2.1 Bandwidth limit exceeded for user. Please try again later.');
|
||||
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if ($user->nearBandwidthLimit() && ! Cache::has("user:{$user->id}:near-bandwidth")) {
|
||||
$user->notify(new NearBandwidthLimit);
|
||||
if ($user->nearBandwidthLimit() && ! Cache::has("user:{$user->username}:near-bandwidth")) {
|
||||
$user->notify(new NearBandwidthLimit());
|
||||
|
||||
Cache::put("user:{$user->id}:near-bandwidth", now()->toDateTimeString(), now()->addDay());
|
||||
Cache::put("user:{$user->username}:near-bandwidth", now()->toDateTimeString(), now()->addDay());
|
||||
}
|
||||
}
|
||||
|
||||
protected function checkRateLimit($user)
|
||||
{
|
||||
\Illuminate\Support\Facades\Redis::throttle("user:{$user->id}:limit:emails")
|
||||
\Illuminate\Support\Facades\Redis::throttle("user:{$user->username}:limit:emails")
|
||||
->allow(config('anonaddy.limit'))
|
||||
->every(3600)
|
||||
->then(
|
||||
function () {},
|
||||
function () use ($user) {
|
||||
$user->update(['defer_until' => now()->addHour()]);
|
||||
|
||||
function () {
|
||||
},
|
||||
function () {
|
||||
$this->error('4.2.1 Rate limit exceeded for user. Please try again later.');
|
||||
|
||||
exit(1);
|
||||
|
@ -484,7 +423,7 @@ class ReceiveEmail extends Command
|
|||
'email' => $item,
|
||||
'local_part' => strtolower($this->option('local_part')[$key]),
|
||||
'extension' => $this->option('extension')[$key],
|
||||
'domain' => strtolower($this->option('domain')[$key]),
|
||||
'domain' => strtolower($this->option('domain')[$key])
|
||||
];
|
||||
});
|
||||
}
|
||||
|
@ -504,7 +443,7 @@ class ReceiveEmail extends Command
|
|||
try {
|
||||
mailparse_rfc822_parse_addresses($value);
|
||||
} catch (\Exception $e) {
|
||||
$part['headers']['from'] = str_replace('\\', '', $part['headers']['from']);
|
||||
$part['headers']['from'] = str_replace("\\", "", $part['headers']['from']);
|
||||
$mimePart->setPart($part);
|
||||
}
|
||||
}
|
||||
|
@ -512,10 +451,10 @@ class ReceiveEmail extends Command
|
|||
return $next($mimePart);
|
||||
});
|
||||
|
||||
if ($file === 'stream') {
|
||||
if ($file == 'stream') {
|
||||
$fd = fopen('php://stdin', 'r');
|
||||
$this->rawEmail = '';
|
||||
while (! feof($fd)) {
|
||||
while (!feof($fd)) {
|
||||
$this->rawEmail .= fread($fd, 1024);
|
||||
}
|
||||
fclose($fd);
|
||||
|
@ -523,7 +462,6 @@ class ReceiveEmail extends Command
|
|||
} else {
|
||||
$parser->setPath($file);
|
||||
}
|
||||
|
||||
return $parser;
|
||||
}
|
||||
|
||||
|
@ -541,31 +479,20 @@ class ReceiveEmail extends Command
|
|||
$result[$key] = trim($matches[2]);
|
||||
}
|
||||
} elseif (preg_match('/^\s+(.+)\s*/', $line) && isset($key)) {
|
||||
$result[$key] .= ' '.$line;
|
||||
$result[$key] .= ' ' . $line;
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
protected function trimUndeliveredMessage($message)
|
||||
{
|
||||
return Str::after($message, 'Content-Type: message/rfc822'.PHP_EOL.PHP_EOL);
|
||||
}
|
||||
|
||||
protected function getBounceType($code, $status)
|
||||
{
|
||||
if (preg_match("/(:?mailbox|address|user|account|recipient|@).*(:?rejected|unknown|disabled|unavailable|invalid|inactive|not exist|does(n't| not) exist)|(:?rejected|unknown|unavailable|no|illegal|invalid|no such).*(:?mailbox|address|user|account|recipient|alias)|(:?address|user|recipient) does(n't| not) have .*(:?mailbox|account)|returned to sender|(:?auth).*(:?required)/i", $code)) {
|
||||
|
||||
// If the status starts with 4 then return soft instead of hard
|
||||
if (Str::startsWith($status, '4')) {
|
||||
return 'soft';
|
||||
}
|
||||
|
||||
return 'hard';
|
||||
}
|
||||
|
||||
if (preg_match('/(:?spam|unsolicited|blacklisting|blacklisted|blacklist|554|mail content denied|reject for policy reason|mail rejected by destination domain|security issue)/i', $code)) {
|
||||
if (preg_match("/(:?spam|unsolicited|blacklisting|blacklisted|blacklist|554|mail content denied|reject for policy reason|mail rejected by destination domain|security issue)/i", $code)) {
|
||||
return 'spam';
|
||||
}
|
||||
|
||||
|
@ -577,51 +504,6 @@ class ReceiveEmail extends Command
|
|||
return 'soft';
|
||||
}
|
||||
|
||||
protected function getSenderFrom()
|
||||
{
|
||||
try {
|
||||
// Ensure contains '@', may be malformed header which causes sends/replies to fail
|
||||
$address = $this->parser->getAddresses('from')[0]['address'];
|
||||
|
||||
return Str::contains($address, '@') && filter_var($address, FILTER_VALIDATE_EMAIL) ? $address : $this->option('sender');
|
||||
} catch (\Exception $e) {
|
||||
return $this->option('sender');
|
||||
}
|
||||
}
|
||||
|
||||
protected function getIdFromVerp($verp)
|
||||
{
|
||||
$localPart = Str::beforeLast($verp, '@');
|
||||
|
||||
$parts = explode('_', $localPart);
|
||||
|
||||
if (count($parts) !== 3) {
|
||||
Log::channel('single')->info('VERP invalid email: '.$verp);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
$id = Base32::decodeNoPadding($parts[1]);
|
||||
|
||||
$signature = Base32::decodeNoPadding($parts[2]);
|
||||
} catch (\Exception $e) {
|
||||
Log::channel('single')->info('VERP base32 decode failure: '.$verp.' '.$e->getMessage());
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$expectedSignature = substr(hash_hmac('sha3-224', $id, config('anonaddy.secret')), 0, 8);
|
||||
|
||||
if ($signature !== $expectedSignature) {
|
||||
Log::channel('single')->info('VERP invalid signature: '.$verp);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
return $id;
|
||||
}
|
||||
|
||||
protected function exitIfFromSelf()
|
||||
{
|
||||
// To prevent recipient alias infinite nested looping.
|
||||
|
|
|
@ -38,6 +38,6 @@ class ResetBandwidth extends Command
|
|||
*/
|
||||
public function handle()
|
||||
{
|
||||
User::where('bandwidth', '>', 0)->update(['bandwidth' => 0, 'reject_until' => null, 'defer_until' => null]);
|
||||
User::where('bandwidth', '>', 0)->update(['bandwidth' => 0]);
|
||||
}
|
||||
}
|
||||
|
|
47
app/Console/Kernel.php
Normal file
47
app/Console/Kernel.php
Normal file
|
@ -0,0 +1,47 @@
|
|||
<?php
|
||||
|
||||
namespace App\Console;
|
||||
|
||||
use Illuminate\Console\Scheduling\Schedule;
|
||||
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
|
||||
|
||||
class Kernel extends ConsoleKernel
|
||||
{
|
||||
/**
|
||||
* The Artisan commands provided by your application.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $commands = [
|
||||
'App\Console\Commands\ResetBandwidth'
|
||||
];
|
||||
|
||||
/**
|
||||
* Define the application's command schedule.
|
||||
*
|
||||
* @param \Illuminate\Console\Scheduling\Schedule $schedule
|
||||
* @return void
|
||||
*/
|
||||
protected function schedule(Schedule $schedule)
|
||||
{
|
||||
$schedule->command('anonaddy:reset-bandwidth')->monthlyOn(1, '00:00');
|
||||
$schedule->command('anonaddy:email-users-with-token-expiring-soon')->dailyAt('12:00');
|
||||
$schedule->command('anonaddy:check-domains-sending-verification')->daily();
|
||||
$schedule->command('anonaddy:check-domains-mx-validation')->daily();
|
||||
$schedule->command('anonaddy:clear-failed-deliveries')->daily();
|
||||
$schedule->command('anonaddy:clear-postfix-queue-ids')->hourly();
|
||||
$schedule->command('auth:clear-resets')->daily();
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the commands for the application.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function commands()
|
||||
{
|
||||
$this->load(__DIR__.'/Commands');
|
||||
|
||||
require base_path('routes/console.php');
|
||||
}
|
||||
}
|
|
@ -3,45 +3,51 @@
|
|||
namespace App\CustomMailDriver;
|
||||
|
||||
use Illuminate\Mail\MailManager;
|
||||
use InvalidArgumentException;
|
||||
|
||||
class CustomMailManager extends MailManager
|
||||
{
|
||||
/**
|
||||
* Resolve the given mailer.
|
||||
* Create an instance of the Sendmail Swift Transport driver.
|
||||
*
|
||||
* @param string $name
|
||||
* @return Mailer
|
||||
* @param array $config
|
||||
* @return \Swift_SendmailTransport
|
||||
*/
|
||||
protected function resolve($name): CustomMailer
|
||||
protected function createSendmailTransport(array $config)
|
||||
{
|
||||
$config = $this->getConfig($name);
|
||||
return new CustomSendmailTransport(
|
||||
$config['path'] ?? $this->app['config']->get('mail.sendmail')
|
||||
);
|
||||
}
|
||||
|
||||
if ($config === null) {
|
||||
throw new InvalidArgumentException("Mailer [{$name}] is not defined.");
|
||||
}
|
||||
|
||||
// Once we have created the mailer instance we will set a container instance
|
||||
// on the mailer. This allows us to resolve mailer classes via containers
|
||||
// for maximum testability on said classes instead of passing Closures.
|
||||
$mailer = new CustomMailer(
|
||||
$name,
|
||||
$this->app['view'],
|
||||
$this->createSymfonyTransport($config),
|
||||
$this->app['events']
|
||||
/**
|
||||
* Create an instance of the SMTP Swift Transport driver.
|
||||
*
|
||||
* @param array $config
|
||||
* @return \Swift_SmtpTransport
|
||||
*/
|
||||
protected function createSmtpTransport(array $config)
|
||||
{
|
||||
// The Swift SMTP transport instance will allow us to use any SMTP backend
|
||||
// for delivering mail such as Sendgrid, Amazon SES, or a custom server
|
||||
// a developer has available. We will just pass this configured host.
|
||||
$transport = new CustomSmtpTransport(
|
||||
$config['host'],
|
||||
$config['port']
|
||||
);
|
||||
|
||||
if ($this->app->bound('queue')) {
|
||||
$mailer->setQueue($this->app['queue']);
|
||||
if (! empty($config['encryption'])) {
|
||||
$transport->setEncryption($config['encryption']);
|
||||
}
|
||||
|
||||
// Next we will set all of the global addresses on this mailer, which allows
|
||||
// for easy unification of all "from" addresses as well as easy debugging
|
||||
// of sent messages since these will be sent to a single email address.
|
||||
foreach (['from', 'reply_to', 'to', 'return_path'] as $type) {
|
||||
$this->setGlobalAddress($mailer, $config, $type);
|
||||
// Once we have the transport we will check for the presence of a username
|
||||
// and password. If we have it we will set the credentials on the Swift
|
||||
// transporter instance so that we'll properly authenticate delivery.
|
||||
if (isset($config['username'])) {
|
||||
$transport->setUsername($config['username']);
|
||||
|
||||
$transport->setPassword($config['password']);
|
||||
}
|
||||
|
||||
return $mailer;
|
||||
return $this->configureSmtpTransport($transport, $config);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,319 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\CustomMailDriver;
|
||||
|
||||
use App\CustomMailDriver\Mime\Crypto\AlreadyEncrypted;
|
||||
use App\CustomMailDriver\Mime\Crypto\OpenPGPEncrypter;
|
||||
use App\Models\Alias;
|
||||
use App\Models\OutboundMessage;
|
||||
use App\Models\Recipient;
|
||||
use App\Models\User;
|
||||
use App\Notifications\FailedDeliveryNotification;
|
||||
use App\Notifications\GpgKeyExpired;
|
||||
use Exception;
|
||||
use Illuminate\Contracts\Mail\Mailable as MailableContract;
|
||||
use Illuminate\Mail\Mailer;
|
||||
use Illuminate\Mail\SentMessage;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Str;
|
||||
use ParagonIE\ConstantTime\Base32;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
use Symfony\Component\Mailer\Envelope;
|
||||
use Symfony\Component\Mime\Crypto\DkimOptions;
|
||||
use Symfony\Component\Mime\Crypto\DkimSigner;
|
||||
use Symfony\Component\Mime\Email;
|
||||
|
||||
class CustomMailer extends Mailer
|
||||
{
|
||||
private $data;
|
||||
|
||||
/**
|
||||
* Send a new message using a view.
|
||||
*
|
||||
* @param MailableContract|string|array $view
|
||||
* @param \Closure|string|null $callback
|
||||
* @return SentMessage|null
|
||||
*/
|
||||
public function send($view, array $data = [], $callback = null)
|
||||
{
|
||||
$this->data = $data;
|
||||
|
||||
if ($view instanceof MailableContract) {
|
||||
return $this->sendMailable($view);
|
||||
}
|
||||
|
||||
// First we need to parse the view, which could either be a string or an array
|
||||
// containing both an HTML and plain text versions of the view which should
|
||||
// be used when sending an e-mail. We will extract both of them out here.
|
||||
[$view, $plain, $raw] = $this->parseView($view);
|
||||
|
||||
$data['message'] = $message = $this->createMessage();
|
||||
|
||||
// Once we have retrieved the view content for the e-mail we will set the body
|
||||
// of this message using the HTML type, which will provide a simple wrapper
|
||||
// to creating view based emails that are able to receive arrays of data.
|
||||
if (! is_null($callback)) {
|
||||
$callback($message);
|
||||
}
|
||||
|
||||
$this->addContent($message, $view, $plain, $raw, $data);
|
||||
|
||||
// If a global "to" address has been set, we will set that address on the mail
|
||||
// message. This is primarily useful during local development in which each
|
||||
// message should be delivered into a single mail address for inspection.
|
||||
if (isset($this->to['address'])) {
|
||||
$this->setGlobalToAndRemoveCcAndBcc($message);
|
||||
}
|
||||
|
||||
// Next we will determine if the message should be sent. We give the developer
|
||||
// one final chance to stop this message and then we will send it to all of
|
||||
// its recipients. We will then fire the sent event for the sent message.
|
||||
$symfonyMessage = $message->getSymfonyMessage();
|
||||
|
||||
// OpenPGPEncrypter
|
||||
if (isset($data['fingerprint']) && $data['fingerprint']) {
|
||||
$recipient = Recipient::find($data['recipientId']);
|
||||
|
||||
try {
|
||||
$encrypter = new OpenPGPEncrypter(config('anonaddy.signing_key_fingerprint'), $data['fingerprint'], '~/.gnupg', $recipient->protected_headers);
|
||||
|
||||
$encryptedSymfonyMessage = $recipient->inline_encryption ? $encrypter->encryptInline($symfonyMessage) : $encrypter->encrypt($symfonyMessage);
|
||||
} catch (Exception $e) {
|
||||
info($e->getMessage());
|
||||
$encryptedSymfonyMessage = null;
|
||||
|
||||
$recipient->update(['should_encrypt' => false]);
|
||||
|
||||
$recipient->notify(new GpgKeyExpired);
|
||||
}
|
||||
|
||||
if ($encryptedSymfonyMessage) {
|
||||
$symfonyMessage = $encryptedSymfonyMessage;
|
||||
}
|
||||
}
|
||||
|
||||
// Already encrypted
|
||||
if (isset($data['encryptedParts']) && $data['encryptedParts']) {
|
||||
$symfonyMessage = (new AlreadyEncrypted($data['encryptedParts']))->update($symfonyMessage);
|
||||
}
|
||||
|
||||
// DkimSigner only for forwards, replies and sends...
|
||||
if (isset($data['needsDkimSignature']) && $data['needsDkimSignature'] && ! is_null(config('anonaddy.dkim_signing_key'))) {
|
||||
$dkimSigner = new DkimSigner(config('anonaddy.dkim_signing_key'), $data['aliasDomain'], config('anonaddy.dkim_selector'));
|
||||
|
||||
$options = (new DkimOptions)->headersToIgnore([
|
||||
'List-Unsubscribe',
|
||||
'List-Unsubscribe-Post',
|
||||
'Return-Path',
|
||||
'Feedback-ID',
|
||||
'Content-Type',
|
||||
'Content-Description',
|
||||
'Content-Disposition',
|
||||
'Content-Transfer-Encoding',
|
||||
'MIME-Version',
|
||||
'Alias-To',
|
||||
'X-AnonAddy-Authentication-Results',
|
||||
'X-AnonAddy-Original-Sender',
|
||||
'X-AnonAddy-Original-Envelope-From',
|
||||
'X-AnonAddy-Original-From-Header',
|
||||
'X-AnonAddy-Original-To',
|
||||
'In-Reply-To',
|
||||
'References',
|
||||
'From',
|
||||
'To',
|
||||
'Message-ID',
|
||||
'Subject',
|
||||
'Date',
|
||||
'Original-Sender',
|
||||
'Sender',
|
||||
'Received',
|
||||
])->toArray();
|
||||
$signedEmail = $dkimSigner->sign($symfonyMessage, $options);
|
||||
$symfonyMessage->setHeaders($signedEmail->getHeaders());
|
||||
}
|
||||
|
||||
if ($this->shouldSendMessage($symfonyMessage, $data)) {
|
||||
// Set VERP address
|
||||
$id = randomString(12);
|
||||
$verpLocalPart = $this->getVerpLocalPart($id);
|
||||
|
||||
// If the message is a forward, reply or send then use the verp domain
|
||||
if (isset($data['emailType']) && in_array($data['emailType'], ['F', 'R', 'S'])) {
|
||||
$symfonyMessage->returnPath($verpLocalPart.'@'.$data['verpDomain']);
|
||||
} else {
|
||||
$symfonyMessage->returnPath($verpLocalPart.'@'.config('anonaddy.domain'));
|
||||
}
|
||||
|
||||
try {
|
||||
$symfonySentMessage = $this->sendSymfonyMessage($symfonyMessage);
|
||||
} catch (Exception $e) {
|
||||
$symfonySentMessage = false;
|
||||
$userId = $data['userId'] ?? '';
|
||||
|
||||
// Store the undelivered message if enabled by user. Do not store email verification notifications.
|
||||
if ($user = User::find($userId)) {
|
||||
$failedDeliveryId = Uuid::uuid4();
|
||||
|
||||
// Example $e->getMessage();
|
||||
// Expected response code "250/251/252" but got code "554", with message "554 5.7.1 Spam message rejected".
|
||||
// Expected response code "250" but got empty code.
|
||||
// Connection could not be established with host "mail.example:25": stream_socket_client(): Unable to connect to mail.example.com:25 (Connection refused)
|
||||
$matches = Str::of($e->getMessage())->matchAll('/"([^"]*)"/');
|
||||
$status = $matches[1] ?? '4.3.2';
|
||||
$code = $matches[2] ?? '453 4.3.2 A temporary error has occurred.';
|
||||
|
||||
if ($code && $status) {
|
||||
// If the error is temporary e.g. connection lost then rethrow the error to allow retry or send to failed_jobs table
|
||||
if (Str::startsWith($status, '4')) {
|
||||
throw $e;
|
||||
}
|
||||
|
||||
// Try to determine the bounce type, HARD, SPAM, SOFT
|
||||
$bounceType = $this->getBounceType($code, $status);
|
||||
|
||||
$diagnosticCode = Str::limit($code, 497);
|
||||
} else {
|
||||
$bounceType = null;
|
||||
$diagnosticCode = null;
|
||||
}
|
||||
|
||||
$emailType = $data['emailType'] ?? null;
|
||||
|
||||
if ($user->store_failed_deliveries && ! in_array($emailType, ['VR', 'VU'])) {
|
||||
$isStored = Storage::disk('local')->put("{$failedDeliveryId}.eml", $symfonyMessage->toString());
|
||||
}
|
||||
|
||||
$failedDelivery = $user->failedDeliveries()->create([
|
||||
'id' => $failedDeliveryId,
|
||||
'recipient_id' => $data['recipientId'] ?? null,
|
||||
'alias_id' => $data['aliasId'] ?? null,
|
||||
'is_stored' => $isStored ?? false,
|
||||
'bounce_type' => $bounceType,
|
||||
'remote_mta' => config('mail.mailers.smtp.host'),
|
||||
'sender' => $symfonyMessage->getHeaders()->get('X-AnonAddy-Original-Sender')?->getValue(),
|
||||
'destination' => $symfonyMessage->getTo()[0]?->getAddress(),
|
||||
'email_type' => $emailType,
|
||||
'status' => $status,
|
||||
'code' => $diagnosticCode,
|
||||
'attempted_at' => now(),
|
||||
]);
|
||||
|
||||
// Calling $failedDelivery->email_type will return 'Failed Delivery' and not 'FDN'
|
||||
// Check if the bounce is a Failed delivery notification or Alias deactivated notification and if so do not notify the user again
|
||||
if (! in_array($emailType, ['FDN', 'ADN']) && ! is_null($emailType)) {
|
||||
|
||||
$recipient = Recipient::find($failedDelivery->recipient_id);
|
||||
$alias = Alias::find($failedDelivery->alias_id);
|
||||
|
||||
$notifiable = $recipient?->email_verified_at ? $recipient : $user?->defaultRecipient;
|
||||
|
||||
// Notify user of failed delivery
|
||||
if ($notifiable?->email_verified_at) {
|
||||
|
||||
$notifiable->notify(new FailedDeliveryNotification($alias->email ?? null, $failedDelivery->sender, $symfonyMessage->getSubject(), $failedDelivery?->is_stored, $user?->store_failed_deliveries, $recipient?->email));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($symfonySentMessage) {
|
||||
$sentMessage = new SentMessage($symfonySentMessage);
|
||||
|
||||
$this->dispatchSentEvent($sentMessage, $data);
|
||||
|
||||
// Create a new Outbound Message for verifying any bounces
|
||||
if (isset($data['userId']) && ! is_null($data['userId']) && isset($data['emailType']) && ! is_null($data['emailType'])) {
|
||||
|
||||
try {
|
||||
OutboundMessage::create([
|
||||
'id' => $id,
|
||||
'user_id' => $data['userId'],
|
||||
'alias_id' => $data['aliasId'] ?? null,
|
||||
'recipient_id' => $data['recipientId'] ?? null,
|
||||
'email_type' => $data['emailType'],
|
||||
]);
|
||||
} catch (Exception $e) {
|
||||
report($e);
|
||||
}
|
||||
}
|
||||
|
||||
return $sentMessage;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a Symfony Email instance.
|
||||
*
|
||||
* @return \Symfony\Component\Mailer\SentMessage|null
|
||||
*/
|
||||
protected function sendSymfonyMessage(Email $message)
|
||||
{
|
||||
try {
|
||||
$envelopeMessage = clone $message;
|
||||
|
||||
// Add in original Tos that have been updated
|
||||
if ($tos = $this->data['tos'] ?? null) {
|
||||
foreach ($tos as $key => $to) {
|
||||
if ($key === 0) {
|
||||
// This allows us to have the To: header set as the alias whilst still delivering to the correct RCPT TO for forwards.
|
||||
$message->to($to); // In order to override recipient email for forwards
|
||||
} else {
|
||||
$message->addTo($to);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Add in original CCs that have been updated
|
||||
if ($ccs = $this->data['ccs'] ?? null) {
|
||||
foreach ($ccs as $cc) {
|
||||
$message->addCc($cc);
|
||||
}
|
||||
}
|
||||
|
||||
// Add the original sender header here to prevent it altering the envelope from address
|
||||
if ($originalSenderHeader = $message->getHeaders()->get('Original-Sender')) {
|
||||
$message->getHeaders()->addMailboxHeader('Sender', $originalSenderHeader->getValue());
|
||||
$message->getHeaders()->remove('Original-Sender');
|
||||
}
|
||||
|
||||
return $this->transport->send($message, Envelope::create($envelopeMessage));
|
||||
} finally {
|
||||
//
|
||||
}
|
||||
}
|
||||
|
||||
protected function getVerpLocalPart($id)
|
||||
{
|
||||
$hmac = hash_hmac('sha3-224', $id, config('anonaddy.secret'));
|
||||
$hmacPayload = substr($hmac, 0, 8);
|
||||
$encodedPayload = Base32::encodeUnpadded($id);
|
||||
$encodedSignature = Base32::encodeUnpadded($hmacPayload);
|
||||
|
||||
return "b_{$encodedPayload}_{$encodedSignature}";
|
||||
}
|
||||
|
||||
protected function getBounceType($code, $status)
|
||||
{
|
||||
if (preg_match("/(:?mailbox|address|user|account|recipient|@).*(:?rejected|unknown|disabled|unavailable|invalid|inactive|not exist|does(n't| not) exist)|(:?rejected|unknown|unavailable|no|illegal|invalid|no such).*(:?mailbox|address|user|account|recipient|alias)|(:?address|user|recipient) does(n't| not) have .*(:?mailbox|account)|returned to sender|(:?auth).*(:?required)/i", $code)) {
|
||||
|
||||
// If the status starts with 4 then return soft instead of hard
|
||||
if (Str::startsWith($status, '4')) {
|
||||
return 'soft';
|
||||
}
|
||||
|
||||
return 'hard';
|
||||
}
|
||||
|
||||
if (preg_match('/(:?spam|unsolicited|blacklisting|blacklisted|blacklist|554|mail content denied|reject for policy reason|mail rejected by destination domain|security issue)/i', $code)) {
|
||||
return 'spam';
|
||||
}
|
||||
|
||||
// No match for code but status starts with 5 e.g. 5.2.2
|
||||
if (Str::startsWith($status, '5')) {
|
||||
return 'hard';
|
||||
}
|
||||
|
||||
return 'soft';
|
||||
}
|
||||
}
|
157
app/CustomMailDriver/CustomSendmailTransport.php
Normal file
157
app/CustomMailDriver/CustomSendmailTransport.php
Normal file
|
@ -0,0 +1,157 @@
|
|||
<?php
|
||||
|
||||
namespace App\CustomMailDriver;
|
||||
|
||||
use Swift_AddressEncoderException;
|
||||
use Swift_DependencyContainer;
|
||||
use Swift_Events_SendEvent;
|
||||
use Swift_Mime_SimpleMessage;
|
||||
use Swift_Transport_SendmailTransport;
|
||||
use Swift_TransportException;
|
||||
|
||||
class CustomSendmailTransport extends Swift_Transport_SendmailTransport
|
||||
{
|
||||
/**
|
||||
* Create a new SendmailTransport, optionally using $command for sending.
|
||||
*
|
||||
* @param string $command
|
||||
*/
|
||||
public function __construct($command = '/usr/sbin/sendmail -bs')
|
||||
{
|
||||
\call_user_func_array(
|
||||
[$this, 'Swift_Transport_SendmailTransport::__construct'],
|
||||
Swift_DependencyContainer::getInstance()
|
||||
->createDependenciesFor('transport.sendmail')
|
||||
);
|
||||
|
||||
$this->setCommand($command);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send the given Message.
|
||||
*
|
||||
* Recipient/sender data will be retrieved from the Message API.
|
||||
* The return value is the number of recipients who were accepted for delivery.
|
||||
*
|
||||
* @param string[] $failedRecipients An array of failures by-reference
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function send(Swift_Mime_SimpleMessage $message, &$failedRecipients = null)
|
||||
{
|
||||
if (!$this->isStarted()) {
|
||||
$this->start();
|
||||
}
|
||||
|
||||
$sent = 0;
|
||||
$failedRecipients = (array) $failedRecipients;
|
||||
|
||||
if ($evt = $this->eventDispatcher->createSendEvent($this, $message)) {
|
||||
$this->eventDispatcher->dispatchEvent($evt, 'beforeSendPerformed');
|
||||
if ($evt->bubbleCancelled()) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$reversePath = $this->getReversePath($message)) {
|
||||
$this->throwException(new Swift_TransportException('Cannot send message without a sender address'));
|
||||
}
|
||||
|
||||
$to = (array) $message->getTo();
|
||||
$cc = (array) $message->getCc();
|
||||
$tos = array_merge($to, $cc);
|
||||
$bcc = (array) $message->getBcc();
|
||||
|
||||
$message->setBcc([]);
|
||||
|
||||
// This allows us to have the To: header set as the alias whilst still delivering to the correct RCPT TO.
|
||||
if ($aliasTo = $message->getHeaders()->get('Alias-To')) {
|
||||
$message->setTo($aliasTo->getFieldBodyModel());
|
||||
$message->getHeaders()->remove('Alias-To');
|
||||
}
|
||||
|
||||
try {
|
||||
$sent += $this->sendTo($message, $reversePath, $tos, $failedRecipients);
|
||||
$sent += $this->sendBcc($message, $reversePath, $bcc, $failedRecipients);
|
||||
} finally {
|
||||
$message->setBcc($bcc);
|
||||
}
|
||||
|
||||
if ($evt) {
|
||||
if ($sent == \count($to) + \count($cc) + \count($bcc)) {
|
||||
$evt->setResult(Swift_Events_SendEvent::RESULT_SUCCESS);
|
||||
} elseif ($sent > 0) {
|
||||
$evt->setResult(Swift_Events_SendEvent::RESULT_TENTATIVE);
|
||||
} else {
|
||||
$evt->setResult(Swift_Events_SendEvent::RESULT_FAILED);
|
||||
}
|
||||
$evt->setFailedRecipients($failedRecipients);
|
||||
$this->eventDispatcher->dispatchEvent($evt, 'sendPerformed');
|
||||
}
|
||||
|
||||
$message->generateId(); //Make sure a new Message ID is used
|
||||
|
||||
return $sent;
|
||||
}
|
||||
|
||||
/** Send a message to the given To: recipients */
|
||||
private function sendTo(Swift_Mime_SimpleMessage $message, $reversePath, array $to, array &$failedRecipients)
|
||||
{
|
||||
if (empty($to)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return $this->doMailTransaction(
|
||||
$message,
|
||||
$reversePath,
|
||||
array_keys($to),
|
||||
$failedRecipients
|
||||
);
|
||||
}
|
||||
|
||||
/** Send a message to all Bcc: recipients */
|
||||
private function sendBcc(Swift_Mime_SimpleMessage $message, $reversePath, array $bcc, array &$failedRecipients)
|
||||
{
|
||||
$sent = 0;
|
||||
foreach ($bcc as $forwardPath => $name) {
|
||||
$message->setBcc([$forwardPath => $name]);
|
||||
$sent += $this->doMailTransaction(
|
||||
$message,
|
||||
$reversePath,
|
||||
[$forwardPath],
|
||||
$failedRecipients
|
||||
);
|
||||
}
|
||||
|
||||
return $sent;
|
||||
}
|
||||
|
||||
/** Send an email to the given recipients from the given reverse path */
|
||||
private function doMailTransaction($message, $reversePath, array $recipients, array &$failedRecipients)
|
||||
{
|
||||
$sent = 0;
|
||||
$this->doMailFromCommand($reversePath);
|
||||
foreach ($recipients as $forwardPath) {
|
||||
try {
|
||||
$this->doRcptToCommand($forwardPath);
|
||||
++$sent;
|
||||
} catch (Swift_TransportException $e) {
|
||||
$failedRecipients[] = $forwardPath;
|
||||
} catch (Swift_AddressEncoderException $e) {
|
||||
$failedRecipients[] = $forwardPath;
|
||||
}
|
||||
}
|
||||
|
||||
if (0 != $sent) {
|
||||
$sent += \count($failedRecipients);
|
||||
$this->doDataCommand($failedRecipients);
|
||||
$sent -= \count($failedRecipients);
|
||||
|
||||
$this->streamMessage($message);
|
||||
} else {
|
||||
$this->reset();
|
||||
}
|
||||
|
||||
return $sent;
|
||||
}
|
||||
}
|
195
app/CustomMailDriver/CustomSmtpTransport.php
Normal file
195
app/CustomMailDriver/CustomSmtpTransport.php
Normal file
|
@ -0,0 +1,195 @@
|
|||
<?php
|
||||
|
||||
namespace App\CustomMailDriver;
|
||||
|
||||
use App\Models\PostfixQueueId;
|
||||
use Illuminate\Database\QueryException;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use Illuminate\Support\Str;
|
||||
use Swift_AddressEncoderException;
|
||||
use Swift_DependencyContainer;
|
||||
use Swift_Events_SendEvent;
|
||||
use Swift_Mime_SimpleMessage;
|
||||
use Swift_Plugins_LoggerPlugin;
|
||||
use Swift_Plugins_Loggers_ArrayLogger;
|
||||
use Swift_Transport_EsmtpTransport;
|
||||
use Swift_TransportException;
|
||||
|
||||
class CustomSmtpTransport extends Swift_Transport_EsmtpTransport
|
||||
{
|
||||
/**
|
||||
* @param string $host
|
||||
* @param int $port
|
||||
* @param string|null $encryption SMTP encryption mode:
|
||||
* - null for plain SMTP (no encryption),
|
||||
* - 'tls' for SMTP with STARTTLS (best effort encryption),
|
||||
* - 'ssl' for SMTPS = SMTP over TLS (always encrypted).
|
||||
*/
|
||||
public function __construct($host = 'localhost', $port = 25, $encryption = null)
|
||||
{
|
||||
\call_user_func_array(
|
||||
[$this, 'Swift_Transport_EsmtpTransport::__construct'],
|
||||
Swift_DependencyContainer::getInstance()
|
||||
->createDependenciesFor('transport.smtp')
|
||||
);
|
||||
|
||||
$this->setHost($host);
|
||||
$this->setPort($port);
|
||||
$this->setEncryption($encryption);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send the given Message.
|
||||
*
|
||||
* Recipient/sender data will be retrieved from the Message API.
|
||||
* The return value is the number of recipients who were accepted for delivery.
|
||||
*
|
||||
* @param string[] $failedRecipients An array of failures by-reference
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function send(Swift_Mime_SimpleMessage $message, &$failedRecipients = null)
|
||||
{
|
||||
if (!$this->isStarted()) {
|
||||
$this->start();
|
||||
}
|
||||
|
||||
$logger = new Swift_Plugins_Loggers_ArrayLogger();
|
||||
Mail::getSwiftMailer()->registerPlugin(new Swift_Plugins_LoggerPlugin($logger));
|
||||
|
||||
$sent = 0;
|
||||
$failedRecipients = (array) $failedRecipients;
|
||||
|
||||
if ($evt = $this->eventDispatcher->createSendEvent($this, $message)) {
|
||||
$this->eventDispatcher->dispatchEvent($evt, 'beforeSendPerformed');
|
||||
if ($evt->bubbleCancelled()) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$reversePath = $this->getReversePath($message)) {
|
||||
$this->throwException(new Swift_TransportException('Cannot send message without a sender address'));
|
||||
}
|
||||
|
||||
$to = (array) $message->getTo();
|
||||
$cc = (array) $message->getCc();
|
||||
$tos = array_merge($to, $cc);
|
||||
$bcc = (array) $message->getBcc();
|
||||
|
||||
$message->setBcc([]);
|
||||
|
||||
// This allows us to have the To: header set as the alias whilst still delivering to the correct RCPT TO.
|
||||
if ($aliasTo = $message->getHeaders()->get('Alias-To')) {
|
||||
$message->setTo($aliasTo->getFieldBodyModel());
|
||||
$message->getHeaders()->remove('Alias-To');
|
||||
}
|
||||
|
||||
// Update Content IDs for inline image attachments
|
||||
if ($oldCids = $message->getHeaders()->get('X-Old-Cids')) {
|
||||
$oldCidsArray = explode(',', $oldCids->getFieldBodyModel());
|
||||
|
||||
$newCids = $message->getHeaders()->get('X-New-Cids');
|
||||
$newCidsArray = explode(',', $newCids->getFieldBodyModel());
|
||||
|
||||
$message->getHeaders()->remove('X-Old-Cids');
|
||||
$message->getHeaders()->remove('X-New-Cids');
|
||||
|
||||
$message->setBody(str_replace($oldCidsArray, $newCidsArray, $message->getBody()));
|
||||
}
|
||||
|
||||
try {
|
||||
$sent += $this->sendTo($message, $reversePath, $tos, $failedRecipients);
|
||||
$sent += $this->sendBcc($message, $reversePath, $bcc, $failedRecipients);
|
||||
} finally {
|
||||
$message->setBcc($bcc);
|
||||
}
|
||||
|
||||
if ($evt) {
|
||||
if ($sent == \count($to) + \count($cc) + \count($bcc)) {
|
||||
$evt->setResult(Swift_Events_SendEvent::RESULT_SUCCESS);
|
||||
} elseif ($sent > 0) {
|
||||
$evt->setResult(Swift_Events_SendEvent::RESULT_TENTATIVE);
|
||||
} else {
|
||||
$evt->setResult(Swift_Events_SendEvent::RESULT_FAILED);
|
||||
}
|
||||
$evt->setFailedRecipients($failedRecipients);
|
||||
$this->eventDispatcher->dispatchEvent($evt, 'sendPerformed');
|
||||
}
|
||||
|
||||
$message->generateId(); //Make sure a new Message ID is used
|
||||
|
||||
try {
|
||||
// Get Postfix Queue ID and store in the database
|
||||
$id = str_replace("\r\n", "", Str::after($logger->dump(), 'Ok: queued as '));
|
||||
|
||||
PostfixQueueId::create([
|
||||
'queue_id' => $id
|
||||
]);
|
||||
} catch (QueryException $e) {
|
||||
// duplicate entry
|
||||
}
|
||||
|
||||
return $sent;
|
||||
}
|
||||
|
||||
/** Send a message to the given To: recipients */
|
||||
private function sendTo(Swift_Mime_SimpleMessage $message, $reversePath, array $to, array &$failedRecipients)
|
||||
{
|
||||
if (empty($to)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return $this->doMailTransaction(
|
||||
$message,
|
||||
$reversePath,
|
||||
array_keys($to),
|
||||
$failedRecipients
|
||||
);
|
||||
}
|
||||
|
||||
/** Send a message to all Bcc: recipients */
|
||||
private function sendBcc(Swift_Mime_SimpleMessage $message, $reversePath, array $bcc, array &$failedRecipients)
|
||||
{
|
||||
$sent = 0;
|
||||
foreach ($bcc as $forwardPath => $name) {
|
||||
$message->setBcc([$forwardPath => $name]);
|
||||
$sent += $this->doMailTransaction(
|
||||
$message,
|
||||
$reversePath,
|
||||
[$forwardPath],
|
||||
$failedRecipients
|
||||
);
|
||||
}
|
||||
|
||||
return $sent;
|
||||
}
|
||||
|
||||
/** Send an email to the given recipients from the given reverse path */
|
||||
private function doMailTransaction($message, $reversePath, array $recipients, array &$failedRecipients)
|
||||
{
|
||||
$sent = 0;
|
||||
$this->doMailFromCommand($reversePath);
|
||||
foreach ($recipients as $forwardPath) {
|
||||
try {
|
||||
$this->doRcptToCommand($forwardPath);
|
||||
++$sent;
|
||||
} catch (Swift_TransportException $e) {
|
||||
$failedRecipients[] = $forwardPath;
|
||||
} catch (Swift_AddressEncoderException $e) {
|
||||
$failedRecipients[] = $forwardPath;
|
||||
}
|
||||
}
|
||||
|
||||
if (0 != $sent) {
|
||||
$sent += \count($failedRecipients);
|
||||
$this->doDataCommand($failedRecipients);
|
||||
$sent -= \count($failedRecipients);
|
||||
|
||||
$this->streamMessage($message);
|
||||
} else {
|
||||
$this->reset();
|
||||
}
|
||||
|
||||
return $sent;
|
||||
}
|
||||
}
|
|
@ -1,40 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\CustomMailDriver\Mime\Crypto;
|
||||
|
||||
use App\CustomMailDriver\Mime\Part\EncryptedPart;
|
||||
use Symfony\Component\Mime\Email;
|
||||
|
||||
class AlreadyEncrypted
|
||||
{
|
||||
protected $encryptedParts;
|
||||
|
||||
public function __construct($encryptedParts)
|
||||
{
|
||||
$this->encryptedParts = $encryptedParts;
|
||||
}
|
||||
|
||||
public function update(Email $message): Email
|
||||
{
|
||||
$boundary = strtr(base64_encode(random_bytes(6)), '+/', '-_');
|
||||
|
||||
$headers = $message->getPreparedHeaders();
|
||||
|
||||
$headers->setHeaderBody('Parameterized', 'Content-Type', 'multipart/encrypted');
|
||||
$headers->setHeaderParameter('Content-Type', 'protocol', 'application/pgp-encrypted');
|
||||
$headers->setHeaderParameter('Content-Type', 'boundary', $boundary);
|
||||
|
||||
$message->setHeaders($headers);
|
||||
|
||||
$body = "This is an OpenPGP/MIME encrypted message (RFC 4880 and 3156)\r\n\r\n";
|
||||
|
||||
foreach ($this->encryptedParts as $part) {
|
||||
$body .= "--{$boundary}\r\n";
|
||||
$body .= $part->getMimePartStr()."\r\n";
|
||||
}
|
||||
|
||||
$body .= "--{$boundary}--";
|
||||
|
||||
return $message->setBody(new EncryptedPart($body));
|
||||
}
|
||||
}
|
|
@ -1,295 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\CustomMailDriver\Mime\Crypto;
|
||||
|
||||
use App\CustomMailDriver\Mime\Part\EncryptedPart;
|
||||
use Illuminate\Support\Str;
|
||||
use Symfony\Component\Mailer\Exception\RuntimeException;
|
||||
use Symfony\Component\Mime\Email;
|
||||
|
||||
class OpenPGPEncrypter
|
||||
{
|
||||
protected $gnupg = null;
|
||||
|
||||
protected $usesProtectedHeaders;
|
||||
|
||||
/**
|
||||
* The signing hash algorithm. 'MD5', SHA1, or SHA256. SHA256 (the default) is highly recommended
|
||||
* unless you need to deal with an old client that doesn't support it. SHA1 and MD5 are
|
||||
* currently considered cryptographically weak.
|
||||
*
|
||||
* This is apparently not supported by the PHP GnuPG module.
|
||||
*
|
||||
* @type string
|
||||
*/
|
||||
protected $micalg = 'SHA256';
|
||||
|
||||
protected $recipientKey = null;
|
||||
|
||||
/**
|
||||
* The fingerprint of the key that will be used to sign the email. Populated either with
|
||||
* autoAddSignature or addSignature.
|
||||
*
|
||||
* @type string
|
||||
*/
|
||||
protected $signingKey;
|
||||
|
||||
/**
|
||||
* An associative array of keyFingerprint=>passwords to decrypt secret keys (if needed).
|
||||
* Populated by calling addKeyPassphrase. Pointless at the moment because the GnuPG module in
|
||||
* PHP doesn't support decrypting keys with passwords. The command line client does, so this
|
||||
* method stays for now.
|
||||
*
|
||||
* @type array
|
||||
*/
|
||||
protected $keyPassphrases = [];
|
||||
|
||||
/**
|
||||
* Specifies the home directory for the GnuPG keyrings. By default this is the user's home
|
||||
* directory + /.gnupg, however when running on a web server (eg: Apache) the home directory
|
||||
* will likely not exist and/or not be writable. Set this by calling setGPGHome before calling
|
||||
* any other encryption/signing methods.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $gnupgHome = null;
|
||||
|
||||
public function __construct($signingKey = null, $recipientKey = null, $gnupgHome = null, $usesProtectedHeaders = false)
|
||||
{
|
||||
$this->initGNUPG();
|
||||
$this->signingKey = $signingKey;
|
||||
$this->recipientKey = $recipientKey;
|
||||
$this->gnupgHome = $gnupgHome;
|
||||
$this->usesProtectedHeaders = $usesProtectedHeaders;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $micalg
|
||||
*/
|
||||
public function setMicalg($micalg)
|
||||
{
|
||||
$this->micalg = $micalg;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param null $passPhrase
|
||||
*
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
public function addSignature($identifier, $keyFingerprint = null, $passPhrase = null)
|
||||
{
|
||||
if (! $keyFingerprint) {
|
||||
$keyFingerprint = $this->getKey($identifier, 'sign');
|
||||
}
|
||||
$this->signingKey = $keyFingerprint;
|
||||
|
||||
if ($passPhrase) {
|
||||
$this->addKeyPassphrase($keyFingerprint, $passPhrase);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
public function addKeyPassphrase($identifier, $passPhrase)
|
||||
{
|
||||
$keyFingerprint = $this->getKey($identifier, 'sign');
|
||||
$this->keyPassphrases[$keyFingerprint] = $passPhrase;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Email $email
|
||||
* @return $this
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public function encrypt(Email $symfonyMessage): Email
|
||||
{
|
||||
$originalMessage = clone $symfonyMessage;
|
||||
// Clone to ensure headers are not altered if encryption fails
|
||||
$message = clone $symfonyMessage;
|
||||
|
||||
$headers = $message->getPreparedHeaders();
|
||||
|
||||
$boundary = strtr(base64_encode(random_bytes(6)), '+/', '-_');
|
||||
|
||||
$headers->setHeaderBody('Parameterized', 'Content-Type', 'multipart/encrypted');
|
||||
$headers->setHeaderParameter('Content-Type', 'protocol', 'application/pgp-encrypted');
|
||||
$headers->setHeaderParameter('Content-Type', 'boundary', $boundary);
|
||||
|
||||
$message->setHeaders($headers);
|
||||
|
||||
// If the email does not have any text part then we need to add a text/plain legacy display part
|
||||
if ($this->usesProtectedHeaders && is_null($originalMessage->getTextBody())) {
|
||||
$originalMessage->text($headers->get('Subject')->toString());
|
||||
}
|
||||
|
||||
$lines = preg_split('/(\r\n|\r|\n)/', rtrim($originalMessage->toString()));
|
||||
|
||||
// Check if using protected headers or not
|
||||
if ($this->usesProtectedHeaders) {
|
||||
$protectedHeadersSet = false;
|
||||
for ($i = 0; $i < count($lines); $i++) {
|
||||
if (Str::startsWith(strtolower($lines[$i]), 'content-type: text/plain') || Str::startsWith(strtolower($lines[$i]), 'content-type: multipart/')) {
|
||||
$lines[$i] = rtrim($lines[$i])."; protected-headers=\"v1\"\r\n";
|
||||
if (! $protectedHeadersSet) {
|
||||
$headers->setHeaderBody('Text', 'Subject', '...');
|
||||
$protectedHeadersSet = true;
|
||||
}
|
||||
} else {
|
||||
$lines[$i] = rtrim($lines[$i])."\r\n";
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for ($i = 0; $i < count($lines); $i++) {
|
||||
$lines[$i] = rtrim($lines[$i])."\r\n";
|
||||
}
|
||||
}
|
||||
|
||||
// Remove excess trailing newlines (RFC3156 section 5.4)
|
||||
$originalBody = rtrim(implode('', $lines))."\r\n";
|
||||
|
||||
// Create encrypted body from original message
|
||||
$encryptedBody = $this->pgpEncryptAndSignString($originalBody, $this->recipientKey, $this->signingKey);
|
||||
|
||||
// Fixes DKIM signature incorrect body hash for custom domains
|
||||
$body = "This is an OpenPGP/MIME encrypted message (RFC 4880 and 3156)\r\n\r\n";
|
||||
$body .= "--{$boundary}\r\n";
|
||||
$body .= "Content-Type: application/pgp-encrypted\r\n";
|
||||
$body .= "Content-Description: PGP/MIME version identification\r\n\r\n";
|
||||
$body .= "Version: 1\r\n\r\n";
|
||||
$body .= "--{$boundary}\r\n";
|
||||
$body .= "Content-Type: application/octet-stream; name=\"encrypted.asc\"\r\n";
|
||||
$body .= "Content-Description: OpenPGP encrypted message\r\n";
|
||||
$body .= "Content-Disposition: inline; filename=\"encrypted.asc\"\r\n\r\n";
|
||||
$body .= $encryptedBody."\r\n\r\n";
|
||||
$body .= "--{$boundary}--";
|
||||
|
||||
return $message->setBody(new EncryptedPart($body));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Email $email
|
||||
* @return $this
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public function encryptInline(Email $symfonyMessage): Email
|
||||
{
|
||||
if (! $this->signingKey) {
|
||||
foreach ($symfonyMessage->getFrom() as $key => $value) {
|
||||
$this->addSignature($this->getKey($key, 'sign'));
|
||||
}
|
||||
}
|
||||
|
||||
if (! $this->signingKey) {
|
||||
throw new RuntimeException('Signing has been enabled, but no signature has been added. Use autoAddSignature() or addSignature()');
|
||||
}
|
||||
|
||||
if (! $this->recipientKey) {
|
||||
throw new RuntimeException('Encryption has been enabled, but no recipients have been added. Use autoAddRecipients() or addRecipient()');
|
||||
}
|
||||
|
||||
$body = $symfonyMessage->getTextBody() ?? '';
|
||||
|
||||
$text = $this->pgpEncryptAndSignString($body, $this->recipientKey, $this->signingKey);
|
||||
|
||||
$headers = $symfonyMessage->getPreparedHeaders();
|
||||
$headers->setHeaderBody('Parameterized', 'Content-Type', 'text/plain');
|
||||
$headers->setHeaderParameter('Content-Type', 'charset', 'utf-8');
|
||||
$symfonyMessage->setHeaders($headers);
|
||||
|
||||
return $symfonyMessage->setBody(new EncryptedPart($text));
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
protected function initGNUPG()
|
||||
{
|
||||
if (! class_exists('gnupg')) {
|
||||
throw new RuntimeException('PHPMailerPGP requires the GnuPG class');
|
||||
}
|
||||
|
||||
if (! $this->gnupgHome && isset($_SERVER['HOME'])) {
|
||||
$this->gnupgHome = $_SERVER['HOME'].'/.gnupg';
|
||||
}
|
||||
|
||||
if (! $this->gnupgHome && getenv('HOME')) {
|
||||
$this->gnupgHome = getenv('HOME').'/.gnupg';
|
||||
}
|
||||
|
||||
if (! $this->gnupg) {
|
||||
$this->gnupg = new \gnupg;
|
||||
}
|
||||
|
||||
$this->gnupg->seterrormode(\gnupg::ERROR_EXCEPTION);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $plaintext
|
||||
* @param $keyFingerprints
|
||||
* @return string
|
||||
*
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
protected function pgpEncryptAndSignString($text, $keyFingerprint, $signingKeyFingerprint)
|
||||
{
|
||||
if (isset($this->keyPassphrases[$signingKeyFingerprint]) && ! $this->keyPassphrases[$signingKeyFingerprint]) {
|
||||
$passPhrase = $this->keyPassphrases[$signingKeyFingerprint];
|
||||
} else {
|
||||
$passPhrase = null;
|
||||
}
|
||||
|
||||
$this->gnupg->clearsignkeys();
|
||||
$this->gnupg->addsignkey($signingKeyFingerprint, $passPhrase);
|
||||
$this->gnupg->clearencryptkeys();
|
||||
$this->gnupg->addencryptkey($keyFingerprint);
|
||||
$this->gnupg->setarmor(1);
|
||||
|
||||
$encrypted = $this->gnupg->encryptsign($text);
|
||||
|
||||
if ($encrypted) {
|
||||
return $encrypted;
|
||||
}
|
||||
|
||||
throw new RuntimeException('Unable to encrypt and sign message');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
protected function getKey($identifier, $purpose)
|
||||
{
|
||||
$keys = $this->gnupg->keyinfo($identifier);
|
||||
$fingerprints = [];
|
||||
|
||||
foreach ($keys as $key) {
|
||||
if ($this->isValidKey($key, $purpose)) {
|
||||
foreach ($key['subkeys'] as $subKey) {
|
||||
if ($this->isValidKey($subKey, $purpose)) {
|
||||
$fingerprints[] = $subKey['fingerprint'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Return first available to encrypt
|
||||
if (count($fingerprints) >= 1) {
|
||||
return $fingerprints[0];
|
||||
}
|
||||
|
||||
/* if (count($fingerprints) > 1) {
|
||||
throw new Swift_SwiftException(sprintf('Found more than one active key for %s use addRecipient() or addSignature()', $identifier));
|
||||
} */
|
||||
|
||||
throw new RuntimeException(sprintf('Unable to find an active key to %s for %s,try importing keys first', $purpose, $identifier));
|
||||
}
|
||||
|
||||
protected function isValidKey($key, $purpose)
|
||||
{
|
||||
return ! ($key['disabled'] || $key['expired'] || $key['revoked'] || ($purpose === 'sign' && ! $key['can_sign']) || ($purpose === 'encrypt' && ! $key['can_encrypt']));
|
||||
}
|
||||
}
|
|
@ -1,25 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\CustomMailDriver\Mime\Encoder;
|
||||
|
||||
use Symfony\Component\Mime\Encoder\ContentEncoderInterface;
|
||||
|
||||
final class RawContentEncoder implements ContentEncoderInterface
|
||||
{
|
||||
public function encodeByteStream($stream, int $maxLineLength = 0): iterable
|
||||
{
|
||||
while (! feof($stream)) {
|
||||
yield fread($stream, 8192);
|
||||
}
|
||||
}
|
||||
|
||||
public function getName(): string
|
||||
{
|
||||
return 'raw';
|
||||
}
|
||||
|
||||
public function encodeString(string $string, ?string $charset = 'utf-8', int $firstLineOffset = 0, int $maxLineLength = 0): string
|
||||
{
|
||||
return $string;
|
||||
}
|
||||
}
|
|
@ -1,129 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\CustomMailDriver\Mime\Part;
|
||||
|
||||
use App\CustomMailDriver\Mime\Encoder\RawContentEncoder;
|
||||
use Symfony\Component\Mime\Encoder\ContentEncoderInterface;
|
||||
use Symfony\Component\Mime\Header\Headers;
|
||||
use Symfony\Component\Mime\Part\AbstractPart;
|
||||
|
||||
class EncryptedPart extends AbstractPart
|
||||
{
|
||||
/** @internal */
|
||||
protected $_headers;
|
||||
|
||||
private $body;
|
||||
|
||||
private $charset;
|
||||
|
||||
private $subtype;
|
||||
|
||||
/**
|
||||
* @var ?string
|
||||
*/
|
||||
private $disposition;
|
||||
|
||||
private $seekable;
|
||||
|
||||
/**
|
||||
* @param resource|string $body
|
||||
*/
|
||||
public function __construct($body, ?string $charset = 'utf-8', string $subtype = 'plain')
|
||||
{
|
||||
unset($this->_headers);
|
||||
|
||||
parent::__construct();
|
||||
|
||||
if (! \is_string($body) && ! \is_resource($body)) {
|
||||
throw new \TypeError(sprintf('The body of "%s" must be a string or a resource (got "%s").', self::class, get_debug_type($body)));
|
||||
}
|
||||
|
||||
$this->body = $body;
|
||||
$this->charset = $charset;
|
||||
$this->subtype = $subtype;
|
||||
$this->seekable = \is_resource($body) ? stream_get_meta_data($body)['seekable'] && fseek($body, 0, \SEEK_CUR) === 0 : null;
|
||||
}
|
||||
|
||||
public function getMediaType(): string
|
||||
{
|
||||
return 'text';
|
||||
}
|
||||
|
||||
public function getMediaSubtype(): string
|
||||
{
|
||||
return $this->subtype;
|
||||
}
|
||||
|
||||
public function getBody(): string
|
||||
{
|
||||
if ($this->seekable === null) {
|
||||
return $this->body;
|
||||
}
|
||||
|
||||
if ($this->seekable) {
|
||||
rewind($this->body);
|
||||
}
|
||||
|
||||
return stream_get_contents($this->body) ?: '';
|
||||
}
|
||||
|
||||
public function bodyToString(): string
|
||||
{
|
||||
return $this->getEncoder()->encodeString($this->getBody(), $this->charset);
|
||||
}
|
||||
|
||||
public function bodyToIterable(): iterable
|
||||
{
|
||||
if ($this->seekable !== null) {
|
||||
if ($this->seekable) {
|
||||
rewind($this->body);
|
||||
}
|
||||
yield from $this->getEncoder()->encodeByteStream($this->body);
|
||||
} else {
|
||||
yield $this->getEncoder()->encodeString($this->body);
|
||||
}
|
||||
}
|
||||
|
||||
public function getPreparedHeaders(): Headers
|
||||
{
|
||||
return clone new Headers;
|
||||
}
|
||||
|
||||
public function asDebugString(): string
|
||||
{
|
||||
$str = parent::asDebugString();
|
||||
if ($this->charset !== null) {
|
||||
$str .= ' charset: '.$this->charset;
|
||||
}
|
||||
if ($this->disposition !== null) {
|
||||
$str .= ' disposition: '.$this->disposition;
|
||||
}
|
||||
|
||||
return $str;
|
||||
}
|
||||
|
||||
private function getEncoder(): ContentEncoderInterface
|
||||
{
|
||||
return new RawContentEncoder;
|
||||
}
|
||||
|
||||
public function __sleep(): array
|
||||
{
|
||||
// convert resources to strings for serialization
|
||||
if ($this->seekable !== null) {
|
||||
$this->body = $this->getBody();
|
||||
}
|
||||
|
||||
$this->_headers = $this->getHeaders();
|
||||
|
||||
return ['_headers', 'body', 'charset', 'subtype', 'disposition', 'name', 'encoding'];
|
||||
}
|
||||
|
||||
public function __wakeup()
|
||||
{
|
||||
$r = new \ReflectionProperty(AbstractPart::class, 'headers');
|
||||
$r->setAccessible(true);
|
||||
$r->setValue($this, $this->_headers);
|
||||
unset($this->_headers);
|
||||
}
|
||||
}
|
|
@ -1,63 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\CustomMailDriver\Mime\Part;
|
||||
|
||||
use Symfony\Component\Mime\Header\Headers;
|
||||
use Symfony\Component\Mime\Part\DataPart;
|
||||
|
||||
class InlineImagePart extends DataPart
|
||||
{
|
||||
/**
|
||||
* Sets the content-id of the file.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setContentId(string $cid): static
|
||||
{
|
||||
$this->cid = $cid;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getContentId(): string
|
||||
{
|
||||
return $this->cid ?: $this->cid = $this->generateContentId();
|
||||
}
|
||||
|
||||
public function hasContentId(): bool
|
||||
{
|
||||
return $this->cid !== null;
|
||||
}
|
||||
|
||||
private function generateContentId(): string
|
||||
{
|
||||
return bin2hex(random_bytes(16)).'@symfony';
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the name of the file.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setFileName(string $filename): static
|
||||
{
|
||||
$this->filename = $filename;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getPreparedHeaders(): Headers
|
||||
{
|
||||
$headers = parent::getPreparedHeaders();
|
||||
|
||||
if ($this->cid !== null) {
|
||||
$headers->setHeaderBody('Id', 'Content-ID', $this->cid);
|
||||
}
|
||||
|
||||
if ($this->filename !== null) {
|
||||
$headers->setHeaderParameter('Content-Disposition', 'filename', $this->filename);
|
||||
}
|
||||
|
||||
return $headers;
|
||||
}
|
||||
}
|
|
@ -1,52 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Validation;
|
||||
|
||||
use Egulias\EmailValidator\EmailLexer;
|
||||
use Egulias\EmailValidator\MessageIDParser;
|
||||
use Egulias\EmailValidator\Result\InvalidEmail;
|
||||
use Egulias\EmailValidator\Result\Reason\ExceptionFound;
|
||||
|
||||
class MessageIDValidation implements EmailValidation
|
||||
{
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $warnings = [];
|
||||
|
||||
/**
|
||||
* @var ?InvalidEmail
|
||||
*/
|
||||
private $error;
|
||||
|
||||
public function isValid(string $email, EmailLexer $emailLexer): bool
|
||||
{
|
||||
$parser = new MessageIDParser($emailLexer);
|
||||
try {
|
||||
$result = $parser->parse($email);
|
||||
$this->warnings = $parser->getWarnings();
|
||||
// Allow invalid message-ids to be forwarded
|
||||
// if ($result->isInvalid()) {
|
||||
// /** @psalm-suppress PropertyTypeCoercion */
|
||||
// $this->error = $result;
|
||||
// return false;
|
||||
// }
|
||||
} catch (\Exception $invalid) {
|
||||
$this->error = new InvalidEmail(new ExceptionFound($invalid), '');
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getWarnings(): array
|
||||
{
|
||||
return $this->warnings;
|
||||
}
|
||||
|
||||
public function getError(): ?InvalidEmail
|
||||
{
|
||||
return $this->error;
|
||||
}
|
||||
}
|
|
@ -1,15 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Enums;
|
||||
|
||||
enum DisplayFromFormat: int
|
||||
{
|
||||
case DEFAULT = 0;
|
||||
case BRACKETS = 1;
|
||||
case DOMAIN = 2;
|
||||
case NAME = 3;
|
||||
case ADDRESS = 4;
|
||||
case NONE = 5;
|
||||
case DOMAINONLY = 6;
|
||||
case LEGACY = 7;
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Enums;
|
||||
|
||||
enum LoginRedirect: int
|
||||
{
|
||||
case DEFAULT = 0;
|
||||
case ALIASES = 1;
|
||||
case RECIPIENTS = 2;
|
||||
case USERNAMES = 3;
|
||||
case DOMAINS = 4;
|
||||
}
|
37
app/Exceptions/Handler.php
Normal file
37
app/Exceptions/Handler.php
Normal file
|
@ -0,0 +1,37 @@
|
|||
<?php
|
||||
|
||||
namespace App\Exceptions;
|
||||
|
||||
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
|
||||
|
||||
class Handler extends ExceptionHandler
|
||||
{
|
||||
/**
|
||||
* A list of the exception types that are not reported.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $dontReport = [
|
||||
//
|
||||
];
|
||||
|
||||
/**
|
||||
* A list of the inputs that are never flashed for validation exceptions.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $dontFlash = [
|
||||
'password',
|
||||
'password_confirmation',
|
||||
];
|
||||
|
||||
/**
|
||||
* Register the exception handling callbacks for the application.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
|
@ -8,8 +8,8 @@ use Maatwebsite\Excel\Concerns\WithHeadings;
|
|||
class AliasesExport implements FromCollection, WithHeadings
|
||||
{
|
||||
/**
|
||||
* @return \Illuminate\Support\Collection
|
||||
*/
|
||||
* @return \Illuminate\Support\Collection
|
||||
*/
|
||||
public function collection()
|
||||
{
|
||||
return user()->aliases()->withTrashed()->get();
|
||||
|
|
74
app/Helpers/AlreadyEncryptedSigner.php
Normal file
74
app/Helpers/AlreadyEncryptedSigner.php
Normal file
|
@ -0,0 +1,74 @@
|
|||
<?php
|
||||
|
||||
namespace App\Helpers;
|
||||
|
||||
use Swift_DependencyContainer;
|
||||
use Swift_Message;
|
||||
use Swift_Signers_BodySigner;
|
||||
use Swift_SwiftException;
|
||||
|
||||
class AlreadyEncryptedSigner implements Swift_Signers_BodySigner
|
||||
{
|
||||
protected $attachments;
|
||||
|
||||
public function __construct($attachments)
|
||||
{
|
||||
$this->attachments = $attachments;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Swift_Message $message
|
||||
*
|
||||
* @return $this
|
||||
*
|
||||
* @throws Swift_DependencyException
|
||||
* @throws Swift_SwiftException
|
||||
*/
|
||||
public function signMessage(Swift_Message $message)
|
||||
{
|
||||
$message->setChildren([]);
|
||||
|
||||
$message->setEncoder(Swift_DependencyContainer::getInstance()->lookup('mime.rawcontentencoder'));
|
||||
|
||||
$type = $message->getHeaders()->get('Content-Type');
|
||||
|
||||
$type->setValue('multipart/encrypted');
|
||||
|
||||
$type->setParameters([
|
||||
'protocol' => 'application/pgp-encrypted',
|
||||
'boundary' => $message->getBoundary()
|
||||
]);
|
||||
|
||||
$body = 'This is an OpenPGP/MIME encrypted message (RFC 4880 and 3156)' . PHP_EOL;
|
||||
|
||||
foreach ($this->attachments as $attachment) {
|
||||
$body .= '--' . $message->getBoundary() . PHP_EOL;
|
||||
$body .= $attachment->getMimePartStr() . PHP_EOL;
|
||||
}
|
||||
|
||||
$body .= '--'. $message->getBoundary() . '--';
|
||||
|
||||
$message->setBody($body);
|
||||
|
||||
$messageHeaders = $message->getHeaders();
|
||||
$messageHeaders->removeAll('Content-Transfer-Encoding');
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getAlteredHeaders()
|
||||
{
|
||||
return ['Content-Type', 'Content-Transfer-Encoding', 'Content-Disposition', 'Content-Description'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function reset()
|
||||
{
|
||||
return $this;
|
||||
}
|
||||
}
|
|
@ -1,84 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Helpers;
|
||||
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Str;
|
||||
use Symfony\Component\Process\Exception\RuntimeException;
|
||||
use Symfony\Component\Process\Process;
|
||||
|
||||
class GitVersionHelper
|
||||
{
|
||||
public static function version()
|
||||
{
|
||||
if (Cache::has('app-version')) {
|
||||
return Cache::get('app-version');
|
||||
}
|
||||
|
||||
return self::cacheFreshVersion();
|
||||
}
|
||||
|
||||
public static function updateAvailable()
|
||||
{
|
||||
$currentVersion = self::version()->value();
|
||||
|
||||
// Cache latestVersion for 1 day
|
||||
$latestVersion = Cache::remember('app-latest-version', now()->addDay(), function () {
|
||||
$response = Http::get('https://api.github.com/repos/anonaddy/anonaddy/releases/latest');
|
||||
|
||||
return Str::of($response->json('tag_name', 'v0.0.0'))->after('v')->trim();
|
||||
});
|
||||
|
||||
return version_compare($latestVersion, $currentVersion, '>');
|
||||
}
|
||||
|
||||
public static function cacheFreshVersion()
|
||||
{
|
||||
$version = self::freshVersion();
|
||||
Cache::put('app-version', $version);
|
||||
|
||||
return $version;
|
||||
}
|
||||
|
||||
public static function freshVersion()
|
||||
{
|
||||
$path = base_path();
|
||||
|
||||
// Get version string from git
|
||||
$command = 'git describe --tags $(git rev-list --tags --max-count=1)';
|
||||
|
||||
if (class_exists('\Symfony\Component\Process\Process')) {
|
||||
try {
|
||||
if (method_exists(Process::class, 'fromShellCommandline')) {
|
||||
$process = Process::fromShellCommandline($command, $path);
|
||||
} else {
|
||||
$process = new Process([$command], $path);
|
||||
}
|
||||
|
||||
$process->mustRun();
|
||||
$output = $process->getOutput();
|
||||
} catch (RuntimeException $e) {
|
||||
// Do nothing
|
||||
$output = null;
|
||||
}
|
||||
} else {
|
||||
// Remember current directory
|
||||
$dir = getcwd();
|
||||
|
||||
// Change to base directory
|
||||
chdir($path);
|
||||
|
||||
$output = shell_exec($command);
|
||||
|
||||
// Change back
|
||||
chdir($dir);
|
||||
}
|
||||
|
||||
if (! $output) {
|
||||
return str(config('anonaddy.version'));
|
||||
}
|
||||
|
||||
return Str::of($output)->after('v')->trim();
|
||||
}
|
||||
}
|
|
@ -1,7 +1,6 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
function user()
|
||||
{
|
||||
|
@ -12,31 +11,3 @@ function carbon(...$args)
|
|||
{
|
||||
return new Carbon(...$args);
|
||||
}
|
||||
|
||||
function randomString(int $length): string
|
||||
{
|
||||
$alphabet = '0123456789abcdefghijklmnopqrstuvwxyz';
|
||||
|
||||
$str = '';
|
||||
|
||||
for ($i = 0; $i < $length; $i++) {
|
||||
$index = random_int(0, 35);
|
||||
$str .= $alphabet[$index];
|
||||
}
|
||||
|
||||
return $str;
|
||||
}
|
||||
|
||||
function stripEmailExtension(string $email): string
|
||||
{
|
||||
if (! Str::contains($email, '@')) {
|
||||
return $email;
|
||||
}
|
||||
|
||||
// Strip the email of extensions
|
||||
[$localPart, $domain] = explode('@', strtolower($email));
|
||||
// Remove plus extension from local part if present
|
||||
$localPart = Str::contains($localPart, '+') ? Str::before($localPart, '+') : $localPart;
|
||||
|
||||
return $localPart.'@'.$domain;
|
||||
}
|
||||
|
|
433
app/Helpers/OpenPGPSigner.php
Normal file
433
app/Helpers/OpenPGPSigner.php
Normal file
|
@ -0,0 +1,433 @@
|
|||
<?php
|
||||
|
||||
namespace App\Helpers;
|
||||
|
||||
use Swift_DependencyContainer;
|
||||
use Swift_Message;
|
||||
use Swift_Signers_BodySigner;
|
||||
use Swift_SwiftException;
|
||||
|
||||
/*
|
||||
* This file is part of SwiftMailer.
|
||||
* (c) 2004-2009 Chris Corbyn
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Message Signer used to apply OpenPGP Signature/Encryption to a message.
|
||||
*
|
||||
* @author Artem Zhuravlev <infzanoza@gmail.com>
|
||||
*/
|
||||
class OpenPGPSigner implements Swift_Signers_BodySigner
|
||||
{
|
||||
protected $gnupg = null;
|
||||
|
||||
/**
|
||||
* The signing hash algorithm. 'MD5', SHA1, or SHA256. SHA256 (the default) is highly recommended
|
||||
* unless you need to deal with an old client that doesn't support it. SHA1 and MD5 are
|
||||
* currently considered cryptographically weak.
|
||||
*
|
||||
* This is apparently not supported by the PHP GnuPG module.
|
||||
*
|
||||
* @type string
|
||||
*/
|
||||
protected $micalg = 'SHA256';
|
||||
|
||||
/**
|
||||
* An associative array of identifier=>keyFingerprint for the recipients we'll encrypt the email
|
||||
* to, where identifier is usually the email address, but could be anything used to look up a
|
||||
* key (including the fingerprint itself). This is populated either by autoAddRecipients or by
|
||||
* calling addRecipient.
|
||||
*
|
||||
* @type array
|
||||
*/
|
||||
protected $recipientKeys = [];
|
||||
|
||||
/**
|
||||
* The fingerprint of the key that will be used to sign the email. Populated either with
|
||||
* autoAddSignature or addSignature.
|
||||
*
|
||||
* @type string
|
||||
*/
|
||||
protected $signingKey;
|
||||
|
||||
/**
|
||||
* An associative array of keyFingerprint=>passwords to decrypt secret keys (if needed).
|
||||
* Populated by calling addKeyPassphrase. Pointless at the moment because the GnuPG module in
|
||||
* PHP doesn't support decrypting keys with passwords. The command line client does, so this
|
||||
* method stays for now.
|
||||
*
|
||||
* @type array
|
||||
*/
|
||||
protected $keyPassphrases = [];
|
||||
|
||||
/**
|
||||
* Specifies the home directory for the GnuPG keyrings. By default this is the user's home
|
||||
* directory + /.gnupg, however when running on a web server (eg: Apache) the home directory
|
||||
* will likely not exist and/or not be writable. Set this by calling setGPGHome before calling
|
||||
* any other encryption/signing methods.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $gnupgHome = null;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
protected $encrypt = true;
|
||||
|
||||
|
||||
public function __construct($signingKey = null, $recipientKeys = [], $gnupgHome = null)
|
||||
{
|
||||
$this->initGNUPG();
|
||||
$this->signingKey = $signingKey;
|
||||
$this->recipientKeys = $recipientKeys;
|
||||
$this->gnupgHome = $gnupgHome;
|
||||
}
|
||||
|
||||
public static function newInstance($signingKey = null, $recipientKeys = [], $gnupgHome = null)
|
||||
{
|
||||
return new self($signingKey, $recipientKeys, $gnupgHome);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param boolean $encrypt
|
||||
*/
|
||||
public function setEncrypt($encrypt)
|
||||
{
|
||||
$this->encrypt = $encrypt;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $gnupgHome
|
||||
*/
|
||||
public function setGnupgHome($gnupgHome)
|
||||
{
|
||||
$this->gnupgHome = $gnupgHome;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $micalg
|
||||
*/
|
||||
public function setMicalg($micalg)
|
||||
{
|
||||
$this->micalg = $micalg;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $identifier
|
||||
* @param null $passPhrase
|
||||
*
|
||||
* @throws Swift_SwiftException
|
||||
*/
|
||||
public function addSignature($identifier, $keyFingerprint = null, $passPhrase = null)
|
||||
{
|
||||
if (!$keyFingerprint) {
|
||||
$keyFingerprint = $this->getKey($identifier, 'sign');
|
||||
}
|
||||
$this->signingKey = $keyFingerprint;
|
||||
|
||||
if ($passPhrase) {
|
||||
$this->addKeyPassphrase($keyFingerprint, $passPhrase);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $identifier
|
||||
* @param $passPhrase
|
||||
*
|
||||
* @throws Swift_SwiftException
|
||||
*/
|
||||
public function addKeyPassphrase($identifier, $passPhrase)
|
||||
{
|
||||
$keyFingerprint = $this->getKey($identifier, 'sign');
|
||||
$this->keyPassphrases[$keyFingerprint] = $passPhrase;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a recipient to encrypt a copy of the email for. If you exclude a key fingerprint, we
|
||||
* will try to find a matching key based on the identifier. However if no match is found, or
|
||||
* if multiple valid keys are found, this will fail. Specifying a key fingerprint avoids these
|
||||
* issues.
|
||||
*
|
||||
* @param string $identifier
|
||||
* an email address, but could be a key fingerprint, key ID, name, etc.
|
||||
*
|
||||
* @param string $keyFingerprint
|
||||
*/
|
||||
public function addRecipient($identifier, $keyFingerprint = null)
|
||||
{
|
||||
if (!$keyFingerprint) {
|
||||
$keyFingerprint = $this->getKey($identifier, 'encrypt');
|
||||
}
|
||||
|
||||
$this->recipientKeys[$identifier] = $keyFingerprint;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Swift_Message $message
|
||||
*
|
||||
* @return $this
|
||||
*
|
||||
* @throws Swift_DependencyException
|
||||
* @throws Swift_SwiftException
|
||||
*/
|
||||
public function signMessage(Swift_Message $message)
|
||||
{
|
||||
$originalMessage = $this->createMessage($message);
|
||||
|
||||
$message->setChildren([]);
|
||||
|
||||
$message->setEncoder(Swift_DependencyContainer::getInstance()->lookup('mime.rawcontentencoder'));
|
||||
|
||||
$type = $message->getHeaders()->get('Content-Type');
|
||||
|
||||
$type->setValue('multipart/signed');
|
||||
|
||||
$type->setParameters([
|
||||
'micalg' => sprintf("pgp-%s", strtolower($this->micalg)),
|
||||
'protocol' => 'application/pgp-signature',
|
||||
'boundary' => $message->getBoundary()
|
||||
]);
|
||||
|
||||
if (!$this->signingKey) {
|
||||
foreach ($message->getFrom() as $key => $value) {
|
||||
$this->addSignature($this->getKey($key, 'sign'));
|
||||
}
|
||||
}
|
||||
|
||||
if (!$this->signingKey) {
|
||||
throw new Swift_SwiftException('Signing has been enabled, but no signature has been added. Use autoAddSignature() or addSignature()');
|
||||
}
|
||||
|
||||
$signedBody = $originalMessage->toString();
|
||||
|
||||
$lines = preg_split('/(\r\n|\r|\n)/', rtrim($signedBody));
|
||||
|
||||
for ($i=0; $i<count($lines); $i++) {
|
||||
$lines[$i] = rtrim($lines[$i])."\r\n";
|
||||
}
|
||||
|
||||
// Remove excess trailing newlines (RFC3156 section 5.4)
|
||||
$signedBody = rtrim(implode('', $lines))."\r\n";
|
||||
|
||||
$signature = $this->pgpSignString($signedBody, $this->signingKey);
|
||||
|
||||
//Swiftmailer is automatically changing content type and this is the hack to prevent it
|
||||
// Fixes DKIM signature incorrect body hash for custom domains
|
||||
$body = "This is an OpenPGP/MIME signed message (RFC 4880 and 3156)\r\n\r\n";
|
||||
$body .= "--{$message->getBoundary()}\r\n";
|
||||
$body .= $signedBody."\r\n";
|
||||
$body .= "--{$message->getBoundary()}\r\n";
|
||||
$body .= "Content-Type: application/pgp-signature; name=\"signature.asc\"\r\n";
|
||||
$body .= "Content-Description: OpenPGP digital signature\r\n";
|
||||
$body .= "Content-Disposition: attachment; filename=\"signature.asc\"\r\n\r\n";
|
||||
$body .= $signature."\r\n\r\n";
|
||||
$body .= "--{$message->getBoundary()}--";
|
||||
|
||||
$message->setBody($body);
|
||||
|
||||
if ($this->encrypt) {
|
||||
$signed = sprintf("%s\r\n%s", $message->getHeaders()->get('Content-Type')->toString(), $body);
|
||||
|
||||
if (!$this->recipientKeys) {
|
||||
foreach ($message->getTo() as $key => $value) {
|
||||
if (!isset($this->recipientKeys[$key])) {
|
||||
$this->addRecipient($key);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!$this->recipientKeys) {
|
||||
throw new Swift_SwiftException('Encryption has been enabled, but no recipients have been added. Use autoAddRecipients() or addRecipient()');
|
||||
}
|
||||
|
||||
//Create body from signed message
|
||||
$encryptedBody = $this->pgpEncryptString($signed, array_keys($this->recipientKeys));
|
||||
|
||||
$type = $message->getHeaders()->get('Content-Type');
|
||||
|
||||
$type->setValue('multipart/encrypted');
|
||||
|
||||
$type->setParameters([
|
||||
'protocol' => 'application/pgp-encrypted',
|
||||
'boundary' => $message->getBoundary()
|
||||
]);
|
||||
|
||||
// Fixes DKIM signature incorrect body hash for custom domains
|
||||
$body = "This is an OpenPGP/MIME encrypted message (RFC 4880 and 3156)\r\n\r\n";
|
||||
$body .= "--{$message->getBoundary()}\r\n";
|
||||
$body .= "Content-Type: application/pgp-encrypted\r\n";
|
||||
$body .= "Content-Description: PGP/MIME version identification\r\n\r\n";
|
||||
$body .= "Version: 1\r\n\r\n";
|
||||
$body .= "--{$message->getBoundary()}\r\n";
|
||||
$body .= "Content-Type: application/octet-stream; name=\"encrypted.asc\"\r\n";
|
||||
$body .= "Content-Description: OpenPGP encrypted message\r\n";
|
||||
$body .= "Content-Disposition: inline; filename=\"encrypted.asc\"\r\n\r\n";
|
||||
$body .= $encryptedBody."\r\n\r\n";
|
||||
$body .= "--{$message->getBoundary()}--";
|
||||
|
||||
$message->setBody($body);
|
||||
}
|
||||
|
||||
$messageHeaders = $message->getHeaders();
|
||||
$messageHeaders->removeAll('Content-Transfer-Encoding');
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getAlteredHeaders()
|
||||
{
|
||||
return ['Content-Type', 'Content-Transfer-Encoding', 'Content-Disposition', 'Content-Description'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function reset()
|
||||
{
|
||||
return $this;
|
||||
}
|
||||
|
||||
protected function createMessage(Swift_Message $message)
|
||||
{
|
||||
$mimeEntity = new Swift_Message('', $message->getBody(), $message->getContentType(), $message->getCharset());
|
||||
$mimeEntity->setChildren($message->getChildren());
|
||||
|
||||
$messageHeaders = $mimeEntity->getHeaders();
|
||||
$messageHeaders->remove('Message-ID');
|
||||
$messageHeaders->remove('Date');
|
||||
$messageHeaders->remove('Subject');
|
||||
$messageHeaders->remove('MIME-Version');
|
||||
$messageHeaders->remove('To');
|
||||
$messageHeaders->remove('From');
|
||||
|
||||
return $mimeEntity;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Swift_SwiftException
|
||||
*/
|
||||
protected function initGNUPG()
|
||||
{
|
||||
if (!class_exists('gnupg')) {
|
||||
throw new Swift_SwiftException('PHPMailerPGP requires the GnuPG class');
|
||||
}
|
||||
|
||||
if (!$this->gnupgHome && isset($_SERVER['HOME'])) {
|
||||
$this->gnupgHome = $_SERVER['HOME'] . '/.gnupg';
|
||||
}
|
||||
|
||||
if (!$this->gnupgHome && getenv('HOME')) {
|
||||
$this->gnupgHome = getenv('HOME') . '/.gnupg';
|
||||
}
|
||||
|
||||
if (!$this->gnupg) {
|
||||
$this->gnupg = new \gnupg();
|
||||
}
|
||||
|
||||
$this->gnupg->seterrormode(\gnupg::ERROR_EXCEPTION);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $plaintext
|
||||
* @param $keyFingerprint
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @throws Swift_SwiftException
|
||||
*/
|
||||
protected function pgpSignString($plaintext, $keyFingerprint)
|
||||
{
|
||||
if (isset($this->keyPassphrases[$keyFingerprint]) && !$this->keyPassphrases[$keyFingerprint]) {
|
||||
$passPhrase = $this->keyPassphrases[$keyFingerprint];
|
||||
} else {
|
||||
$passPhrase = null;
|
||||
}
|
||||
|
||||
$this->gnupg->clearsignkeys();
|
||||
$this->gnupg->addsignkey($keyFingerprint, $passPhrase);
|
||||
$this->gnupg->setsignmode(\gnupg::SIG_MODE_DETACH);
|
||||
$this->gnupg->setarmor(1);
|
||||
|
||||
$signed = $this->gnupg->sign($plaintext);
|
||||
|
||||
if ($signed) {
|
||||
return $signed;
|
||||
}
|
||||
|
||||
throw new Swift_SwiftException('Unable to sign message (perhaps the secret key is encrypted with a passphrase?)');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $plaintext
|
||||
* @param $keyFingerprints
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @throws Swift_SwiftException
|
||||
*/
|
||||
protected function pgpEncryptString($plaintext, $keyFingerprints)
|
||||
{
|
||||
$this->gnupg->clearencryptkeys();
|
||||
|
||||
foreach ($keyFingerprints as $keyFingerprint) {
|
||||
$this->gnupg->addencryptkey($keyFingerprint);
|
||||
}
|
||||
|
||||
$this->gnupg->setarmor(1);
|
||||
|
||||
$encrypted = $this->gnupg->encrypt($plaintext);
|
||||
|
||||
if ($encrypted) {
|
||||
return $encrypted;
|
||||
}
|
||||
|
||||
throw new Swift_SwiftException('Unable to encrypt message');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $identifier
|
||||
* @param $purpose
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @throws Swift_SwiftException
|
||||
*/
|
||||
protected function getKey($identifier, $purpose)
|
||||
{
|
||||
$keys = $this->gnupg->keyinfo($identifier);
|
||||
$fingerprints = [];
|
||||
|
||||
foreach ($keys as $key) {
|
||||
if ($this->isValidKey($key, $purpose)) {
|
||||
foreach ($key['subkeys'] as $subKey) {
|
||||
if ($this->isValidKey($subKey, $purpose)) {
|
||||
$fingerprints[] = $subKey['fingerprint'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Return first available to encrypt
|
||||
if (count($fingerprints) >= 1) {
|
||||
return $fingerprints[0];
|
||||
}
|
||||
|
||||
/* if (count($fingerprints) > 1) {
|
||||
throw new Swift_SwiftException(sprintf('Found more than one active key for %s use addRecipient() or addSignature()', $identifier));
|
||||
} */
|
||||
|
||||
throw new Swift_SwiftException(sprintf('Unable to find an active key to %s for %s,try importing keys first', $purpose, $identifier));
|
||||
}
|
||||
|
||||
protected function isValidKey($key, $purpose)
|
||||
{
|
||||
return !($key['disabled'] || $key['expired'] || $key['revoked'] || ($purpose == 'sign' && !$key['can_sign']) || ($purpose == 'encrypt' && !$key['can_encrypt']));
|
||||
}
|
||||
}
|
|
@ -9,9 +9,7 @@ class AliasExportController extends Controller
|
|||
{
|
||||
public function export()
|
||||
{
|
||||
if (! user()->allAliases()->count()) {
|
||||
return back()->withErrors(['aliases_export' => 'You don\'t have any aliases to export.']);
|
||||
}
|
||||
//return (new AliasesExport)->download('aliases.csv', \Maatwebsite\Excel\Excel::CSV);
|
||||
|
||||
return Excel::download(new AliasesExport, 'aliases-'.now()->toDateString().'.csv');
|
||||
}
|
||||
|
|
|
@ -1,41 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Http\Requests\ImportAliasesRequest;
|
||||
use App\Imports\AliasesImport;
|
||||
use Illuminate\Support\Facades\App;
|
||||
use Maatwebsite\Excel\HeadingRowImport;
|
||||
|
||||
class AliasImportController extends Controller
|
||||
{
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('throttle:1,1'); // Limit to 1 upload per minute
|
||||
}
|
||||
|
||||
public function import(ImportAliasesRequest $request)
|
||||
{
|
||||
try {
|
||||
$import = new AliasesImport(user());
|
||||
|
||||
$headings = (new HeadingRowImport)->toCollection($request->file('aliases_import'))->flatten();
|
||||
|
||||
// Validate the heading row
|
||||
if (($headings->diff(['alias', 'description', 'recipients'])->count() || $headings->count() !== 3) && ! App::environment('testing')) {
|
||||
return back()->withErrors(['aliases_import' => 'The aliases import file has invalid headers, please use the template provided above.']);
|
||||
}
|
||||
|
||||
$import->queue($request->file('aliases_import'));
|
||||
} catch (\Exception $e) {
|
||||
report($e);
|
||||
}
|
||||
|
||||
return back()->with(['flash' => 'File uploaded successfully, your aliases are being imported']);
|
||||
}
|
||||
}
|
|
@ -10,7 +10,7 @@ class AccountDetailController extends Controller
|
|||
public function index()
|
||||
{
|
||||
return response()->json([
|
||||
'data' => new UserResource(user()),
|
||||
'data' => new UserResource(user())
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Resources\AdditionalUsernameResource;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ActiveAdditionalUsernameController extends Controller
|
||||
{
|
||||
public function store(Request $request)
|
||||
{
|
||||
$username = user()->additionalUsernames()->findOrFail($request->id);
|
||||
|
||||
$username->activate();
|
||||
|
||||
return new AdditionalUsernameResource($username);
|
||||
}
|
||||
|
||||
public function destroy($id)
|
||||
{
|
||||
$username = user()->additionalUsernames()->findOrFail($id);
|
||||
|
||||
$username->deactivate();
|
||||
|
||||
return response('', 204);
|
||||
}
|
||||
}
|
|
@ -10,8 +10,6 @@ class ActiveAliasController extends Controller
|
|||
{
|
||||
public function store(Request $request)
|
||||
{
|
||||
$request->validate(['id' => 'required|string']);
|
||||
|
||||
$alias = user()->aliases()->withTrashed()->findOrFail($request->id);
|
||||
|
||||
if ($alias->trashed()) {
|
||||
|
@ -20,7 +18,7 @@ class ActiveAliasController extends Controller
|
|||
|
||||
$alias->activate();
|
||||
|
||||
return new AliasResource($alias->load('recipients'));
|
||||
return new AliasResource($alias);
|
||||
}
|
||||
|
||||
public function destroy($id)
|
||||
|
|
|
@ -10,13 +10,11 @@ class ActiveDomainController extends Controller
|
|||
{
|
||||
public function store(Request $request)
|
||||
{
|
||||
$request->validate(['id' => 'required|string']);
|
||||
|
||||
$domain = user()->domains()->findOrFail($request->id);
|
||||
|
||||
$domain->activate();
|
||||
|
||||
return new DomainResource($domain->load('defaultRecipient')->loadCount('aliases'));
|
||||
return new DomainResource($domain);
|
||||
}
|
||||
|
||||
public function destroy($id)
|
||||
|
|
|
@ -10,8 +10,6 @@ class ActiveRuleController extends Controller
|
|||
{
|
||||
public function store(Request $request)
|
||||
{
|
||||
$request->validate(['id' => 'required|string']);
|
||||
|
||||
$rule = user()->rules()->findOrFail($request->id);
|
||||
|
||||
$rule->activate();
|
||||
|
|
|
@ -1,30 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Resources\UsernameResource;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ActiveUsernameController extends Controller
|
||||
{
|
||||
public function store(Request $request)
|
||||
{
|
||||
$request->validate(['id' => 'required|string']);
|
||||
|
||||
$username = user()->usernames()->findOrFail($request->id);
|
||||
|
||||
$username->activate();
|
||||
|
||||
return new UsernameResource($username->load('defaultRecipient')->loadCount('aliases'));
|
||||
}
|
||||
|
||||
public function destroy($id)
|
||||
{
|
||||
$username = user()->usernames()->findOrFail($id);
|
||||
|
||||
$username->deactivate();
|
||||
|
||||
return response('', 204);
|
||||
}
|
||||
}
|
54
app/Http/Controllers/Api/AdditionalUsernameController.php
Normal file
54
app/Http/Controllers/Api/AdditionalUsernameController.php
Normal file
|
@ -0,0 +1,54 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\StoreAdditionalUsernameRequest;
|
||||
use App\Http\Requests\UpdateAdditionalUsernameRequest;
|
||||
use App\Http\Resources\AdditionalUsernameResource;
|
||||
|
||||
class AdditionalUsernameController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
return AdditionalUsernameResource::collection(user()->additionalUsernames()->with(['aliases', 'defaultRecipient'])->latest()->get());
|
||||
}
|
||||
|
||||
public function show($id)
|
||||
{
|
||||
$username = user()->additionalUsernames()->findOrFail($id);
|
||||
|
||||
return new AdditionalUsernameResource($username->load(['aliases', 'defaultRecipient']));
|
||||
}
|
||||
|
||||
public function store(StoreAdditionalUsernameRequest $request)
|
||||
{
|
||||
if (user()->hasReachedAdditionalUsernameLimit()) {
|
||||
return response('', 403);
|
||||
}
|
||||
|
||||
$username = user()->additionalUsernames()->create(['username' => $request->username]);
|
||||
|
||||
user()->increment('username_count');
|
||||
|
||||
return new AdditionalUsernameResource($username->refresh()->load(['aliases', 'defaultRecipient']));
|
||||
}
|
||||
|
||||
public function update(UpdateAdditionalUsernameRequest $request, $id)
|
||||
{
|
||||
$username = user()->additionalUsernames()->findOrFail($id);
|
||||
|
||||
$username->update(['description' => $request->description]);
|
||||
|
||||
return new AdditionalUsernameResource($username->refresh()->load(['aliases', 'defaultRecipient']));
|
||||
}
|
||||
|
||||
public function destroy($id)
|
||||
{
|
||||
$username = user()->additionalUsernames()->findOrFail($id);
|
||||
|
||||
$username->delete();
|
||||
|
||||
return response('', 204);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\UpdateAdditionalUsernameDefaultRecipientRequest;
|
||||
use App\Http\Resources\AdditionalUsernameResource;
|
||||
|
||||
class AdditionalUsernameDefaultRecipientController extends Controller
|
||||
{
|
||||
public function update(UpdateAdditionalUsernameDefaultRecipientRequest $request, $id)
|
||||
{
|
||||
$additionalUsername = user()->additionalUsernames()->findOrFail($id);
|
||||
if (empty($request->default_recipient)) {
|
||||
$additionalUsername->default_recipient_id = null;
|
||||
} else {
|
||||
$recipient = user()->verifiedRecipients()->findOrFail($request->default_recipient);
|
||||
$additionalUsername->default_recipient = $recipient;
|
||||
}
|
||||
|
||||
$additionalUsername->save();
|
||||
|
||||
return new AdditionalUsernameResource($additionalUsername);
|
||||
}
|
||||
}
|
|
@ -1,227 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\GeneralAliasBulkRequest;
|
||||
use App\Http\Requests\RecipientsAliasBulkRequest;
|
||||
use App\Http\Resources\AliasResource;
|
||||
use App\Rules\VerifiedRecipientId;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
|
||||
class AliasBulkController extends Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('throttle:12,1');
|
||||
}
|
||||
|
||||
public function get(GeneralAliasBulkRequest $request)
|
||||
{
|
||||
$aliases = user()->aliases()->withTrashed()
|
||||
->whereIn('id', $request->ids)
|
||||
->get();
|
||||
|
||||
// If there are no aliases found return 404 response
|
||||
if (! $aliases->count()) {
|
||||
return response()->json(['message' => 'No aliases found'], 404);
|
||||
}
|
||||
|
||||
return AliasResource::collection($aliases);
|
||||
}
|
||||
|
||||
public function activate(GeneralAliasBulkRequest $request)
|
||||
{
|
||||
$aliasesWithTrashed = user()->aliases()->withTrashed()
|
||||
->select(['id', 'user_id', 'active', 'deleted_at'])
|
||||
->where('active', false)
|
||||
->whereIn('id', $request->ids)
|
||||
->get();
|
||||
|
||||
// If there are no aliases found return 404 response
|
||||
if (! $aliasesWithTrashedCount = $aliasesWithTrashed->count()) {
|
||||
return response()->json(['message' => 'No aliases found'], 404);
|
||||
}
|
||||
|
||||
// Check if all aliases are deleted, if so return message
|
||||
$aliases = $aliasesWithTrashed->filter(function ($alias) {
|
||||
return ! $alias->trashed();
|
||||
});
|
||||
|
||||
if ($aliases->count() === 0) {
|
||||
return response()->json([
|
||||
'message' => $aliasesWithTrashedCount === 1 ? 'You need to restore this alias before you can activate it' : 'You need to restore these aliases before you can activate them',
|
||||
'ids' => $aliasesWithTrashed->pluck('id'),
|
||||
], 422);
|
||||
}
|
||||
|
||||
$aliasIds = $aliases->pluck('id')->all();
|
||||
$aliasIdsCount = count($aliasIds);
|
||||
user()->aliases()->whereIn('id', $aliasIds)->update(['active' => true]);
|
||||
|
||||
return response()->json([
|
||||
'message' => $aliasIdsCount === 1 ? '1 alias activated successfully' : "{$aliasIdsCount} aliases activated successfully",
|
||||
'ids' => $aliasIds,
|
||||
], 200);
|
||||
}
|
||||
|
||||
public function deactivate(GeneralAliasBulkRequest $request)
|
||||
{
|
||||
$aliasIds = user()->aliases()
|
||||
->where('active', true)
|
||||
->whereIn('id', $request->ids)
|
||||
->pluck('id');
|
||||
|
||||
// If there are no aliases found return 404 response
|
||||
if (! $aliasIdsCount = $aliasIds->count()) {
|
||||
return response()->json(['message' => 'No aliases found'], 404);
|
||||
}
|
||||
|
||||
user()->aliases()->whereIn('id', $aliasIds)->update(['active' => false]);
|
||||
|
||||
return response()->json([
|
||||
'message' => $aliasIdsCount === 1 ? '1 alias deactivated successfully' : "{$aliasIdsCount} aliases deactivated successfully",
|
||||
'ids' => $aliasIds,
|
||||
], 200);
|
||||
}
|
||||
|
||||
public function delete(GeneralAliasBulkRequest $request)
|
||||
{
|
||||
$aliasIds = user()->aliases()
|
||||
->whereIn('id', $request->ids)
|
||||
->pluck('id');
|
||||
|
||||
// If there are no aliases found return 404 response
|
||||
if (! $aliasIdsCount = $aliasIds->count()) {
|
||||
return response()->json(['message' => 'No aliases found'], 404);
|
||||
}
|
||||
|
||||
// Detach any recipients
|
||||
DB::table('alias_recipients')->whereIn('alias_id', $aliasIds)->delete();
|
||||
|
||||
// Use update since delete() does not trigger model event
|
||||
user()->aliases()->whereIn('id', $aliasIds)->update(['active' => false, 'deleted_at' => now()]);
|
||||
|
||||
// Don't return 204 as that is only for empty responses
|
||||
return response()->json([
|
||||
'message' => $aliasIdsCount === 1 ? '1 alias deleted successfully' : "{$aliasIdsCount} aliases deleted successfully",
|
||||
'ids' => $aliasIds,
|
||||
], 200);
|
||||
}
|
||||
|
||||
public function forget(GeneralAliasBulkRequest $request)
|
||||
{
|
||||
$aliasIds = user()->aliases()->withTrashed()
|
||||
->whereIn('id', $request->ids)
|
||||
->pluck('id');
|
||||
|
||||
// If there are no aliases found return 404 response
|
||||
if (! $aliasIdsCount = $aliasIds->count()) {
|
||||
return response()->json(['message' => 'No aliases found'], 404);
|
||||
}
|
||||
|
||||
// Detach any recipients
|
||||
DB::table('alias_recipients')->whereIn('alias_id', $aliasIds)->delete();
|
||||
|
||||
// Shared Domain aliases, remove all data and change user_id
|
||||
$forgottenSharedDomainCount = user()->aliases()->withTrashed()
|
||||
->whereIn('id', $aliasIds)
|
||||
->whereIn('domain', config('anonaddy.all_domains'))
|
||||
->update([
|
||||
'user_id' => '00000000-0000-0000-0000-000000000000',
|
||||
'extension' => null,
|
||||
'description' => null,
|
||||
'emails_forwarded' => 0,
|
||||
'emails_blocked' => 0,
|
||||
'emails_replied' => 0,
|
||||
'emails_sent' => 0,
|
||||
'last_forwarded' => null,
|
||||
'last_blocked' => null,
|
||||
'last_replied' => null,
|
||||
'last_sent' => null,
|
||||
'active' => false,
|
||||
'deleted_at' => now(),
|
||||
]);
|
||||
|
||||
if ($forgottenSharedDomainCount < $aliasIdsCount) {
|
||||
// Standard aliases
|
||||
user()->aliases()->withTrashed()
|
||||
->whereIn('id', $aliasIds)
|
||||
->whereNotIn('domain', config('anonaddy.all_domains'))
|
||||
->forceDelete();
|
||||
}
|
||||
|
||||
// Don't return 204 as that is only for empty responses
|
||||
return response()->json([
|
||||
'message' => $aliasIdsCount === 1 ? '1 alias forgotten successfully' : "{$aliasIdsCount} aliases forgotten successfully",
|
||||
'ids' => $aliasIds,
|
||||
], 200);
|
||||
}
|
||||
|
||||
public function restore(GeneralAliasBulkRequest $request)
|
||||
{
|
||||
$aliasIds = user()->aliases()->onlyTrashed()
|
||||
->whereIn('id', $request->ids)
|
||||
->pluck('id');
|
||||
|
||||
// If there are no aliases found return 404 response
|
||||
if (! $aliasIdsCount = $aliasIds->count()) {
|
||||
return response()->json(['message' => 'No aliases found'], 404);
|
||||
}
|
||||
|
||||
// Use update since delete() does not trigger model event
|
||||
user()->aliases()->onlyTrashed()->whereIn('id', $aliasIds)->update(['active' => true, 'deleted_at' => null]);
|
||||
|
||||
// Don't return 204 as that is only for empty responses
|
||||
return response()->json([
|
||||
'message' => $aliasIdsCount === 1 ? '1 alias restored successfully' : "{$aliasIdsCount} aliases restored successfully",
|
||||
'ids' => $aliasIds,
|
||||
], 200);
|
||||
}
|
||||
|
||||
public function recipients(RecipientsAliasBulkRequest $request)
|
||||
{
|
||||
$request->validate([
|
||||
'ids' => 'required|array|max:25|min:1',
|
||||
'ids.*' => 'required|uuid|distinct',
|
||||
'recipient_ids' => [
|
||||
'array',
|
||||
'max:10',
|
||||
new VerifiedRecipientId,
|
||||
],
|
||||
'recipient_ids.*' => 'required|uuid|distinct',
|
||||
]);
|
||||
|
||||
$aliasIds = user()->aliases()->withTrashed()
|
||||
->whereIn('id', $request->ids)
|
||||
->pluck('id');
|
||||
|
||||
// If there are no aliases found return 404 response
|
||||
if (! $aliasIdsCount = $aliasIds->count()) {
|
||||
return response()->json(['message' => 'No aliases found'], 404);
|
||||
}
|
||||
|
||||
// First delete existing alias recipients
|
||||
DB::table('alias_recipients')->whereIn('alias_id', $aliasIds)->delete();
|
||||
// Then create alias recipients
|
||||
DB::table('alias_recipients')->insert((collect($aliasIds))->flatMap(function ($aliasId) use ($request) {
|
||||
$val = [];
|
||||
foreach ($request->recipient_ids as $recipientId) {
|
||||
$val[] = [
|
||||
'id' => Uuid::uuid4(),
|
||||
'alias_id' => $aliasId,
|
||||
'recipient_id' => $recipientId,
|
||||
];
|
||||
}
|
||||
|
||||
return $val;
|
||||
})->all());
|
||||
|
||||
// Don't return 204 as that is only for empty responses
|
||||
return response()->json([
|
||||
'message' => $aliasIdsCount === 1 ? 'recipients updated for 1 alias successfully' : "recipients updated for {$aliasIdsCount} aliases successfully",
|
||||
'ids' => $aliasIds,
|
||||
], 200);
|
||||
}
|
||||
}
|
|
@ -7,8 +7,8 @@ use App\Http\Requests\IndexAliasRequest;
|
|||
use App\Http\Requests\StoreAliasRequest;
|
||||
use App\Http\Requests\UpdateAliasRequest;
|
||||
use App\Http\Resources\AliasResource;
|
||||
use App\Models\AdditionalUsername;
|
||||
use App\Models\Domain;
|
||||
use App\Models\Username;
|
||||
use Illuminate\Support\Str;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
|
||||
|
@ -17,50 +17,10 @@ class AliasController extends Controller
|
|||
public function index(IndexAliasRequest $request)
|
||||
{
|
||||
$aliases = user()->aliases()->with('recipients')
|
||||
->when($request->input('recipient'), function ($query, $id) {
|
||||
return $query->usesRecipientWithId($id, $id === user()->default_recipient_id);
|
||||
})
|
||||
->when($request->input('domain'), function ($query, $id) {
|
||||
return $query->belongsToAliasable('App\Models\Domain', $id);
|
||||
})
|
||||
->when($request->input('username'), function ($query, $id) {
|
||||
return $query->belongsToAliasable('App\Models\Username', $id);
|
||||
})
|
||||
->when($request->input('sort'), function ($query, $sort) {
|
||||
$direction = strpos($sort, '-') === 0 ? 'desc' : 'asc';
|
||||
$sort = ltrim($sort, '-');
|
||||
$compareOperator = $direction === 'desc' ? '>' : '<';
|
||||
|
||||
// If sort is last_used then order by all and return
|
||||
if ($sort === 'last_used') {
|
||||
return $query
|
||||
->orderByRaw(
|
||||
"CASE
|
||||
WHEN (last_forwarded {$compareOperator} last_replied
|
||||
OR (last_forwarded IS NOT NULL
|
||||
AND last_replied IS NULL))
|
||||
AND (last_forwarded {$compareOperator} last_sent
|
||||
OR (last_forwarded IS NOT NULL
|
||||
AND last_sent IS NULL))
|
||||
THEN last_forwarded
|
||||
WHEN last_replied {$compareOperator} last_sent
|
||||
OR (last_replied IS NOT NULL
|
||||
AND last_sent IS NULL)
|
||||
THEN last_replied
|
||||
ELSE last_sent
|
||||
END {$direction}"
|
||||
)->orderBy('created_at', 'desc');
|
||||
}
|
||||
|
||||
// If sort is created at then simply return as no need for secondary sorting below
|
||||
if ($sort === 'created_at') {
|
||||
return $query->orderBy($sort, $direction);
|
||||
}
|
||||
|
||||
// Secondary order by latest first
|
||||
return $query
|
||||
->orderBy($sort, $direction)
|
||||
->orderBy('created_at', 'desc');
|
||||
return $query->orderBy(ltrim($sort, '-'), $direction);
|
||||
}, function ($query) {
|
||||
return $query->latest();
|
||||
})
|
||||
|
@ -105,8 +65,8 @@ class AliasController extends Controller
|
|||
return response('You have reached your hourly limit for creating new aliases', 429);
|
||||
}
|
||||
|
||||
if (isset($request->validated()['local_part_without_extension'])) {
|
||||
$localPart = $request->local_part; // To get the local_part with any potential extension
|
||||
if (isset($request->validated()['local_part'])) {
|
||||
$localPart = $request->validated()['local_part'];
|
||||
|
||||
// Local part has extension
|
||||
if (Str::contains($localPart, '+')) {
|
||||
|
@ -115,50 +75,52 @@ class AliasController extends Controller
|
|||
}
|
||||
|
||||
$data = [
|
||||
'email' => $localPart.'@'.$request->domain,
|
||||
'email' => $localPart . '@' . $request->domain,
|
||||
'local_part' => $localPart,
|
||||
'extension' => $extension ?? null,
|
||||
'extension' => $extension ?? null
|
||||
];
|
||||
} else {
|
||||
$format = $request->input('format');
|
||||
// If the request doesn't have format, use user's default alias format
|
||||
if (! $format) {
|
||||
$format = user()->default_alias_format ?? 'random_characters';
|
||||
}
|
||||
|
||||
$data = [];
|
||||
|
||||
if ($format === 'random_words') {
|
||||
// Random Words
|
||||
if ($request->input('format', 'random_characters') === 'random_words') {
|
||||
$localPart = user()->generateRandomWordLocalPart();
|
||||
} elseif ($format === 'uuid') {
|
||||
// UUID
|
||||
$localPart = Uuid::uuid4();
|
||||
$data['id'] = $localPart;
|
||||
} else {
|
||||
// Random Characters
|
||||
$localPart = user()->generateRandomCharacterLocalPart(8);
|
||||
}
|
||||
|
||||
$data['email'] = $localPart.'@'.$request->domain;
|
||||
$data['local_part'] = $localPart;
|
||||
$data = [
|
||||
'email' => $localPart . '@' . $request->domain,
|
||||
'local_part' => $localPart,
|
||||
];
|
||||
} elseif ($request->input('format', 'random_characters') === 'random_characters') {
|
||||
$localPart = user()->generateRandomCharacterLocalPart(8);
|
||||
|
||||
$data = [
|
||||
'email' => $localPart . '@' . $request->domain,
|
||||
'local_part' => $localPart,
|
||||
];
|
||||
} else {
|
||||
$uuid = Uuid::uuid4();
|
||||
|
||||
$data = [
|
||||
'id' => $uuid,
|
||||
'email' => $uuid . '@' . $request->domain,
|
||||
'local_part' => $uuid,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
// Check if domain is for username or custom domain
|
||||
|
||||
// Check if domain is for additional username or custom domain
|
||||
$parentDomain = collect(config('anonaddy.all_domains'))
|
||||
->filter(function ($name) use ($request) {
|
||||
return Str::endsWith($request->domain, $name);
|
||||
})
|
||||
->first();
|
||||
->filter(function ($name) use ($request) {
|
||||
return Str::endsWith($request->domain, $name);
|
||||
})
|
||||
->first();
|
||||
|
||||
$aliasable = null;
|
||||
|
||||
// This is an addy.io domain.
|
||||
// This is an AnonAddy domain.
|
||||
if ($parentDomain) {
|
||||
$subdomain = substr($request->domain, 0, strrpos($request->domain, '.'.$parentDomain));
|
||||
|
||||
if ($username = Username::where('username', $subdomain)->first()) {
|
||||
$aliasable = $username;
|
||||
if ($additionalUsername = AdditionalUsername::where('username', $subdomain)->first()) {
|
||||
$aliasable = $additionalUsername;
|
||||
}
|
||||
} else {
|
||||
if ($customDomain = Domain::where('domain', $request->domain)->first()) {
|
||||
|
@ -185,15 +147,7 @@ class AliasController extends Controller
|
|||
{
|
||||
$alias = user()->aliases()->withTrashed()->findOrFail($id);
|
||||
|
||||
if ($request->has('description')) {
|
||||
$alias->description = $request->description;
|
||||
}
|
||||
|
||||
if ($request->has('from_name')) {
|
||||
$alias->from_name = $request->from_name;
|
||||
}
|
||||
|
||||
$alias->save();
|
||||
$alias->update(['description' => $request->description]);
|
||||
|
||||
return new AliasResource($alias->refresh()->load('recipients'));
|
||||
}
|
||||
|
@ -233,14 +187,11 @@ class AliasController extends Controller
|
|||
'emails_forwarded' => 0,
|
||||
'emails_blocked' => 0,
|
||||
'emails_replied' => 0,
|
||||
'emails_sent' => 0,
|
||||
'last_forwarded' => null,
|
||||
'last_blocked' => null,
|
||||
'last_replied' => null,
|
||||
'last_sent' => null,
|
||||
'active' => false,
|
||||
'deleted_at' => now(), // Soft delete to prevent from being regenerated
|
||||
'emails_sent' => 0
|
||||
]);
|
||||
|
||||
// Soft delete to prevent from being regenerated
|
||||
$alias->delete();
|
||||
} else {
|
||||
$alias->forceDelete();
|
||||
}
|
||||
|
|
|
@ -1,30 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Resources\RecipientResource;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class AllowedRecipientController extends Controller
|
||||
{
|
||||
public function store(Request $request)
|
||||
{
|
||||
$request->validate(['id' => 'required|string']);
|
||||
|
||||
$recipient = user()->recipients()->findOrFail($request->id);
|
||||
|
||||
$recipient->update(['can_reply_send' => true]);
|
||||
|
||||
return new RecipientResource($recipient->loadCount('aliases'));
|
||||
}
|
||||
|
||||
public function destroy($id)
|
||||
{
|
||||
$recipient = user()->recipients()->findOrFail($id);
|
||||
|
||||
$recipient->update(['can_reply_send' => false]);
|
||||
|
||||
return response('', 204);
|
||||
}
|
||||
}
|
|
@ -1,24 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ApiTokenDetailController extends Controller
|
||||
{
|
||||
public function show(Request $request)
|
||||
{
|
||||
$token = $request->user()->currentAccessToken();
|
||||
|
||||
if (! $token) {
|
||||
return response('Current token could not be found', 404);
|
||||
}
|
||||
|
||||
return response()->json([
|
||||
'name' => $token->name,
|
||||
'created_at' => $token->created_at?->toDateTimeString(),
|
||||
'expires_at' => $token->expires_at?->toDateTimeString(),
|
||||
]);
|
||||
}
|
||||
}
|
|
@ -2,21 +2,18 @@
|
|||
|
||||
namespace App\Http\Controllers\Api;
|
||||
|
||||
use App\Helpers\GitVersionHelper as Version;
|
||||
use App\Http\Controllers\Controller;
|
||||
use PragmaRX\Version\Package\Facade as Version;
|
||||
|
||||
class AppVersionController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
$ver = Version::version();
|
||||
$parts = $ver->explode('.');
|
||||
|
||||
return response()->json([
|
||||
'version' => $ver,
|
||||
'major' => isset($parts[0]) && $parts[0] !== '' ? (int) $parts[0] : 0,
|
||||
'minor' => isset($parts[1]) ? (int) $parts[1] : 0,
|
||||
'patch' => isset($parts[2]) ? (int) $parts[2] : 0,
|
||||
'version' => Version::version(),
|
||||
'major' => (int) Version::major(),
|
||||
'minor' => (int) Version::minor(),
|
||||
'patch' => (int) Version::patch()
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Resources\AdditionalUsernameResource;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class CatchAllAdditionalUsernameController extends Controller
|
||||
{
|
||||
public function store(Request $request)
|
||||
{
|
||||
$username = user()->additionalUsernames()->findOrFail($request->id);
|
||||
|
||||
$username->enableCatchAll();
|
||||
|
||||
return new AdditionalUsernameResource($username);
|
||||
}
|
||||
|
||||
public function destroy($id)
|
||||
{
|
||||
$username = user()->additionalUsernames()->findOrFail($id);
|
||||
|
||||
$username->disableCatchAll();
|
||||
|
||||
return response('', 204);
|
||||
}
|
||||
}
|
|
@ -10,13 +10,11 @@ class CatchAllDomainController extends Controller
|
|||
{
|
||||
public function store(Request $request)
|
||||
{
|
||||
$request->validate(['id' => 'required|string']);
|
||||
|
||||
$domain = user()->domains()->findOrFail($request->id);
|
||||
|
||||
$domain->enableCatchAll();
|
||||
|
||||
return new DomainResource($domain->load('defaultRecipient')->loadCount('aliases'));
|
||||
return new DomainResource($domain);
|
||||
}
|
||||
|
||||
public function destroy($id)
|
||||
|
|
|
@ -1,30 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Resources\UsernameResource;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class CatchAllUsernameController extends Controller
|
||||
{
|
||||
public function store(Request $request)
|
||||
{
|
||||
$request->validate(['id' => 'required|string']);
|
||||
|
||||
$username = user()->usernames()->findOrFail($request->id);
|
||||
|
||||
$username->enableCatchAll();
|
||||
|
||||
return new UsernameResource($username->load('defaultRecipient')->loadCount('aliases'));
|
||||
}
|
||||
|
||||
public function destroy($id)
|
||||
{
|
||||
$username = user()->usernames()->findOrFail($id);
|
||||
|
||||
$username->disableCatchAll();
|
||||
|
||||
return response('', 204);
|
||||
}
|
||||
}
|
|
@ -1,62 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
class ChartDataController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
$outboundMessages = user()->outboundMessages()
|
||||
->select(['user_id', 'email_type', 'created_at'])
|
||||
->where('created_at', '>=', now()->subDays(6)->startOfDay())
|
||||
->get()
|
||||
->groupBy(function ($outboundMessage) {
|
||||
return $outboundMessage->created_at->format('l');
|
||||
})
|
||||
->map(function ($group) {
|
||||
return [
|
||||
'forwards' => $group->where('email_type', 'F')->count(),
|
||||
'replies' => $group->where('email_type', 'R')->count(),
|
||||
'sends' => $group->where('email_type', 'S')->count(),
|
||||
];
|
||||
});
|
||||
|
||||
$days = [
|
||||
'Sunday',
|
||||
'Monday',
|
||||
'Tuesday',
|
||||
'Wednesday',
|
||||
'Thursday',
|
||||
'Friday',
|
||||
'Saturday',
|
||||
];
|
||||
|
||||
$today = date('w'); // 0 Sunday
|
||||
|
||||
// Get the days until today including today
|
||||
$previous = array_slice($days, 0, $today + 1);
|
||||
|
||||
// Get remaining days in week
|
||||
$coming = array_slice($days, $today + 1);
|
||||
|
||||
$data = collect(array_merge($coming, $previous))->mapWithKeys(function ($day) use ($outboundMessages) {
|
||||
return [$day => $outboundMessages->get($day, ['forwards' => 0, 'replies' => 0, 'sends' => 0])];
|
||||
});
|
||||
|
||||
$outboundMessageTotals = [
|
||||
$outboundMessages->sum('forwards'),
|
||||
$outboundMessages->sum('replies'),
|
||||
$outboundMessages->sum('sends'),
|
||||
];
|
||||
|
||||
return response()->json([
|
||||
'forwardsData' => $data->pluck('forwards'),
|
||||
'repliesData' => $data->pluck('replies'),
|
||||
'sendsData' => $data->pluck('sends'),
|
||||
'labels' => $data->keys(),
|
||||
'outboundMessageTotals' => $outboundMessageTotals,
|
||||
]);
|
||||
}
|
||||
}
|
|
@ -17,51 +17,39 @@ class DomainController extends Controller
|
|||
|
||||
public function index()
|
||||
{
|
||||
return DomainResource::collection(user()->domains()->with('defaultRecipient')->withCount('aliases')->latest()->get());
|
||||
return DomainResource::collection(user()->domains()->with(['aliases', 'defaultRecipient'])->latest()->get());
|
||||
}
|
||||
|
||||
public function show($id)
|
||||
{
|
||||
$domain = user()->domains()->findOrFail($id);
|
||||
|
||||
return new DomainResource($domain->load('defaultRecipient')->loadCount('aliases'));
|
||||
return new DomainResource($domain->load(['aliases', 'defaultRecipient']));
|
||||
}
|
||||
|
||||
public function store(StoreDomainRequest $request)
|
||||
{
|
||||
$domain = new Domain;
|
||||
$domain = new Domain();
|
||||
$domain->domain = $request->domain;
|
||||
|
||||
if (! $domain->checkVerification()) {
|
||||
return response('Verification record not found, please add the following TXT record to your domain: aa-verify='.sha1(config('anonaddy.secret').user()->id.user()->domains->count()), 404);
|
||||
return response('Verification record not found, please add the following TXT record to your domain: aa-verify=' . sha1(config('anonaddy.secret') . user()->id . user()->domains->count()), 404);
|
||||
}
|
||||
|
||||
user()->domains()->save($domain);
|
||||
|
||||
$domain->markDomainAsVerified();
|
||||
|
||||
return new DomainResource($domain->refresh()->load('defaultRecipient')->loadCount('aliases'));
|
||||
return new DomainResource($domain->refresh()->load(['aliases', 'defaultRecipient']));
|
||||
}
|
||||
|
||||
public function update(UpdateDomainRequest $request, $id)
|
||||
{
|
||||
$domain = user()->domains()->findOrFail($id);
|
||||
|
||||
if ($request->has('description')) {
|
||||
$domain->description = $request->description;
|
||||
}
|
||||
$domain->update(['description' => $request->description]);
|
||||
|
||||
if ($request->has('from_name')) {
|
||||
$domain->from_name = $request->from_name;
|
||||
}
|
||||
|
||||
if ($request->has('auto_create_regex')) {
|
||||
$domain->auto_create_regex = $request->auto_create_regex;
|
||||
}
|
||||
|
||||
$domain->save();
|
||||
|
||||
return new DomainResource($domain->refresh()->load('defaultRecipient')->loadCount('aliases'));
|
||||
return new DomainResource($domain->refresh()->load(['aliases', 'defaultRecipient']));
|
||||
}
|
||||
|
||||
public function destroy($id)
|
||||
|
|
|
@ -20,6 +20,6 @@ class DomainDefaultRecipientController extends Controller
|
|||
|
||||
$domain->save();
|
||||
|
||||
return new DomainResource($domain->load('defaultRecipient')->loadCount('aliases'));
|
||||
return new DomainResource($domain);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,9 +10,8 @@ class DomainOptionController extends Controller
|
|||
{
|
||||
return response()->json([
|
||||
'data' => user()->domainOptions(),
|
||||
'sharedDomains' => user()->sharedDomainOptions(),
|
||||
'defaultAliasDomain' => user()->default_alias_domain,
|
||||
'defaultAliasFormat' => user()->default_alias_format,
|
||||
'defaultAliasFormat' => user()->default_alias_format
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,17 +10,11 @@ class EncryptedRecipientController extends Controller
|
|||
{
|
||||
public function store(Request $request)
|
||||
{
|
||||
$request->validate(['id' => 'required|string']);
|
||||
|
||||
$recipient = user()->recipients()->findOrFail($request->id);
|
||||
|
||||
if (! $recipient->fingerprint) {
|
||||
return response('You need to add a public key to this recipient before you can enable encryption', 422);
|
||||
}
|
||||
|
||||
$recipient->update(['should_encrypt' => true]);
|
||||
|
||||
return new RecipientResource($recipient->loadCount('aliases'));
|
||||
return new RecipientResource($recipient);
|
||||
}
|
||||
|
||||
public function destroy($id)
|
||||
|
|
|
@ -9,7 +9,7 @@ class FailedDeliveryController extends Controller
|
|||
{
|
||||
public function index()
|
||||
{
|
||||
$failedDeliveries = user()->failedDeliveries()->with(['recipient:id,email', 'alias:id,email'])->latest();
|
||||
$failedDeliveries = user()->failedDeliveries()->with(['recipient:id,email','alias:id,email'])->latest();
|
||||
|
||||
return FailedDeliveryResource::collection($failedDeliveries->get());
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ class FailedDeliveryController extends Controller
|
|||
{
|
||||
$failedDelivery = user()->failedDeliveries()->findOrFail($id);
|
||||
|
||||
return new FailedDeliveryResource($failedDelivery->load(['recipient:id,email', 'alias:id,email']));
|
||||
return new FailedDeliveryResource($failedDelivery->load(['recipient:id,email','alias:id,email']));
|
||||
}
|
||||
|
||||
public function destroy($id)
|
||||
|
|
|
@ -1,38 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Resources\RecipientResource;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class InlineEncryptedRecipientController extends Controller
|
||||
{
|
||||
public function store(Request $request)
|
||||
{
|
||||
$request->validate(['id' => 'required|string']);
|
||||
|
||||
$recipient = user()->recipients()->findOrFail($request->id);
|
||||
|
||||
if (! $recipient->fingerprint) {
|
||||
return response('You need to add a public key to this recipient before you can enable inline encryption', 422);
|
||||
}
|
||||
|
||||
if ($recipient->protected_headers) {
|
||||
return response('You need to disable protected headers (hide subject) before you can enable inline encryption', 422);
|
||||
}
|
||||
|
||||
$recipient->update(['inline_encryption' => true]);
|
||||
|
||||
return new RecipientResource($recipient->loadCount('aliases'));
|
||||
}
|
||||
|
||||
public function destroy($id)
|
||||
{
|
||||
$recipient = user()->recipients()->findOrFail($id);
|
||||
|
||||
$recipient->update(['inline_encryption' => false]);
|
||||
|
||||
return response('', 204);
|
||||
}
|
||||
}
|
|
@ -1,34 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Resources\UsernameResource;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class LoginableUsernameController extends Controller
|
||||
{
|
||||
public function store(Request $request)
|
||||
{
|
||||
$request->validate(['id' => 'required|string']);
|
||||
|
||||
$username = user()->usernames()->findOrFail($request->id);
|
||||
|
||||
$username->allowLogin();
|
||||
|
||||
return new UsernameResource($username->load('defaultRecipient')->loadCount('aliases'));
|
||||
}
|
||||
|
||||
public function destroy($id)
|
||||
{
|
||||
$username = user()->usernames()->findOrFail($id);
|
||||
|
||||
if ($id === user()->default_username_id) {
|
||||
return response('You cannot disallow login for your default username', 403);
|
||||
}
|
||||
|
||||
$username->disallowLogin();
|
||||
|
||||
return response('', 204);
|
||||
}
|
||||
}
|
|
@ -1,38 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Resources\RecipientResource;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ProtectedHeadersRecipientController extends Controller
|
||||
{
|
||||
public function store(Request $request)
|
||||
{
|
||||
$request->validate(['id' => 'required|string']);
|
||||
|
||||
$recipient = user()->recipients()->findOrFail($request->id);
|
||||
|
||||
if (! $recipient->fingerprint) {
|
||||
return response('You need to add a public key to this recipient before you can enable protected headers (hide subject)', 422);
|
||||
}
|
||||
|
||||
if ($recipient->inline_encryption) {
|
||||
return response('You need to disable inline encryption before you can enable protected headers (hide subject)', 422);
|
||||
}
|
||||
|
||||
$recipient->update(['protected_headers' => true]);
|
||||
|
||||
return new RecipientResource($recipient->loadCount('aliases'));
|
||||
}
|
||||
|
||||
public function destroy($id)
|
||||
{
|
||||
$recipient = user()->recipients()->findOrFail($id);
|
||||
|
||||
$recipient->update(['protected_headers' => false]);
|
||||
|
||||
return response('', 204);
|
||||
}
|
||||
}
|
|
@ -11,7 +11,7 @@ class RecipientController extends Controller
|
|||
{
|
||||
public function index(IndexRecipientRequest $request)
|
||||
{
|
||||
$recipients = user()->recipients()->withCount('aliases')->latest();
|
||||
$recipients = user()->recipients()->with('aliases')->latest();
|
||||
|
||||
if ($request->input('filter.verified') === 'true') {
|
||||
$recipients->verified();
|
||||
|
@ -28,30 +28,22 @@ class RecipientController extends Controller
|
|||
{
|
||||
$recipient = user()->recipients()->findOrFail($id);
|
||||
|
||||
return new RecipientResource($recipient->loadCount('aliases'));
|
||||
return new RecipientResource($recipient->load('aliases'));
|
||||
}
|
||||
|
||||
public function store(StoreRecipientRequest $request)
|
||||
{
|
||||
$data = ['email' => strtolower($request->email)];
|
||||
$recipient = user()->recipients()->create(['email' => strtolower($request->email)]);
|
||||
|
||||
if (config('anonaddy.auto_verify_new_recipients')) {
|
||||
$data['email_verified_at'] = now();
|
||||
}
|
||||
$recipient->sendEmailVerificationNotification();
|
||||
|
||||
$recipient = user()->recipients()->create($data);
|
||||
|
||||
if (! config('anonaddy.auto_verify_new_recipients')) {
|
||||
$recipient->sendEmailVerificationNotification();
|
||||
}
|
||||
|
||||
return new RecipientResource($recipient->refresh()->loadCount('aliases'));
|
||||
return new RecipientResource($recipient->refresh()->load('aliases'));
|
||||
}
|
||||
|
||||
public function destroy($id)
|
||||
{
|
||||
if ($id === user()->default_recipient_id) {
|
||||
return response('You cannot delete your default recipient', 403);
|
||||
return response('', 403);
|
||||
}
|
||||
|
||||
$recipient = user()->recipients()->findOrFail($id);
|
||||
|
|
|
@ -12,7 +12,7 @@ class RecipientKeyController extends Controller
|
|||
|
||||
public function __construct()
|
||||
{
|
||||
$this->gnupg = new \gnupg;
|
||||
$this->gnupg = new \gnupg();
|
||||
}
|
||||
|
||||
public function update(UpdateRecipientKeyRequest $request, $id)
|
||||
|
@ -21,16 +21,16 @@ class RecipientKeyController extends Controller
|
|||
|
||||
$info = $this->gnupg->import($request->key_data);
|
||||
|
||||
if (! $info || ! $info['fingerprint']) {
|
||||
if (!$info || !$info['fingerprint']) {
|
||||
return response('Key could not be imported', 404);
|
||||
}
|
||||
|
||||
$recipient->update([
|
||||
'should_encrypt' => true,
|
||||
'fingerprint' => $info['fingerprint'],
|
||||
'fingerprint' => $info['fingerprint']
|
||||
]);
|
||||
|
||||
return new RecipientResource($recipient->fresh()->loadCount('aliases'));
|
||||
return new RecipientResource($recipient->fresh());
|
||||
}
|
||||
|
||||
public function destroy($id)
|
||||
|
@ -41,11 +41,7 @@ class RecipientKeyController extends Controller
|
|||
|
||||
$recipient->update([
|
||||
'should_encrypt' => false,
|
||||
'inline_encryption' => false,
|
||||
'protected_headers' => false,
|
||||
'inline_encryption' => false,
|
||||
'protected_headers' => false,
|
||||
'fingerprint' => null,
|
||||
'fingerprint' => null
|
||||
]);
|
||||
|
||||
return response('', 204);
|
||||
|
|
|
@ -14,7 +14,7 @@ class ReorderRuleController extends Controller
|
|||
$rule = Rule::findOrFail($id);
|
||||
|
||||
$rule->update([
|
||||
'order' => $key,
|
||||
'order' => $key
|
||||
]);
|
||||
});
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ class RuleController extends Controller
|
|||
'operator' => $request->operator,
|
||||
'forwards' => $request->forwards ?? false,
|
||||
'replies' => $request->replies ?? false,
|
||||
'sends' => $request->sends ?? false,
|
||||
'sends' => $request->sends ?? false
|
||||
]);
|
||||
|
||||
return new RuleResource($rule->refresh());
|
||||
|
@ -62,7 +62,7 @@ class RuleController extends Controller
|
|||
'operator' => $request->operator,
|
||||
'forwards' => $request->forwards ?? false,
|
||||
'replies' => $request->replies ?? false,
|
||||
'sends' => $request->sends ?? false,
|
||||
'sends' => $request->sends ?? false
|
||||
]);
|
||||
|
||||
return new RuleResource($rule->refresh());
|
||||
|
|
|
@ -1,70 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\StoreUsernameRequest;
|
||||
use App\Http\Requests\UpdateUsernameRequest;
|
||||
use App\Http\Resources\UsernameResource;
|
||||
|
||||
class UsernameController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
return UsernameResource::collection(user()->usernames()->with('defaultRecipient')->withCount('aliases')->latest()->get());
|
||||
}
|
||||
|
||||
public function show($id)
|
||||
{
|
||||
$username = user()->usernames()->findOrFail($id);
|
||||
|
||||
return new UsernameResource($username->load('defaultRecipient')->loadCount('aliases'));
|
||||
}
|
||||
|
||||
public function store(StoreUsernameRequest $request)
|
||||
{
|
||||
if (user()->hasReachedUsernameLimit()) {
|
||||
return response('', 403);
|
||||
}
|
||||
|
||||
$username = user()->usernames()->create(['username' => $request->username]);
|
||||
|
||||
user()->increment('username_count');
|
||||
|
||||
return new UsernameResource($username->refresh()->load('defaultRecipient')->loadCount('aliases'));
|
||||
}
|
||||
|
||||
public function update(UpdateUsernameRequest $request, $id)
|
||||
{
|
||||
$username = user()->usernames()->findOrFail($id);
|
||||
|
||||
if ($request->has('description')) {
|
||||
$username->description = $request->description;
|
||||
}
|
||||
|
||||
if ($request->has('from_name')) {
|
||||
$username->from_name = $request->from_name;
|
||||
}
|
||||
|
||||
if ($request->has('auto_create_regex')) {
|
||||
$username->auto_create_regex = $request->auto_create_regex;
|
||||
}
|
||||
|
||||
$username->save();
|
||||
|
||||
return new UsernameResource($username->refresh()->load('defaultRecipient')->loadCount('aliases'));
|
||||
}
|
||||
|
||||
public function destroy($id)
|
||||
{
|
||||
if ($id === user()->default_username_id) {
|
||||
return response('You cannot delete your default username', 403);
|
||||
}
|
||||
|
||||
$username = user()->usernames()->findOrFail($id);
|
||||
|
||||
$username->delete();
|
||||
|
||||
return response('', 204);
|
||||
}
|
||||
}
|
|
@ -1,25 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\UpdateUsernameDefaultRecipientRequest;
|
||||
use App\Http\Resources\UsernameResource;
|
||||
|
||||
class UsernameDefaultRecipientController extends Controller
|
||||
{
|
||||
public function update(UpdateUsernameDefaultRecipientRequest $request, $id)
|
||||
{
|
||||
$username = user()->usernames()->findOrFail($id);
|
||||
if (empty($request->default_recipient)) {
|
||||
$username->default_recipient_id = null;
|
||||
} else {
|
||||
$recipient = user()->verifiedRecipients()->findOrFail($request->default_recipient);
|
||||
$username->default_recipient = $recipient;
|
||||
}
|
||||
|
||||
$username->save();
|
||||
|
||||
return new UsernameResource($username->load('defaultRecipient')->loadCount('aliases'));
|
||||
}
|
||||
}
|
|
@ -1,165 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Facades\Webauthn;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\ApiAuthenticationLoginRequest;
|
||||
use App\Http\Requests\ApiAuthenticationMfaRequest;
|
||||
use App\Http\Requests\DestroyAccountRequest;
|
||||
use App\Jobs\DeleteAccount;
|
||||
use App\Models\User;
|
||||
use App\Models\Username;
|
||||
use Illuminate\Contracts\Encryption\DecryptException;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Illuminate\Support\Facades\Crypt;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use PragmaRX\Google2FA\Google2FA;
|
||||
|
||||
class ApiAuthenticationController extends Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('throttle:3,1');
|
||||
|
||||
$this->middleware(['auth:sanctum', 'verified'])->only(['logout', 'destroy']);
|
||||
}
|
||||
|
||||
public function login(ApiAuthenticationLoginRequest $request)
|
||||
{
|
||||
$user = Username::select(['user_id', 'username'])->firstWhere('username', $request->username)?->user;
|
||||
|
||||
if (! $user || ! Hash::check($request->password, $user->password)) {
|
||||
return response()->json([
|
||||
'message' => 'The provided credentials are incorrect.',
|
||||
], 401);
|
||||
}
|
||||
|
||||
if (! $user->hasVerifiedDefaultRecipient()) {
|
||||
return response()->json([
|
||||
'message' => 'Your email address is not verified.',
|
||||
], 401);
|
||||
}
|
||||
|
||||
// Check if user has 2FA enabled, if needs OTP then return mfa_key
|
||||
if ($user->two_factor_enabled) {
|
||||
return response()->json([
|
||||
'message' => "OTP required, please make a request to /api/auth/mfa with the 'mfa_key', 'otp' and 'device_name' including a 'X-CSRF-TOKEN' header.",
|
||||
'mfa_key' => Crypt::encryptString($user->id.'|'.config('anonaddy.secret').'|'.Carbon::now()->addMinutes(5)->getTimestamp()),
|
||||
'csrf_token' => csrf_token(),
|
||||
], 422);
|
||||
} elseif (Webauthn::enabled($user)) {
|
||||
// If WebAuthn is enabled then return currently unsupported message
|
||||
return response()->json([
|
||||
'message' => 'Security key authentication is not currently supported from the extension or mobile apps, please use an API key to login instead.',
|
||||
], 403);
|
||||
}
|
||||
|
||||
// day, week, month, year or null
|
||||
if ($request->expiration) {
|
||||
$method = 'add'.ucfirst($request->expiration);
|
||||
$expiration = now()->{$method}();
|
||||
} else {
|
||||
$expiration = null;
|
||||
}
|
||||
|
||||
// Token expires after 3 months, user must re-login
|
||||
$newToken = $user->createToken($request->device_name, ['*'], $expiration);
|
||||
$token = $newToken->accessToken;
|
||||
|
||||
// If the user doesn't use 2FA then return the new API key
|
||||
return response()->json([
|
||||
'api_key' => explode('|', $newToken->plainTextToken, 2)[1],
|
||||
'name' => $token->name,
|
||||
'created_at' => $token->created_at?->toDateTimeString(),
|
||||
'expires_at' => $token->expires_at?->toDateTimeString(),
|
||||
]);
|
||||
}
|
||||
|
||||
public function mfa(ApiAuthenticationMfaRequest $request)
|
||||
{
|
||||
try {
|
||||
$mfaKey = Crypt::decryptString($request->mfa_key);
|
||||
} catch (DecryptException $e) {
|
||||
return response()->json([
|
||||
'message' => 'Invalid mfa_key.',
|
||||
], 401);
|
||||
}
|
||||
$parts = explode('|', $mfaKey, 3);
|
||||
|
||||
$user = User::find($parts[0]);
|
||||
|
||||
if (! $user || $parts[1] !== config('anonaddy.secret')) {
|
||||
|
||||
return response()->json([
|
||||
'message' => 'Invalid mfa_key.',
|
||||
], 401);
|
||||
}
|
||||
|
||||
// Check if the mfa_key has expired
|
||||
if (Carbon::now()->getTimestamp() > $parts[2]) {
|
||||
|
||||
return response()->json([
|
||||
'message' => 'mfa_key expired, please request a new one at /api/auth/login.',
|
||||
], 401);
|
||||
}
|
||||
|
||||
$google2fa = new Google2FA;
|
||||
$lastTimeStamp = Cache::get('2fa_ts:'.$user->id, 0);
|
||||
|
||||
$timestamp = $google2fa->verifyKeyNewer($user->two_factor_secret, $request->otp, $lastTimeStamp, config('google2fa.window'));
|
||||
|
||||
if (! $timestamp) {
|
||||
|
||||
return response()->json([
|
||||
'message' => 'The \'One Time Password\' typed was wrong.',
|
||||
], 401);
|
||||
}
|
||||
|
||||
if (is_int($timestamp)) {
|
||||
Cache::put('2fa_ts:'.$user->id, $timestamp, now()->addMinutes(5));
|
||||
}
|
||||
|
||||
// day, week, month, year or null
|
||||
if ($request->expiration) {
|
||||
$method = 'add'.ucfirst($request->expiration);
|
||||
$expiration = now()->{$method}();
|
||||
} else {
|
||||
$expiration = null;
|
||||
}
|
||||
|
||||
$newToken = $user->createToken($request->device_name, ['*'], $expiration);
|
||||
$token = $newToken->accessToken;
|
||||
|
||||
return response()->json([
|
||||
'api_key' => explode('|', $newToken->plainTextToken, 2)[1],
|
||||
'name' => $token->name,
|
||||
'created_at' => $token->created_at?->toDateTimeString(),
|
||||
'expires_at' => $token->expires_at?->toDateTimeString(),
|
||||
]);
|
||||
}
|
||||
|
||||
public function logout(Request $request)
|
||||
{
|
||||
$token = $request->user()?->currentAccessToken();
|
||||
|
||||
if (! $token) {
|
||||
return response()->json([
|
||||
'message', 'API key not found.',
|
||||
], 404);
|
||||
}
|
||||
|
||||
$token->delete();
|
||||
|
||||
return response()->json([], 204);
|
||||
}
|
||||
|
||||
public function destroy(DestroyAccountRequest $request)
|
||||
{
|
||||
DeleteAccount::dispatch($request->user());
|
||||
|
||||
return response()->json([], 204);
|
||||
}
|
||||
}
|
|
@ -6,7 +6,6 @@ use App\Facades\Webauthn;
|
|||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Str;
|
||||
use PragmaRX\Google2FALaravel\Support\Authenticator;
|
||||
|
||||
class BackupCodeController extends Controller
|
||||
|
@ -14,7 +13,7 @@ class BackupCodeController extends Controller
|
|||
public function __construct()
|
||||
{
|
||||
$this->middleware('auth');
|
||||
$this->middleware('throttle:3,1')->only(['login', 'update']);
|
||||
$this->middleware('throttle:3,1')->only('login');
|
||||
}
|
||||
|
||||
public function index(Request $request)
|
||||
|
@ -36,7 +35,7 @@ class BackupCodeController extends Controller
|
|||
|
||||
if (! Hash::check($request->backup_code, user()->two_factor_backup_code)) {
|
||||
return back()->withErrors([
|
||||
'backup_code' => __('The backup code was invalid.'),
|
||||
'backup_code' => __('The backup code was invalid.')
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -45,7 +44,7 @@ class BackupCodeController extends Controller
|
|||
user()->update([
|
||||
'two_factor_enabled' => false,
|
||||
'two_factor_secret' => $twoFactor->generateSecretKey(),
|
||||
'two_factor_backup_code' => null,
|
||||
'two_factor_backup_code' => null
|
||||
]);
|
||||
|
||||
user()->webauthnKeys()->delete();
|
||||
|
@ -56,20 +55,4 @@ class BackupCodeController extends Controller
|
|||
|
||||
return redirect()->intended($request->redirectPath);
|
||||
}
|
||||
|
||||
public function update(Request $request)
|
||||
{
|
||||
$request->validate([
|
||||
'current' => 'required|string|current_password',
|
||||
]);
|
||||
|
||||
user()->update([
|
||||
'two_factor_backup_code' => bcrypt($code = Str::random(40)),
|
||||
]);
|
||||
|
||||
return back()->with([
|
||||
'flash' => 'New Backup Code Generated Successfully',
|
||||
'regeneratedBackupCode' => $code,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,10 +3,9 @@
|
|||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Username;
|
||||
use App\Models\User;
|
||||
use Illuminate\Foundation\Auth\SendsPasswordResetEmails;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\App;
|
||||
use Illuminate\Support\Facades\Password;
|
||||
|
||||
class ForgotPasswordController extends Controller
|
||||
|
@ -38,20 +37,18 @@ class ForgotPasswordController extends Controller
|
|||
/**
|
||||
* Send a reset link to the given user.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function sendResetLinkEmail(Request $request)
|
||||
{
|
||||
$this->validateUsername($request);
|
||||
|
||||
// Find the user_id and use that for the credentials
|
||||
$userId = Username::firstWhere('username', $request->username)?->user_id;
|
||||
|
||||
// We will send the password reset link to this user. Once we have attempted
|
||||
// to send the link, we will examine the response then see the message we
|
||||
// need to show to the user. Finally, we'll send out a proper response.
|
||||
$response = $this->broker()->sendResetLink(
|
||||
['id' => $userId]
|
||||
$request->only('username')
|
||||
);
|
||||
|
||||
return $response == Password::RESET_LINK_SENT
|
||||
|
@ -62,34 +59,25 @@ class ForgotPasswordController extends Controller
|
|||
/**
|
||||
* Validate the email for the given request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return void
|
||||
*/
|
||||
protected function validateUsername(Request $request)
|
||||
{
|
||||
// Validate captcha separately first to prevent username enumeration
|
||||
if (! App::environment('testing')) {
|
||||
$request->validate([
|
||||
'captcha' => 'required|captcha',
|
||||
], [
|
||||
'captcha.captcha' => 'The text entered was incorrect, please try again.',
|
||||
]);
|
||||
}
|
||||
|
||||
$request->validate(['username' => 'required|regex:/^[a-zA-Z0-9]*$/|max:20'], [
|
||||
'username.regex' => 'Your username can only contain letters and numbers, do not use your email.',
|
||||
]);
|
||||
$request->validate(['username' => 'required|regex:/^[a-zA-Z0-9]*$/|max:20']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the response for a failed password reset link.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param string $response
|
||||
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Http\JsonResponse
|
||||
*/
|
||||
protected function sendResetLinkFailedResponse(Request $request, $response)
|
||||
{
|
||||
return back()
|
||||
->withInput($request->only('username'))
|
||||
->withErrors(['username' => trans($response)]);
|
||||
->withInput($request->only('username'))
|
||||
->withErrors(['username' => trans($response)]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,7 +5,6 @@ namespace App\Http\Controllers\Auth;
|
|||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Recipient;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\App;
|
||||
|
||||
class ForgotUsernameController extends Controller
|
||||
{
|
||||
|
@ -33,13 +32,14 @@ class ForgotUsernameController extends Controller
|
|||
/**
|
||||
* Send a reset link to the given user.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function sendReminderEmail(Request $request)
|
||||
{
|
||||
$this->validateEmail($request);
|
||||
|
||||
$recipient = Recipient::select(['id', 'user_id', 'email', 'should_encrypt', 'fingerprint', 'email_verified_at'])->whereNotNull('email_verified_at')->get()->firstWhere('email', strtolower($request->email));
|
||||
$recipient = Recipient::select(['id', 'email', 'email_verified_at'])->whereNotNull('email_verified_at')->get()->firstWhere('email', strtolower($request->email));
|
||||
|
||||
if (isset($recipient)) {
|
||||
$recipient->sendUsernameReminderNotification();
|
||||
|
@ -51,18 +51,11 @@ class ForgotUsernameController extends Controller
|
|||
/**
|
||||
* Validate the email for the given request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return void
|
||||
*/
|
||||
protected function validateEmail(Request $request)
|
||||
{
|
||||
if (! App::environment('testing')) {
|
||||
$request->validate([
|
||||
'captcha' => 'required|captcha',
|
||||
], [
|
||||
'captcha.captcha' => 'The text entered was incorrect, please try again.',
|
||||
]);
|
||||
}
|
||||
|
||||
$request->validate(['email' => 'required|email:rfc']);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,14 +2,8 @@
|
|||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Enums\LoginRedirect;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Username;
|
||||
use Illuminate\Foundation\Auth\AuthenticatesUsers;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
use Inertia\Inertia;
|
||||
|
||||
class LoginController extends Controller
|
||||
{
|
||||
|
@ -43,106 +37,8 @@ class LoginController extends Controller
|
|||
$this->middleware('guest')->except('logout');
|
||||
}
|
||||
|
||||
public function redirectTo()
|
||||
{
|
||||
// Dynamic redirect setting to allow users to choose to go to /aliases page instead etc.
|
||||
return match (user()->login_redirect) {
|
||||
LoginRedirect::ALIASES => '/aliases',
|
||||
LoginRedirect::RECIPIENTS => '/recipients',
|
||||
LoginRedirect::USERNAMES => '/usernames',
|
||||
LoginRedirect::DOMAINS => '/domains',
|
||||
default => '/',
|
||||
};
|
||||
}
|
||||
|
||||
public function username()
|
||||
{
|
||||
return 'id';
|
||||
}
|
||||
|
||||
public function addIdToRequest()
|
||||
{
|
||||
$userId = Username::select(['user_id', 'username', 'can_login'])
|
||||
->where('username', request()->input('username'))
|
||||
->where('can_login', true)
|
||||
->first()?->user_id;
|
||||
|
||||
request()->merge(['id' => $userId]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate the user login request.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @throws \Illuminate\Validation\ValidationException
|
||||
*/
|
||||
protected function validateLogin(Request $request)
|
||||
{
|
||||
$this->addIdToRequest();
|
||||
|
||||
Validator::make($request->all(), [
|
||||
'username' => 'required|regex:/^[a-zA-Z0-9]*$/|min:1|max:20',
|
||||
'password' => 'required|string',
|
||||
$this->username() => 'nullable|string',
|
||||
], [
|
||||
'username.regex' => 'Your username can only contain letters and numbers, do not use your email.',
|
||||
])->validate();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the needed authorization credentials from the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function credentials(Request $request)
|
||||
{
|
||||
return $request->only('id', 'password');
|
||||
}
|
||||
|
||||
/**
|
||||
* Send the response after the user was authenticated.
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Http\JsonResponse
|
||||
*/
|
||||
protected function sendLoginResponse(Request $request)
|
||||
{
|
||||
$request->session()->regenerate();
|
||||
|
||||
$this->clearLoginAttempts($request);
|
||||
|
||||
if ($response = $this->authenticated($request, $this->guard()->user())) {
|
||||
return $response;
|
||||
}
|
||||
|
||||
// If the intended path is just the dashboard then ignore and use the user's login redirect instead
|
||||
$redirectTo = $this->redirectTo();
|
||||
$intended = session()->pull('url.intended');
|
||||
|
||||
return $intended === url('/') ? redirect()->to($redirectTo) : redirect()->intended($intended ?? $redirectTo);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the failed login response instance.
|
||||
*
|
||||
* @return \Symfony\Component\HttpFoundation\Response
|
||||
*
|
||||
* @throws \Illuminate\Validation\ValidationException
|
||||
*/
|
||||
protected function sendFailedLoginResponse(Request $request)
|
||||
{
|
||||
throw ValidationException::withMessages([
|
||||
'username' => [trans('auth.failed')],
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* The user has logged out of the application.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
protected function loggedOut(Request $request)
|
||||
{
|
||||
return Inertia::location(route('login'));
|
||||
return 'username';
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,51 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\StorePersonalAccessTokenRequest;
|
||||
use App\Http\Resources\PersonalAccessTokenResource;
|
||||
use chillerlan\QRCode\QRCode;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
|
||||
class PersonalAccessTokenController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
return PersonalAccessTokenResource::collection(user()->tokens()->select(['id', 'tokenable_id', 'name', 'created_at', 'last_used_at', 'expires_at', 'updated_at', 'created_at'])->get());
|
||||
}
|
||||
|
||||
public function store(StorePersonalAccessTokenRequest $request)
|
||||
{
|
||||
if (! Hash::check($request->password, user()->password)) {
|
||||
throw ValidationException::withMessages(['password' => 'Incorrect password entered']);
|
||||
}
|
||||
|
||||
// day, week, month, year or null
|
||||
if ($request->expiration) {
|
||||
$method = 'add'.ucfirst($request->expiration);
|
||||
$expiration = now()->{$method}();
|
||||
} else {
|
||||
$expiration = null;
|
||||
}
|
||||
|
||||
$token = user()->createToken($request->name, ['*'], $expiration);
|
||||
$accessToken = explode('|', $token->plainTextToken, 2)[1];
|
||||
|
||||
return [
|
||||
'token' => new PersonalAccessTokenResource($token->accessToken),
|
||||
'accessToken' => $accessToken,
|
||||
'qrCode' => (new QRCode)->render(config('app.url').'|'.$accessToken),
|
||||
];
|
||||
}
|
||||
|
||||
public function destroy($id)
|
||||
{
|
||||
$token = user()->tokens()->findOrFail($id);
|
||||
|
||||
$token->delete();
|
||||
|
||||
return response('', 204);
|
||||
}
|
||||
}
|
|
@ -5,7 +5,6 @@ namespace App\Http\Controllers\Auth;
|
|||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Recipient;
|
||||
use App\Models\User;
|
||||
use App\Models\Username;
|
||||
use App\Rules\NotBlacklisted;
|
||||
use App\Rules\NotDeletedUsername;
|
||||
use App\Rules\NotLocalRecipient;
|
||||
|
@ -14,7 +13,6 @@ use Illuminate\Foundation\Auth\RegistersUsers;
|
|||
use Illuminate\Support\Facades\App;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Validation\Rules\Password;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
|
||||
class RegisterController extends Controller
|
||||
|
@ -52,54 +50,42 @@ class RegisterController extends Controller
|
|||
/**
|
||||
* Get a validator for an incoming registration request.
|
||||
*
|
||||
* @param array $data
|
||||
* @return \Illuminate\Contracts\Validation\Validator
|
||||
*/
|
||||
protected function validator(array $data)
|
||||
{
|
||||
// Validate captcha separately first to prevent username enumeration
|
||||
if (! App::environment('testing')) {
|
||||
$validator = Validator::make($data, [
|
||||
'captcha' => [
|
||||
'required',
|
||||
'captcha',
|
||||
],
|
||||
], [
|
||||
'captcha.captcha' => 'The text entered was incorrect, please try again.',
|
||||
]);
|
||||
|
||||
if ($validator->fails()) {
|
||||
return $validator;
|
||||
}
|
||||
}
|
||||
|
||||
return Validator::make($data, [
|
||||
'username' => [
|
||||
'bail',
|
||||
'required',
|
||||
'regex:/^[a-zA-Z0-9]*$/',
|
||||
'max:20',
|
||||
'unique:usernames,username',
|
||||
'unique:users,username',
|
||||
'unique:additional_usernames,username',
|
||||
new NotBlacklisted,
|
||||
new NotDeletedUsername,
|
||||
new NotDeletedUsername
|
||||
],
|
||||
'email' => [
|
||||
'bail',
|
||||
'required',
|
||||
'email:rfc,dns',
|
||||
'max:254',
|
||||
'confirmed',
|
||||
new RegisterUniqueRecipient,
|
||||
new NotLocalRecipient,
|
||||
new NotLocalRecipient
|
||||
],
|
||||
'password' => ['required', Password::defaults()],
|
||||
'password' => ['required', 'min:8'],
|
||||
], [
|
||||
'username.regex' => 'Your username can only contain letters and numbers.',
|
||||
]);
|
||||
'captcha.captcha' => 'The text entered was incorrect, please try again.',
|
||||
])
|
||||
->sometimes('captcha', 'required|captcha', function () {
|
||||
return ! App::environment('testing');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new user instance after a valid registration.
|
||||
*
|
||||
* @param array $data
|
||||
* @return \App\Models\User
|
||||
*/
|
||||
protected function create(array $data)
|
||||
|
@ -108,22 +94,17 @@ class RegisterController extends Controller
|
|||
|
||||
$recipient = Recipient::create([
|
||||
'email' => $data['email'],
|
||||
'user_id' => $userId,
|
||||
]);
|
||||
|
||||
$username = Username::create([
|
||||
'username' => $data['username'],
|
||||
'user_id' => $userId,
|
||||
'user_id' => $userId
|
||||
]);
|
||||
|
||||
$twoFactor = app('pragmarx.google2fa');
|
||||
|
||||
return User::create([
|
||||
'id' => $userId,
|
||||
'default_username_id' => $username->id,
|
||||
'username' => $data['username'],
|
||||
'default_recipient_id' => $recipient->id,
|
||||
'password' => Hash::make($data['password']),
|
||||
'two_factor_secret' => $twoFactor->generateSecretKey(),
|
||||
'two_factor_secret' => $twoFactor->generateSecretKey()
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,10 +3,8 @@
|
|||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Username;
|
||||
use Illuminate\Foundation\Auth\ResetsPasswords;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Validation\Rules\Password;
|
||||
|
||||
class ResetPasswordController extends Controller
|
||||
{
|
||||
|
@ -45,12 +43,12 @@ class ResetPasswordController extends Controller
|
|||
*
|
||||
* If no token is present, display the link request form.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param string|null $token
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
*/
|
||||
public function showResetForm(Request $request)
|
||||
public function showResetForm(Request $request, $token = null)
|
||||
{
|
||||
$token = $request->route()->parameter('token');
|
||||
|
||||
return view('auth.passwords.reset')->with(
|
||||
['token' => $token, 'username' => $request->username]
|
||||
);
|
||||
|
@ -66,28 +64,20 @@ class ResetPasswordController extends Controller
|
|||
return [
|
||||
'token' => 'required',
|
||||
'username' => 'required|regex:/^[a-zA-Z0-9]*$/|max:20',
|
||||
'password' => [
|
||||
'required',
|
||||
'confirmed',
|
||||
Password::defaults(),
|
||||
],
|
||||
'password' => 'required|confirmed|min:8',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the password reset credentials from the request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array
|
||||
*/
|
||||
protected function credentials(Request $request)
|
||||
{
|
||||
// Find the user_id and use that for the credentials
|
||||
$userId = Username::firstWhere('username', $request->username)?->user_id;
|
||||
|
||||
$request->merge(['id' => $userId]);
|
||||
|
||||
return $request->only(
|
||||
'id',
|
||||
'username',
|
||||
'password',
|
||||
'password_confirmation',
|
||||
'token'
|
||||
|
@ -97,13 +87,14 @@ class ResetPasswordController extends Controller
|
|||
/**
|
||||
* Get the response for a failed password reset.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param string $response
|
||||
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Http\JsonResponse
|
||||
*/
|
||||
protected function sendResetFailedResponse(Request $request, $response)
|
||||
{
|
||||
return back()
|
||||
->withInput($request->only('username'))
|
||||
->withErrors(['username' => trans($response)]);
|
||||
->withInput($request->only('username'))
|
||||
->withErrors(['username' => trans($response)]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,30 +5,24 @@ namespace App\Http\Controllers\Auth;
|
|||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\EnableTwoFactorAuthRequest;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Str;
|
||||
use PragmaRX\Google2FALaravel\Support\Authenticator;
|
||||
|
||||
class TwoFactorAuthController extends Controller
|
||||
{
|
||||
protected $twoFactor;
|
||||
|
||||
protected $authenticator;
|
||||
|
||||
public function __construct(Request $request)
|
||||
{
|
||||
$this->middleware('throttle:3,1')->only(['store', 'update', 'destroy']);
|
||||
$this->twoFactor = app('pragmarx.google2fa');
|
||||
$this->authenticator = app(Authenticator::class)->boot($request);
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
return redirect('/');
|
||||
}
|
||||
|
||||
public function store(EnableTwoFactorAuthRequest $request)
|
||||
{
|
||||
if (! $this->twoFactor->verifyKey(user()->two_factor_secret, $request->two_factor_token, config('google2fa.window'))) {
|
||||
if (!$this->twoFactor->verifyKey(user()->two_factor_secret, $request->two_factor_token)) {
|
||||
return redirect(url()->previous().'#two-factor')->withErrors(['two_factor_token' => 'The token you entered was incorrect']);
|
||||
}
|
||||
|
||||
|
@ -36,7 +30,7 @@ class TwoFactorAuthController extends Controller
|
|||
|
||||
user()->update([
|
||||
'two_factor_enabled' => true,
|
||||
'two_factor_backup_code' => bcrypt($code = Str::random(40)),
|
||||
'two_factor_backup_code' => bcrypt($code = Str::random(40))
|
||||
]);
|
||||
|
||||
$this->authenticator->login();
|
||||
|
@ -52,23 +46,23 @@ class TwoFactorAuthController extends Controller
|
|||
|
||||
user()->update(['two_factor_secret' => $this->twoFactor->generateSecretKey()]);
|
||||
|
||||
return back()->with(['flash' => '2FA Secret Successfully Regenerated']);
|
||||
return back()->with(['status' => '2FA Secret Successfully Regenerated']);
|
||||
}
|
||||
|
||||
public function destroy(Request $request)
|
||||
{
|
||||
$request->validate([
|
||||
'current' => 'required|string|current_password',
|
||||
]);
|
||||
if (!Hash::check($request->current_password_2fa, user()->password)) {
|
||||
return back()->withErrors(['current_password_2fa' => 'Current password incorrect']);
|
||||
}
|
||||
|
||||
user()->update([
|
||||
'two_factor_enabled' => false,
|
||||
'two_factor_secret' => $this->twoFactor->generateSecretKey(),
|
||||
'two_factor_secret' => $this->twoFactor->generateSecretKey()
|
||||
]);
|
||||
|
||||
$this->authenticator->logout();
|
||||
|
||||
return back()->with(['flash' => '2FA Disabled Successfully']);
|
||||
return back()->with(['status' => '2FA Disabled Successfully']);
|
||||
}
|
||||
|
||||
public function authenticateTwoFactor(Request $request)
|
||||
|
|
|
@ -5,15 +5,11 @@ namespace App\Http\Controllers\Auth;
|
|||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Recipient;
|
||||
use App\Models\User;
|
||||
use App\Notifications\DefaultRecipientUpdated;
|
||||
use Illuminate\Auth\Access\AuthorizationException;
|
||||
use Illuminate\Auth\Events\Verified;
|
||||
use Illuminate\Foundation\Auth\VerifiesEmails;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Facades\Notification;
|
||||
use Inertia\Inertia;
|
||||
|
||||
class VerificationController extends Controller
|
||||
{
|
||||
|
@ -44,34 +40,22 @@ class VerificationController extends Controller
|
|||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('auth');
|
||||
$this->middleware('auth')->except('verify');
|
||||
$this->middleware('signed')->only('verify');
|
||||
$this->middleware('throttle:1,1')->only('resend');
|
||||
$this->middleware('throttle:6,1')->only('verify');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the email verification notice.
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse|\Illuminate\View\View
|
||||
*/
|
||||
public function show(Request $request)
|
||||
{
|
||||
return $request->user()->hasVerifiedEmail()
|
||||
? redirect($this->redirectPath())
|
||||
: Inertia::render('Auth/Verify', ['flash' => $request->session()->get('resent', null) ? 'A fresh verification link has been sent to your email address.' : null]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Mark the authenticated user's email address as verified.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*
|
||||
* @throws \Illuminate\Auth\Access\AuthorizationException
|
||||
*/
|
||||
public function verify(Request $request)
|
||||
{
|
||||
$verifiable = User::find($request->route('id')) ?? Recipient::withPending()->find($request->route('id'));
|
||||
$verifiable = User::find($request->route('id')) ?? Recipient::find($request->route('id'));
|
||||
|
||||
if (is_null($verifiable)) {
|
||||
throw new AuthorizationException('Email address not found.');
|
||||
|
@ -99,36 +83,8 @@ class VerificationController extends Controller
|
|||
$redirect = 'login';
|
||||
}
|
||||
|
||||
// Check if the verifiable is a pending new email Recipient
|
||||
if ($verifiable instanceof Recipient && $verifiable->pending) {
|
||||
|
||||
try {
|
||||
DB::transaction(function () use ($verifiable) {
|
||||
$user = $verifiable->user;
|
||||
$defaultRecipient = $user->defaultRecipient;
|
||||
// Notify the current default recipient of the change
|
||||
// Have to use sendNow method here to ensure this notification is sent before the current defaultRecipient's email is updated below
|
||||
Notification::sendNow($defaultRecipient, new DefaultRecipientUpdated($verifiable->email));
|
||||
|
||||
// Set verifiable email as new default recipient
|
||||
$defaultRecipient->update([
|
||||
'email' => strtolower($verifiable->email),
|
||||
'email_verified_at' => now(),
|
||||
]);
|
||||
|
||||
// Delete pending verifiable
|
||||
$verifiable->delete();
|
||||
});
|
||||
} catch (\Exception $e) {
|
||||
report($e);
|
||||
|
||||
return redirect($redirect)
|
||||
->with(['flash' => 'An error has occurred, please try again later.']);
|
||||
}
|
||||
}
|
||||
|
||||
return redirect($redirect)
|
||||
->with('verified', true)
|
||||
->with(['flash' => 'Email Address Verified Successfully']);
|
||||
->with(['status' => 'Email Address Verified Successfully']);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,91 +2,139 @@
|
|||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Facades\Webauthn;
|
||||
use App\Models\WebauthnKey;
|
||||
use Illuminate\Database\Eloquent\ModelNotFoundException;
|
||||
use Illuminate\Http\Request;
|
||||
use LaravelWebauthn\Actions\PrepareCreationData;
|
||||
use LaravelWebauthn\Actions\ValidateKeyCreation;
|
||||
use LaravelWebauthn\Contracts\DestroyResponse;
|
||||
use LaravelWebauthn\Contracts\RegisterSuccessResponse;
|
||||
use LaravelWebauthn\Contracts\RegisterViewResponse;
|
||||
use LaravelWebauthn\Facades\Webauthn;
|
||||
use LaravelWebauthn\Http\Controllers\WebauthnKeyController as ControllersWebauthnController;
|
||||
use LaravelWebauthn\Http\Requests\WebauthnRegisterRequest;
|
||||
use Illuminate\Support\Facades\Redirect;
|
||||
use Illuminate\Support\Facades\Response;
|
||||
use Illuminate\Support\Str;
|
||||
use LaravelWebauthn\Http\Controllers\WebauthnController as ControllersWebauthnController;
|
||||
use Webauthn\PublicKeyCredentialCreationOptions;
|
||||
|
||||
class WebauthnController extends ControllersWebauthnController
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('throttle:3,1')->only('destroy');
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
return user()->webauthnKeys()->latest()->select(['id', 'name', 'enabled', 'created_at'])->get()->values();
|
||||
return user()->webauthnKeys()->latest()->select(['id','name','enabled','created_at'])->get()->values();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the register data to attempt a Webauthn registration.
|
||||
* PublicKey Creation session name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
/* public function create(Request $request): RegisterViewResponse
|
||||
{
|
||||
$publicKey = app(PrepareCreationData::class)($request->user());
|
||||
|
||||
return app(RegisterViewResponse::class)
|
||||
->setPublicKey($request, $publicKey);
|
||||
} */
|
||||
private const SESSION_PUBLICKEY_CREATION = 'webauthn.publicKeyCreation';
|
||||
|
||||
/**
|
||||
* Validate and create the Webauthn request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\JsonResponse|\Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function store(WebauthnRegisterRequest $request): RegisterSuccessResponse
|
||||
public function create(Request $request)
|
||||
{
|
||||
$request->validate([
|
||||
'name' => 'required|string|max:50',
|
||||
'password' => 'required|string|current_password',
|
||||
'name' => 'required|max:50',
|
||||
'register' => 'required',
|
||||
]);
|
||||
|
||||
$webauthnKey = app(ValidateKeyCreation::class)(
|
||||
$request->user(),
|
||||
$request->only(['id', 'rawId', 'response', 'type']),
|
||||
$request->input('name')
|
||||
);
|
||||
try {
|
||||
$publicKey = $request->session()->pull(self::SESSION_PUBLICKEY_CREATION);
|
||||
if (! $publicKey instanceof PublicKeyCredentialCreationOptions) {
|
||||
throw new ModelNotFoundException(trans('webauthn::errors.create_data_not_found'));
|
||||
}
|
||||
|
||||
user()->update([
|
||||
'two_factor_enabled' => false,
|
||||
]);
|
||||
$webauthnKey = Webauthn::doRegister(
|
||||
$request->user(),
|
||||
$publicKey,
|
||||
$this->input($request, 'register'),
|
||||
$this->input($request, 'name')
|
||||
);
|
||||
|
||||
return app(RegisterSuccessResponse::class)
|
||||
->setWebauthnKey($request, $webauthnKey);
|
||||
user()->update([
|
||||
'two_factor_enabled' => false
|
||||
]);
|
||||
|
||||
return $this->redirectAfterSuccessRegister($webauthnKey);
|
||||
} catch (\Exception $e) {
|
||||
return Response::json([
|
||||
'error' => [
|
||||
'message' => $e->getMessage(),
|
||||
],
|
||||
], 403);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the redirect destination after a successfull register.
|
||||
*
|
||||
* @param WebauthnKey $webauthnKey
|
||||
* @return \Illuminate\Http\JsonResponse|\Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
protected function redirectAfterSuccessRegister($webauthnKey)
|
||||
{
|
||||
if ($this->config->get('webauthn.register.postSuccessRedirectRoute', '') !== '') {
|
||||
|
||||
// If the user already has at least one key do not generate a new backup code.
|
||||
if (user()->webauthnKeys()->count() > 1) {
|
||||
return Redirect::intended($this->config->get('webauthn.register.postSuccessRedirectRoute'));
|
||||
}
|
||||
|
||||
user()->update([
|
||||
'two_factor_backup_code' => bcrypt($code = Str::random(40))
|
||||
]);
|
||||
|
||||
return Redirect::intended($this->config->get('webauthn.register.postSuccessRedirectRoute'))->with(['backupCode' => $code]);
|
||||
} else {
|
||||
return Response::json([
|
||||
'result' => true,
|
||||
'id' => $webauthnKey->id,
|
||||
'object' => 'webauthnKey',
|
||||
'name' => $webauthnKey->name,
|
||||
'counter' => $webauthnKey->counter,
|
||||
], 201);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove an existing Webauthn key.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function destroy(Request $request, $webauthnKeyId): DestroyResponse
|
||||
public function destroy(Request $request, $webauthnKeyId)
|
||||
{
|
||||
$request->validate([
|
||||
'current' => 'required|string|current_password',
|
||||
]);
|
||||
try {
|
||||
user()->webauthnKeys()
|
||||
->findOrFail($webauthnKeyId)
|
||||
->delete();
|
||||
|
||||
user()->webauthnKeys()
|
||||
->findOrFail($webauthnKeyId)
|
||||
->delete();
|
||||
|
||||
// Using vendor Facade to ensure disabled keys are included
|
||||
if (! Webauthn::hasKey(user())) {
|
||||
// Remove session value when last key is deleted
|
||||
Webauthn::logout();
|
||||
return Response::json([
|
||||
'deleted' => true,
|
||||
'id' => $webauthnKeyId,
|
||||
]);
|
||||
} catch (ModelNotFoundException $e) {
|
||||
return Response::json([
|
||||
'error' => [
|
||||
'message' => trans('webauthn::errors.object_not_found'),
|
||||
],
|
||||
], 404);
|
||||
}
|
||||
|
||||
return app(DestroyResponse::class);
|
||||
}
|
||||
|
||||
public function delete()
|
||||
/**
|
||||
* Retrieve the input with a string result.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param string $name
|
||||
* @param string $default
|
||||
* @return string
|
||||
*/
|
||||
private function input(Request $request, string $name, string $default = ''): string
|
||||
{
|
||||
return abort(404);
|
||||
$result = $request->input($name);
|
||||
|
||||
return is_string($result) ? $result : $default;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,11 +7,6 @@ use Illuminate\Http\Request;
|
|||
|
||||
class WebauthnEnabledKeyController extends Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('throttle:3,1')->only('destroy');
|
||||
}
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
$webauthnKey = user()->webauthnKeys()->findOrFail($request->id);
|
||||
|
@ -21,12 +16,8 @@ class WebauthnEnabledKeyController extends Controller
|
|||
return response('', 201);
|
||||
}
|
||||
|
||||
public function destroy(Request $request, $id)
|
||||
public function destroy($id)
|
||||
{
|
||||
$request->validate([
|
||||
'current' => 'required|string|current_password',
|
||||
]);
|
||||
|
||||
$webauthnKey = user()->webauthnKeys()->findOrFail($id);
|
||||
|
||||
$webauthnKey->disable();
|
||||
|
|
|
@ -10,6 +10,6 @@ class BannerLocationController extends Controller
|
|||
{
|
||||
user()->update(['banner_location' => $request->banner_location]);
|
||||
|
||||
return back()->with(['flash' => 'Location Updated Successfully']);
|
||||
return back()->with(['status' => 'Location Updated Successfully']);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,19 +7,14 @@ use Illuminate\Support\Facades\Auth;
|
|||
|
||||
class BrowserSessionController extends Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('throttle:3,1')->only('destroy');
|
||||
}
|
||||
|
||||
public function destroy(Request $request)
|
||||
{
|
||||
$request->validate([
|
||||
'current' => 'required|string|current_password',
|
||||
'current_password_sesssions' => 'password',
|
||||
]);
|
||||
|
||||
Auth::logoutOtherDevices($request->current);
|
||||
Auth::logoutOtherDevices($request->current_password_sesssions);
|
||||
|
||||
return back()->with(['flash' => 'Successfully logged out of other browser sessions!']);
|
||||
return back()->with(['status' => 'Successfully logged out of other browser sessions!']);
|
||||
}
|
||||
}
|
||||
|
|
19
app/Http/Controllers/CatchAllController.php
Normal file
19
app/Http/Controllers/CatchAllController.php
Normal file
|
@ -0,0 +1,19 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Http\Requests\UpdateCatchAllRequest;
|
||||
|
||||
class CatchAllController extends Controller
|
||||
{
|
||||
public function update(UpdateCatchAllRequest $request)
|
||||
{
|
||||
if ($request->catch_all) {
|
||||
user()->enableCatchAll();
|
||||
} else {
|
||||
user()->disableCatchAll();
|
||||
}
|
||||
|
||||
return back()->with(['status' => $request->catch_all ? 'Catch-All Enabled Successfully' : 'Catch-All Disabled Successfully']);
|
||||
}
|
||||
}
|
|
@ -3,11 +3,11 @@
|
|||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
|
||||
use Illuminate\Foundation\Bus\DispatchesJobs;
|
||||
use Illuminate\Foundation\Validation\ValidatesRequests;
|
||||
use Illuminate\Routing\Controller as BaseController;
|
||||
|
||||
class Controller extends BaseController
|
||||
{
|
||||
use AuthorizesRequests;
|
||||
use ValidatesRequests;
|
||||
use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
|
||||
}
|
||||
|
|
|
@ -22,6 +22,6 @@ class DeactivateAliasController extends Controller
|
|||
$alias->deactivate();
|
||||
|
||||
return redirect()->route('aliases.index')
|
||||
->with(['flash' => 'Alias '.$alias->email.' deactivated successfully!']);
|
||||
->with(['status' => 'Alias ' . $alias->email . ' deactivated successfully!']);
|
||||
}
|
||||
}
|
||||
|
|
16
app/Http/Controllers/DefaultAliasController.php
Normal file
16
app/Http/Controllers/DefaultAliasController.php
Normal file
|
@ -0,0 +1,16 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Http\Requests\UpdateDefaultAliasFormatRequest;
|
||||
|
||||
class DefaultAliasFormatController extends Controller
|
||||
{
|
||||
public function update(UpdateDefaultAliasFormatRequest $request)
|
||||
{
|
||||
user()->default_alias_format = $request->format;
|
||||
user()->save();
|
||||
|
||||
return back()->with(['status' => 'Default Alias Format Updated Successfully']);
|
||||
}
|
||||
}
|
|
@ -11,6 +11,6 @@ class DefaultAliasDomainController extends Controller
|
|||
user()->default_alias_domain = $request->domain;
|
||||
user()->save();
|
||||
|
||||
return back()->with(['flash' => 'Default Alias Domain Updated Successfully']);
|
||||
return back()->with(['status' => 'Default Alias Domain Updated Successfully']);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,6 +11,6 @@ class DefaultAliasFormatController extends Controller
|
|||
user()->default_alias_format = $request->format;
|
||||
user()->save();
|
||||
|
||||
return back()->with(['flash' => 'Default Alias Format Updated Successfully']);
|
||||
return back()->with(['status' => 'Default Alias Format Updated Successfully']);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,6 @@ namespace App\Http\Controllers;
|
|||
|
||||
use App\Http\Requests\EditDefaultRecipientRequest;
|
||||
use App\Http\Requests\UpdateDefaultRecipientRequest;
|
||||
use App\Notifications\DefaultRecipientUpdated;
|
||||
|
||||
class DefaultRecipientController extends Controller
|
||||
{
|
||||
|
@ -16,51 +15,27 @@ class DefaultRecipientController extends Controller
|
|||
public function __construct()
|
||||
{
|
||||
$this->middleware('throttle:1,1')->only('edit');
|
||||
$this->middleware('throttle:3,1')->only('update');
|
||||
}
|
||||
|
||||
public function update(UpdateDefaultRecipientRequest $request)
|
||||
{
|
||||
$recipient = user()->verifiedRecipients()->findOrFail($request->id);
|
||||
$recipient = user()->verifiedRecipients()->findOrFail($request->default_recipient);
|
||||
|
||||
$currentDefaultRecipient = user()->defaultRecipient;
|
||||
user()->default_recipient = $recipient;
|
||||
user()->save();
|
||||
|
||||
user()->update(['default_recipient_id' => $recipient->id]);
|
||||
|
||||
if ($currentDefaultRecipient->id !== $recipient->id) {
|
||||
$currentDefaultRecipient->notify(new DefaultRecipientUpdated($recipient->email));
|
||||
}
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
]);
|
||||
return back()->with(['status' => 'Default Recipient Updated Successfully']);
|
||||
}
|
||||
|
||||
public function edit(EditDefaultRecipientRequest $request)
|
||||
{
|
||||
$recipient = user()->defaultRecipient;
|
||||
|
||||
// Updating already verified default recipient, create new pending entry and send verification email.
|
||||
if ($recipient->hasVerifiedEmail()) {
|
||||
// Clear all other pending entries
|
||||
user()->pendingRecipients()->delete();
|
||||
|
||||
$pendingRecipient = user()->recipients()->create([
|
||||
'email' => strtolower($request->email),
|
||||
'pending' => true,
|
||||
]);
|
||||
|
||||
$pendingRecipient->sendEmailVerificationNotification();
|
||||
|
||||
return back()->with(['flash' => 'Email Pending Verification, Please Check Your Inbox For The Verification Email']);
|
||||
}
|
||||
|
||||
// Unverified default recipient so we can simply update and send the verification email.
|
||||
$recipient->email = strtolower($request->email);
|
||||
$recipient->email = $request->email;
|
||||
$recipient->save();
|
||||
|
||||
user()->sendEmailVerificationNotification();
|
||||
|
||||
return back()->with(['flash' => 'Email Updated Successfully, Please Check Your Inbox For The Verification Email']);
|
||||
return back()->with(['status' => 'Email Updated Successfully, Please Check Your Inbox For The Verification Email']);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,22 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Http\Requests\UpdateDefaultUsernameRequest;
|
||||
|
||||
class DefaultUsernameController extends Controller
|
||||
{
|
||||
public function update(UpdateDefaultUsernameRequest $request)
|
||||
{
|
||||
$username = user()->usernames()->findOrFail($request->id);
|
||||
|
||||
// Ensure username can be used to login
|
||||
$username->allowLogin();
|
||||
|
||||
user()->update(['default_username_id' => $username->id]);
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
]);
|
||||
}
|
||||
}
|
|
@ -1,17 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Enums\DisplayFromFormat;
|
||||
use App\Http\Requests\UpdateDisplayFromFormatRequest;
|
||||
|
||||
class DisplayFromFormatController extends Controller
|
||||
{
|
||||
public function update(UpdateDisplayFromFormatRequest $request)
|
||||
{
|
||||
user()->display_from_format = DisplayFromFormat::from($request->format);
|
||||
user()->save();
|
||||
|
||||
return back()->with(['flash' => 'Default Alias Format Updated Successfully']);
|
||||
}
|
||||
}
|
|
@ -17,7 +17,7 @@ class DomainVerificationController extends Controller
|
|||
if (! $domain->checkMxRecords()) {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'MX record not found or does not have correct priority. This could be due to DNS caching, please try again later.',
|
||||
'message' => 'MX record not found or does not have correct priority. This could be due to DNS caching, please try again later.'
|
||||
]);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,23 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
class DownloadableFailedDeliveryController extends Controller
|
||||
{
|
||||
public function index($id)
|
||||
{
|
||||
$failedDelivery = user()->failedDeliveries()->findOrFail($id);
|
||||
|
||||
if (! $failedDelivery->is_stored) {
|
||||
abort(404);
|
||||
}
|
||||
|
||||
if (! Storage::disk('local')->exists($failedDelivery->id.'.eml')) {
|
||||
abort(404);
|
||||
}
|
||||
|
||||
return Storage::disk('local')->download($failedDelivery->id.'.eml');
|
||||
}
|
||||
}
|
|
@ -10,6 +10,6 @@ class EmailSubjectController extends Controller
|
|||
{
|
||||
user()->update(['email_subject' => $request->email_subject]);
|
||||
|
||||
return back()->with(['flash' => 'Email Subject Updated Successfully']);
|
||||
return back()->with(['status' => 'Email Subject Updated Successfully']);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,14 +2,14 @@
|
|||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Http\Requests\UpdateAccountFromNameRequest;
|
||||
use App\Http\Requests\UpdateFromNameRequest;
|
||||
|
||||
class FromNameController extends Controller
|
||||
{
|
||||
public function update(UpdateAccountFromNameRequest $request)
|
||||
public function update(UpdateFromNameRequest $request)
|
||||
{
|
||||
user()->update(['from_name' => $request->from_name]);
|
||||
|
||||
return back()->with(['flash' => 'From Name Updated Successfully']);
|
||||
return back()->with(['status' => 'From Name Updated Successfully']);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,17 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Enums\LoginRedirect;
|
||||
use App\Http\Requests\UpdateLoginRedirectRequest;
|
||||
|
||||
class LoginRedirectController extends Controller
|
||||
{
|
||||
public function update(UpdateLoginRedirectRequest $request)
|
||||
{
|
||||
user()->login_redirect = LoginRedirect::from($request->redirect);
|
||||
user()->save();
|
||||
|
||||
return back()->with(['flash' => 'Login Redirect Updated Successfully']);
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue