Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
664cd32f81 | |||
33f0eb6c41 | |||
9fd2fa9a78 | |||
3c77f8af4b |
57
app/.github/workflows/main.yml
vendored
57
app/.github/workflows/main.yml
vendored
@ -1,6 +1,12 @@
|
||||
name: Test and lint
|
||||
name: SimpleLogin actions
|
||||
|
||||
on: [push, pull_request]
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
tags:
|
||||
- v*
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
lint:
|
||||
@ -9,35 +15,30 @@ jobs:
|
||||
- name: Check out repo
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Install poetry
|
||||
run: pipx install poetry
|
||||
|
||||
- uses: actions/setup-python@v4
|
||||
- name: "Install rye"
|
||||
id: setup-rye
|
||||
uses: eifinger/setup-rye@v4
|
||||
with:
|
||||
python-version: '3.10'
|
||||
cache: 'poetry'
|
||||
version: '0.43.0'
|
||||
checksum: 'ca702c3d93fd6ec76a1a0efaaa605e10736ee79a0674d241aad1bc0fe26f7d80'
|
||||
enable-cache: true
|
||||
|
||||
- name: Install OS dependencies
|
||||
if: ${{ matrix.python-version }} == '3.10'
|
||||
run: |
|
||||
sudo apt update
|
||||
sudo apt install -y libre2-dev libpq-dev
|
||||
|
||||
- name: Install dependencies
|
||||
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
|
||||
run: poetry install --no-interaction
|
||||
if: steps.setup-rye.outputs.cache-hit != 'true'
|
||||
run: rye sync --no-lock
|
||||
|
||||
- name: Check formatting & linting
|
||||
run: |
|
||||
poetry run pre-commit run --all-files
|
||||
rye run pre-commit run --all-files
|
||||
|
||||
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
max-parallel: 4
|
||||
matrix:
|
||||
python-version: ["3.10"]
|
||||
|
||||
# service containers to run with `postgres-job`
|
||||
services:
|
||||
@ -69,24 +70,23 @@ jobs:
|
||||
- name: Check out repo
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Install poetry
|
||||
run: pipx install poetry
|
||||
|
||||
- uses: actions/setup-python@v4
|
||||
- name: Install rye
|
||||
id: setup-rye
|
||||
uses: eifinger/setup-rye@v4
|
||||
with:
|
||||
python-version: ${{ matrix.python-version }}
|
||||
cache: 'poetry'
|
||||
version: '0.43.0'
|
||||
checksum: 'ca702c3d93fd6ec76a1a0efaaa605e10736ee79a0674d241aad1bc0fe26f7d80'
|
||||
enable-cache: true
|
||||
cache-prefix: 'rye-cache'
|
||||
|
||||
- name: Install OS dependencies
|
||||
if: ${{ matrix.python-version }} == '3.10'
|
||||
run: |
|
||||
sudo apt update
|
||||
sudo apt install -y libre2-dev libpq-dev
|
||||
|
||||
- name: Install dependencies
|
||||
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
|
||||
run: poetry install --no-interaction
|
||||
|
||||
if: steps.setup-rye.outputs.cache-hit != 'true'
|
||||
run: rye sync --no-lock
|
||||
|
||||
- name: Start Redis v6
|
||||
uses: superchargejs/redis-github-action@1.1.0
|
||||
@ -95,7 +95,8 @@ jobs:
|
||||
|
||||
- name: Run db migration
|
||||
run: |
|
||||
CONFIG=tests/test.env poetry run alembic upgrade head
|
||||
rye install alembic
|
||||
CONFIG=tests/test.env rye run alembic upgrade head
|
||||
|
||||
- name: Prepare version file
|
||||
run: |
|
||||
@ -104,7 +105,7 @@ jobs:
|
||||
|
||||
- name: Test with pytest
|
||||
run: |
|
||||
poetry run pytest
|
||||
rye run pytest
|
||||
env:
|
||||
GITHUB_ACTIONS_TEST: true
|
||||
|
||||
|
1
app/.python-version
Normal file
1
app/.python-version
Normal file
@ -0,0 +1 @@
|
||||
3.10.16
|
@ -20,7 +20,7 @@ SimpleLogin backend consists of 2 main components:
|
||||
## Install dependencies
|
||||
|
||||
The project requires:
|
||||
- Python 3.10 and poetry to manage dependencies
|
||||
- Python 3.10 and rye to manage dependencies
|
||||
- Node v10 for front-end.
|
||||
- Postgres 13+
|
||||
|
||||
@ -28,7 +28,7 @@ First, install all dependencies by running the following command.
|
||||
Feel free to use `virtualenv` or similar tools to isolate development environment.
|
||||
|
||||
```bash
|
||||
poetry sync
|
||||
rye sync
|
||||
```
|
||||
|
||||
On Mac, sometimes you might need to install some other packages via `brew`:
|
||||
@ -55,7 +55,7 @@ brew install -s re2 pybind11
|
||||
We use pre-commit to run all our linting and static analysis checks. Please run
|
||||
|
||||
```bash
|
||||
poetry run pre-commit install
|
||||
rye run pre-commit install
|
||||
```
|
||||
|
||||
To install it in your development environment.
|
||||
@ -160,25 +160,25 @@ Here are the small sum-ups of the directory structures and their roles:
|
||||
The code is formatted using [ruff](https://github.com/astral-sh/ruff), to format the code, simply run
|
||||
|
||||
```
|
||||
poetry run ruff format .
|
||||
rye run ruff format .
|
||||
```
|
||||
|
||||
The code is also checked with `flake8`, make sure to run `flake8` before creating the pull request by
|
||||
|
||||
```bash
|
||||
poetry run flake8
|
||||
rye run flake8
|
||||
```
|
||||
|
||||
For HTML templates, we use `djlint`. Before creating a pull request, please run
|
||||
|
||||
```bash
|
||||
poetry run djlint --check templates
|
||||
rye run djlint --check templates
|
||||
```
|
||||
|
||||
If some files aren't properly formatted, you can format all files with
|
||||
|
||||
```bash
|
||||
poetry run djlint --reformat .
|
||||
rye run djlint --reformat .
|
||||
```
|
||||
|
||||
## Test sending email
|
||||
@ -236,18 +236,11 @@ There are several ways to setup Python and manage the project dependencies on Ma
|
||||
# we haven't managed to make python 3.12 work
|
||||
brew install python3.10
|
||||
|
||||
# make sure to update the PATH so python, pip point to Python3
|
||||
# for us it can be done by adding "export PATH=/opt/homebrew/opt/python@3.10/libexec/bin:$PATH" to .zprofile
|
||||
# Install rye using the official installation script, found on https://rye.astral.sh/guide/installation/
|
||||
|
||||
# Although pipx is the recommended way to install poetry,
|
||||
# install pipx via brew will automatically install python 3.12
|
||||
# and poetry will then use python 3.12
|
||||
# so we recommend using poetry this way instead
|
||||
curl -sSL https://install.python-poetry.org | python3 -
|
||||
|
||||
poetry install
|
||||
# Install the dependencies
|
||||
rye sync
|
||||
|
||||
# activate the virtualenv and you should be good to go!
|
||||
source .venv/bin/activate
|
||||
|
||||
```
|
@ -4,43 +4,45 @@ WORKDIR /code
|
||||
COPY ./static/package*.json /code/static/
|
||||
RUN cd /code/static && npm ci
|
||||
|
||||
# Main image
|
||||
FROM python:3.10
|
||||
FROM --platform=linux/amd64 ubuntu:22.04
|
||||
|
||||
ARG RYE_VERSION="0.43.0"
|
||||
ARG RYE_HASH="ca702c3d93fd6ec76a1a0efaaa605e10736ee79a0674d241aad1bc0fe26f7d80"
|
||||
|
||||
# Keeps Python from generating .pyc files in the container
|
||||
ENV PYTHONDONTWRITEBYTECODE 1
|
||||
ENV PYTHONDONTWRITEBYTECODE=1
|
||||
# Turns off buffering for easier container logging
|
||||
ENV PYTHONUNBUFFERED 1
|
||||
ENV PYTHONUNBUFFERED=1
|
||||
|
||||
# Add poetry to PATH
|
||||
ENV PATH="${PATH}:/root/.local/bin"
|
||||
|
||||
WORKDIR /code
|
||||
|
||||
# Copy poetry files
|
||||
COPY poetry.lock pyproject.toml ./
|
||||
# Copy dependency files
|
||||
COPY pyproject.toml requirements.lock requirements-dev.lock .python-version ./
|
||||
|
||||
# Install and setup poetry
|
||||
RUN pip install -U pip \
|
||||
&& apt-get update \
|
||||
&& apt install -y curl netcat-traditional gcc python3-dev gnupg git libre2-dev cmake ninja-build\
|
||||
&& curl -sSL https://install.python-poetry.org | python3 - \
|
||||
# Remove curl and netcat from the image
|
||||
&& apt-get purge -y curl netcat-traditional \
|
||||
# Run poetry
|
||||
&& poetry config virtualenvs.create false \
|
||||
&& poetry install --no-interaction --no-ansi --no-root \
|
||||
# Clear apt cache \
|
||||
&& apt-get purge -y libre2-dev cmake ninja-build\
|
||||
# Install deps
|
||||
RUN apt-get update \
|
||||
&& apt-get install -y curl netcat-traditional gcc python3-dev gnupg git libre2-dev build-essential pkg-config cmake ninja-build bash clang \
|
||||
&& curl -sSL "https://github.com/astral-sh/rye/releases/download/${RYE_VERSION}/rye-x86_64-linux.gz" > rye.gz \
|
||||
&& echo "${RYE_HASH} rye.gz" | sha256sum -c - \
|
||||
&& gunzip rye.gz \
|
||||
&& chmod +x rye \
|
||||
&& mv rye /usr/bin/rye \
|
||||
&& rye toolchain fetch `cat .python-version` \
|
||||
&& rye sync --no-lock --no-dev \
|
||||
&& apt-get autoremove -y \
|
||||
&& apt-get purge -y curl netcat-traditional build-essential pkg-config cmake ninja-build python3-dev clang\
|
||||
&& apt-get autoremove -y \
|
||||
&& apt-get clean \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Copy code
|
||||
COPY . .
|
||||
|
||||
# copy npm packages
|
||||
COPY --from=npm /code /code
|
||||
|
||||
# copy everything else into /code
|
||||
COPY . .
|
||||
|
||||
ENV PATH="/code/.venv/bin:$PATH"
|
||||
EXPOSE 7777
|
||||
|
||||
#gunicorn wsgi:app -b 0.0.0.0:7777 -w 2 --timeout 15 --log-level DEBUG
|
||||
|
@ -4,6 +4,7 @@ from enum import Enum
|
||||
from typing import Optional
|
||||
|
||||
import arrow
|
||||
import sqlalchemy.exc
|
||||
from arrow import Arrow
|
||||
from newrelic import agent
|
||||
from psycopg2.errors import UniqueViolation
|
||||
@ -35,6 +36,7 @@ from app.utils import random_string
|
||||
class SLPlanType(Enum):
|
||||
Free = 1
|
||||
Premium = 2
|
||||
PremiumLifetime = 3
|
||||
|
||||
|
||||
@dataclass
|
||||
@ -75,6 +77,7 @@ def send_user_plan_changed_event(partner_user: PartnerUser) -> Optional[int]:
|
||||
|
||||
def set_plan_for_partner_user(partner_user: PartnerUser, plan: SLPlan):
|
||||
sub = PartnerSubscription.get_by(partner_user_id=partner_user.id)
|
||||
is_lifetime = plan.type == SLPlanType.PremiumLifetime
|
||||
if plan.type == SLPlanType.Free:
|
||||
if sub is not None:
|
||||
LOG.i(
|
||||
@ -83,25 +86,30 @@ def set_plan_for_partner_user(partner_user: PartnerUser, plan: SLPlan):
|
||||
PartnerSubscription.delete(sub.id)
|
||||
agent.record_custom_event("PlanChange", {"plan": "free"})
|
||||
else:
|
||||
end_time = plan.expiration
|
||||
if plan.type == SLPlanType.PremiumLifetime:
|
||||
end_time = None
|
||||
if sub is None:
|
||||
LOG.i(
|
||||
f"Creating partner_subscription [user_id={partner_user.user_id}] [partner_id={partner_user.partner_id}]"
|
||||
f"Creating partner_subscription [user_id={partner_user.user_id}] [partner_id={partner_user.partner_id}] with {end_time} / {is_lifetime}"
|
||||
)
|
||||
create_partner_subscription(
|
||||
partner_user=partner_user,
|
||||
expiration=plan.expiration,
|
||||
expiration=end_time,
|
||||
lifetime=is_lifetime,
|
||||
msg="Upgraded via partner. User did not have a previous partner subscription",
|
||||
)
|
||||
agent.record_custom_event("PlanChange", {"plan": "premium", "type": "new"})
|
||||
else:
|
||||
if sub.end_at != plan.expiration:
|
||||
LOG.i(
|
||||
f"Updating partner_subscription [user_id={partner_user.user_id}] [partner_id={partner_user.partner_id}]"
|
||||
)
|
||||
if sub.end_at != plan.expiration or sub.lifetime != is_lifetime:
|
||||
agent.record_custom_event(
|
||||
"PlanChange", {"plan": "premium", "type": "extension"}
|
||||
)
|
||||
sub.end_at = plan.expiration
|
||||
sub.end_at = plan.expiration if not is_lifetime else None
|
||||
sub.lifetime = is_lifetime
|
||||
LOG.i(
|
||||
f"Updating partner_subscription [user_id={partner_user.user_id}] [partner_id={partner_user.partner_id}] to {sub.end_at} / {sub.lifetime} "
|
||||
)
|
||||
emit_user_audit_log(
|
||||
user=partner_user.user,
|
||||
action=UserAuditLogAction.SubscriptionExtended,
|
||||
@ -185,7 +193,8 @@ class NewUserStrategy(ClientMergeStrategy):
|
||||
user=new_user,
|
||||
strategy=self.__class__.__name__,
|
||||
)
|
||||
except UniqueViolation:
|
||||
except (UniqueViolation, sqlalchemy.exc.IntegrityError) as e:
|
||||
LOG.debug(f"Got the duplicate user error: {e}")
|
||||
return self.create_missing_link(canonical_email)
|
||||
|
||||
def create_missing_link(self, canonical_email: str):
|
||||
|
@ -8,14 +8,16 @@ from flask_admin.form import SecureForm
|
||||
from flask_admin.model.template import EndpointLinkRowAction
|
||||
from markupsafe import Markup
|
||||
|
||||
from app import models, s3
|
||||
from app import models, s3, config
|
||||
from flask import redirect, url_for, request, flash, Response
|
||||
from flask_admin import expose, AdminIndexView
|
||||
from flask_admin.actions import action
|
||||
from flask_admin.contrib import sqla
|
||||
from flask_login import current_user
|
||||
|
||||
from app.custom_domain_validation import CustomDomainValidation, DomainValidationResult
|
||||
from app.db import Session
|
||||
from app.dns_utils import get_network_dns_client
|
||||
from app.events.event_dispatcher import EventDispatcher
|
||||
from app.events.generated.event_pb2 import EventContent, UserPlanChanged
|
||||
from app.models import (
|
||||
@ -39,6 +41,7 @@ from app.models import (
|
||||
AliasMailbox,
|
||||
AliasAuditLog,
|
||||
UserAuditLog,
|
||||
CustomDomain,
|
||||
)
|
||||
from app.newsletter_utils import send_newsletter_to_user, send_newsletter_to_address
|
||||
from app.user_audit_log_utils import emit_user_audit_log, UserAuditLogAction
|
||||
@ -773,21 +776,22 @@ class InvalidMailboxDomainAdmin(SLModelView):
|
||||
|
||||
|
||||
class EmailSearchResult:
|
||||
no_match: bool = True
|
||||
alias: Optional[Alias] = None
|
||||
alias_audit_log: Optional[List[AliasAuditLog]] = None
|
||||
mailbox: List[Mailbox] = []
|
||||
mailbox_count: int = 0
|
||||
deleted_alias: Optional[DeletedAlias] = None
|
||||
deleted_alias_audit_log: Optional[List[AliasAuditLog]] = None
|
||||
domain_deleted_alias: Optional[DomainDeletedAlias] = None
|
||||
domain_deleted_alias_audit_log: Optional[List[AliasAuditLog]] = None
|
||||
user: Optional[User] = None
|
||||
user_audit_log: Optional[List[UserAuditLog]] = None
|
||||
query: str
|
||||
def __init__(self):
|
||||
self.no_match: bool = True
|
||||
self.alias: Optional[Alias] = None
|
||||
self.alias_audit_log: Optional[List[AliasAuditLog]] = None
|
||||
self.mailbox: List[Mailbox] = []
|
||||
self.mailbox_count: int = 0
|
||||
self.deleted_alias: Optional[DeletedAlias] = None
|
||||
self.deleted_alias_audit_log: Optional[List[AliasAuditLog]] = None
|
||||
self.domain_deleted_alias: Optional[DomainDeletedAlias] = None
|
||||
self.domain_deleted_alias_audit_log: Optional[List[AliasAuditLog]] = None
|
||||
self.user: Optional[User] = None
|
||||
self.user_audit_log: Optional[List[UserAuditLog]] = None
|
||||
self.query: str
|
||||
|
||||
@staticmethod
|
||||
def from_email(email: str) -> EmailSearchResult:
|
||||
def from_request_email(email: str) -> EmailSearchResult:
|
||||
output = EmailSearchResult()
|
||||
output.query = email
|
||||
alias = Alias.get_by(email=email)
|
||||
@ -799,6 +803,10 @@ class EmailSearchResult:
|
||||
.all()
|
||||
)
|
||||
output.no_match = False
|
||||
try:
|
||||
user_id = int(email)
|
||||
user = User.get(user_id)
|
||||
except ValueError:
|
||||
user = User.get_by(email=email)
|
||||
if user:
|
||||
output.user = user
|
||||
@ -908,7 +916,7 @@ class EmailSearchAdmin(BaseView):
|
||||
email = request.args.get("email")
|
||||
if email is not None and len(email) > 0:
|
||||
email = email.strip()
|
||||
search = EmailSearchResult.from_email(email)
|
||||
search = EmailSearchResult.from_request_email(email)
|
||||
|
||||
return self.render(
|
||||
"admin/email_search.html",
|
||||
@ -916,3 +924,106 @@ class EmailSearchAdmin(BaseView):
|
||||
data=search,
|
||||
helper=EmailSearchHelpers,
|
||||
)
|
||||
|
||||
|
||||
class CustomDomainWithValidationData:
|
||||
def __init__(self, domain: CustomDomain):
|
||||
self.domain: CustomDomain = domain
|
||||
self.ownership_expected: Optional[str] = None
|
||||
self.ownership_validation: Optional[DomainValidationResult] = None
|
||||
self.mx_expected: Optional[str] = None
|
||||
self.mx_validation: Optional[DomainValidationResult] = None
|
||||
self.spf_expected: Optional[str] = None
|
||||
self.spf_validation: Optional[DomainValidationResult] = None
|
||||
self.dkim_expected: {str: str} = {}
|
||||
self.dkim_validation: {str: str} = {}
|
||||
|
||||
|
||||
class CustomDomainSearchResult:
|
||||
def __init__(self):
|
||||
self.no_match: bool = False
|
||||
self.user: Optional[User] = None
|
||||
self.domains: list[CustomDomainWithValidationData] = []
|
||||
|
||||
@staticmethod
|
||||
def from_user(user: Optional[User]) -> CustomDomainSearchResult:
|
||||
out = CustomDomainSearchResult()
|
||||
if user is None:
|
||||
out.no_match = True
|
||||
return out
|
||||
out.user = user
|
||||
dns_client = get_network_dns_client()
|
||||
validator = CustomDomainValidation(
|
||||
dkim_domain=config.EMAIL_DOMAIN,
|
||||
partner_domains=config.PARTNER_DNS_CUSTOM_DOMAINS,
|
||||
partner_domains_validation_prefixes=config.PARTNER_CUSTOM_DOMAIN_VALIDATION_PREFIXES,
|
||||
dns_client=dns_client,
|
||||
)
|
||||
for custom_domain in user.custom_domains:
|
||||
validation_data = CustomDomainWithValidationData(custom_domain)
|
||||
if not custom_domain.ownership_verified:
|
||||
validation_data.ownership_expected = (
|
||||
validator.get_ownership_verification_record(custom_domain)
|
||||
)
|
||||
validation_data.ownership_validation = (
|
||||
validator.validate_domain_ownership(custom_domain)
|
||||
)
|
||||
if not custom_domain.verified:
|
||||
validation_data.mx_expected = validator.get_expected_mx_records(
|
||||
custom_domain
|
||||
)
|
||||
validation_data.mx_validation = validator.validate_mx_records(
|
||||
custom_domain
|
||||
)
|
||||
if not custom_domain.spf_verified:
|
||||
validation_data.spf_expected = validator.get_expected_spf_record(
|
||||
custom_domain
|
||||
)
|
||||
validation_data.spf_validation = validator.validate_spf_records(
|
||||
custom_domain
|
||||
)
|
||||
if not custom_domain.dkim_verified:
|
||||
validation_data.dkim_expected = validator.get_dkim_records(
|
||||
custom_domain
|
||||
)
|
||||
validation_data.dkim_validation = validator.validate_dkim_records(
|
||||
custom_domain
|
||||
)
|
||||
out.domains.append(validation_data)
|
||||
print(validation_data.dkim_expected, validation_data.dkim_validation)
|
||||
|
||||
return out
|
||||
|
||||
|
||||
class CustomDomainSearchAdmin(BaseView):
|
||||
def is_accessible(self):
|
||||
return current_user.is_authenticated and current_user.is_admin
|
||||
|
||||
def inaccessible_callback(self, name, **kwargs):
|
||||
# redirect to login page if user doesn't have access
|
||||
flash("You don't have access to the admin page", "error")
|
||||
return redirect(url_for("dashboard.index", next=request.url))
|
||||
|
||||
@expose("/", methods=["GET", "POST"])
|
||||
def index(self):
|
||||
query = request.args.get("user")
|
||||
if query is None:
|
||||
search = CustomDomainSearchResult()
|
||||
else:
|
||||
try:
|
||||
user_id = int(query)
|
||||
user = User.get_by(id=user_id)
|
||||
except ValueError:
|
||||
user = User.get_by(email=query)
|
||||
if user is None:
|
||||
cd = CustomDomain.get_by(domain=query)
|
||||
if cd is not None:
|
||||
user = cd.user
|
||||
search = CustomDomainSearchResult.from_user(user)
|
||||
print("NEW", search.domains)
|
||||
|
||||
return self.render(
|
||||
"admin/custom_domain_search.html",
|
||||
data=search,
|
||||
query=query,
|
||||
)
|
||||
|
@ -299,7 +299,10 @@ def update_alias(alias_id):
|
||||
changed = True
|
||||
|
||||
if "mailbox_ids" in data:
|
||||
try:
|
||||
mailbox_ids = [int(m_id) for m_id in data.get("mailbox_ids")]
|
||||
except ValueError:
|
||||
return jsonify(error="Invalid mailbox_id"), 400
|
||||
err = set_mailboxes_for_alias(
|
||||
user_id=user.id, alias=alias, mailbox_ids=mailbox_ids
|
||||
)
|
||||
|
@ -1,3 +1,4 @@
|
||||
from email_validator import EmailNotValidError
|
||||
from flask import g
|
||||
from flask import jsonify, request
|
||||
|
||||
@ -93,12 +94,15 @@ def new_custom_alias_v2():
|
||||
400,
|
||||
)
|
||||
|
||||
try:
|
||||
alias = Alias.create(
|
||||
user_id=user.id,
|
||||
email=full_alias,
|
||||
mailbox_id=user.default_mailbox_id,
|
||||
note=note,
|
||||
)
|
||||
except EmailNotValidError:
|
||||
return jsonify(error="Email is not valid"), 400
|
||||
|
||||
Session.commit()
|
||||
|
||||
@ -154,8 +158,16 @@ def new_custom_alias_v3():
|
||||
return jsonify(error="request body does not follow the required format"), 400
|
||||
|
||||
alias_prefix_data = data.get("alias_prefix", "") or ""
|
||||
|
||||
if not isinstance(alias_prefix_data, str):
|
||||
return jsonify(error="request body does not follow the required format"), 400
|
||||
|
||||
alias_prefix = alias_prefix_data.strip().lower().replace(" ", "")
|
||||
signed_suffix = data.get("signed_suffix", "") or ""
|
||||
|
||||
if not isinstance(signed_suffix, str):
|
||||
return jsonify(error="request body does not follow the required format"), 400
|
||||
|
||||
signed_suffix = signed_suffix.strip()
|
||||
|
||||
mailbox_ids = data.get("mailbox_ids")
|
||||
|
@ -1345,17 +1345,16 @@ def get_queue_id(msg: Message) -> Optional[str]:
|
||||
|
||||
received_header = str(msg[headers.RECEIVED])
|
||||
if not received_header:
|
||||
return
|
||||
return None
|
||||
|
||||
# received_header looks like 'from mail-wr1-x434.google.com (mail-wr1-x434.google.com [IPv6:2a00:1450:4864:20::434])\r\n\t(using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits))\r\n\t(No client certificate requested)\r\n\tby mx1.simplelogin.co (Postfix) with ESMTPS id 4FxQmw1DXdz2vK2\r\n\tfor <jglfdjgld@alias.com>; Fri, 4 Jun 2021 14:55:43 +0000 (UTC)'
|
||||
search_result = re.search("with ESMTPS id [0-9a-zA-Z]{1,}", received_header)
|
||||
if not search_result:
|
||||
return
|
||||
|
||||
# the "with ESMTPS id 4FxQmw1DXdz2vK2" part
|
||||
with_esmtps = received_header[search_result.start() : search_result.end()]
|
||||
|
||||
return with_esmtps[len("with ESMTPS id ") :]
|
||||
search_result = re.search(r"with E?SMTP[AS]? id ([0-9a-zA-Z]{1,})", received_header)
|
||||
if search_result:
|
||||
return search_result.group(1)
|
||||
search_result = re.search("\(Postfix\)\r\n\tid ([a-zA-Z0-9]{1,});", received_header)
|
||||
if search_result:
|
||||
return search_result.group(1)
|
||||
return None
|
||||
|
||||
|
||||
def should_ignore_bounce(mail_from: str) -> bool:
|
||||
|
@ -12,11 +12,13 @@ from app.email_utils import (
|
||||
email_can_be_used_as_mailbox,
|
||||
send_email,
|
||||
render,
|
||||
get_email_domain_part,
|
||||
)
|
||||
from app.email_validation import is_valid_email
|
||||
from app.log import LOG
|
||||
from app.models import User, Mailbox, Job, MailboxActivation
|
||||
from app.models import User, Mailbox, Job, MailboxActivation, Alias
|
||||
from app.user_audit_log_utils import emit_user_audit_log, UserAuditLogAction
|
||||
from app.utils import canonicalize_email, sanitize_email
|
||||
|
||||
|
||||
@dataclasses.dataclass
|
||||
@ -52,6 +54,7 @@ def create_mailbox(
|
||||
use_digit_codes: bool = False,
|
||||
send_link: bool = True,
|
||||
) -> CreateMailboxOutput:
|
||||
email = sanitize_email(email)
|
||||
if not user.is_premium():
|
||||
LOG.i(
|
||||
f"User {user} has tried to create mailbox with {email} but is not premium"
|
||||
@ -104,7 +107,10 @@ def create_mailbox(
|
||||
|
||||
|
||||
def delete_mailbox(
|
||||
user: User, mailbox_id: int, transfer_mailbox_id: Optional[int]
|
||||
user: User,
|
||||
mailbox_id: int,
|
||||
transfer_mailbox_id: Optional[int],
|
||||
send_mail: bool = True,
|
||||
) -> Mailbox:
|
||||
mailbox = Mailbox.get(mailbox_id)
|
||||
|
||||
@ -150,6 +156,7 @@ def delete_mailbox(
|
||||
"transfer_mailbox_id": transfer_mailbox_id
|
||||
if transfer_mailbox_id and transfer_mailbox_id > 0
|
||||
else None,
|
||||
"send_mail": send_mail,
|
||||
},
|
||||
run_at=arrow.now(),
|
||||
commit=True,
|
||||
@ -328,3 +335,56 @@ def perform_mailbox_email_change(mailbox_id: int) -> MailboxEmailChangeResult:
|
||||
message="Invalid link",
|
||||
message_category="error",
|
||||
)
|
||||
|
||||
|
||||
def __get_alias_mailbox_from_email(
|
||||
email_address: str, alias: Alias
|
||||
) -> Optional[Mailbox]:
|
||||
for mailbox in alias.mailboxes:
|
||||
if mailbox.email == email_address:
|
||||
return mailbox
|
||||
|
||||
for authorized_address in mailbox.authorized_addresses:
|
||||
if authorized_address.email == email_address:
|
||||
LOG.d(
|
||||
"Found an authorized address for %s %s %s",
|
||||
alias,
|
||||
mailbox,
|
||||
authorized_address,
|
||||
)
|
||||
return mailbox
|
||||
return None
|
||||
|
||||
|
||||
def __get_alias_mailbox_from_email_or_canonical_email(
|
||||
email_address: str, alias: Alias
|
||||
) -> Optional[Mailbox]:
|
||||
# We need to first check for the uncanonicalized version because we still have users in the db with the
|
||||
# email non canonicalized. So if it matches the already existing one use that, otherwise check the canonical one
|
||||
mbox = __get_alias_mailbox_from_email(email_address, alias)
|
||||
if mbox is not None:
|
||||
return mbox
|
||||
canonical_email = canonicalize_email(email_address)
|
||||
if canonical_email != email_address:
|
||||
return __get_alias_mailbox_from_email(canonical_email, alias)
|
||||
return None
|
||||
|
||||
|
||||
def get_mailbox_for_reply_phase(
|
||||
envelope_mail_from: str, header_mail_from: str, alias
|
||||
) -> Optional[Mailbox]:
|
||||
"""return the corresponding mailbox given the mail_from and alias
|
||||
Usually the mail_from=mailbox.email but it can also be one of the authorized address
|
||||
"""
|
||||
mbox = __get_alias_mailbox_from_email_or_canonical_email(envelope_mail_from, alias)
|
||||
if mbox is not None:
|
||||
return mbox
|
||||
if not header_mail_from:
|
||||
return None
|
||||
envelope_from_domain = get_email_domain_part(envelope_mail_from)
|
||||
header_from_domain = get_email_domain_part(header_mail_from)
|
||||
if envelope_from_domain != header_from_domain:
|
||||
return None
|
||||
# For services that use VERP sending (envelope from has encoded data to account for bounces)
|
||||
# if the domain is the same in the header from as the envelope from we can use the header from
|
||||
return __get_alias_mailbox_from_email_or_canonical_email(header_mail_from, alias)
|
||||
|
@ -343,7 +343,7 @@ class Fido(Base, ModelMixin):
|
||||
class User(Base, ModelMixin, UserMixin, PasswordOracle):
|
||||
__tablename__ = "users"
|
||||
|
||||
FLAG_DISABLE_CREATE_CONTACTS = 1 << 0
|
||||
FLAG_FREE_DISABLE_CREATE_CONTACTS = 1 << 0
|
||||
FLAG_CREATED_FROM_PARTNER = 1 << 1
|
||||
FLAG_FREE_OLD_ALIAS_LIMIT = 1 << 2
|
||||
FLAG_CREATED_ALIAS_FROM_PARTNER = 1 << 3
|
||||
@ -550,7 +550,7 @@ class User(Base, ModelMixin, UserMixin, PasswordOracle):
|
||||
# bitwise flags. Allow for future expansion
|
||||
flags = sa.Column(
|
||||
sa.BigInteger,
|
||||
default=FLAG_DISABLE_CREATE_CONTACTS,
|
||||
default=FLAG_FREE_DISABLE_CREATE_CONTACTS,
|
||||
server_default="0",
|
||||
nullable=False,
|
||||
)
|
||||
@ -640,7 +640,7 @@ class User(Base, ModelMixin, UserMixin, PasswordOracle):
|
||||
# If the user is created from partner, do not notify
|
||||
# nor give a trial
|
||||
if from_partner:
|
||||
user.flags = User.FLAG_CREATED_FROM_PARTNER
|
||||
user.flags = user.flags | User.FLAG_CREATED_FROM_PARTNER
|
||||
user.notification = False
|
||||
user.trial_end = None
|
||||
Job.create(
|
||||
@ -1189,7 +1189,7 @@ class User(Base, ModelMixin, UserMixin, PasswordOracle):
|
||||
def can_create_contacts(self) -> bool:
|
||||
if self.is_premium():
|
||||
return True
|
||||
if self.flags & User.FLAG_DISABLE_CREATE_CONTACTS == 0:
|
||||
if self.flags & User.FLAG_FREE_DISABLE_CREATE_CONTACTS == 0:
|
||||
return True
|
||||
return not config.DISABLE_CREATE_CONTACTS_FOR_FREE_USERS
|
||||
|
||||
@ -1659,7 +1659,7 @@ class Alias(Base, ModelMixin):
|
||||
return False
|
||||
|
||||
@staticmethod
|
||||
def get_custom_domain(alias_address) -> Optional["CustomDomain"]:
|
||||
def get_custom_domain(alias_address: str) -> Optional["CustomDomain"]:
|
||||
alias_domain = validate_email(
|
||||
alias_address, check_deliverability=False, allow_smtputf8=False
|
||||
).domain
|
||||
@ -3778,7 +3778,8 @@ class PartnerSubscription(Base, ModelMixin):
|
||||
)
|
||||
|
||||
# when the partner subscription ends
|
||||
end_at = sa.Column(ArrowType, nullable=False, index=True)
|
||||
end_at = sa.Column(ArrowType, nullable=True, index=True)
|
||||
lifetime = sa.Column(sa.Boolean, default=False, nullable=False, server_default="0")
|
||||
|
||||
partner_user = orm.relationship(PartnerUser)
|
||||
|
||||
@ -3800,7 +3801,9 @@ class PartnerSubscription(Base, ModelMixin):
|
||||
return None
|
||||
|
||||
def is_active(self):
|
||||
return self.end_at > arrow.now().shift(days=-_PARTNER_SUBSCRIPTION_GRACE_DAYS)
|
||||
return self.lifetime or self.end_at > arrow.now().shift(
|
||||
days=-_PARTNER_SUBSCRIPTION_GRACE_DAYS
|
||||
)
|
||||
|
||||
|
||||
# endregion
|
||||
|
@ -33,12 +33,14 @@ def create_partner_user(
|
||||
|
||||
def create_partner_subscription(
|
||||
partner_user: PartnerUser,
|
||||
expiration: Optional[Arrow],
|
||||
expiration: Optional[Arrow] = None,
|
||||
lifetime: bool = False,
|
||||
msg: Optional[str] = None,
|
||||
) -> PartnerSubscription:
|
||||
instance = PartnerSubscription.create(
|
||||
partner_user_id=partner_user.id,
|
||||
end_at=expiration,
|
||||
lifetime=lifetime,
|
||||
)
|
||||
|
||||
message = "User upgraded through partner subscription"
|
||||
|
@ -16,6 +16,7 @@ PROTON_ERROR_CODE_HV_NEEDED = 9001
|
||||
|
||||
PLAN_FREE = 1
|
||||
PLAN_PREMIUM = 2
|
||||
PLAN_PREMIUM_LIFETIME = 3
|
||||
|
||||
|
||||
@dataclass
|
||||
@ -112,10 +113,13 @@ class HttpProtonClient(ProtonClient):
|
||||
if plan_value == PLAN_FREE:
|
||||
plan = SLPlan(type=SLPlanType.Free, expiration=None)
|
||||
elif plan_value == PLAN_PREMIUM:
|
||||
expiration = info.get("PlanExpiration", "1")
|
||||
plan = SLPlan(
|
||||
type=SLPlanType.Premium,
|
||||
expiration=Arrow.fromtimestamp(info["PlanExpiration"], tzinfo="utc"),
|
||||
expiration=Arrow.fromtimestamp(expiration, tzinfo="utc"),
|
||||
)
|
||||
elif plan_value == PLAN_PREMIUM_LIFETIME:
|
||||
plan = SLPlan(SLPlanType.PremiumLifetime, expiration=None)
|
||||
else:
|
||||
raise Exception(f"Invalid value for plan: {plan_value}")
|
||||
|
||||
|
@ -27,7 +27,7 @@ jobs:
|
||||
- name: SimpleLogin HIBP check
|
||||
command: python /code/cron.py -j check_hibp
|
||||
shell: /bin/bash
|
||||
schedule: "*/5 * * * *"
|
||||
schedule: "13 */4 * * *"
|
||||
captureStderr: true
|
||||
concurrencyPolicy: Forbid
|
||||
onFailure:
|
||||
|
@ -149,6 +149,7 @@ from app.handler.unsubscribe_generator import UnsubscribeGenerator
|
||||
from app.handler.unsubscribe_handler import UnsubscribeHandler
|
||||
from app.log import LOG, set_message_id
|
||||
from app.mail_sender import sl_sendmail
|
||||
from app.mailbox_utils import get_mailbox_for_reply_phase
|
||||
from app.message_utils import message_to_bytes
|
||||
from app.models import (
|
||||
Alias,
|
||||
@ -172,7 +173,7 @@ from app.pgp_utils import (
|
||||
sign_data,
|
||||
load_public_key_and_check,
|
||||
)
|
||||
from app.utils import sanitize_email, canonicalize_email
|
||||
from app.utils import sanitize_email
|
||||
from init_app import load_pgp_public_keys
|
||||
from server import create_light_app
|
||||
|
||||
@ -599,6 +600,17 @@ def handle_forward(envelope, msg: Message, rcpt_to: str) -> List[Tuple[bool, str
|
||||
else:
|
||||
reply_to_contact = get_or_create_reply_to_contact(reply_to, alias, msg)
|
||||
|
||||
if alias.user.delete_on is not None:
|
||||
LOG.d(f"user {user} is pending to be deleted. Do not forward")
|
||||
EmailLog.create(
|
||||
contact_id=contact.id,
|
||||
user_id=contact.user_id,
|
||||
blocked=True,
|
||||
alias_id=contact.alias_id,
|
||||
commit=True,
|
||||
)
|
||||
return [(True, status.E502)]
|
||||
|
||||
if not alias.enabled or contact.block_forward:
|
||||
LOG.d("%s is disabled, do not forward", alias)
|
||||
EmailLog.create(
|
||||
@ -1008,7 +1020,6 @@ def handle_reply(envelope, msg: Message, rcpt_to: str) -> (bool, str):
|
||||
return False, status.E503
|
||||
|
||||
user = alias.user
|
||||
mail_from = envelope.mail_from
|
||||
|
||||
if not user.can_send_or_receive():
|
||||
LOG.i(f"User {user} cannot send emails")
|
||||
@ -1022,13 +1033,15 @@ def handle_reply(envelope, msg: Message, rcpt_to: str) -> (bool, str):
|
||||
return False, dmarc_delivery_status
|
||||
|
||||
# Anti-spoofing
|
||||
mailbox = get_mailbox_from_mail_from(mail_from, alias)
|
||||
mailbox = get_mailbox_for_reply_phase(
|
||||
envelope.mail_from, get_header_unicode(msg[headers.FROM]), alias
|
||||
)
|
||||
if not mailbox:
|
||||
if alias.disable_email_spoofing_check:
|
||||
# ignore this error, use default alias mailbox
|
||||
LOG.w(
|
||||
"ignore unknown sender to reverse-alias %s: %s -> %s",
|
||||
mail_from,
|
||||
envelope.mail_from,
|
||||
alias,
|
||||
contact,
|
||||
)
|
||||
@ -1367,32 +1380,6 @@ def replace_original_message_id(alias: Alias, email_log: EmailLog, msg: Message)
|
||||
msg[headers.REFERENCES] = " ".join(new_message_ids)
|
||||
|
||||
|
||||
def get_mailbox_from_mail_from(mail_from: str, alias) -> Optional[Mailbox]:
|
||||
"""return the corresponding mailbox given the mail_from and alias
|
||||
Usually the mail_from=mailbox.email but it can also be one of the authorized address
|
||||
"""
|
||||
|
||||
def __check(email_address: str, alias: Alias) -> Optional[Mailbox]:
|
||||
for mailbox in alias.mailboxes:
|
||||
if mailbox.email == email_address:
|
||||
return mailbox
|
||||
|
||||
for authorized_address in mailbox.authorized_addresses:
|
||||
if authorized_address.email == email_address:
|
||||
LOG.d(
|
||||
"Found an authorized address for %s %s %s",
|
||||
alias,
|
||||
mailbox,
|
||||
authorized_address,
|
||||
)
|
||||
return mailbox
|
||||
return None
|
||||
|
||||
# We need to first check for the uncanonicalized version because we still have users in the db with the
|
||||
# email non canonicalized. So if it matches the already existing one use that, otherwise check the canonical one
|
||||
return __check(mail_from, alias) or __check(canonicalize_email(mail_from), alias)
|
||||
|
||||
|
||||
def handle_unknown_mailbox(
|
||||
envelope, msg, reply_email: str, user: User, alias: Alias, contact: Contact
|
||||
):
|
||||
|
@ -164,6 +164,8 @@ def delete_mailbox_job(job: Job):
|
||||
Session.commit()
|
||||
LOG.d("Mailbox %s %s deleted", mailbox_id, mailbox_email)
|
||||
|
||||
if not job.payload.get("send_mail", True):
|
||||
return
|
||||
if alias_transferred_to:
|
||||
send_email(
|
||||
user.email,
|
||||
|
@ -1,6 +1,4 @@
|
||||
abacus
|
||||
abdomen
|
||||
abdominal
|
||||
abide
|
||||
abiding
|
||||
ability
|
||||
@ -1031,7 +1029,6 @@ chosen
|
||||
chowder
|
||||
chowtime
|
||||
chrome
|
||||
chubby
|
||||
chuck
|
||||
chug
|
||||
chummy
|
||||
@ -2041,8 +2038,6 @@ dwindling
|
||||
dynamic
|
||||
dynamite
|
||||
dynasty
|
||||
dyslexia
|
||||
dyslexic
|
||||
each
|
||||
eagle
|
||||
earache
|
||||
@ -2081,7 +2076,6 @@ eatery
|
||||
eating
|
||||
eats
|
||||
ebay
|
||||
ebony
|
||||
ebook
|
||||
ecard
|
||||
eccentric
|
||||
@ -2375,8 +2369,6 @@ exclude
|
||||
excluding
|
||||
exclusion
|
||||
exclusive
|
||||
excretion
|
||||
excretory
|
||||
excursion
|
||||
excusable
|
||||
excusably
|
||||
@ -2396,8 +2388,6 @@ existing
|
||||
exit
|
||||
exodus
|
||||
exonerate
|
||||
exorcism
|
||||
exorcist
|
||||
expand
|
||||
expanse
|
||||
expansion
|
||||
@ -2483,7 +2473,6 @@ fanning
|
||||
fantasize
|
||||
fantastic
|
||||
fantasy
|
||||
fascism
|
||||
fastball
|
||||
faster
|
||||
fasting
|
||||
@ -3028,7 +3017,6 @@ guiding
|
||||
guileless
|
||||
guise
|
||||
gulf
|
||||
gullible
|
||||
gully
|
||||
gulp
|
||||
gumball
|
||||
@ -3040,10 +3028,6 @@ gurgle
|
||||
gurgling
|
||||
guru
|
||||
gush
|
||||
gusto
|
||||
gusty
|
||||
gutless
|
||||
guts
|
||||
gutter
|
||||
guy
|
||||
guzzler
|
||||
@ -3242,8 +3226,6 @@ humble
|
||||
humbling
|
||||
humbly
|
||||
humid
|
||||
humiliate
|
||||
humility
|
||||
humming
|
||||
hummus
|
||||
humongous
|
||||
@ -3271,7 +3253,6 @@ hurray
|
||||
hurricane
|
||||
hurried
|
||||
hurry
|
||||
hurt
|
||||
husband
|
||||
hush
|
||||
husked
|
||||
@ -3292,8 +3273,6 @@ hypnotic
|
||||
hypnotism
|
||||
hypnotist
|
||||
hypnotize
|
||||
hypocrisy
|
||||
hypocrite
|
||||
ibuprofen
|
||||
ice
|
||||
iciness
|
||||
@ -3323,7 +3302,6 @@ image
|
||||
imaginary
|
||||
imagines
|
||||
imaging
|
||||
imbecile
|
||||
imitate
|
||||
imitation
|
||||
immerse
|
||||
@ -3746,7 +3724,6 @@ machine
|
||||
machinist
|
||||
magazine
|
||||
magenta
|
||||
maggot
|
||||
magical
|
||||
magician
|
||||
magma
|
||||
@ -3968,8 +3945,6 @@ multitude
|
||||
mumble
|
||||
mumbling
|
||||
mumbo
|
||||
mummified
|
||||
mummify
|
||||
mumps
|
||||
munchkin
|
||||
mundane
|
||||
@ -4022,8 +3997,6 @@ napped
|
||||
napping
|
||||
nappy
|
||||
narrow
|
||||
nastily
|
||||
nastiness
|
||||
national
|
||||
native
|
||||
nativity
|
||||
@ -4446,7 +4419,6 @@ pasta
|
||||
pasted
|
||||
pastel
|
||||
pastime
|
||||
pastor
|
||||
pastrami
|
||||
pasture
|
||||
pasty
|
||||
@ -4458,7 +4430,6 @@ path
|
||||
patience
|
||||
patient
|
||||
patio
|
||||
patriarch
|
||||
patriot
|
||||
patrol
|
||||
patronage
|
||||
@ -4549,7 +4520,6 @@ pettiness
|
||||
petty
|
||||
petunia
|
||||
phantom
|
||||
phobia
|
||||
phoenix
|
||||
phonebook
|
||||
phoney
|
||||
@ -4608,7 +4578,6 @@ plot
|
||||
plow
|
||||
ploy
|
||||
pluck
|
||||
plug
|
||||
plunder
|
||||
plunging
|
||||
plural
|
||||
@ -4875,7 +4844,6 @@ pupil
|
||||
puppet
|
||||
puppy
|
||||
purchase
|
||||
pureblood
|
||||
purebred
|
||||
purely
|
||||
pureness
|
||||
@ -5047,7 +5015,6 @@ recharger
|
||||
recipient
|
||||
recital
|
||||
recite
|
||||
reckless
|
||||
reclaim
|
||||
recliner
|
||||
reclining
|
||||
@ -5440,7 +5407,6 @@ rubdown
|
||||
ruby
|
||||
ruckus
|
||||
rudder
|
||||
rug
|
||||
ruined
|
||||
rule
|
||||
rumble
|
||||
@ -5448,7 +5414,6 @@ rumbling
|
||||
rummage
|
||||
rumor
|
||||
runaround
|
||||
rundown
|
||||
runner
|
||||
running
|
||||
runny
|
||||
@ -5518,7 +5483,6 @@ sandpaper
|
||||
sandpit
|
||||
sandstone
|
||||
sandstorm
|
||||
sandworm
|
||||
sandy
|
||||
sanitary
|
||||
sanitizer
|
||||
@ -5541,7 +5505,6 @@ satisfy
|
||||
saturate
|
||||
saturday
|
||||
sauciness
|
||||
saucy
|
||||
sauna
|
||||
savage
|
||||
savanna
|
||||
@ -5552,7 +5515,6 @@ savor
|
||||
saxophone
|
||||
say
|
||||
scabbed
|
||||
scabby
|
||||
scalded
|
||||
scalding
|
||||
scale
|
||||
@ -5587,7 +5549,6 @@ science
|
||||
scientist
|
||||
scion
|
||||
scoff
|
||||
scolding
|
||||
scone
|
||||
scoop
|
||||
scooter
|
||||
@ -5651,8 +5612,6 @@ sedate
|
||||
sedation
|
||||
sedative
|
||||
sediment
|
||||
seduce
|
||||
seducing
|
||||
segment
|
||||
seismic
|
||||
seizing
|
||||
@ -5899,7 +5858,6 @@ skimpily
|
||||
skincare
|
||||
skinless
|
||||
skinning
|
||||
skinny
|
||||
skintight
|
||||
skipper
|
||||
skipping
|
||||
@ -6248,17 +6206,12 @@ stifle
|
||||
stifling
|
||||
stillness
|
||||
stilt
|
||||
stimulant
|
||||
stimulate
|
||||
stimuli
|
||||
stimulus
|
||||
stinger
|
||||
stingily
|
||||
stinging
|
||||
stingray
|
||||
stingy
|
||||
stinking
|
||||
stinky
|
||||
stipend
|
||||
stipulate
|
||||
stir
|
||||
@ -6866,7 +6819,6 @@ unbent
|
||||
unbiased
|
||||
unbitten
|
||||
unblended
|
||||
unblessed
|
||||
unblock
|
||||
unbolted
|
||||
unbounded
|
||||
@ -6947,7 +6899,6 @@ undertone
|
||||
undertook
|
||||
undertow
|
||||
underuse
|
||||
underwear
|
||||
underwent
|
||||
underwire
|
||||
undesired
|
||||
@ -7031,7 +6982,6 @@ uninsured
|
||||
uninvited
|
||||
union
|
||||
uniquely
|
||||
unisexual
|
||||
unison
|
||||
unissued
|
||||
unit
|
||||
@ -7492,8 +7442,6 @@ wheat
|
||||
whenever
|
||||
whiff
|
||||
whimsical
|
||||
whinny
|
||||
whiny
|
||||
whisking
|
||||
whoever
|
||||
whole
|
||||
@ -7599,7 +7547,6 @@ wrongness
|
||||
wrought
|
||||
xbox
|
||||
xerox
|
||||
yahoo
|
||||
yam
|
||||
yanking
|
||||
yapping
|
||||
|
35
app/migrations/versions/2024_112619_085f77996ce3_.py
Normal file
35
app/migrations/versions/2024_112619_085f77996ce3_.py
Normal file
@ -0,0 +1,35 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: 085f77996ce3
|
||||
Revises: 0f3ee15b0014
|
||||
Create Date: 2024-11-26 19:20:32.227899
|
||||
|
||||
"""
|
||||
import sqlalchemy_utils
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.dialects import postgresql
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '085f77996ce3'
|
||||
down_revision = '0f3ee15b0014'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.add_column('partner_subscription', sa.Column('lifetime', sa.Boolean(), server_default='0', nullable=False))
|
||||
op.alter_column('partner_subscription', 'end_at',
|
||||
existing_type=postgresql.TIMESTAMP(),
|
||||
nullable=True)
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.alter_column('partner_subscription', 'end_at',
|
||||
existing_type=postgresql.TIMESTAMP(),
|
||||
nullable=False)
|
||||
op.drop_column('partner_subscription', 'lifetime')
|
||||
# ### end Alembic commands ###
|
@ -1,3 +1,83 @@
|
||||
[project]
|
||||
name = "SimpleLogin"
|
||||
version = "0.1.0"
|
||||
description = "SimpleLogin partner API"
|
||||
authors = [ {name="SimpleLogin", email="dev@simplelogin.io"}]
|
||||
license = "MIT"
|
||||
repository = "https://github.com/simple-login/app"
|
||||
keywords = ["email", "alias", "privacy", "oauth2", "openid"]
|
||||
packages = [
|
||||
{ include = "app/" },
|
||||
{ include = "migrations/" },
|
||||
]
|
||||
include = ["templates/*", "templates/**/*", "local_data/*.txt"]
|
||||
|
||||
requires-python = "~=3.10"
|
||||
|
||||
dependencies = [
|
||||
"flask ~= 1.1.2",
|
||||
"flask_login ~= 0.5.0",
|
||||
"wtforms ~= 2.3.3",
|
||||
"unidecode ~= 1.1.1",
|
||||
"gunicorn ~= 20.0.4",
|
||||
"bcrypt ~= 3.2.0",
|
||||
"python-dotenv ~= 0.14.0",
|
||||
"ipython ~= 7.31.1",
|
||||
"sqlalchemy_utils ~= 0.36.8",
|
||||
"psycopg2-binary ~= 2.9.3",
|
||||
"sentry_sdk ~= 2.20.0",
|
||||
"blinker ~= 1.4",
|
||||
"arrow ~= 0.16.0",
|
||||
"Flask-WTF ~= 0.14.3",
|
||||
"boto3 ~= 1.35.37",
|
||||
"Flask-Migrate ~= 2.5.3",
|
||||
"flask_admin ~= 1.5.6",
|
||||
"flask-cors ~= 3.0.9",
|
||||
"watchtower ~= 0.8.0",
|
||||
"sqlalchemy-utils == 0.36.8",
|
||||
"jwcrypto ~= 0.8",
|
||||
"yacron>=0.19.0",
|
||||
"flask-debugtoolbar ~= 0.11.0",
|
||||
"requests_oauthlib ~= 1.3.0",
|
||||
"pyopenssl ~= 19.1.0",
|
||||
"aiosmtpd ~= 1.2",
|
||||
"dnspython == 2.6.1",
|
||||
"coloredlogs ~= 14.0",
|
||||
"pycryptodome ~= 3.9.8",
|
||||
"phpserialize ~= 1.3",
|
||||
"dkimpy ~= 1.0.5",
|
||||
"pyotp ~= 2.4.0",
|
||||
"flask_profiler ~= 1.8.1",
|
||||
"facebook-sdk ~= 3.1.0",
|
||||
"google-api-python-client ~= 1.12.3",
|
||||
"google-auth-httplib2 ~= 0.0.4",
|
||||
"python-gnupg ~= 0.4.6",
|
||||
"webauthn ~= 0.4.7",
|
||||
"pyspf ~= 2.0.14",
|
||||
"Flask-Limiter == 1.4",
|
||||
"memory_profiler ~= 0.57.0",
|
||||
"gevent ~= 24.11.1",
|
||||
"email-validator ~= 1.1.3",
|
||||
"PGPy == 0.5.4",
|
||||
"coinbase-commerce ~= 1.0.1",
|
||||
"requests ~= 2.25.1",
|
||||
"newrelic ~= 8.8.0",
|
||||
"flanker ~= 0.9.11",
|
||||
"pyre2 ~= 0.3.6",
|
||||
"tldextract ~= 3.1.2",
|
||||
"flask-debugtoolbar-sqlalchemy ~= 0.2.0",
|
||||
"twilio ~= 7.3.2",
|
||||
"Deprecated ~= 1.2.13",
|
||||
"MarkupSafe~=1.1.1",
|
||||
"cryptography ~= 37.0.1",
|
||||
"SQLAlchemy ~= 1.3.24",
|
||||
"redis ~= 4.5.3",
|
||||
"newrelic-telemetry-sdk ~= 0.5.0",
|
||||
"aiospamc == 0.10",
|
||||
"itsdangerous ~= 1.1.0",
|
||||
"werkzeug ~= 1.0.1",
|
||||
]
|
||||
|
||||
[tool.black]
|
||||
target-version = ['py310']
|
||||
exclude = '''
|
||||
@ -27,7 +107,6 @@ exclude = [".venv", "migrations", "app/events/generated"]
|
||||
indent = 2
|
||||
profile = "jinja"
|
||||
blank_line_after_tag = "if,for,include,load,extends,block,endcall"
|
||||
|
||||
# H006: Images should have a height attribute
|
||||
# H013: Images should have an alt attribute
|
||||
# H016: Missing title tag in html. | False positive on template
|
||||
@ -43,92 +122,26 @@ blank_line_after_tag = "if,for,include,load,extends,block,endcall"
|
||||
# T001: Variables should be wrapped in a single whitespace. | Messes up with comments
|
||||
ignore = "H006,H013,H016,H017,H019,H021,H025,H030,H031,T003,J004,J018,T001"
|
||||
|
||||
[tool.poetry]
|
||||
name = "SimpleLogin"
|
||||
version = "0.1.0"
|
||||
description = "open-source email alias solution"
|
||||
authors = ["SimpleLogin <dev@simplelogin.io>"]
|
||||
license = "MIT"
|
||||
repository = "https://github.com/simple-login/app"
|
||||
keywords = ["email", "alias", "privacy", "oauth2", "openid"]
|
||||
packages = [
|
||||
{ include = "app/" },
|
||||
{ include = "migrations/" },
|
||||
[tool.uv]
|
||||
dev-dependencies = [
|
||||
"pytest ~= 7.0.0",
|
||||
"pytest-cov ~= 3.0.0",
|
||||
"pre-commit ~= 2.17.0",
|
||||
"black ~= 22.1.0",
|
||||
"djlint ~= 1.3.0",
|
||||
"pylint ~= 2.14.4",
|
||||
"ruff ~= 0.1.5",
|
||||
]
|
||||
include = ["templates/*", "templates/**/*", "local_data/*.txt"]
|
||||
|
||||
[tool.poetry.dependencies]
|
||||
python = "^3.10"
|
||||
flask = "^1.1.2"
|
||||
flask_login = "^0.5.0"
|
||||
wtforms = "^2.3.3"
|
||||
unidecode = "^1.1.1"
|
||||
gunicorn = "^20.0.4"
|
||||
bcrypt = "^3.2.0"
|
||||
python-dotenv = "^0.14.0"
|
||||
ipython = "^7.31.1"
|
||||
sqlalchemy_utils = "^0.36.8"
|
||||
psycopg2-binary = "^2.9.3"
|
||||
sentry_sdk = "^2.16.0"
|
||||
blinker = "^1.4"
|
||||
arrow = "^0.16.0"
|
||||
Flask-WTF = "^0.14.3"
|
||||
boto3 = "^1.15.9"
|
||||
Flask-Migrate = "^2.5.3"
|
||||
flask_admin = "^1.5.6"
|
||||
flask-cors = "^3.0.9"
|
||||
watchtower = "^0.8.0"
|
||||
sqlalchemy-utils = "^0.36.8"
|
||||
jwcrypto = "^0.8"
|
||||
yacron = "^0.11.1"
|
||||
flask-debugtoolbar = "^0.11.0"
|
||||
requests_oauthlib = "^1.3.0"
|
||||
pyopenssl = "^19.1.0"
|
||||
aiosmtpd = "^1.2"
|
||||
dnspython = "^2.0.0"
|
||||
coloredlogs = "^14.0"
|
||||
pycryptodome = "^3.9.8"
|
||||
phpserialize = "^1.3"
|
||||
dkimpy = "^1.0.5"
|
||||
pyotp = "^2.4.0"
|
||||
flask_profiler = "^1.8.1"
|
||||
facebook-sdk = "^3.1.0"
|
||||
google-api-python-client = "^1.12.3"
|
||||
google-auth-httplib2 = "^0.0.4"
|
||||
python-gnupg = "^0.4.6"
|
||||
webauthn = "^0.4.7"
|
||||
pyspf = "^2.0.14"
|
||||
Flask-Limiter = "^1.4"
|
||||
memory_profiler = "^0.57.0"
|
||||
gevent = "22.10.2"
|
||||
email_validator = "^1.1.1"
|
||||
PGPy = "0.5.4"
|
||||
coinbase-commerce = "^1.0.1"
|
||||
requests = "^2.25.1"
|
||||
newrelic = "8.8.0"
|
||||
flanker = "^0.9.11"
|
||||
pyre2 = "^0.3.6"
|
||||
tldextract = "^3.1.2"
|
||||
flask-debugtoolbar-sqlalchemy = "^0.2.0"
|
||||
twilio = "^7.3.2"
|
||||
Deprecated = "^1.2.13"
|
||||
cryptography = "37.0.1"
|
||||
SQLAlchemy = "1.3.24"
|
||||
redis = "^4.5.3"
|
||||
newrelic-telemetry-sdk = "^0.5.0"
|
||||
aiospamc = "0.10"
|
||||
|
||||
[tool.poetry.dev-dependencies]
|
||||
pytest = "^7.0.0"
|
||||
pytest-cov = "^3.0.0"
|
||||
black = "^22.1.0"
|
||||
djlint = "^1.3.0"
|
||||
pylint = "^2.14.4"
|
||||
|
||||
[tool.poetry.group.dev.dependencies]
|
||||
ruff = "^0.1.5"
|
||||
pre-commit = "^3.8.0"
|
||||
|
||||
[build-system]
|
||||
requires = ["poetry>=0.12"]
|
||||
build-backend = "poetry.masonry.api"
|
||||
requires = ["hatchling"]
|
||||
build-backend = "hatchling.build"
|
||||
|
||||
[tool.hatch.metadata]
|
||||
allow-direct-references = true
|
||||
|
||||
[tool.hatch.build.targets.sdist]
|
||||
include = ["app", "local_data", "migrations", "templates"]
|
||||
|
||||
[tool.hatch.build.targets.wheel]
|
||||
packages = ["app", "local_data", "migrations", "templates"]
|
||||
|
469
app/requirements-dev.lock
Normal file
469
app/requirements-dev.lock
Normal file
@ -0,0 +1,469 @@
|
||||
# generated by rye
|
||||
# use `rye lock` or `rye sync` to update this lockfile
|
||||
#
|
||||
# last locked with the following flags:
|
||||
# pre: false
|
||||
# features: []
|
||||
# all-features: false
|
||||
# with-sources: false
|
||||
# generate-hashes: false
|
||||
# universal: false
|
||||
|
||||
-e file:.
|
||||
aiohappyeyeballs==2.4.4
|
||||
# via aiohttp
|
||||
aiohttp==3.11.11
|
||||
# via yacron
|
||||
aiosignal==1.3.2
|
||||
# via aiohttp
|
||||
aiosmtpd==1.4.6
|
||||
# via simplelogin
|
||||
aiosmtplib==3.0.2
|
||||
# via yacron
|
||||
aiospamc==0.10.0
|
||||
# via simplelogin
|
||||
alembic==1.14.0
|
||||
# via flask-migrate
|
||||
appnope==0.1.4
|
||||
# via ipython
|
||||
arrow==0.16.0
|
||||
# via simplelogin
|
||||
astroid==2.11.7
|
||||
# via pylint
|
||||
async-timeout==5.0.1
|
||||
# via aiohttp
|
||||
# via redis
|
||||
atpublic==5.0
|
||||
# via aiosmtpd
|
||||
attrs==24.3.0
|
||||
# via aiohttp
|
||||
# via aiosmtpd
|
||||
# via flanker
|
||||
# via pytest
|
||||
backcall==0.2.0
|
||||
# via ipython
|
||||
bcrypt==3.2.2
|
||||
# via simplelogin
|
||||
black==22.1.0
|
||||
blinker==1.9.0
|
||||
# via flask-debugtoolbar
|
||||
# via simplelogin
|
||||
boto3==1.35.99
|
||||
# via simplelogin
|
||||
# via watchtower
|
||||
botocore==1.35.99
|
||||
# via boto3
|
||||
# via s3transfer
|
||||
cachetools==5.5.0
|
||||
# via google-auth
|
||||
cbor2==5.6.5
|
||||
# via webauthn
|
||||
certifi==2024.12.14
|
||||
# via aiospamc
|
||||
# via requests
|
||||
# via sentry-sdk
|
||||
cffi==1.17.1
|
||||
# via bcrypt
|
||||
# via cryptography
|
||||
cfgv==3.4.0
|
||||
# via pre-commit
|
||||
chardet==4.0.0
|
||||
# via flanker
|
||||
# via requests
|
||||
click==8.1.8
|
||||
# via black
|
||||
# via djlint
|
||||
# via flask
|
||||
# via typer
|
||||
coinbase-commerce==1.0.1
|
||||
# via simplelogin
|
||||
colorama==0.4.6
|
||||
# via djlint
|
||||
coloredlogs==14.3
|
||||
# via simplelogin
|
||||
coverage==7.6.10
|
||||
# via pytest-cov
|
||||
crontab==0.22.8
|
||||
# via yacron
|
||||
cryptography==37.0.4
|
||||
# via flanker
|
||||
# via jwcrypto
|
||||
# via pgpy
|
||||
# via pyopenssl
|
||||
# via simplelogin
|
||||
# via webauthn
|
||||
decorator==5.1.1
|
||||
# via ipython
|
||||
deprecated==1.2.15
|
||||
# via jwcrypto
|
||||
# via limits
|
||||
# via simplelogin
|
||||
dill==0.3.9
|
||||
# via pylint
|
||||
distlib==0.3.9
|
||||
# via virtualenv
|
||||
djlint==1.3.0
|
||||
dkimpy==1.0.6
|
||||
# via simplelogin
|
||||
dnspython==2.6.1
|
||||
# via dkimpy
|
||||
# via email-validator
|
||||
# via simplelogin
|
||||
email-validator==1.1.3
|
||||
# via simplelogin
|
||||
facebook-sdk==3.1.0
|
||||
# via simplelogin
|
||||
filelock==3.16.1
|
||||
# via tldextract
|
||||
# via virtualenv
|
||||
flanker==0.9.11
|
||||
# via simplelogin
|
||||
flask==1.1.2
|
||||
# via flask-admin
|
||||
# via flask-cors
|
||||
# via flask-debugtoolbar
|
||||
# via flask-httpauth
|
||||
# via flask-limiter
|
||||
# via flask-login
|
||||
# via flask-migrate
|
||||
# via flask-profiler
|
||||
# via flask-sqlalchemy
|
||||
# via flask-wtf
|
||||
# via simplelogin
|
||||
flask-admin==1.5.8
|
||||
# via simplelogin
|
||||
flask-cors==3.0.10
|
||||
# via simplelogin
|
||||
flask-debugtoolbar==0.11.0
|
||||
# via flask-debugtoolbar-sqlalchemy
|
||||
# via simplelogin
|
||||
flask-debugtoolbar-sqlalchemy==0.2.0
|
||||
# via simplelogin
|
||||
flask-httpauth==4.8.0
|
||||
# via flask-profiler
|
||||
flask-limiter==1.4
|
||||
# via simplelogin
|
||||
flask-login==0.5.0
|
||||
# via simplelogin
|
||||
flask-migrate==2.5.3
|
||||
# via simplelogin
|
||||
flask-profiler==1.8.1
|
||||
# via simplelogin
|
||||
flask-sqlalchemy==2.5.1
|
||||
# via flask-migrate
|
||||
flask-wtf==0.14.3
|
||||
# via simplelogin
|
||||
frozenlist==1.5.0
|
||||
# via aiohttp
|
||||
# via aiosignal
|
||||
future==1.0.0
|
||||
# via webauthn
|
||||
gevent==24.11.1
|
||||
# via simplelogin
|
||||
google-api-core==2.24.0
|
||||
# via google-api-python-client
|
||||
google-api-python-client==1.12.11
|
||||
# via simplelogin
|
||||
google-auth==2.37.0
|
||||
# via google-api-core
|
||||
# via google-api-python-client
|
||||
# via google-auth-httplib2
|
||||
google-auth-httplib2==0.0.4
|
||||
# via google-api-python-client
|
||||
# via simplelogin
|
||||
googleapis-common-protos==1.66.0
|
||||
# via google-api-core
|
||||
greenlet==3.1.1
|
||||
# via gevent
|
||||
gunicorn==20.0.4
|
||||
# via simplelogin
|
||||
html-tag-names==0.1.2
|
||||
# via djlint
|
||||
html-void-elements==0.1.0
|
||||
# via djlint
|
||||
httplib2==0.22.0
|
||||
# via google-api-python-client
|
||||
# via google-auth-httplib2
|
||||
humanfriendly==10.0
|
||||
# via coloredlogs
|
||||
identify==2.6.5
|
||||
# via pre-commit
|
||||
idna==2.10
|
||||
# via email-validator
|
||||
# via flanker
|
||||
# via requests
|
||||
# via tldextract
|
||||
# via yarl
|
||||
importlib-metadata==4.13.0
|
||||
# via djlint
|
||||
iniconfig==2.0.0
|
||||
# via pytest
|
||||
ipython==7.31.1
|
||||
# via simplelogin
|
||||
isort==5.13.2
|
||||
# via pylint
|
||||
itsdangerous==1.1.0
|
||||
# via flask
|
||||
# via flask-debugtoolbar
|
||||
# via flask-wtf
|
||||
# via simplelogin
|
||||
jedi==0.19.2
|
||||
# via ipython
|
||||
jinja2==2.11.3
|
||||
# via flask
|
||||
# via yacron
|
||||
jmespath==1.0.1
|
||||
# via boto3
|
||||
# via botocore
|
||||
jwcrypto==0.9.1
|
||||
# via simplelogin
|
||||
lazy-object-proxy==1.10.0
|
||||
# via astroid
|
||||
limits==4.0.0
|
||||
# via flask-limiter
|
||||
loguru==0.7.3
|
||||
# via aiospamc
|
||||
mako==1.3.8
|
||||
# via alembic
|
||||
markupsafe==1.1.1
|
||||
# via jinja2
|
||||
# via mako
|
||||
# via simplelogin
|
||||
# via wtforms
|
||||
matplotlib-inline==0.1.7
|
||||
# via ipython
|
||||
mccabe==0.7.0
|
||||
# via pylint
|
||||
memory-profiler==0.57.0
|
||||
# via simplelogin
|
||||
multidict==6.1.0
|
||||
# via aiohttp
|
||||
# via yarl
|
||||
mypy-extensions==1.0.0
|
||||
# via black
|
||||
newrelic==8.8.1
|
||||
# via simplelogin
|
||||
newrelic-telemetry-sdk==0.5.1
|
||||
# via simplelogin
|
||||
nodeenv==1.9.1
|
||||
# via pre-commit
|
||||
oauthlib==3.2.2
|
||||
# via requests-oauthlib
|
||||
packaging==24.2
|
||||
# via limits
|
||||
# via pytest
|
||||
parso==0.8.4
|
||||
# via jedi
|
||||
pathspec==0.9.0
|
||||
# via black
|
||||
# via djlint
|
||||
pexpect==4.9.0
|
||||
# via ipython
|
||||
pgpy==0.5.4
|
||||
# via simplelogin
|
||||
phpserialize==1.3
|
||||
# via simplelogin
|
||||
pickleshare==0.7.5
|
||||
# via ipython
|
||||
platformdirs==4.3.6
|
||||
# via black
|
||||
# via pylint
|
||||
# via virtualenv
|
||||
pluggy==1.5.0
|
||||
# via pytest
|
||||
ply==3.11
|
||||
# via flanker
|
||||
pre-commit==2.17.0
|
||||
prompt-toolkit==3.0.48
|
||||
# via ipython
|
||||
propcache==0.2.1
|
||||
# via aiohttp
|
||||
# via yarl
|
||||
proto-plus==1.25.0
|
||||
# via google-api-core
|
||||
protobuf==5.29.3
|
||||
# via google-api-core
|
||||
# via googleapis-common-protos
|
||||
# via proto-plus
|
||||
psutil==6.1.1
|
||||
# via memory-profiler
|
||||
psycopg2-binary==2.9.10
|
||||
# via simplelogin
|
||||
ptyprocess==0.7.0
|
||||
# via pexpect
|
||||
py==1.11.0
|
||||
# via pytest
|
||||
pyasn1==0.6.1
|
||||
# via pgpy
|
||||
# via pyasn1-modules
|
||||
# via rsa
|
||||
pyasn1-modules==0.4.1
|
||||
# via google-auth
|
||||
pycparser==2.22
|
||||
# via cffi
|
||||
pycryptodome==3.9.9
|
||||
# via simplelogin
|
||||
pygments==2.19.1
|
||||
# via flask-debugtoolbar-sqlalchemy
|
||||
# via ipython
|
||||
pyjwt==2.10.1
|
||||
# via twilio
|
||||
pylint==2.14.5
|
||||
pyopenssl==19.1.0
|
||||
# via simplelogin
|
||||
# via webauthn
|
||||
pyotp==2.4.1
|
||||
# via simplelogin
|
||||
pyparsing==3.2.1
|
||||
# via httplib2
|
||||
pyre2==0.3.6
|
||||
# via simplelogin
|
||||
pyspf==2.0.14
|
||||
# via simplelogin
|
||||
pytest==7.0.1
|
||||
# via pytest-cov
|
||||
pytest-cov==3.0.0
|
||||
python-dateutil==2.9.0.post0
|
||||
# via arrow
|
||||
# via botocore
|
||||
# via strictyaml
|
||||
python-dotenv==0.14.0
|
||||
# via simplelogin
|
||||
python-gnupg==0.4.9
|
||||
# via simplelogin
|
||||
pytz==2024.2
|
||||
# via twilio
|
||||
# via yacron
|
||||
pyyaml==6.0.2
|
||||
# via djlint
|
||||
# via pre-commit
|
||||
redis==4.5.5
|
||||
# via simplelogin
|
||||
regex==2022.10.31
|
||||
# via djlint
|
||||
# via flanker
|
||||
requests==2.25.1
|
||||
# via coinbase-commerce
|
||||
# via facebook-sdk
|
||||
# via google-api-core
|
||||
# via requests-file
|
||||
# via requests-oauthlib
|
||||
# via simplelogin
|
||||
# via tldextract
|
||||
# via twilio
|
||||
requests-file==2.1.0
|
||||
# via tldextract
|
||||
requests-oauthlib==1.3.1
|
||||
# via simplelogin
|
||||
rsa==4.9
|
||||
# via google-auth
|
||||
ruamel-yaml==0.17.4
|
||||
# via yacron
|
||||
ruff==0.1.15
|
||||
s3transfer==0.10.4
|
||||
# via boto3
|
||||
sentry-sdk==2.20.0
|
||||
# via simplelogin
|
||||
# via yacron
|
||||
setuptools==75.8.0
|
||||
# via astroid
|
||||
# via gunicorn
|
||||
# via ipython
|
||||
# via zope-event
|
||||
# via zope-interface
|
||||
simplejson==3.19.3
|
||||
# via flask-profiler
|
||||
six==1.17.0
|
||||
# via coinbase-commerce
|
||||
# via flanker
|
||||
# via flask-cors
|
||||
# via flask-limiter
|
||||
# via google-api-python-client
|
||||
# via google-auth-httplib2
|
||||
# via jwcrypto
|
||||
# via pgpy
|
||||
# via pyopenssl
|
||||
# via python-dateutil
|
||||
# via sqlalchemy-utils
|
||||
# via webauthn
|
||||
sqlalchemy==1.3.24
|
||||
# via alembic
|
||||
# via flask-debugtoolbar-sqlalchemy
|
||||
# via flask-sqlalchemy
|
||||
# via simplelogin
|
||||
# via sqlalchemy-utils
|
||||
sqlalchemy-utils==0.36.8
|
||||
# via simplelogin
|
||||
sqlparse==0.5.3
|
||||
# via flask-debugtoolbar-sqlalchemy
|
||||
strictyaml==1.7.3
|
||||
# via yacron
|
||||
tld==0.13
|
||||
# via flanker
|
||||
tldextract==3.1.2
|
||||
# via simplelogin
|
||||
toml==0.10.2
|
||||
# via pre-commit
|
||||
tomli==2.2.1
|
||||
# via black
|
||||
# via coverage
|
||||
# via djlint
|
||||
# via pylint
|
||||
# via pytest
|
||||
tomlkit==0.13.2
|
||||
# via pylint
|
||||
tqdm==4.67.1
|
||||
# via djlint
|
||||
traitlets==5.14.3
|
||||
# via ipython
|
||||
# via matplotlib-inline
|
||||
twilio==7.3.2
|
||||
# via simplelogin
|
||||
typer==0.9.4
|
||||
# via aiospamc
|
||||
typing-extensions==4.12.2
|
||||
# via aiospamc
|
||||
# via alembic
|
||||
# via limits
|
||||
# via multidict
|
||||
# via typer
|
||||
unidecode==1.1.2
|
||||
# via simplelogin
|
||||
uritemplate==3.0.1
|
||||
# via google-api-python-client
|
||||
urllib3==1.26.20
|
||||
# via botocore
|
||||
# via newrelic-telemetry-sdk
|
||||
# via requests
|
||||
# via sentry-sdk
|
||||
virtualenv==20.29.0
|
||||
# via pre-commit
|
||||
watchtower==0.8.0
|
||||
# via simplelogin
|
||||
wcwidth==0.2.13
|
||||
# via prompt-toolkit
|
||||
webauthn==0.4.7
|
||||
# via simplelogin
|
||||
webob==1.8.9
|
||||
# via flanker
|
||||
werkzeug==1.0.1
|
||||
# via flask
|
||||
# via flask-debugtoolbar
|
||||
# via simplelogin
|
||||
wrapt==1.17.2
|
||||
# via astroid
|
||||
# via deprecated
|
||||
wtforms==2.3.3
|
||||
# via flask-admin
|
||||
# via flask-wtf
|
||||
# via simplelogin
|
||||
yacron==0.19.0
|
||||
# via simplelogin
|
||||
yarl==1.18.3
|
||||
# via aiohttp
|
||||
zipp==3.21.0
|
||||
# via importlib-metadata
|
||||
zope-event==5.0
|
||||
# via gevent
|
||||
zope-interface==7.2
|
||||
# via gevent
|
392
app/requirements.lock
Normal file
392
app/requirements.lock
Normal file
@ -0,0 +1,392 @@
|
||||
# generated by rye
|
||||
# use `rye lock` or `rye sync` to update this lockfile
|
||||
#
|
||||
# last locked with the following flags:
|
||||
# pre: false
|
||||
# features: []
|
||||
# all-features: false
|
||||
# with-sources: false
|
||||
# generate-hashes: false
|
||||
# universal: false
|
||||
|
||||
-e file:.
|
||||
aiohttp==3.8.4
|
||||
# via google-auth
|
||||
# via yacron
|
||||
aiosignal==1.2.0
|
||||
# via aiohttp
|
||||
aiosmtpd==1.4.2
|
||||
# via simplelogin
|
||||
aiosmtplib==1.1.4
|
||||
# via yacron
|
||||
aiospamc==0.10.0
|
||||
# via simplelogin
|
||||
alembic==1.4.3
|
||||
# via flask-migrate
|
||||
appnope==0.1.0
|
||||
# via ipython
|
||||
arrow==0.16.0
|
||||
# via simplelogin
|
||||
async-timeout==4.0.2
|
||||
# via aiohttp
|
||||
# via redis
|
||||
atpublic==2.0
|
||||
# via aiosmtpd
|
||||
attrs==20.2.0
|
||||
# via aiohttp
|
||||
# via aiosmtpd
|
||||
# via flanker
|
||||
backcall==0.2.0
|
||||
# via ipython
|
||||
bcrypt==3.2.0
|
||||
# via simplelogin
|
||||
blinker==1.4
|
||||
# via flask-debugtoolbar
|
||||
# via simplelogin
|
||||
boto3==1.35.99
|
||||
# via simplelogin
|
||||
# via watchtower
|
||||
botocore==1.35.99
|
||||
# via boto3
|
||||
# via s3transfer
|
||||
cachetools==4.1.1
|
||||
# via google-auth
|
||||
cbor2==5.2.0
|
||||
# via webauthn
|
||||
certifi==2019.11.28
|
||||
# via aiospamc
|
||||
# via requests
|
||||
# via sentry-sdk
|
||||
cffi==1.14.4
|
||||
# via bcrypt
|
||||
# via cryptography
|
||||
chardet==3.0.4
|
||||
# via flanker
|
||||
# via requests
|
||||
charset-normalizer==3.4.1
|
||||
# via aiohttp
|
||||
click==8.0.3
|
||||
# via flask
|
||||
# via typer
|
||||
coinbase-commerce==1.0.1
|
||||
# via simplelogin
|
||||
coloredlogs==14.0
|
||||
# via simplelogin
|
||||
crontab==0.22.8
|
||||
# via yacron
|
||||
cryptography==37.0.1
|
||||
# via flanker
|
||||
# via jwcrypto
|
||||
# via pgpy
|
||||
# via pyopenssl
|
||||
# via simplelogin
|
||||
# via webauthn
|
||||
decorator==4.4.2
|
||||
# via ipython
|
||||
deprecated==1.2.13
|
||||
# via simplelogin
|
||||
dkimpy==1.0.5
|
||||
# via simplelogin
|
||||
dnspython==2.6.1
|
||||
# via dkimpy
|
||||
# via email-validator
|
||||
# via simplelogin
|
||||
email-validator==1.1.3
|
||||
# via simplelogin
|
||||
facebook-sdk==3.1.0
|
||||
# via simplelogin
|
||||
filelock==3.15.4
|
||||
# via tldextract
|
||||
flanker==0.9.11
|
||||
# via simplelogin
|
||||
flask==1.1.2
|
||||
# via flask-admin
|
||||
# via flask-cors
|
||||
# via flask-debugtoolbar
|
||||
# via flask-httpauth
|
||||
# via flask-limiter
|
||||
# via flask-login
|
||||
# via flask-migrate
|
||||
# via flask-profiler
|
||||
# via flask-sqlalchemy
|
||||
# via flask-wtf
|
||||
# via simplelogin
|
||||
flask-admin==1.5.7
|
||||
# via simplelogin
|
||||
flask-cors==3.0.9
|
||||
# via simplelogin
|
||||
flask-debugtoolbar==0.11.0
|
||||
# via flask-debugtoolbar-sqlalchemy
|
||||
# via simplelogin
|
||||
flask-debugtoolbar-sqlalchemy==0.2.0
|
||||
# via simplelogin
|
||||
flask-httpauth==4.1.0
|
||||
# via flask-profiler
|
||||
flask-limiter==1.4
|
||||
# via simplelogin
|
||||
flask-login==0.5.0
|
||||
# via simplelogin
|
||||
flask-migrate==2.5.3
|
||||
# via simplelogin
|
||||
flask-profiler==1.8.1
|
||||
# via simplelogin
|
||||
flask-sqlalchemy==2.5.1
|
||||
# via flask-migrate
|
||||
flask-wtf==0.14.3
|
||||
# via simplelogin
|
||||
frozenlist==1.3.3
|
||||
# via aiohttp
|
||||
# via aiosignal
|
||||
future==0.18.3
|
||||
# via webauthn
|
||||
gevent==24.11.1
|
||||
# via simplelogin
|
||||
google-api-core==1.22.2
|
||||
# via google-api-python-client
|
||||
google-api-python-client==1.12.3
|
||||
# via simplelogin
|
||||
google-auth==1.22.0
|
||||
# via google-api-core
|
||||
# via google-api-python-client
|
||||
# via google-auth-httplib2
|
||||
google-auth-httplib2==0.0.4
|
||||
# via google-api-python-client
|
||||
# via simplelogin
|
||||
googleapis-common-protos==1.52.0
|
||||
# via google-api-core
|
||||
greenlet==3.1.1
|
||||
# via gevent
|
||||
gunicorn==20.0.4
|
||||
# via simplelogin
|
||||
httplib2==0.22.0
|
||||
# via google-api-python-client
|
||||
# via google-auth-httplib2
|
||||
humanfriendly==8.2
|
||||
# via coloredlogs
|
||||
idna==2.10
|
||||
# via email-validator
|
||||
# via flanker
|
||||
# via requests
|
||||
# via tldextract
|
||||
# via yarl
|
||||
ipython==7.31.1
|
||||
# via simplelogin
|
||||
ipython-genutils==0.2.0
|
||||
# via traitlets
|
||||
itsdangerous==1.1.0
|
||||
# via flask
|
||||
# via flask-debugtoolbar
|
||||
# via flask-wtf
|
||||
# via simplelogin
|
||||
jedi==0.17.2
|
||||
# via ipython
|
||||
jinja2==2.11.3
|
||||
# via flask
|
||||
# via yacron
|
||||
jmespath==0.10.0
|
||||
# via boto3
|
||||
# via botocore
|
||||
jwcrypto==0.8
|
||||
# via simplelogin
|
||||
limits==1.5.1
|
||||
# via flask-limiter
|
||||
loguru==0.7.2
|
||||
# via aiospamc
|
||||
mako==1.2.4
|
||||
# via alembic
|
||||
markupsafe==1.1.1
|
||||
# via jinja2
|
||||
# via mako
|
||||
# via simplelogin
|
||||
# via wtforms
|
||||
matplotlib-inline==0.1.3
|
||||
# via ipython
|
||||
memory-profiler==0.57.0
|
||||
# via simplelogin
|
||||
multidict==4.7.6
|
||||
# via aiohttp
|
||||
# via yarl
|
||||
newrelic==8.8.0
|
||||
# via simplelogin
|
||||
newrelic-telemetry-sdk==0.5.0
|
||||
# via simplelogin
|
||||
oauthlib==3.1.0
|
||||
# via requests-oauthlib
|
||||
parso==0.7.1
|
||||
# via jedi
|
||||
pexpect==4.8.0
|
||||
# via ipython
|
||||
pgpy==0.5.4
|
||||
# via simplelogin
|
||||
phpserialize==1.3
|
||||
# via simplelogin
|
||||
pickleshare==0.7.5
|
||||
# via ipython
|
||||
ply==3.11
|
||||
# via flanker
|
||||
prompt-toolkit==3.0.7
|
||||
# via ipython
|
||||
protobuf==5.27.1
|
||||
# via google-api-core
|
||||
# via googleapis-common-protos
|
||||
psutil==5.7.2
|
||||
# via memory-profiler
|
||||
psycopg2-binary==2.9.3
|
||||
# via simplelogin
|
||||
ptyprocess==0.6.0
|
||||
# via pexpect
|
||||
pyasn1==0.4.8
|
||||
# via pgpy
|
||||
# via pyasn1-modules
|
||||
# via rsa
|
||||
pyasn1-modules==0.2.8
|
||||
# via google-auth
|
||||
pycparser==2.20
|
||||
# via cffi
|
||||
pycryptodome==3.9.8
|
||||
# via simplelogin
|
||||
pygments==2.7.4
|
||||
# via flask-debugtoolbar-sqlalchemy
|
||||
# via ipython
|
||||
pyjwt==2.4.0
|
||||
# via twilio
|
||||
pyopenssl==19.1.0
|
||||
# via simplelogin
|
||||
# via webauthn
|
||||
pyotp==2.4.0
|
||||
# via simplelogin
|
||||
pyparsing==2.4.7
|
||||
# via httplib2
|
||||
pyre2==0.3.6
|
||||
# via simplelogin
|
||||
pyspf==2.0.14
|
||||
# via simplelogin
|
||||
python-dateutil==2.8.1
|
||||
# via alembic
|
||||
# via arrow
|
||||
# via botocore
|
||||
# via strictyaml
|
||||
python-dotenv==0.14.0
|
||||
# via simplelogin
|
||||
python-editor==1.0.4
|
||||
# via alembic
|
||||
python-gnupg==0.4.6
|
||||
# via simplelogin
|
||||
pytz==2020.1
|
||||
# via google-api-core
|
||||
# via twilio
|
||||
# via yacron
|
||||
redis==4.5.5
|
||||
# via simplelogin
|
||||
regex==2023.12.25
|
||||
# via flanker
|
||||
requests==2.25.1
|
||||
# via coinbase-commerce
|
||||
# via facebook-sdk
|
||||
# via google-api-core
|
||||
# via requests-file
|
||||
# via requests-oauthlib
|
||||
# via simplelogin
|
||||
# via tldextract
|
||||
# via twilio
|
||||
requests-file==1.5.1
|
||||
# via tldextract
|
||||
requests-oauthlib==1.3.0
|
||||
# via simplelogin
|
||||
rsa==4.6
|
||||
# via google-auth
|
||||
ruamel-yaml==0.17.4
|
||||
# via strictyaml
|
||||
# via yacron
|
||||
s3transfer==0.10.4
|
||||
# via boto3
|
||||
sentry-sdk==2.20.0
|
||||
# via simplelogin
|
||||
# via yacron
|
||||
setuptools==67.6.0
|
||||
# via google-api-core
|
||||
# via google-auth
|
||||
# via gunicorn
|
||||
# via ipython
|
||||
# via zope-event
|
||||
# via zope-interface
|
||||
simplejson==3.17.2
|
||||
# via flask-profiler
|
||||
six==1.15.0
|
||||
# via bcrypt
|
||||
# via coinbase-commerce
|
||||
# via flanker
|
||||
# via flask-cors
|
||||
# via flask-limiter
|
||||
# via google-api-core
|
||||
# via google-api-python-client
|
||||
# via google-auth
|
||||
# via google-auth-httplib2
|
||||
# via limits
|
||||
# via pgpy
|
||||
# via pyopenssl
|
||||
# via python-dateutil
|
||||
# via requests-file
|
||||
# via sqlalchemy-utils
|
||||
# via webauthn
|
||||
sqlalchemy==1.3.24
|
||||
# via alembic
|
||||
# via flask-debugtoolbar-sqlalchemy
|
||||
# via flask-sqlalchemy
|
||||
# via simplelogin
|
||||
# via sqlalchemy-utils
|
||||
sqlalchemy-utils==0.36.8
|
||||
# via simplelogin
|
||||
sqlparse==0.4.4
|
||||
# via flask-debugtoolbar-sqlalchemy
|
||||
strictyaml==1.1.0
|
||||
# via yacron
|
||||
tld==0.12.6
|
||||
# via flanker
|
||||
tldextract==3.1.2
|
||||
# via simplelogin
|
||||
traitlets==5.0.4
|
||||
# via ipython
|
||||
# via matplotlib-inline
|
||||
twilio==7.3.2
|
||||
# via simplelogin
|
||||
typer==0.9.0
|
||||
# via aiospamc
|
||||
typing-extensions==4.8.0
|
||||
# via aiospamc
|
||||
# via typer
|
||||
unidecode==1.1.1
|
||||
# via simplelogin
|
||||
uritemplate==3.0.1
|
||||
# via google-api-python-client
|
||||
urllib3==1.26.20
|
||||
# via botocore
|
||||
# via newrelic-telemetry-sdk
|
||||
# via requests
|
||||
# via sentry-sdk
|
||||
watchtower==0.8.0
|
||||
# via simplelogin
|
||||
wcwidth==0.2.5
|
||||
# via prompt-toolkit
|
||||
webauthn==0.4.7
|
||||
# via simplelogin
|
||||
webob==1.8.7
|
||||
# via flanker
|
||||
werkzeug==1.0.1
|
||||
# via flask
|
||||
# via flask-debugtoolbar
|
||||
# via simplelogin
|
||||
wrapt==1.15.0
|
||||
# via deprecated
|
||||
wtforms==2.3.3
|
||||
# via flask-admin
|
||||
# via flask-wtf
|
||||
# via simplelogin
|
||||
yacron==0.19.0
|
||||
# via simplelogin
|
||||
yarl==1.9.2
|
||||
# via aiohttp
|
||||
zope-event==5.0
|
||||
# via gevent
|
||||
zope-interface==7.2
|
||||
# via gevent
|
@ -12,10 +12,10 @@ docker run -p 25432:5432 --name ${container_name} -e POSTGRES_PASSWORD=postgres
|
||||
sleep 3
|
||||
|
||||
# upgrade the DB to the latest stage and
|
||||
env DB_URI=postgresql://postgres:postgres@127.0.0.1:25432/sl poetry run alembic upgrade head
|
||||
env DB_URI=postgresql://postgres:postgres@127.0.0.1:25432/sl rye run alembic upgrade head
|
||||
|
||||
# generate the migration script.
|
||||
env DB_URI=postgresql://postgres:postgres@127.0.0.1:25432/sl poetry run alembic revision --autogenerate $@
|
||||
env DB_URI=postgresql://postgres:postgres@127.0.0.1:25432/sl rye run alembic revision --autogenerate $@
|
||||
|
||||
# remove the db
|
||||
docker rm -f ${container_name}
|
||||
|
@ -3,5 +3,5 @@
|
||||
export DB_URI=postgresql://myuser:mypassword@localhost:15432/simplelogin
|
||||
echo 'drop schema public cascade; create schema public;' | psql $DB_URI
|
||||
|
||||
poetry run alembic upgrade head
|
||||
poetry run flask dummy-data
|
||||
rye run alembic upgrade head
|
||||
rye run flask dummy-data
|
||||
|
@ -3,4 +3,4 @@
|
||||
export DB_URI=postgresql://myuser:mypassword@localhost:15432/test
|
||||
echo 'drop schema public cascade; create schema public;' | psql $DB_URI
|
||||
|
||||
poetry run alembic upgrade head
|
||||
rye run alembic upgrade head
|
||||
|
@ -10,10 +10,10 @@ docker run -d --name sl-test-db -e POSTGRES_PASSWORD=test -e POSTGRES_USER=test
|
||||
sleep 3
|
||||
|
||||
# migrate the DB to the latest version
|
||||
CONFIG=tests/test.env poetry run alembic upgrade head
|
||||
CONFIG=tests/test.env rye run alembic upgrade head
|
||||
|
||||
# run test
|
||||
poetry run pytest -c pytest.ci.ini
|
||||
rye run pytest -c pytest.ci.ini
|
||||
|
||||
# Delete the test DB
|
||||
docker rm -f sl-test-db
|
||||
|
@ -44,6 +44,7 @@ from app.admin_model import (
|
||||
MetricAdmin,
|
||||
InvalidMailboxDomainAdmin,
|
||||
EmailSearchAdmin,
|
||||
CustomDomainSearchAdmin,
|
||||
)
|
||||
from app.api.base import api_bp
|
||||
from app.auth.base import auth_bp
|
||||
@ -443,6 +444,11 @@ def init_admin(app):
|
||||
|
||||
admin.init_app(app, index_view=SLAdminIndexView())
|
||||
admin.add_view(EmailSearchAdmin(name="Email Search", endpoint="email_search"))
|
||||
admin.add_view(
|
||||
CustomDomainSearchAdmin(
|
||||
name="Custom domain search", endpoint="custom_domain_search"
|
||||
)
|
||||
)
|
||||
admin.add_view(UserAdmin(User, Session))
|
||||
admin.add_view(AliasAdmin(Alias, Session))
|
||||
admin.add_view(MailboxAdmin(Mailbox, Session))
|
||||
|
118
app/templates/admin/custom_domain_search.html
Normal file
118
app/templates/admin/custom_domain_search.html
Normal file
@ -0,0 +1,118 @@
|
||||
{% extends 'admin/master.html' %}
|
||||
|
||||
{% macro show_user(user) -%}
|
||||
<h4>User <a href="/admin/email_search?email={{ user.email }}">{{ user.email }}</a> with ID {{ user.id }}.</h4>
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">User ID</th>
|
||||
<th scope="col">Email</th>
|
||||
<th scope="col">Verified</th>
|
||||
<th scope="col">Status</th>
|
||||
<th scope="col">Paid</th>
|
||||
<th scope="col">Premium</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>{{ user.id }}</td>
|
||||
<td>
|
||||
<a href="/admin/email_search?email={{ user.email }}">{{ user.email }}</a>
|
||||
</td>
|
||||
{% if user.activated %}
|
||||
|
||||
<td class="text-success">Activated</td>
|
||||
{% else %}
|
||||
<td class="text-warning">Pending</td>
|
||||
{% endif %}
|
||||
{% if user.disabled %}
|
||||
|
||||
<td class="text-danger">Disabled</td>
|
||||
{% else %}
|
||||
<td class="text-success">Enabled</td>
|
||||
{% endif %}
|
||||
<td>{{ "yes" if user.is_paid() else "No" }}</td>
|
||||
<td>{{ "yes" if user.is_premium() else "No" }}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
{%- endmacro %}
|
||||
|
||||
|
||||
{% macro show_verification(title, expected, errors) -%}
|
||||
{% if not expected %}
|
||||
<h4 class="mb-3">{{ title }} <span class="text-success">Verified</span></h4>
|
||||
{% else %}
|
||||
<h4 class="mb-3">{{ title }}</h4>
|
||||
<p>Expected</p>
|
||||
<p>{{expected}}</p>
|
||||
<p>Current response</p>
|
||||
<ul class="list-group">
|
||||
{% for error in errors %}
|
||||
<li class="list-group-item">{{ error }}</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% endif %}
|
||||
{%- endmacro %}
|
||||
|
||||
|
||||
{% macro show_domain(domain_with_data) -%}
|
||||
<h3>Domain {{ domain_with_data.domain.domain }}</h3>
|
||||
{% set domain = domain_with_data.domain %}
|
||||
<ul class="list-group">
|
||||
<li class="list-group-item">
|
||||
{{ show_verification("Ownership", domain_with_data.ownership_expected, domain_with_data.ownership_validation.errors) }}
|
||||
</li>
|
||||
<li class="list-group-item">
|
||||
{{ show_verification("MX", domain_with_data.mx_expected, domain_with_data.mx_validation.errors) }}
|
||||
</li>
|
||||
<li class="list-group-item">
|
||||
{{ show_verification("SPF", domain_with_data.spf_expected, domain_with_data.spf_validation.errors) }}
|
||||
</li>
|
||||
{% for dkim_domain in domain_with_data.dkim_expected %}
|
||||
<li class="list-group-item">
|
||||
{{ show_verification("DKIM {}.{}".format(dkim_domain, domain.domain), domain_with_data.dkim_expected[dkim_domain], [domain_with_data.dkim_validation.get(dkim_domain+"."+domain.domain,'')]) }}
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
|
||||
{%- endmacro %}
|
||||
|
||||
|
||||
{% block body %}
|
||||
|
||||
<div class="border border-dark border-2 mt-1 mb-2 p-3">
|
||||
<form method="get">
|
||||
<div class="form-group">
|
||||
<label for="email">User or domain to search:</label>
|
||||
<input type="text"
|
||||
class="form-control"
|
||||
name="user"
|
||||
value="{{ query or '' }}" />
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary">Submit</button>
|
||||
</form>
|
||||
</div>
|
||||
{% if data.no_match and query %}
|
||||
<div class="border border-dark border-2 mt-1 mb-2 p-3 alert alert-warning"
|
||||
role="alert">No user, alias or mailbox found for {{ query }}</div>
|
||||
{% endif %}
|
||||
{% if data.user %}
|
||||
<div class="border border-dark border-2 mt-1 mb-2 p-3">
|
||||
<h3 class="mb-3">Found User {{ data.user.email }}</h3>
|
||||
{{ show_user(data.user) }}
|
||||
</div>
|
||||
{% endif %}
|
||||
<div class="d-flex">
|
||||
|
||||
{% for domain_with_data in data.domains %}
|
||||
<div class="card m-2 border-dark" style="width: 30rem;">
|
||||
<div class="card-body">
|
||||
{{ show_domain(domain_with_data) }}
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
|
||||
|
||||
{% endblock %}
|
@ -57,31 +57,21 @@
|
||||
{% endblock %}
|
||||
{% block default_content %}
|
||||
|
||||
{% if NOW.timestamp < 1701475201 %}
|
||||
{% if NOW.timestamp < 1733184000 %}
|
||||
|
||||
<div class="alert alert-info">
|
||||
Black Friday Deal: 33% off on the yearly plan for the <b>first</b> year ($20 instead of $30).
|
||||
<div class="alert alert-primary">
|
||||
Lifetime deal for SimpleLogin Premium and Proton Pass Plus for $199
|
||||
<a class="btn btn-primary"
|
||||
href="https://proton.me/pass/black-friday"
|
||||
target="_blank">Buy now</a>
|
||||
<br>
|
||||
Please use this coupon code
|
||||
<em data-toggle="tooltip"
|
||||
title="Click to copy"
|
||||
class="clipboard"
|
||||
data-clipboard-text="BF2023">BF2023</em> during the checkout.
|
||||
<br>
|
||||
<img src="/static/images/coupon.png" class="m-2" style="max-width: 300px">
|
||||
<br>
|
||||
Available until December 1, 2023.
|
||||
Available until December 3, 2024.
|
||||
</div>
|
||||
{% endif %}
|
||||
<div class="pb-8">
|
||||
<div class="text-center mx-md-auto mb-8 mt-6">
|
||||
<div class="text-center mx-md-auto mb-4 mt-4">
|
||||
<h1>Upgrade to unlock premium features</h1>
|
||||
</div>
|
||||
<div class="alert alert-info">
|
||||
<span class="badge badge-success">new</span> SimpleLogin Premium now includes Proton Pass premium features.
|
||||
<a href="https://simplelogin.io/blog/sl-premium-including-pass-plus/"
|
||||
target="_blank">Learn more ↗</a>
|
||||
</div>
|
||||
{% if manual_sub %}
|
||||
|
||||
<div class="alert alert-info mt-0 mb-6">
|
||||
@ -131,6 +121,11 @@
|
||||
aria-selected="true">Yearly<span class="badge badge-success position-absolute tab-yearly__badge"
|
||||
style="font-size: 12px">Save $18</span></a>
|
||||
</div>
|
||||
<div class="alert alert-info">
|
||||
<span class="badge badge-success">new</span> SimpleLogin Premium now includes Proton Pass premium features.
|
||||
<a href="https://simplelogin.io/blog/sl-premium-including-pass-plus/"
|
||||
target="_blank">Learn more ↗</a>
|
||||
</div>
|
||||
<div class="tab-content mb-8">
|
||||
<!-- monthly tab content -->
|
||||
<div class="tab-pane"
|
||||
@ -223,12 +218,12 @@
|
||||
<div class="card card-md flex-grow-1">
|
||||
<div class="card-body">
|
||||
<div class="text-center">
|
||||
<div class="h3">Proton plan</div>
|
||||
<div class="h3">Proton Unlimited</div>
|
||||
<div class="h3 my-3">Starts at $12.99 / month</div>
|
||||
<div class="text-center mt-4 mb-6">
|
||||
<a class="btn btn-lg btn-outline-primary w-100"
|
||||
role="button"
|
||||
href="https://account.proton.me/u/0/mail/upgrade"
|
||||
href="https://account.proton.me/u/0/pass/upgrade"
|
||||
target="_blank">Upgrade your Proton account</a>
|
||||
</div>
|
||||
</div>
|
||||
@ -362,12 +357,12 @@
|
||||
<div class="card card-md flex-grow-1">
|
||||
<div class="card-body">
|
||||
<div class="text-center">
|
||||
<div class="h3">Proton plan</div>
|
||||
<div class="h3">Proton Unlimited</div>
|
||||
<div class="h3 my-3">Starts at $119.88 / year</div>
|
||||
<div class="text-center mt-4 mb-6">
|
||||
<a class="btn btn-lg btn-outline-primary w-100"
|
||||
role="button"
|
||||
href="https://account.proton.me/u/0/mail/upgrade"
|
||||
href="https://account.proton.me/u/0/pass/upgrade"
|
||||
target="_blank">Upgrade your Proton account</a>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -79,7 +79,14 @@
|
||||
</a>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if partner_sub %}<div>Premium subscription managed by {{ partner_name }}.</div>{% endif %}
|
||||
{% if partner_sub %}
|
||||
{% if partner_sub.lifetime %}
|
||||
|
||||
<div>Premium lifetime subscription managed by {{ partner_name }}.</div>
|
||||
{% else %}
|
||||
<div>Premium subscription managed by {{ partner_name }}.</div>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% elif current_user.in_trial() %}
|
||||
Your Premium trial expires {{ current_user.trial_end | dt }}.
|
||||
{% else %}
|
||||
|
@ -549,7 +549,7 @@ def test_create_contact_route_free_users(flask_client):
|
||||
assert r.status_code == 201
|
||||
|
||||
# End trial and disallow for new free users. Config should allow it
|
||||
user.flags = User.FLAG_DISABLE_CREATE_CONTACTS
|
||||
user.flags = User.FLAG_FREE_DISABLE_CREATE_CONTACTS
|
||||
Session.commit()
|
||||
r = flask_client.post(
|
||||
url_for("api.create_contact_route", alias_id=alias.id),
|
||||
|
@ -36,6 +36,24 @@ def test_delete_mailbox_transfer_mailbox_primary(flask_client):
|
||||
assert str(mails_sent[0].msg).find("alias have been transferred") > -1
|
||||
|
||||
|
||||
@mail_sender.store_emails_test_decorator
|
||||
def test_delete_mailbox_no_email(flask_client):
|
||||
user = create_new_user()
|
||||
m1 = Mailbox.create(
|
||||
user_id=user.id, email=random_email(), verified=True, flush=True
|
||||
)
|
||||
job = Job.create(
|
||||
name=JOB_DELETE_MAILBOX,
|
||||
payload={"mailbox_id": m1.id, "transfer_mailbox_id": None, "send_mail": False},
|
||||
run_at=arrow.now(),
|
||||
commit=True,
|
||||
)
|
||||
Session.commit()
|
||||
delete_mailbox_job(job)
|
||||
mails_sent = mail_sender.get_stored_emails()
|
||||
assert len(mails_sent) == 0
|
||||
|
||||
|
||||
@mail_sender.store_emails_test_decorator
|
||||
def test_delete_mailbox_transfer_mailbox_in_list(flask_client):
|
||||
user = create_new_user()
|
||||
|
100
app/tests/proton/test_account_linking.py
Normal file
100
app/tests/proton/test_account_linking.py
Normal file
@ -0,0 +1,100 @@
|
||||
import arrow
|
||||
|
||||
from app.account_linking import (
|
||||
SLPlan,
|
||||
SLPlanType,
|
||||
set_plan_for_partner_user,
|
||||
)
|
||||
from app.db import Session
|
||||
from app.models import User, PartnerUser, PartnerSubscription
|
||||
from app.proton.utils import get_proton_partner
|
||||
from app.utils import random_string
|
||||
from tests.utils import random_email
|
||||
|
||||
partner_user_id: int = 0
|
||||
|
||||
|
||||
def setup_module():
|
||||
global partner_user_id
|
||||
email = random_email()
|
||||
external_id = random_string()
|
||||
sl_user = User.create(email, commit=True)
|
||||
partner_user_id = PartnerUser.create(
|
||||
user_id=sl_user.id,
|
||||
partner_id=get_proton_partner().id,
|
||||
external_user_id=external_id,
|
||||
partner_email=email,
|
||||
commit=True,
|
||||
).id
|
||||
|
||||
|
||||
def setup_function(func):
|
||||
Session.query(PartnerSubscription).delete()
|
||||
|
||||
|
||||
def test_free_plan_removes_sub():
|
||||
pu = PartnerUser.get(partner_user_id)
|
||||
sub_id = PartnerSubscription.create(
|
||||
partner_user_id=partner_user_id,
|
||||
end_at=arrow.utcnow(),
|
||||
lifetime=False,
|
||||
commit=True,
|
||||
).id
|
||||
set_plan_for_partner_user(pu, plan=SLPlan(type=SLPlanType.Free, expiration=None))
|
||||
assert PartnerSubscription.get(sub_id) is None
|
||||
|
||||
|
||||
def test_premium_plan_updates_expiration():
|
||||
pu = PartnerUser.get(partner_user_id)
|
||||
sub_id = PartnerSubscription.create(
|
||||
partner_user_id=partner_user_id,
|
||||
end_at=arrow.utcnow(),
|
||||
lifetime=False,
|
||||
commit=True,
|
||||
).id
|
||||
new_expiration = arrow.utcnow().shift(days=+10)
|
||||
set_plan_for_partner_user(
|
||||
pu, plan=SLPlan(type=SLPlanType.Premium, expiration=new_expiration)
|
||||
)
|
||||
assert PartnerSubscription.get(sub_id).end_at == new_expiration
|
||||
|
||||
|
||||
def test_premium_plan_creates_sub():
|
||||
pu = PartnerUser.get(partner_user_id)
|
||||
new_expiration = arrow.utcnow().shift(days=+10)
|
||||
set_plan_for_partner_user(
|
||||
pu, plan=SLPlan(type=SLPlanType.Premium, expiration=new_expiration)
|
||||
)
|
||||
assert (
|
||||
PartnerSubscription.get_by(partner_user_id=partner_user_id).end_at
|
||||
== new_expiration
|
||||
)
|
||||
|
||||
|
||||
def test_lifetime_creates_sub():
|
||||
pu = PartnerUser.get(partner_user_id)
|
||||
new_expiration = arrow.utcnow().shift(days=+10)
|
||||
set_plan_for_partner_user(
|
||||
pu, plan=SLPlan(type=SLPlanType.PremiumLifetime, expiration=new_expiration)
|
||||
)
|
||||
sub = PartnerSubscription.get_by(partner_user_id=partner_user_id)
|
||||
assert sub is not None
|
||||
assert sub.end_at is None
|
||||
assert sub.lifetime
|
||||
|
||||
|
||||
def test_lifetime_updates_sub():
|
||||
pu = PartnerUser.get(partner_user_id)
|
||||
sub_id = PartnerSubscription.create(
|
||||
partner_user_id=partner_user_id,
|
||||
end_at=arrow.utcnow(),
|
||||
lifetime=False,
|
||||
commit=True,
|
||||
).id
|
||||
set_plan_for_partner_user(
|
||||
pu, plan=SLPlan(type=SLPlanType.PremiumLifetime, expiration=arrow.utcnow())
|
||||
)
|
||||
sub = PartnerSubscription.get(sub_id)
|
||||
assert sub is not None
|
||||
assert sub.end_at is None
|
||||
assert sub.lifetime
|
@ -135,7 +135,7 @@ def test_create_contact_free_user():
|
||||
assert result.contact is not None
|
||||
assert not result.contact.automatic_created
|
||||
# Free users with the flag should be able to still create automatic emails
|
||||
user.flags = User.FLAG_DISABLE_CREATE_CONTACTS
|
||||
user.flags = User.FLAG_FREE_DISABLE_CREATE_CONTACTS
|
||||
Session.flush()
|
||||
result = create_contact(random_email(), alias, automatic_created=True)
|
||||
assert result.error is None
|
||||
|
@ -2,6 +2,7 @@ import random
|
||||
from email.message import EmailMessage
|
||||
from typing import List
|
||||
|
||||
import arrow
|
||||
import pytest
|
||||
from aiosmtpd.smtp import Envelope
|
||||
|
||||
@ -14,7 +15,6 @@ from app.email_utils import generate_verp_email
|
||||
from app.mail_sender import mail_sender
|
||||
from app.models import (
|
||||
Alias,
|
||||
AuthorizedAddress,
|
||||
IgnoredEmail,
|
||||
EmailLog,
|
||||
Notification,
|
||||
@ -24,35 +24,12 @@ from app.models import (
|
||||
)
|
||||
from app.utils import random_string, canonicalize_email
|
||||
from email_handler import (
|
||||
get_mailbox_from_mail_from,
|
||||
should_ignore,
|
||||
is_automatic_out_of_office,
|
||||
)
|
||||
from tests.utils import load_eml_file, create_new_user, random_email
|
||||
|
||||
|
||||
def test_get_mailbox_from_mail_from(flask_client):
|
||||
user = create_new_user()
|
||||
alias = Alias.create_new_random(user)
|
||||
Session.commit()
|
||||
|
||||
mb = get_mailbox_from_mail_from(user.email, alias)
|
||||
assert mb.email == user.email
|
||||
|
||||
mb = get_mailbox_from_mail_from("unauthorized@gmail.com", alias)
|
||||
assert mb is None
|
||||
|
||||
# authorized address
|
||||
AuthorizedAddress.create(
|
||||
user_id=user.id,
|
||||
mailbox_id=user.default_mailbox_id,
|
||||
email="unauthorized@gmail.com",
|
||||
commit=True,
|
||||
)
|
||||
mb = get_mailbox_from_mail_from("unauthorized@gmail.com", alias)
|
||||
assert mb.email == user.email
|
||||
|
||||
|
||||
def test_should_ignore(flask_client):
|
||||
assert should_ignore("mail_from", []) is False
|
||||
|
||||
@ -411,3 +388,15 @@ def test_preserve_headers(flask_client):
|
||||
msg = sent_mails[0].msg
|
||||
for header in headers_to_keep:
|
||||
assert msg[header] == header + "keep"
|
||||
|
||||
|
||||
def test_not_send_to_pending_to_delete_users(flask_client):
|
||||
user = create_new_user()
|
||||
alias = Alias.create_new_random(user)
|
||||
user.delete_on = arrow.utcnow()
|
||||
envelope = Envelope()
|
||||
envelope.mail_from = "somewhere@lo.cal"
|
||||
envelope.rcpt_tos = [alias.email]
|
||||
msg = EmailMessage()
|
||||
result = email_handler.handle(envelope, msg)
|
||||
assert result == status.E504
|
||||
|
@ -791,12 +791,21 @@ def test_parse_id_from_bounce():
|
||||
assert parse_id_from_bounce("anything+1234+@local") == 1234
|
||||
|
||||
|
||||
def test_get_queue_id():
|
||||
def test_get_queue_id_esmtps():
|
||||
for id_type in ["SMTP", "ESMTP", "ESMTPA", "ESMTPS"]:
|
||||
msg = email.message_from_string(
|
||||
"Received: from mail-wr1-x434.google.com (mail-wr1-x434.google.com [IPv6:2a00:1450:4864:20::434])\r\n\t(using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits))\r\n\t(No client certificate requested)\r\n\tby mx1.simplelogin.co (Postfix) with ESMTPS id 4FxQmw1DXdz2vK2\r\n\tfor <jglfdjgld@alias.com>; Fri, 4 Jun 2021 14:55:43 +0000 (UTC)"
|
||||
f"Received: from mail-wr1-x434.google.com (mail-wr1-x434.google.com [IPv6:2a00:1450:4864:20::434])\r\n\t(using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits))\r\n\t(No client certificate requested)\r\n\tby mx1.simplelogin.co (Postfix) with {id_type} id 4FxQmw1DXdz2vK2\r\n\tfor <jglfdjgld@alias.com>; Fri, 4 Jun 2021 14:55:43 +0000 (UTC)"
|
||||
)
|
||||
|
||||
assert get_queue_id(msg) == "4FxQmw1DXdz2vK2"
|
||||
assert get_queue_id(msg) == "4FxQmw1DXdz2vK2", f"Failed for {id_type}"
|
||||
|
||||
|
||||
def test_get_queue_id_postfix():
|
||||
msg = email.message_from_string(
|
||||
"Received: by mailin001.somewhere.net (Postfix)\r\n\tid 4Xz5pb2nMszGrqpL; Wed, 27 Nov 2024 17:21:59 +0000 (UTC)'] by mailin001.somewhere.net (Postfix)"
|
||||
)
|
||||
|
||||
assert get_queue_id(msg) == "4Xz5pb2nMszGrqpL"
|
||||
|
||||
|
||||
def test_get_queue_id_from_double_header():
|
||||
|
@ -6,9 +6,18 @@ import pytest
|
||||
from app import mailbox_utils, config
|
||||
from app.db import Session
|
||||
from app.mail_sender import mail_sender
|
||||
from app.mailbox_utils import MailboxEmailChangeError
|
||||
from app.models import Mailbox, MailboxActivation, User, Job, UserAuditLog
|
||||
from app.mailbox_utils import MailboxEmailChangeError, get_mailbox_for_reply_phase
|
||||
from app.models import (
|
||||
Mailbox,
|
||||
MailboxActivation,
|
||||
User,
|
||||
Job,
|
||||
UserAuditLog,
|
||||
Alias,
|
||||
AuthorizedAddress,
|
||||
)
|
||||
from app.user_audit_log_utils import UserAuditLogAction
|
||||
from app.utils import random_string, canonicalize_email
|
||||
from tests.utils import create_new_user, random_email
|
||||
|
||||
|
||||
@ -50,6 +59,14 @@ def test_already_used():
|
||||
mailbox_utils.create_mailbox(user, user.email)
|
||||
|
||||
|
||||
def test_already_used_with_different_case():
|
||||
user.lifetime = True
|
||||
email = random_email()
|
||||
mailbox_utils.create_mailbox(user, email)
|
||||
with pytest.raises(mailbox_utils.MailboxError):
|
||||
mailbox_utils.create_mailbox(user, email.upper())
|
||||
|
||||
|
||||
@mail_sender.store_emails_test_decorator
|
||||
def test_create_mailbox():
|
||||
email = random_email()
|
||||
@ -418,3 +435,75 @@ def test_perform_mailbox_email_change_success():
|
||||
user_id=user.id, action=UserAuditLogAction.UpdateMailbox.value
|
||||
).count()
|
||||
assert audit_log_entries == 1
|
||||
|
||||
|
||||
def test_get_mailbox_from_mail_from(flask_client):
|
||||
user = create_new_user()
|
||||
alias = Alias.create_new_random(user)
|
||||
Session.commit()
|
||||
|
||||
mb = get_mailbox_for_reply_phase(user.email, "", alias)
|
||||
assert mb.email == user.email
|
||||
|
||||
mb = get_mailbox_for_reply_phase("unauthorized@gmail.com", "", alias)
|
||||
assert mb is None
|
||||
|
||||
# authorized address
|
||||
AuthorizedAddress.create(
|
||||
user_id=user.id,
|
||||
mailbox_id=user.default_mailbox_id,
|
||||
email="unauthorized@gmail.com",
|
||||
commit=True,
|
||||
)
|
||||
mb = get_mailbox_for_reply_phase("unauthorized@gmail.com", "", alias)
|
||||
assert mb.email == user.email
|
||||
|
||||
|
||||
def test_get_mailbox_from_mail_from_for_canonical_email(flask_client):
|
||||
prefix = random_string(10)
|
||||
email = f"{prefix}+subaddresxs@gmail.com"
|
||||
canonical_email = canonicalize_email(email)
|
||||
assert canonical_email != email
|
||||
|
||||
user = create_new_user()
|
||||
mbox = Mailbox.create(
|
||||
email=canonical_email, user_id=user.id, verified=True, flush=True
|
||||
)
|
||||
alias = Alias.create(user_id=user.id, email=random_email(), mailbox_id=mbox.id)
|
||||
Session.flush()
|
||||
|
||||
mb = get_mailbox_for_reply_phase(email, "", alias)
|
||||
assert mb.email == canonical_email
|
||||
|
||||
mb = get_mailbox_for_reply_phase(canonical_email, "", alias)
|
||||
assert mb.email == canonical_email
|
||||
|
||||
|
||||
def test_get_mailbox_from_mail_from_coming_from_header_if_domain_is_aligned(
|
||||
flask_client,
|
||||
):
|
||||
domain = f"{random_string(10)}.com"
|
||||
envelope_from = f"envelope_verp@{domain}"
|
||||
mail_from = f"mail_from@{domain}"
|
||||
user = create_new_user()
|
||||
mbox = Mailbox.create(email=mail_from, user_id=user.id, verified=True, flush=True)
|
||||
alias = Alias.create(user_id=user.id, email=random_email(), mailbox_id=mbox.id)
|
||||
Session.flush()
|
||||
|
||||
mb = get_mailbox_for_reply_phase(envelope_from, mail_from, alias)
|
||||
assert mb.email == mail_from
|
||||
|
||||
|
||||
def test_get_mailbox_from_mail_from_coming_from_header_if_domain_is_not_aligned(
|
||||
flask_client,
|
||||
):
|
||||
domain = f"{random_string(10)}.com"
|
||||
envelope_from = f"envelope_verp@{domain}"
|
||||
mail_from = f"mail_from@other_{domain}"
|
||||
user = create_new_user()
|
||||
mbox = Mailbox.create(email=mail_from, user_id=user.id, verified=True, flush=True)
|
||||
alias = Alias.create(user_id=user.id, email=random_email(), mailbox_id=mbox.id)
|
||||
Session.flush()
|
||||
|
||||
mb = get_mailbox_for_reply_phase(envelope_from, mail_from, alias)
|
||||
assert mb is None
|
||||
|
Reference in New Issue
Block a user