2020-06-11 22:02:07 +00:00
|
|
|
import email
|
2019-11-16 14:19:43 +00:00
|
|
|
import os
|
2020-04-05 10:07:40 +00:00
|
|
|
from email.header import decode_header
|
2020-03-15 21:32:48 +00:00
|
|
|
from email.message import Message
|
2020-02-22 13:39:45 +00:00
|
|
|
from email.mime.base import MIMEBase
|
|
|
|
from email.mime.multipart import MIMEMultipart
|
|
|
|
from email.mime.text import MIMEText
|
2020-04-16 07:43:14 +00:00
|
|
|
from email.utils import make_msgid, formatdate, parseaddr
|
2019-11-15 13:11:51 +00:00
|
|
|
from smtplib import SMTP
|
2020-02-22 13:39:45 +00:00
|
|
|
from typing import Optional
|
create BaseForm to enable CSRF
register page
redirect user to dashboard if they are logged in
enable csrf for login page
Set models more strict
bootstrap developer page
add helper method to ModelMixin, remove CRUDMixin
display list of clients on developer index, add copy client-secret to clipboard using clipboardjs
add toastr and use jquery non slim
display a toast when user copies the client-secret
create new client, generate client-id using unidecode
client detail page: can edit client
add delete client
implement /oauth/authorize and /oauth/allow-deny
implement /oauth/token
add /oauth/user_info endpoint
handle scopes: wip
take into account scope: display scope, return user data according to scope
create virtual-domain, gen email, client_user model WIP
create authorize_nonlogin_user page
user can choose to generate a new email
no need to interfere with root logger
log for before and after request
if user has already allowed a client: generate a auth-code and redirect user to client
get_user_info takes into account gen email
display list of clients that have user has authorised
use yk-client domain instead of localhost as cookie depends on the domain name
use wtforms instead of flask_wtf
Dockerfile
delete virtual domain
EMAIL_DOMAIN can come from env var
bind to host 0.0.0.0
fix signup error: use session as default csrf_context
rename yourkey to simplelogin
add python-dotenv, ipython, sqlalchemy_utils
create DB_URI, FLASK_SECRET. Load config from CONFIG file if exist
add shortcuts to logging
create shell
add psycopg2
do not add local data in Dockerfile
add drop_db into shell
add shell.prepare_db()
fix prepare_db
setup sentry
copy assets from tabler/dist
add icon downloaded from https://commons.wikimedia.org/wiki/File:Simpleicons_Interface_key-tool-1.svg
integrate tabler - login and register page
add favicon
template: default, header. Use gravatar for user avatar url
use default template for dashboard, developer page
use another icon
add clipboard and notie
prettify dashboard
add notie css
add fake gen email and client-user
prettify list client page, use notie for toast
add email, name scope to new client
display client scope in client list
prettify new-client, client-detail
add sentry-sdk and blinker
add arrow, add dt jinja filter, prettify logout, dashboard
comment "last used" in dashboard for now
prettify date display
add copy email to clipboard to dashboard
use "users" as table name for User as "user" is reserved key in postgres
call prepare_db() when creating new db
error page 400, 401, 403, 404
prettify authorize_login_user
create already_authorize.html for user who has already authorized a client
user can generate new email
display all other generated emails
add ENV variable, only reset DB when ENV=local
fix: not return other users gen emails
display nb users for each client
refactor shell: remove prepare_db()
add sendgrid
add /favicon.ico route
add new config: URL, SUPPORT_EMAIL, SENDGRID_API_KEY
user needs to activate their account before login
create copy button on dashboard
client can have multiple redirect uris, in client detail can add/remove redirect-uri,
use redirect_uri passed in /authorize
refactor: move get_user_info into ClientUser model
dashboard: display all apps, all generated emails
add "id" into user_info
add trigger email button
invalidate the session at each new version by changing the secret
centralize Client creation into Client.create_new
user can enable/disable email forwarding
setup auto dismiss alert: just add .alert-auto-dismiss
move name down in register form
add shell.add_real_data
move blueprint template to its own package
prettify authorize page for non-authenticated user
update readme, return error if not redirect_uri
add flask-wtf, use psycopg2-binary
use flask-wtf FlaskForm instead of Form
rename email -> email_utils
add AWS_REGION, BUCKET, AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY to config
add s3 module
add File model, add Client.icon_id
handle client icon update
can create client with icon
display client icon in client list page
add Client.home_url
take into account Client.home_url
add boto3
register: ask name first
only show "trigger test email" if email forwarding is enabled
display gen email in alphabetical order, client in client.name alphabetical order
better error page
the modal does not get close when user clicks outside of modal
add Client.published column
discover page that displays all published Client
add missing bootstrap.bundle.min.js.map
developer can publish/unpublish their app in discover
use notie for display flash message
create hotmail account
fix missing jquery
add footer, add global jinja2 variable
strengthen model: use nullable=False whenever possible,
rename client_id to oauth_client_id, client_secret to oauth_client_secret
add flask-migrate
init migrate
1st migrate version
fix rename client_id -> oauth_client_id
prettify UI
use flask_migrate.upgrade() instead of db.create_all()
make sure requirejs.config is called for all page
enable sentry for js, use uppercase for global jinja2 variables
add flask-admin
add User.is_admin column
setup flask admin, only accessible to admin user
fix migration: add server_default
replace session[redirect_after_login] by "next" request args
add pyproject.toml: ignore migrations/ in black
add register waiting_activation_email page
better email wording
add pytest
add get_host_name_and_scheme and tests
example fail test
fix test
fix client-id display
add flask-cors
/user_info supports cors, add /me as /user_info synonym
return client in /me
support implicit flow
no need to use with "app.app_context()"
add watchtower to requirement
add param ENABLE_CLOUDWATCH, CLOUDWATCH_LOG_GROUP, CLOUDWATCH_LOG_STREAM
add cloudwatch logger if cloudwatch is enabled
add 500 error page
add help text for list of used client
display list of app/website that an email has been used
click on client name brings to client detail page
create style.css to add additional style, append its url with the current sha1 to avoid cache
POC on how to send email using postfix
add sqlalchemy-utils
use arrow instead of datetime
add new params STRIPE_API, STRIPE_YEARLY_SKU, STRIPE_MONTHLY_PLAN
show full error in local
add plan, plan_expiration to User, need to create enum directly in migration script, cf https://github.com/sqlalchemy/alembic/issues/67
reformat all html files: use space instead of tab
new user will have trial plan for 15 days
add new param MAX_NB_EMAIL_FREE_PLAN
only user with enough quota can create new email
if user cannot create new gen email, pick randomly one from existing gen emails. Use flush instead of commit
rename STRIPE_YEARLY_SKU -> STRIPE_YEARLY_PLAN
open client page in discover in a new tab
add stripe
not logging /static call: disable flask logging, replace by after_request
add param STRIPE_SECRET_KEY
add 3 columns stripe_customer_id, stripe_card_token, stripe_subscription_id
user can upgrade their pricing
add setting page as coming-soon
add GenEmail, ClientUser to admin
ignore /admin/static logging
add more fake data
add ondelete="cascade" whenever possible
rename plan_expiration -> trial_expiration
reset migration: delete old migrations, create new one
rename test_send_email -> poc_send_email to avoid the file being called by pytest
add new param LYRA_ANALYTICS_ID, add lyra analytics
add how to create new migration into readme
add drift to base.html
notify admin when new user signs up or pays subscription
log exception in case of 500
use sendgrid to notify admin
add alias /userinfo to user_info endpoint
add change_password to shell
add info on how payment is handled
invite user to retry if card not working
remove drift and add "contact us" link
move poc_send_email into poc/
support getting client-id, client-secret from form-data in addition to basic auth
client-id, client-secret is passed in form-data by passport-oauth2 for ex
add jwtRS256 private and public key
add jwk-jws-jwt poc
add new param OPENID_PRIVATE_KEY_PATH, OPENID_PRIVATE_KEY_PATH
add scope, redirect_url to AuthorizationCode and OauthToken
take into scope when creating oauth-token, authorization-code
add jwcrypto
add jose_utils: make_id_token and verify_id_token
add &scope to redirect uri
add "email_verified": True into user_info
fix user not activated
add /oauth2 as alias for /oauth
handle case where scope and state are empty
remove threaded=False
Use Email Alias as wording
remove help text
user can re-send activation email
add "expired" into ActivationCode
Handle the case activation code is expired
reformat: use form.validate_on_submit instead of request.method == post && form.validate
use error text instead of flash()
display client oauth-id and oauth-secret on client detail page
not display oauth-secret on client listing
fix expiration check
improve page title, footer
add /jwks and /.well-known/openid-configuration
init properly tests, fix blueprint conflict bug in flask-admin
create oauth_models module
rename Scope -> ScopeE to distinguish with Scope DB model
set app.url_map.strict_slashes = False
use ScopeE instead of SCOPE_NAME, ...
support access_token passed as args in /userinfo
merge /allow-deny into /authorize
improve wording
take into account the case response_type=code and openid is in scope
take into account response_type=id_token, id_token token, id_token code
make sure to use in-memory db in test
fix scope can be null
allow cross_origin for /.well-known/openid-configuration and /jwks
fix footer link
center authorize form
rename trial_expiration to plan_expiration
move stripe init to create_app()
use real email to be able to receive email notification
add user.profile_picture_id column
use user profile picture and fallback to gravatar
use nguyenkims+local@gm to distinguish with staging
handle plan cancel, reactivation, user profile update
fix can_create_new_email
create cron.py that set plan to free when expired
add crontab.yml
add yacron
use notify_admin instead of LOG.error
add ResetPasswordCode model
user can change password in setting
increase display time for notie
add forgot_password page
If login error: redirect to this page upon success login.
hide discover tab
add column user.is_developer
only show developer menu to developer
comment out the publish button
set local user to developer
make sure only developer can access /developer blueprint
User is invited to upgrade if they are in free plan or their trial ends soon
not sending email when in local mode
create Partner model
create become partner page
use normal error handling on local
fix migration
add "import sqlalchemy_utils" into migration template
small refactoring on setting page
handle promo code. TODO: add migration file
add migration for user.promo_codes
move email alias on top of apps in dashboard
add introjs
move encode_url to utils
create GenEmail.create_new_gen_email
create a first alias mail to show user how to use when they login
show intro when user visits the website the first time
fix register
2019-07-02 07:20:12 +00:00
|
|
|
|
2020-05-09 18:43:17 +00:00
|
|
|
import arrow
|
2019-12-17 16:48:06 +00:00
|
|
|
import dkim
|
2019-11-16 14:19:43 +00:00
|
|
|
from jinja2 import Environment, FileSystemLoader
|
create BaseForm to enable CSRF
register page
redirect user to dashboard if they are logged in
enable csrf for login page
Set models more strict
bootstrap developer page
add helper method to ModelMixin, remove CRUDMixin
display list of clients on developer index, add copy client-secret to clipboard using clipboardjs
add toastr and use jquery non slim
display a toast when user copies the client-secret
create new client, generate client-id using unidecode
client detail page: can edit client
add delete client
implement /oauth/authorize and /oauth/allow-deny
implement /oauth/token
add /oauth/user_info endpoint
handle scopes: wip
take into account scope: display scope, return user data according to scope
create virtual-domain, gen email, client_user model WIP
create authorize_nonlogin_user page
user can choose to generate a new email
no need to interfere with root logger
log for before and after request
if user has already allowed a client: generate a auth-code and redirect user to client
get_user_info takes into account gen email
display list of clients that have user has authorised
use yk-client domain instead of localhost as cookie depends on the domain name
use wtforms instead of flask_wtf
Dockerfile
delete virtual domain
EMAIL_DOMAIN can come from env var
bind to host 0.0.0.0
fix signup error: use session as default csrf_context
rename yourkey to simplelogin
add python-dotenv, ipython, sqlalchemy_utils
create DB_URI, FLASK_SECRET. Load config from CONFIG file if exist
add shortcuts to logging
create shell
add psycopg2
do not add local data in Dockerfile
add drop_db into shell
add shell.prepare_db()
fix prepare_db
setup sentry
copy assets from tabler/dist
add icon downloaded from https://commons.wikimedia.org/wiki/File:Simpleicons_Interface_key-tool-1.svg
integrate tabler - login and register page
add favicon
template: default, header. Use gravatar for user avatar url
use default template for dashboard, developer page
use another icon
add clipboard and notie
prettify dashboard
add notie css
add fake gen email and client-user
prettify list client page, use notie for toast
add email, name scope to new client
display client scope in client list
prettify new-client, client-detail
add sentry-sdk and blinker
add arrow, add dt jinja filter, prettify logout, dashboard
comment "last used" in dashboard for now
prettify date display
add copy email to clipboard to dashboard
use "users" as table name for User as "user" is reserved key in postgres
call prepare_db() when creating new db
error page 400, 401, 403, 404
prettify authorize_login_user
create already_authorize.html for user who has already authorized a client
user can generate new email
display all other generated emails
add ENV variable, only reset DB when ENV=local
fix: not return other users gen emails
display nb users for each client
refactor shell: remove prepare_db()
add sendgrid
add /favicon.ico route
add new config: URL, SUPPORT_EMAIL, SENDGRID_API_KEY
user needs to activate their account before login
create copy button on dashboard
client can have multiple redirect uris, in client detail can add/remove redirect-uri,
use redirect_uri passed in /authorize
refactor: move get_user_info into ClientUser model
dashboard: display all apps, all generated emails
add "id" into user_info
add trigger email button
invalidate the session at each new version by changing the secret
centralize Client creation into Client.create_new
user can enable/disable email forwarding
setup auto dismiss alert: just add .alert-auto-dismiss
move name down in register form
add shell.add_real_data
move blueprint template to its own package
prettify authorize page for non-authenticated user
update readme, return error if not redirect_uri
add flask-wtf, use psycopg2-binary
use flask-wtf FlaskForm instead of Form
rename email -> email_utils
add AWS_REGION, BUCKET, AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY to config
add s3 module
add File model, add Client.icon_id
handle client icon update
can create client with icon
display client icon in client list page
add Client.home_url
take into account Client.home_url
add boto3
register: ask name first
only show "trigger test email" if email forwarding is enabled
display gen email in alphabetical order, client in client.name alphabetical order
better error page
the modal does not get close when user clicks outside of modal
add Client.published column
discover page that displays all published Client
add missing bootstrap.bundle.min.js.map
developer can publish/unpublish their app in discover
use notie for display flash message
create hotmail account
fix missing jquery
add footer, add global jinja2 variable
strengthen model: use nullable=False whenever possible,
rename client_id to oauth_client_id, client_secret to oauth_client_secret
add flask-migrate
init migrate
1st migrate version
fix rename client_id -> oauth_client_id
prettify UI
use flask_migrate.upgrade() instead of db.create_all()
make sure requirejs.config is called for all page
enable sentry for js, use uppercase for global jinja2 variables
add flask-admin
add User.is_admin column
setup flask admin, only accessible to admin user
fix migration: add server_default
replace session[redirect_after_login] by "next" request args
add pyproject.toml: ignore migrations/ in black
add register waiting_activation_email page
better email wording
add pytest
add get_host_name_and_scheme and tests
example fail test
fix test
fix client-id display
add flask-cors
/user_info supports cors, add /me as /user_info synonym
return client in /me
support implicit flow
no need to use with "app.app_context()"
add watchtower to requirement
add param ENABLE_CLOUDWATCH, CLOUDWATCH_LOG_GROUP, CLOUDWATCH_LOG_STREAM
add cloudwatch logger if cloudwatch is enabled
add 500 error page
add help text for list of used client
display list of app/website that an email has been used
click on client name brings to client detail page
create style.css to add additional style, append its url with the current sha1 to avoid cache
POC on how to send email using postfix
add sqlalchemy-utils
use arrow instead of datetime
add new params STRIPE_API, STRIPE_YEARLY_SKU, STRIPE_MONTHLY_PLAN
show full error in local
add plan, plan_expiration to User, need to create enum directly in migration script, cf https://github.com/sqlalchemy/alembic/issues/67
reformat all html files: use space instead of tab
new user will have trial plan for 15 days
add new param MAX_NB_EMAIL_FREE_PLAN
only user with enough quota can create new email
if user cannot create new gen email, pick randomly one from existing gen emails. Use flush instead of commit
rename STRIPE_YEARLY_SKU -> STRIPE_YEARLY_PLAN
open client page in discover in a new tab
add stripe
not logging /static call: disable flask logging, replace by after_request
add param STRIPE_SECRET_KEY
add 3 columns stripe_customer_id, stripe_card_token, stripe_subscription_id
user can upgrade their pricing
add setting page as coming-soon
add GenEmail, ClientUser to admin
ignore /admin/static logging
add more fake data
add ondelete="cascade" whenever possible
rename plan_expiration -> trial_expiration
reset migration: delete old migrations, create new one
rename test_send_email -> poc_send_email to avoid the file being called by pytest
add new param LYRA_ANALYTICS_ID, add lyra analytics
add how to create new migration into readme
add drift to base.html
notify admin when new user signs up or pays subscription
log exception in case of 500
use sendgrid to notify admin
add alias /userinfo to user_info endpoint
add change_password to shell
add info on how payment is handled
invite user to retry if card not working
remove drift and add "contact us" link
move poc_send_email into poc/
support getting client-id, client-secret from form-data in addition to basic auth
client-id, client-secret is passed in form-data by passport-oauth2 for ex
add jwtRS256 private and public key
add jwk-jws-jwt poc
add new param OPENID_PRIVATE_KEY_PATH, OPENID_PRIVATE_KEY_PATH
add scope, redirect_url to AuthorizationCode and OauthToken
take into scope when creating oauth-token, authorization-code
add jwcrypto
add jose_utils: make_id_token and verify_id_token
add &scope to redirect uri
add "email_verified": True into user_info
fix user not activated
add /oauth2 as alias for /oauth
handle case where scope and state are empty
remove threaded=False
Use Email Alias as wording
remove help text
user can re-send activation email
add "expired" into ActivationCode
Handle the case activation code is expired
reformat: use form.validate_on_submit instead of request.method == post && form.validate
use error text instead of flash()
display client oauth-id and oauth-secret on client detail page
not display oauth-secret on client listing
fix expiration check
improve page title, footer
add /jwks and /.well-known/openid-configuration
init properly tests, fix blueprint conflict bug in flask-admin
create oauth_models module
rename Scope -> ScopeE to distinguish with Scope DB model
set app.url_map.strict_slashes = False
use ScopeE instead of SCOPE_NAME, ...
support access_token passed as args in /userinfo
merge /allow-deny into /authorize
improve wording
take into account the case response_type=code and openid is in scope
take into account response_type=id_token, id_token token, id_token code
make sure to use in-memory db in test
fix scope can be null
allow cross_origin for /.well-known/openid-configuration and /jwks
fix footer link
center authorize form
rename trial_expiration to plan_expiration
move stripe init to create_app()
use real email to be able to receive email notification
add user.profile_picture_id column
use user profile picture and fallback to gravatar
use nguyenkims+local@gm to distinguish with staging
handle plan cancel, reactivation, user profile update
fix can_create_new_email
create cron.py that set plan to free when expired
add crontab.yml
add yacron
use notify_admin instead of LOG.error
add ResetPasswordCode model
user can change password in setting
increase display time for notie
add forgot_password page
If login error: redirect to this page upon success login.
hide discover tab
add column user.is_developer
only show developer menu to developer
comment out the publish button
set local user to developer
make sure only developer can access /developer blueprint
User is invited to upgrade if they are in free plan or their trial ends soon
not sending email when in local mode
create Partner model
create become partner page
use normal error handling on local
fix migration
add "import sqlalchemy_utils" into migration template
small refactoring on setting page
handle promo code. TODO: add migration file
add migration for user.promo_codes
move email alias on top of apps in dashboard
add introjs
move encode_url to utils
create GenEmail.create_new_gen_email
create a first alias mail to show user how to use when they login
show intro when user visits the website the first time
fix register
2019-07-02 07:20:12 +00:00
|
|
|
|
2019-12-17 16:48:06 +00:00
|
|
|
from app.config import (
|
|
|
|
SUPPORT_EMAIL,
|
|
|
|
ROOT_DIR,
|
|
|
|
POSTFIX_SERVER,
|
|
|
|
NOT_SEND_EMAIL,
|
|
|
|
DKIM_SELECTOR,
|
|
|
|
DKIM_PRIVATE_KEY,
|
|
|
|
DKIM_HEADERS,
|
2020-01-22 09:13:58 +00:00
|
|
|
ALIAS_DOMAINS,
|
2020-01-28 02:31:47 +00:00
|
|
|
SUPPORT_NAME,
|
2020-03-03 09:48:55 +00:00
|
|
|
POSTFIX_SUBMISSION_TLS,
|
2020-04-08 21:06:56 +00:00
|
|
|
MAX_NB_EMAIL_FREE_PLAN,
|
2020-04-16 07:43:14 +00:00
|
|
|
DISPOSABLE_EMAIL_DOMAINS,
|
2020-05-09 18:43:17 +00:00
|
|
|
MAX_ALERT_24H,
|
2020-05-21 18:43:03 +00:00
|
|
|
POSTFIX_PORT,
|
2020-06-10 11:55:47 +00:00
|
|
|
SENDER,
|
2020-08-14 14:23:29 +00:00
|
|
|
URL,
|
2019-12-17 16:48:06 +00:00
|
|
|
)
|
2020-04-27 16:17:50 +00:00
|
|
|
from app.dns_utils import get_mx_domains
|
2020-05-09 18:43:17 +00:00
|
|
|
from app.extensions import db
|
2019-11-16 21:20:48 +00:00
|
|
|
from app.log import LOG
|
2020-05-09 18:43:17 +00:00
|
|
|
from app.models import Mailbox, User, SentAlert
|
create BaseForm to enable CSRF
register page
redirect user to dashboard if they are logged in
enable csrf for login page
Set models more strict
bootstrap developer page
add helper method to ModelMixin, remove CRUDMixin
display list of clients on developer index, add copy client-secret to clipboard using clipboardjs
add toastr and use jquery non slim
display a toast when user copies the client-secret
create new client, generate client-id using unidecode
client detail page: can edit client
add delete client
implement /oauth/authorize and /oauth/allow-deny
implement /oauth/token
add /oauth/user_info endpoint
handle scopes: wip
take into account scope: display scope, return user data according to scope
create virtual-domain, gen email, client_user model WIP
create authorize_nonlogin_user page
user can choose to generate a new email
no need to interfere with root logger
log for before and after request
if user has already allowed a client: generate a auth-code and redirect user to client
get_user_info takes into account gen email
display list of clients that have user has authorised
use yk-client domain instead of localhost as cookie depends on the domain name
use wtforms instead of flask_wtf
Dockerfile
delete virtual domain
EMAIL_DOMAIN can come from env var
bind to host 0.0.0.0
fix signup error: use session as default csrf_context
rename yourkey to simplelogin
add python-dotenv, ipython, sqlalchemy_utils
create DB_URI, FLASK_SECRET. Load config from CONFIG file if exist
add shortcuts to logging
create shell
add psycopg2
do not add local data in Dockerfile
add drop_db into shell
add shell.prepare_db()
fix prepare_db
setup sentry
copy assets from tabler/dist
add icon downloaded from https://commons.wikimedia.org/wiki/File:Simpleicons_Interface_key-tool-1.svg
integrate tabler - login and register page
add favicon
template: default, header. Use gravatar for user avatar url
use default template for dashboard, developer page
use another icon
add clipboard and notie
prettify dashboard
add notie css
add fake gen email and client-user
prettify list client page, use notie for toast
add email, name scope to new client
display client scope in client list
prettify new-client, client-detail
add sentry-sdk and blinker
add arrow, add dt jinja filter, prettify logout, dashboard
comment "last used" in dashboard for now
prettify date display
add copy email to clipboard to dashboard
use "users" as table name for User as "user" is reserved key in postgres
call prepare_db() when creating new db
error page 400, 401, 403, 404
prettify authorize_login_user
create already_authorize.html for user who has already authorized a client
user can generate new email
display all other generated emails
add ENV variable, only reset DB when ENV=local
fix: not return other users gen emails
display nb users for each client
refactor shell: remove prepare_db()
add sendgrid
add /favicon.ico route
add new config: URL, SUPPORT_EMAIL, SENDGRID_API_KEY
user needs to activate their account before login
create copy button on dashboard
client can have multiple redirect uris, in client detail can add/remove redirect-uri,
use redirect_uri passed in /authorize
refactor: move get_user_info into ClientUser model
dashboard: display all apps, all generated emails
add "id" into user_info
add trigger email button
invalidate the session at each new version by changing the secret
centralize Client creation into Client.create_new
user can enable/disable email forwarding
setup auto dismiss alert: just add .alert-auto-dismiss
move name down in register form
add shell.add_real_data
move blueprint template to its own package
prettify authorize page for non-authenticated user
update readme, return error if not redirect_uri
add flask-wtf, use psycopg2-binary
use flask-wtf FlaskForm instead of Form
rename email -> email_utils
add AWS_REGION, BUCKET, AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY to config
add s3 module
add File model, add Client.icon_id
handle client icon update
can create client with icon
display client icon in client list page
add Client.home_url
take into account Client.home_url
add boto3
register: ask name first
only show "trigger test email" if email forwarding is enabled
display gen email in alphabetical order, client in client.name alphabetical order
better error page
the modal does not get close when user clicks outside of modal
add Client.published column
discover page that displays all published Client
add missing bootstrap.bundle.min.js.map
developer can publish/unpublish their app in discover
use notie for display flash message
create hotmail account
fix missing jquery
add footer, add global jinja2 variable
strengthen model: use nullable=False whenever possible,
rename client_id to oauth_client_id, client_secret to oauth_client_secret
add flask-migrate
init migrate
1st migrate version
fix rename client_id -> oauth_client_id
prettify UI
use flask_migrate.upgrade() instead of db.create_all()
make sure requirejs.config is called for all page
enable sentry for js, use uppercase for global jinja2 variables
add flask-admin
add User.is_admin column
setup flask admin, only accessible to admin user
fix migration: add server_default
replace session[redirect_after_login] by "next" request args
add pyproject.toml: ignore migrations/ in black
add register waiting_activation_email page
better email wording
add pytest
add get_host_name_and_scheme and tests
example fail test
fix test
fix client-id display
add flask-cors
/user_info supports cors, add /me as /user_info synonym
return client in /me
support implicit flow
no need to use with "app.app_context()"
add watchtower to requirement
add param ENABLE_CLOUDWATCH, CLOUDWATCH_LOG_GROUP, CLOUDWATCH_LOG_STREAM
add cloudwatch logger if cloudwatch is enabled
add 500 error page
add help text for list of used client
display list of app/website that an email has been used
click on client name brings to client detail page
create style.css to add additional style, append its url with the current sha1 to avoid cache
POC on how to send email using postfix
add sqlalchemy-utils
use arrow instead of datetime
add new params STRIPE_API, STRIPE_YEARLY_SKU, STRIPE_MONTHLY_PLAN
show full error in local
add plan, plan_expiration to User, need to create enum directly in migration script, cf https://github.com/sqlalchemy/alembic/issues/67
reformat all html files: use space instead of tab
new user will have trial plan for 15 days
add new param MAX_NB_EMAIL_FREE_PLAN
only user with enough quota can create new email
if user cannot create new gen email, pick randomly one from existing gen emails. Use flush instead of commit
rename STRIPE_YEARLY_SKU -> STRIPE_YEARLY_PLAN
open client page in discover in a new tab
add stripe
not logging /static call: disable flask logging, replace by after_request
add param STRIPE_SECRET_KEY
add 3 columns stripe_customer_id, stripe_card_token, stripe_subscription_id
user can upgrade their pricing
add setting page as coming-soon
add GenEmail, ClientUser to admin
ignore /admin/static logging
add more fake data
add ondelete="cascade" whenever possible
rename plan_expiration -> trial_expiration
reset migration: delete old migrations, create new one
rename test_send_email -> poc_send_email to avoid the file being called by pytest
add new param LYRA_ANALYTICS_ID, add lyra analytics
add how to create new migration into readme
add drift to base.html
notify admin when new user signs up or pays subscription
log exception in case of 500
use sendgrid to notify admin
add alias /userinfo to user_info endpoint
add change_password to shell
add info on how payment is handled
invite user to retry if card not working
remove drift and add "contact us" link
move poc_send_email into poc/
support getting client-id, client-secret from form-data in addition to basic auth
client-id, client-secret is passed in form-data by passport-oauth2 for ex
add jwtRS256 private and public key
add jwk-jws-jwt poc
add new param OPENID_PRIVATE_KEY_PATH, OPENID_PRIVATE_KEY_PATH
add scope, redirect_url to AuthorizationCode and OauthToken
take into scope when creating oauth-token, authorization-code
add jwcrypto
add jose_utils: make_id_token and verify_id_token
add &scope to redirect uri
add "email_verified": True into user_info
fix user not activated
add /oauth2 as alias for /oauth
handle case where scope and state are empty
remove threaded=False
Use Email Alias as wording
remove help text
user can re-send activation email
add "expired" into ActivationCode
Handle the case activation code is expired
reformat: use form.validate_on_submit instead of request.method == post && form.validate
use error text instead of flash()
display client oauth-id and oauth-secret on client detail page
not display oauth-secret on client listing
fix expiration check
improve page title, footer
add /jwks and /.well-known/openid-configuration
init properly tests, fix blueprint conflict bug in flask-admin
create oauth_models module
rename Scope -> ScopeE to distinguish with Scope DB model
set app.url_map.strict_slashes = False
use ScopeE instead of SCOPE_NAME, ...
support access_token passed as args in /userinfo
merge /allow-deny into /authorize
improve wording
take into account the case response_type=code and openid is in scope
take into account response_type=id_token, id_token token, id_token code
make sure to use in-memory db in test
fix scope can be null
allow cross_origin for /.well-known/openid-configuration and /jwks
fix footer link
center authorize form
rename trial_expiration to plan_expiration
move stripe init to create_app()
use real email to be able to receive email notification
add user.profile_picture_id column
use user profile picture and fallback to gravatar
use nguyenkims+local@gm to distinguish with staging
handle plan cancel, reactivation, user profile update
fix can_create_new_email
create cron.py that set plan to free when expired
add crontab.yml
add yacron
use notify_admin instead of LOG.error
add ResetPasswordCode model
user can change password in setting
increase display time for notie
add forgot_password page
If login error: redirect to this page upon success login.
hide discover tab
add column user.is_developer
only show developer menu to developer
comment out the publish button
set local user to developer
make sure only developer can access /developer blueprint
User is invited to upgrade if they are in free plan or their trial ends soon
not sending email when in local mode
create Partner model
create become partner page
use normal error handling on local
fix migration
add "import sqlalchemy_utils" into migration template
small refactoring on setting page
handle promo code. TODO: add migration file
add migration for user.promo_codes
move email alias on top of apps in dashboard
add introjs
move encode_url to utils
create GenEmail.create_new_gen_email
create a first alias mail to show user how to use when they login
show intro when user visits the website the first time
fix register
2019-07-02 07:20:12 +00:00
|
|
|
|
|
|
|
|
2020-02-03 06:00:58 +00:00
|
|
|
def render(template_name, **kwargs) -> str:
|
2019-11-16 14:19:43 +00:00
|
|
|
templates_dir = os.path.join(ROOT_DIR, "templates", "emails")
|
|
|
|
env = Environment(loader=FileSystemLoader(templates_dir))
|
create BaseForm to enable CSRF
register page
redirect user to dashboard if they are logged in
enable csrf for login page
Set models more strict
bootstrap developer page
add helper method to ModelMixin, remove CRUDMixin
display list of clients on developer index, add copy client-secret to clipboard using clipboardjs
add toastr and use jquery non slim
display a toast when user copies the client-secret
create new client, generate client-id using unidecode
client detail page: can edit client
add delete client
implement /oauth/authorize and /oauth/allow-deny
implement /oauth/token
add /oauth/user_info endpoint
handle scopes: wip
take into account scope: display scope, return user data according to scope
create virtual-domain, gen email, client_user model WIP
create authorize_nonlogin_user page
user can choose to generate a new email
no need to interfere with root logger
log for before and after request
if user has already allowed a client: generate a auth-code and redirect user to client
get_user_info takes into account gen email
display list of clients that have user has authorised
use yk-client domain instead of localhost as cookie depends on the domain name
use wtforms instead of flask_wtf
Dockerfile
delete virtual domain
EMAIL_DOMAIN can come from env var
bind to host 0.0.0.0
fix signup error: use session as default csrf_context
rename yourkey to simplelogin
add python-dotenv, ipython, sqlalchemy_utils
create DB_URI, FLASK_SECRET. Load config from CONFIG file if exist
add shortcuts to logging
create shell
add psycopg2
do not add local data in Dockerfile
add drop_db into shell
add shell.prepare_db()
fix prepare_db
setup sentry
copy assets from tabler/dist
add icon downloaded from https://commons.wikimedia.org/wiki/File:Simpleicons_Interface_key-tool-1.svg
integrate tabler - login and register page
add favicon
template: default, header. Use gravatar for user avatar url
use default template for dashboard, developer page
use another icon
add clipboard and notie
prettify dashboard
add notie css
add fake gen email and client-user
prettify list client page, use notie for toast
add email, name scope to new client
display client scope in client list
prettify new-client, client-detail
add sentry-sdk and blinker
add arrow, add dt jinja filter, prettify logout, dashboard
comment "last used" in dashboard for now
prettify date display
add copy email to clipboard to dashboard
use "users" as table name for User as "user" is reserved key in postgres
call prepare_db() when creating new db
error page 400, 401, 403, 404
prettify authorize_login_user
create already_authorize.html for user who has already authorized a client
user can generate new email
display all other generated emails
add ENV variable, only reset DB when ENV=local
fix: not return other users gen emails
display nb users for each client
refactor shell: remove prepare_db()
add sendgrid
add /favicon.ico route
add new config: URL, SUPPORT_EMAIL, SENDGRID_API_KEY
user needs to activate their account before login
create copy button on dashboard
client can have multiple redirect uris, in client detail can add/remove redirect-uri,
use redirect_uri passed in /authorize
refactor: move get_user_info into ClientUser model
dashboard: display all apps, all generated emails
add "id" into user_info
add trigger email button
invalidate the session at each new version by changing the secret
centralize Client creation into Client.create_new
user can enable/disable email forwarding
setup auto dismiss alert: just add .alert-auto-dismiss
move name down in register form
add shell.add_real_data
move blueprint template to its own package
prettify authorize page for non-authenticated user
update readme, return error if not redirect_uri
add flask-wtf, use psycopg2-binary
use flask-wtf FlaskForm instead of Form
rename email -> email_utils
add AWS_REGION, BUCKET, AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY to config
add s3 module
add File model, add Client.icon_id
handle client icon update
can create client with icon
display client icon in client list page
add Client.home_url
take into account Client.home_url
add boto3
register: ask name first
only show "trigger test email" if email forwarding is enabled
display gen email in alphabetical order, client in client.name alphabetical order
better error page
the modal does not get close when user clicks outside of modal
add Client.published column
discover page that displays all published Client
add missing bootstrap.bundle.min.js.map
developer can publish/unpublish their app in discover
use notie for display flash message
create hotmail account
fix missing jquery
add footer, add global jinja2 variable
strengthen model: use nullable=False whenever possible,
rename client_id to oauth_client_id, client_secret to oauth_client_secret
add flask-migrate
init migrate
1st migrate version
fix rename client_id -> oauth_client_id
prettify UI
use flask_migrate.upgrade() instead of db.create_all()
make sure requirejs.config is called for all page
enable sentry for js, use uppercase for global jinja2 variables
add flask-admin
add User.is_admin column
setup flask admin, only accessible to admin user
fix migration: add server_default
replace session[redirect_after_login] by "next" request args
add pyproject.toml: ignore migrations/ in black
add register waiting_activation_email page
better email wording
add pytest
add get_host_name_and_scheme and tests
example fail test
fix test
fix client-id display
add flask-cors
/user_info supports cors, add /me as /user_info synonym
return client in /me
support implicit flow
no need to use with "app.app_context()"
add watchtower to requirement
add param ENABLE_CLOUDWATCH, CLOUDWATCH_LOG_GROUP, CLOUDWATCH_LOG_STREAM
add cloudwatch logger if cloudwatch is enabled
add 500 error page
add help text for list of used client
display list of app/website that an email has been used
click on client name brings to client detail page
create style.css to add additional style, append its url with the current sha1 to avoid cache
POC on how to send email using postfix
add sqlalchemy-utils
use arrow instead of datetime
add new params STRIPE_API, STRIPE_YEARLY_SKU, STRIPE_MONTHLY_PLAN
show full error in local
add plan, plan_expiration to User, need to create enum directly in migration script, cf https://github.com/sqlalchemy/alembic/issues/67
reformat all html files: use space instead of tab
new user will have trial plan for 15 days
add new param MAX_NB_EMAIL_FREE_PLAN
only user with enough quota can create new email
if user cannot create new gen email, pick randomly one from existing gen emails. Use flush instead of commit
rename STRIPE_YEARLY_SKU -> STRIPE_YEARLY_PLAN
open client page in discover in a new tab
add stripe
not logging /static call: disable flask logging, replace by after_request
add param STRIPE_SECRET_KEY
add 3 columns stripe_customer_id, stripe_card_token, stripe_subscription_id
user can upgrade their pricing
add setting page as coming-soon
add GenEmail, ClientUser to admin
ignore /admin/static logging
add more fake data
add ondelete="cascade" whenever possible
rename plan_expiration -> trial_expiration
reset migration: delete old migrations, create new one
rename test_send_email -> poc_send_email to avoid the file being called by pytest
add new param LYRA_ANALYTICS_ID, add lyra analytics
add how to create new migration into readme
add drift to base.html
notify admin when new user signs up or pays subscription
log exception in case of 500
use sendgrid to notify admin
add alias /userinfo to user_info endpoint
add change_password to shell
add info on how payment is handled
invite user to retry if card not working
remove drift and add "contact us" link
move poc_send_email into poc/
support getting client-id, client-secret from form-data in addition to basic auth
client-id, client-secret is passed in form-data by passport-oauth2 for ex
add jwtRS256 private and public key
add jwk-jws-jwt poc
add new param OPENID_PRIVATE_KEY_PATH, OPENID_PRIVATE_KEY_PATH
add scope, redirect_url to AuthorizationCode and OauthToken
take into scope when creating oauth-token, authorization-code
add jwcrypto
add jose_utils: make_id_token and verify_id_token
add &scope to redirect uri
add "email_verified": True into user_info
fix user not activated
add /oauth2 as alias for /oauth
handle case where scope and state are empty
remove threaded=False
Use Email Alias as wording
remove help text
user can re-send activation email
add "expired" into ActivationCode
Handle the case activation code is expired
reformat: use form.validate_on_submit instead of request.method == post && form.validate
use error text instead of flash()
display client oauth-id and oauth-secret on client detail page
not display oauth-secret on client listing
fix expiration check
improve page title, footer
add /jwks and /.well-known/openid-configuration
init properly tests, fix blueprint conflict bug in flask-admin
create oauth_models module
rename Scope -> ScopeE to distinguish with Scope DB model
set app.url_map.strict_slashes = False
use ScopeE instead of SCOPE_NAME, ...
support access_token passed as args in /userinfo
merge /allow-deny into /authorize
improve wording
take into account the case response_type=code and openid is in scope
take into account response_type=id_token, id_token token, id_token code
make sure to use in-memory db in test
fix scope can be null
allow cross_origin for /.well-known/openid-configuration and /jwks
fix footer link
center authorize form
rename trial_expiration to plan_expiration
move stripe init to create_app()
use real email to be able to receive email notification
add user.profile_picture_id column
use user profile picture and fallback to gravatar
use nguyenkims+local@gm to distinguish with staging
handle plan cancel, reactivation, user profile update
fix can_create_new_email
create cron.py that set plan to free when expired
add crontab.yml
add yacron
use notify_admin instead of LOG.error
add ResetPasswordCode model
user can change password in setting
increase display time for notie
add forgot_password page
If login error: redirect to this page upon success login.
hide discover tab
add column user.is_developer
only show developer menu to developer
comment out the publish button
set local user to developer
make sure only developer can access /developer blueprint
User is invited to upgrade if they are in free plan or their trial ends soon
not sending email when in local mode
create Partner model
create become partner page
use normal error handling on local
fix migration
add "import sqlalchemy_utils" into migration template
small refactoring on setting page
handle promo code. TODO: add migration file
add migration for user.promo_codes
move email alias on top of apps in dashboard
add introjs
move encode_url to utils
create GenEmail.create_new_gen_email
create a first alias mail to show user how to use when they login
show intro when user visits the website the first time
fix register
2019-07-02 07:20:12 +00:00
|
|
|
|
2019-11-16 14:19:43 +00:00
|
|
|
template = env.get_template(template_name)
|
2019-07-03 09:22:38 +00:00
|
|
|
|
2020-08-14 14:30:43 +00:00
|
|
|
return template.render(
|
2020-08-14 14:50:59 +00:00
|
|
|
MAX_NB_EMAIL_FREE_PLAN=MAX_NB_EMAIL_FREE_PLAN, URL=URL, **kwargs,
|
|
|
|
)
|
2019-11-16 14:19:43 +00:00
|
|
|
|
|
|
|
|
2020-01-30 06:54:33 +00:00
|
|
|
def send_welcome_email(user):
|
2019-12-16 17:36:59 +00:00
|
|
|
send_email(
|
2020-01-30 06:54:33 +00:00
|
|
|
user.email,
|
|
|
|
f"Welcome to SimpleLogin {user.name}",
|
2020-02-03 06:00:58 +00:00
|
|
|
render("com/welcome.txt", name=user.name, user=user),
|
|
|
|
render("com/welcome.html", name=user.name, user=user),
|
2019-11-16 14:19:43 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
|
2020-01-30 07:19:09 +00:00
|
|
|
def send_trial_end_soon_email(user):
|
|
|
|
send_email(
|
|
|
|
user.email,
|
|
|
|
f"Your trial will end soon {user.name}",
|
2020-02-03 06:00:58 +00:00
|
|
|
render("transactional/trial-end.txt", name=user.name, user=user),
|
|
|
|
render("transactional/trial-end.html", name=user.name, user=user),
|
2020-01-30 07:19:09 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
|
2019-11-16 14:19:43 +00:00
|
|
|
def send_activation_email(email, name, activation_link):
|
2019-12-16 17:36:59 +00:00
|
|
|
send_email(
|
2019-11-16 14:19:43 +00:00
|
|
|
email,
|
2020-01-11 21:33:25 +00:00
|
|
|
f"Just one more step to join SimpleLogin {name}",
|
2020-02-03 06:00:58 +00:00
|
|
|
render(
|
2020-02-02 14:49:38 +00:00
|
|
|
"transactional/activation.txt",
|
|
|
|
name=name,
|
|
|
|
activation_link=activation_link,
|
|
|
|
email=email,
|
2019-11-20 20:51:12 +00:00
|
|
|
),
|
2020-02-03 06:00:58 +00:00
|
|
|
render(
|
2020-02-02 14:49:38 +00:00
|
|
|
"transactional/activation.html",
|
|
|
|
name=name,
|
|
|
|
activation_link=activation_link,
|
|
|
|
email=email,
|
2019-11-20 20:51:12 +00:00
|
|
|
),
|
create BaseForm to enable CSRF
register page
redirect user to dashboard if they are logged in
enable csrf for login page
Set models more strict
bootstrap developer page
add helper method to ModelMixin, remove CRUDMixin
display list of clients on developer index, add copy client-secret to clipboard using clipboardjs
add toastr and use jquery non slim
display a toast when user copies the client-secret
create new client, generate client-id using unidecode
client detail page: can edit client
add delete client
implement /oauth/authorize and /oauth/allow-deny
implement /oauth/token
add /oauth/user_info endpoint
handle scopes: wip
take into account scope: display scope, return user data according to scope
create virtual-domain, gen email, client_user model WIP
create authorize_nonlogin_user page
user can choose to generate a new email
no need to interfere with root logger
log for before and after request
if user has already allowed a client: generate a auth-code and redirect user to client
get_user_info takes into account gen email
display list of clients that have user has authorised
use yk-client domain instead of localhost as cookie depends on the domain name
use wtforms instead of flask_wtf
Dockerfile
delete virtual domain
EMAIL_DOMAIN can come from env var
bind to host 0.0.0.0
fix signup error: use session as default csrf_context
rename yourkey to simplelogin
add python-dotenv, ipython, sqlalchemy_utils
create DB_URI, FLASK_SECRET. Load config from CONFIG file if exist
add shortcuts to logging
create shell
add psycopg2
do not add local data in Dockerfile
add drop_db into shell
add shell.prepare_db()
fix prepare_db
setup sentry
copy assets from tabler/dist
add icon downloaded from https://commons.wikimedia.org/wiki/File:Simpleicons_Interface_key-tool-1.svg
integrate tabler - login and register page
add favicon
template: default, header. Use gravatar for user avatar url
use default template for dashboard, developer page
use another icon
add clipboard and notie
prettify dashboard
add notie css
add fake gen email and client-user
prettify list client page, use notie for toast
add email, name scope to new client
display client scope in client list
prettify new-client, client-detail
add sentry-sdk and blinker
add arrow, add dt jinja filter, prettify logout, dashboard
comment "last used" in dashboard for now
prettify date display
add copy email to clipboard to dashboard
use "users" as table name for User as "user" is reserved key in postgres
call prepare_db() when creating new db
error page 400, 401, 403, 404
prettify authorize_login_user
create already_authorize.html for user who has already authorized a client
user can generate new email
display all other generated emails
add ENV variable, only reset DB when ENV=local
fix: not return other users gen emails
display nb users for each client
refactor shell: remove prepare_db()
add sendgrid
add /favicon.ico route
add new config: URL, SUPPORT_EMAIL, SENDGRID_API_KEY
user needs to activate their account before login
create copy button on dashboard
client can have multiple redirect uris, in client detail can add/remove redirect-uri,
use redirect_uri passed in /authorize
refactor: move get_user_info into ClientUser model
dashboard: display all apps, all generated emails
add "id" into user_info
add trigger email button
invalidate the session at each new version by changing the secret
centralize Client creation into Client.create_new
user can enable/disable email forwarding
setup auto dismiss alert: just add .alert-auto-dismiss
move name down in register form
add shell.add_real_data
move blueprint template to its own package
prettify authorize page for non-authenticated user
update readme, return error if not redirect_uri
add flask-wtf, use psycopg2-binary
use flask-wtf FlaskForm instead of Form
rename email -> email_utils
add AWS_REGION, BUCKET, AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY to config
add s3 module
add File model, add Client.icon_id
handle client icon update
can create client with icon
display client icon in client list page
add Client.home_url
take into account Client.home_url
add boto3
register: ask name first
only show "trigger test email" if email forwarding is enabled
display gen email in alphabetical order, client in client.name alphabetical order
better error page
the modal does not get close when user clicks outside of modal
add Client.published column
discover page that displays all published Client
add missing bootstrap.bundle.min.js.map
developer can publish/unpublish their app in discover
use notie for display flash message
create hotmail account
fix missing jquery
add footer, add global jinja2 variable
strengthen model: use nullable=False whenever possible,
rename client_id to oauth_client_id, client_secret to oauth_client_secret
add flask-migrate
init migrate
1st migrate version
fix rename client_id -> oauth_client_id
prettify UI
use flask_migrate.upgrade() instead of db.create_all()
make sure requirejs.config is called for all page
enable sentry for js, use uppercase for global jinja2 variables
add flask-admin
add User.is_admin column
setup flask admin, only accessible to admin user
fix migration: add server_default
replace session[redirect_after_login] by "next" request args
add pyproject.toml: ignore migrations/ in black
add register waiting_activation_email page
better email wording
add pytest
add get_host_name_and_scheme and tests
example fail test
fix test
fix client-id display
add flask-cors
/user_info supports cors, add /me as /user_info synonym
return client in /me
support implicit flow
no need to use with "app.app_context()"
add watchtower to requirement
add param ENABLE_CLOUDWATCH, CLOUDWATCH_LOG_GROUP, CLOUDWATCH_LOG_STREAM
add cloudwatch logger if cloudwatch is enabled
add 500 error page
add help text for list of used client
display list of app/website that an email has been used
click on client name brings to client detail page
create style.css to add additional style, append its url with the current sha1 to avoid cache
POC on how to send email using postfix
add sqlalchemy-utils
use arrow instead of datetime
add new params STRIPE_API, STRIPE_YEARLY_SKU, STRIPE_MONTHLY_PLAN
show full error in local
add plan, plan_expiration to User, need to create enum directly in migration script, cf https://github.com/sqlalchemy/alembic/issues/67
reformat all html files: use space instead of tab
new user will have trial plan for 15 days
add new param MAX_NB_EMAIL_FREE_PLAN
only user with enough quota can create new email
if user cannot create new gen email, pick randomly one from existing gen emails. Use flush instead of commit
rename STRIPE_YEARLY_SKU -> STRIPE_YEARLY_PLAN
open client page in discover in a new tab
add stripe
not logging /static call: disable flask logging, replace by after_request
add param STRIPE_SECRET_KEY
add 3 columns stripe_customer_id, stripe_card_token, stripe_subscription_id
user can upgrade their pricing
add setting page as coming-soon
add GenEmail, ClientUser to admin
ignore /admin/static logging
add more fake data
add ondelete="cascade" whenever possible
rename plan_expiration -> trial_expiration
reset migration: delete old migrations, create new one
rename test_send_email -> poc_send_email to avoid the file being called by pytest
add new param LYRA_ANALYTICS_ID, add lyra analytics
add how to create new migration into readme
add drift to base.html
notify admin when new user signs up or pays subscription
log exception in case of 500
use sendgrid to notify admin
add alias /userinfo to user_info endpoint
add change_password to shell
add info on how payment is handled
invite user to retry if card not working
remove drift and add "contact us" link
move poc_send_email into poc/
support getting client-id, client-secret from form-data in addition to basic auth
client-id, client-secret is passed in form-data by passport-oauth2 for ex
add jwtRS256 private and public key
add jwk-jws-jwt poc
add new param OPENID_PRIVATE_KEY_PATH, OPENID_PRIVATE_KEY_PATH
add scope, redirect_url to AuthorizationCode and OauthToken
take into scope when creating oauth-token, authorization-code
add jwcrypto
add jose_utils: make_id_token and verify_id_token
add &scope to redirect uri
add "email_verified": True into user_info
fix user not activated
add /oauth2 as alias for /oauth
handle case where scope and state are empty
remove threaded=False
Use Email Alias as wording
remove help text
user can re-send activation email
add "expired" into ActivationCode
Handle the case activation code is expired
reformat: use form.validate_on_submit instead of request.method == post && form.validate
use error text instead of flash()
display client oauth-id and oauth-secret on client detail page
not display oauth-secret on client listing
fix expiration check
improve page title, footer
add /jwks and /.well-known/openid-configuration
init properly tests, fix blueprint conflict bug in flask-admin
create oauth_models module
rename Scope -> ScopeE to distinguish with Scope DB model
set app.url_map.strict_slashes = False
use ScopeE instead of SCOPE_NAME, ...
support access_token passed as args in /userinfo
merge /allow-deny into /authorize
improve wording
take into account the case response_type=code and openid is in scope
take into account response_type=id_token, id_token token, id_token code
make sure to use in-memory db in test
fix scope can be null
allow cross_origin for /.well-known/openid-configuration and /jwks
fix footer link
center authorize form
rename trial_expiration to plan_expiration
move stripe init to create_app()
use real email to be able to receive email notification
add user.profile_picture_id column
use user profile picture and fallback to gravatar
use nguyenkims+local@gm to distinguish with staging
handle plan cancel, reactivation, user profile update
fix can_create_new_email
create cron.py that set plan to free when expired
add crontab.yml
add yacron
use notify_admin instead of LOG.error
add ResetPasswordCode model
user can change password in setting
increase display time for notie
add forgot_password page
If login error: redirect to this page upon success login.
hide discover tab
add column user.is_developer
only show developer menu to developer
comment out the publish button
set local user to developer
make sure only developer can access /developer blueprint
User is invited to upgrade if they are in free plan or their trial ends soon
not sending email when in local mode
create Partner model
create become partner page
use normal error handling on local
fix migration
add "import sqlalchemy_utils" into migration template
small refactoring on setting page
handle promo code. TODO: add migration file
add migration for user.promo_codes
move email alias on top of apps in dashboard
add introjs
move encode_url to utils
create GenEmail.create_new_gen_email
create a first alias mail to show user how to use when they login
show intro when user visits the website the first time
fix register
2019-07-02 07:20:12 +00:00
|
|
|
)
|
2019-11-15 13:11:51 +00:00
|
|
|
|
create BaseForm to enable CSRF
register page
redirect user to dashboard if they are logged in
enable csrf for login page
Set models more strict
bootstrap developer page
add helper method to ModelMixin, remove CRUDMixin
display list of clients on developer index, add copy client-secret to clipboard using clipboardjs
add toastr and use jquery non slim
display a toast when user copies the client-secret
create new client, generate client-id using unidecode
client detail page: can edit client
add delete client
implement /oauth/authorize and /oauth/allow-deny
implement /oauth/token
add /oauth/user_info endpoint
handle scopes: wip
take into account scope: display scope, return user data according to scope
create virtual-domain, gen email, client_user model WIP
create authorize_nonlogin_user page
user can choose to generate a new email
no need to interfere with root logger
log for before and after request
if user has already allowed a client: generate a auth-code and redirect user to client
get_user_info takes into account gen email
display list of clients that have user has authorised
use yk-client domain instead of localhost as cookie depends on the domain name
use wtforms instead of flask_wtf
Dockerfile
delete virtual domain
EMAIL_DOMAIN can come from env var
bind to host 0.0.0.0
fix signup error: use session as default csrf_context
rename yourkey to simplelogin
add python-dotenv, ipython, sqlalchemy_utils
create DB_URI, FLASK_SECRET. Load config from CONFIG file if exist
add shortcuts to logging
create shell
add psycopg2
do not add local data in Dockerfile
add drop_db into shell
add shell.prepare_db()
fix prepare_db
setup sentry
copy assets from tabler/dist
add icon downloaded from https://commons.wikimedia.org/wiki/File:Simpleicons_Interface_key-tool-1.svg
integrate tabler - login and register page
add favicon
template: default, header. Use gravatar for user avatar url
use default template for dashboard, developer page
use another icon
add clipboard and notie
prettify dashboard
add notie css
add fake gen email and client-user
prettify list client page, use notie for toast
add email, name scope to new client
display client scope in client list
prettify new-client, client-detail
add sentry-sdk and blinker
add arrow, add dt jinja filter, prettify logout, dashboard
comment "last used" in dashboard for now
prettify date display
add copy email to clipboard to dashboard
use "users" as table name for User as "user" is reserved key in postgres
call prepare_db() when creating new db
error page 400, 401, 403, 404
prettify authorize_login_user
create already_authorize.html for user who has already authorized a client
user can generate new email
display all other generated emails
add ENV variable, only reset DB when ENV=local
fix: not return other users gen emails
display nb users for each client
refactor shell: remove prepare_db()
add sendgrid
add /favicon.ico route
add new config: URL, SUPPORT_EMAIL, SENDGRID_API_KEY
user needs to activate their account before login
create copy button on dashboard
client can have multiple redirect uris, in client detail can add/remove redirect-uri,
use redirect_uri passed in /authorize
refactor: move get_user_info into ClientUser model
dashboard: display all apps, all generated emails
add "id" into user_info
add trigger email button
invalidate the session at each new version by changing the secret
centralize Client creation into Client.create_new
user can enable/disable email forwarding
setup auto dismiss alert: just add .alert-auto-dismiss
move name down in register form
add shell.add_real_data
move blueprint template to its own package
prettify authorize page for non-authenticated user
update readme, return error if not redirect_uri
add flask-wtf, use psycopg2-binary
use flask-wtf FlaskForm instead of Form
rename email -> email_utils
add AWS_REGION, BUCKET, AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY to config
add s3 module
add File model, add Client.icon_id
handle client icon update
can create client with icon
display client icon in client list page
add Client.home_url
take into account Client.home_url
add boto3
register: ask name first
only show "trigger test email" if email forwarding is enabled
display gen email in alphabetical order, client in client.name alphabetical order
better error page
the modal does not get close when user clicks outside of modal
add Client.published column
discover page that displays all published Client
add missing bootstrap.bundle.min.js.map
developer can publish/unpublish their app in discover
use notie for display flash message
create hotmail account
fix missing jquery
add footer, add global jinja2 variable
strengthen model: use nullable=False whenever possible,
rename client_id to oauth_client_id, client_secret to oauth_client_secret
add flask-migrate
init migrate
1st migrate version
fix rename client_id -> oauth_client_id
prettify UI
use flask_migrate.upgrade() instead of db.create_all()
make sure requirejs.config is called for all page
enable sentry for js, use uppercase for global jinja2 variables
add flask-admin
add User.is_admin column
setup flask admin, only accessible to admin user
fix migration: add server_default
replace session[redirect_after_login] by "next" request args
add pyproject.toml: ignore migrations/ in black
add register waiting_activation_email page
better email wording
add pytest
add get_host_name_and_scheme and tests
example fail test
fix test
fix client-id display
add flask-cors
/user_info supports cors, add /me as /user_info synonym
return client in /me
support implicit flow
no need to use with "app.app_context()"
add watchtower to requirement
add param ENABLE_CLOUDWATCH, CLOUDWATCH_LOG_GROUP, CLOUDWATCH_LOG_STREAM
add cloudwatch logger if cloudwatch is enabled
add 500 error page
add help text for list of used client
display list of app/website that an email has been used
click on client name brings to client detail page
create style.css to add additional style, append its url with the current sha1 to avoid cache
POC on how to send email using postfix
add sqlalchemy-utils
use arrow instead of datetime
add new params STRIPE_API, STRIPE_YEARLY_SKU, STRIPE_MONTHLY_PLAN
show full error in local
add plan, plan_expiration to User, need to create enum directly in migration script, cf https://github.com/sqlalchemy/alembic/issues/67
reformat all html files: use space instead of tab
new user will have trial plan for 15 days
add new param MAX_NB_EMAIL_FREE_PLAN
only user with enough quota can create new email
if user cannot create new gen email, pick randomly one from existing gen emails. Use flush instead of commit
rename STRIPE_YEARLY_SKU -> STRIPE_YEARLY_PLAN
open client page in discover in a new tab
add stripe
not logging /static call: disable flask logging, replace by after_request
add param STRIPE_SECRET_KEY
add 3 columns stripe_customer_id, stripe_card_token, stripe_subscription_id
user can upgrade their pricing
add setting page as coming-soon
add GenEmail, ClientUser to admin
ignore /admin/static logging
add more fake data
add ondelete="cascade" whenever possible
rename plan_expiration -> trial_expiration
reset migration: delete old migrations, create new one
rename test_send_email -> poc_send_email to avoid the file being called by pytest
add new param LYRA_ANALYTICS_ID, add lyra analytics
add how to create new migration into readme
add drift to base.html
notify admin when new user signs up or pays subscription
log exception in case of 500
use sendgrid to notify admin
add alias /userinfo to user_info endpoint
add change_password to shell
add info on how payment is handled
invite user to retry if card not working
remove drift and add "contact us" link
move poc_send_email into poc/
support getting client-id, client-secret from form-data in addition to basic auth
client-id, client-secret is passed in form-data by passport-oauth2 for ex
add jwtRS256 private and public key
add jwk-jws-jwt poc
add new param OPENID_PRIVATE_KEY_PATH, OPENID_PRIVATE_KEY_PATH
add scope, redirect_url to AuthorizationCode and OauthToken
take into scope when creating oauth-token, authorization-code
add jwcrypto
add jose_utils: make_id_token and verify_id_token
add &scope to redirect uri
add "email_verified": True into user_info
fix user not activated
add /oauth2 as alias for /oauth
handle case where scope and state are empty
remove threaded=False
Use Email Alias as wording
remove help text
user can re-send activation email
add "expired" into ActivationCode
Handle the case activation code is expired
reformat: use form.validate_on_submit instead of request.method == post && form.validate
use error text instead of flash()
display client oauth-id and oauth-secret on client detail page
not display oauth-secret on client listing
fix expiration check
improve page title, footer
add /jwks and /.well-known/openid-configuration
init properly tests, fix blueprint conflict bug in flask-admin
create oauth_models module
rename Scope -> ScopeE to distinguish with Scope DB model
set app.url_map.strict_slashes = False
use ScopeE instead of SCOPE_NAME, ...
support access_token passed as args in /userinfo
merge /allow-deny into /authorize
improve wording
take into account the case response_type=code and openid is in scope
take into account response_type=id_token, id_token token, id_token code
make sure to use in-memory db in test
fix scope can be null
allow cross_origin for /.well-known/openid-configuration and /jwks
fix footer link
center authorize form
rename trial_expiration to plan_expiration
move stripe init to create_app()
use real email to be able to receive email notification
add user.profile_picture_id column
use user profile picture and fallback to gravatar
use nguyenkims+local@gm to distinguish with staging
handle plan cancel, reactivation, user profile update
fix can_create_new_email
create cron.py that set plan to free when expired
add crontab.yml
add yacron
use notify_admin instead of LOG.error
add ResetPasswordCode model
user can change password in setting
increase display time for notie
add forgot_password page
If login error: redirect to this page upon success login.
hide discover tab
add column user.is_developer
only show developer menu to developer
comment out the publish button
set local user to developer
make sure only developer can access /developer blueprint
User is invited to upgrade if they are in free plan or their trial ends soon
not sending email when in local mode
create Partner model
create become partner page
use normal error handling on local
fix migration
add "import sqlalchemy_utils" into migration template
small refactoring on setting page
handle promo code. TODO: add migration file
add migration for user.promo_codes
move email alias on top of apps in dashboard
add introjs
move encode_url to utils
create GenEmail.create_new_gen_email
create a first alias mail to show user how to use when they login
show intro when user visits the website the first time
fix register
2019-07-02 07:20:12 +00:00
|
|
|
|
2019-11-16 14:19:43 +00:00
|
|
|
def send_reset_password_email(email, name, reset_password_link):
|
2019-12-16 17:36:59 +00:00
|
|
|
send_email(
|
2019-11-16 14:19:43 +00:00
|
|
|
email,
|
2020-01-11 21:33:25 +00:00
|
|
|
f"Reset your password on SimpleLogin",
|
2020-02-03 06:00:58 +00:00
|
|
|
render(
|
2020-02-02 14:49:38 +00:00
|
|
|
"transactional/reset-password.txt",
|
|
|
|
name=name,
|
|
|
|
reset_password_link=reset_password_link,
|
2019-11-16 14:19:43 +00:00
|
|
|
),
|
2020-02-03 06:00:58 +00:00
|
|
|
render(
|
2020-02-02 14:49:38 +00:00
|
|
|
"transactional/reset-password.html",
|
|
|
|
name=name,
|
|
|
|
reset_password_link=reset_password_link,
|
2019-11-16 14:19:43 +00:00
|
|
|
),
|
|
|
|
)
|
create BaseForm to enable CSRF
register page
redirect user to dashboard if they are logged in
enable csrf for login page
Set models more strict
bootstrap developer page
add helper method to ModelMixin, remove CRUDMixin
display list of clients on developer index, add copy client-secret to clipboard using clipboardjs
add toastr and use jquery non slim
display a toast when user copies the client-secret
create new client, generate client-id using unidecode
client detail page: can edit client
add delete client
implement /oauth/authorize and /oauth/allow-deny
implement /oauth/token
add /oauth/user_info endpoint
handle scopes: wip
take into account scope: display scope, return user data according to scope
create virtual-domain, gen email, client_user model WIP
create authorize_nonlogin_user page
user can choose to generate a new email
no need to interfere with root logger
log for before and after request
if user has already allowed a client: generate a auth-code and redirect user to client
get_user_info takes into account gen email
display list of clients that have user has authorised
use yk-client domain instead of localhost as cookie depends on the domain name
use wtforms instead of flask_wtf
Dockerfile
delete virtual domain
EMAIL_DOMAIN can come from env var
bind to host 0.0.0.0
fix signup error: use session as default csrf_context
rename yourkey to simplelogin
add python-dotenv, ipython, sqlalchemy_utils
create DB_URI, FLASK_SECRET. Load config from CONFIG file if exist
add shortcuts to logging
create shell
add psycopg2
do not add local data in Dockerfile
add drop_db into shell
add shell.prepare_db()
fix prepare_db
setup sentry
copy assets from tabler/dist
add icon downloaded from https://commons.wikimedia.org/wiki/File:Simpleicons_Interface_key-tool-1.svg
integrate tabler - login and register page
add favicon
template: default, header. Use gravatar for user avatar url
use default template for dashboard, developer page
use another icon
add clipboard and notie
prettify dashboard
add notie css
add fake gen email and client-user
prettify list client page, use notie for toast
add email, name scope to new client
display client scope in client list
prettify new-client, client-detail
add sentry-sdk and blinker
add arrow, add dt jinja filter, prettify logout, dashboard
comment "last used" in dashboard for now
prettify date display
add copy email to clipboard to dashboard
use "users" as table name for User as "user" is reserved key in postgres
call prepare_db() when creating new db
error page 400, 401, 403, 404
prettify authorize_login_user
create already_authorize.html for user who has already authorized a client
user can generate new email
display all other generated emails
add ENV variable, only reset DB when ENV=local
fix: not return other users gen emails
display nb users for each client
refactor shell: remove prepare_db()
add sendgrid
add /favicon.ico route
add new config: URL, SUPPORT_EMAIL, SENDGRID_API_KEY
user needs to activate their account before login
create copy button on dashboard
client can have multiple redirect uris, in client detail can add/remove redirect-uri,
use redirect_uri passed in /authorize
refactor: move get_user_info into ClientUser model
dashboard: display all apps, all generated emails
add "id" into user_info
add trigger email button
invalidate the session at each new version by changing the secret
centralize Client creation into Client.create_new
user can enable/disable email forwarding
setup auto dismiss alert: just add .alert-auto-dismiss
move name down in register form
add shell.add_real_data
move blueprint template to its own package
prettify authorize page for non-authenticated user
update readme, return error if not redirect_uri
add flask-wtf, use psycopg2-binary
use flask-wtf FlaskForm instead of Form
rename email -> email_utils
add AWS_REGION, BUCKET, AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY to config
add s3 module
add File model, add Client.icon_id
handle client icon update
can create client with icon
display client icon in client list page
add Client.home_url
take into account Client.home_url
add boto3
register: ask name first
only show "trigger test email" if email forwarding is enabled
display gen email in alphabetical order, client in client.name alphabetical order
better error page
the modal does not get close when user clicks outside of modal
add Client.published column
discover page that displays all published Client
add missing bootstrap.bundle.min.js.map
developer can publish/unpublish their app in discover
use notie for display flash message
create hotmail account
fix missing jquery
add footer, add global jinja2 variable
strengthen model: use nullable=False whenever possible,
rename client_id to oauth_client_id, client_secret to oauth_client_secret
add flask-migrate
init migrate
1st migrate version
fix rename client_id -> oauth_client_id
prettify UI
use flask_migrate.upgrade() instead of db.create_all()
make sure requirejs.config is called for all page
enable sentry for js, use uppercase for global jinja2 variables
add flask-admin
add User.is_admin column
setup flask admin, only accessible to admin user
fix migration: add server_default
replace session[redirect_after_login] by "next" request args
add pyproject.toml: ignore migrations/ in black
add register waiting_activation_email page
better email wording
add pytest
add get_host_name_and_scheme and tests
example fail test
fix test
fix client-id display
add flask-cors
/user_info supports cors, add /me as /user_info synonym
return client in /me
support implicit flow
no need to use with "app.app_context()"
add watchtower to requirement
add param ENABLE_CLOUDWATCH, CLOUDWATCH_LOG_GROUP, CLOUDWATCH_LOG_STREAM
add cloudwatch logger if cloudwatch is enabled
add 500 error page
add help text for list of used client
display list of app/website that an email has been used
click on client name brings to client detail page
create style.css to add additional style, append its url with the current sha1 to avoid cache
POC on how to send email using postfix
add sqlalchemy-utils
use arrow instead of datetime
add new params STRIPE_API, STRIPE_YEARLY_SKU, STRIPE_MONTHLY_PLAN
show full error in local
add plan, plan_expiration to User, need to create enum directly in migration script, cf https://github.com/sqlalchemy/alembic/issues/67
reformat all html files: use space instead of tab
new user will have trial plan for 15 days
add new param MAX_NB_EMAIL_FREE_PLAN
only user with enough quota can create new email
if user cannot create new gen email, pick randomly one from existing gen emails. Use flush instead of commit
rename STRIPE_YEARLY_SKU -> STRIPE_YEARLY_PLAN
open client page in discover in a new tab
add stripe
not logging /static call: disable flask logging, replace by after_request
add param STRIPE_SECRET_KEY
add 3 columns stripe_customer_id, stripe_card_token, stripe_subscription_id
user can upgrade their pricing
add setting page as coming-soon
add GenEmail, ClientUser to admin
ignore /admin/static logging
add more fake data
add ondelete="cascade" whenever possible
rename plan_expiration -> trial_expiration
reset migration: delete old migrations, create new one
rename test_send_email -> poc_send_email to avoid the file being called by pytest
add new param LYRA_ANALYTICS_ID, add lyra analytics
add how to create new migration into readme
add drift to base.html
notify admin when new user signs up or pays subscription
log exception in case of 500
use sendgrid to notify admin
add alias /userinfo to user_info endpoint
add change_password to shell
add info on how payment is handled
invite user to retry if card not working
remove drift and add "contact us" link
move poc_send_email into poc/
support getting client-id, client-secret from form-data in addition to basic auth
client-id, client-secret is passed in form-data by passport-oauth2 for ex
add jwtRS256 private and public key
add jwk-jws-jwt poc
add new param OPENID_PRIVATE_KEY_PATH, OPENID_PRIVATE_KEY_PATH
add scope, redirect_url to AuthorizationCode and OauthToken
take into scope when creating oauth-token, authorization-code
add jwcrypto
add jose_utils: make_id_token and verify_id_token
add &scope to redirect uri
add "email_verified": True into user_info
fix user not activated
add /oauth2 as alias for /oauth
handle case where scope and state are empty
remove threaded=False
Use Email Alias as wording
remove help text
user can re-send activation email
add "expired" into ActivationCode
Handle the case activation code is expired
reformat: use form.validate_on_submit instead of request.method == post && form.validate
use error text instead of flash()
display client oauth-id and oauth-secret on client detail page
not display oauth-secret on client listing
fix expiration check
improve page title, footer
add /jwks and /.well-known/openid-configuration
init properly tests, fix blueprint conflict bug in flask-admin
create oauth_models module
rename Scope -> ScopeE to distinguish with Scope DB model
set app.url_map.strict_slashes = False
use ScopeE instead of SCOPE_NAME, ...
support access_token passed as args in /userinfo
merge /allow-deny into /authorize
improve wording
take into account the case response_type=code and openid is in scope
take into account response_type=id_token, id_token token, id_token code
make sure to use in-memory db in test
fix scope can be null
allow cross_origin for /.well-known/openid-configuration and /jwks
fix footer link
center authorize form
rename trial_expiration to plan_expiration
move stripe init to create_app()
use real email to be able to receive email notification
add user.profile_picture_id column
use user profile picture and fallback to gravatar
use nguyenkims+local@gm to distinguish with staging
handle plan cancel, reactivation, user profile update
fix can_create_new_email
create cron.py that set plan to free when expired
add crontab.yml
add yacron
use notify_admin instead of LOG.error
add ResetPasswordCode model
user can change password in setting
increase display time for notie
add forgot_password page
If login error: redirect to this page upon success login.
hide discover tab
add column user.is_developer
only show developer menu to developer
comment out the publish button
set local user to developer
make sure only developer can access /developer blueprint
User is invited to upgrade if they are in free plan or their trial ends soon
not sending email when in local mode
create Partner model
create become partner page
use normal error handling on local
fix migration
add "import sqlalchemy_utils" into migration template
small refactoring on setting page
handle promo code. TODO: add migration file
add migration for user.promo_codes
move email alias on top of apps in dashboard
add introjs
move encode_url to utils
create GenEmail.create_new_gen_email
create a first alias mail to show user how to use when they login
show intro when user visits the website the first time
fix register
2019-07-02 07:20:12 +00:00
|
|
|
|
2019-11-16 14:19:43 +00:00
|
|
|
|
2019-11-18 18:34:53 +00:00
|
|
|
def send_change_email(new_email, current_email, name, link):
|
2019-12-16 17:36:59 +00:00
|
|
|
send_email(
|
2019-11-18 18:34:53 +00:00
|
|
|
new_email,
|
2020-01-11 21:33:25 +00:00
|
|
|
f"Confirm email update on SimpleLogin",
|
2020-02-03 06:00:58 +00:00
|
|
|
render(
|
2020-02-02 14:49:22 +00:00
|
|
|
"transactional/change-email.txt",
|
2019-11-18 18:34:53 +00:00
|
|
|
name=name,
|
|
|
|
link=link,
|
|
|
|
new_email=new_email,
|
|
|
|
current_email=current_email,
|
|
|
|
),
|
2020-02-03 06:00:58 +00:00
|
|
|
render(
|
2020-02-02 14:49:22 +00:00
|
|
|
"transactional/change-email.html",
|
2019-11-18 18:34:53 +00:00
|
|
|
name=name,
|
|
|
|
link=link,
|
|
|
|
new_email=new_email,
|
|
|
|
current_email=current_email,
|
|
|
|
),
|
|
|
|
)
|
|
|
|
|
|
|
|
|
2019-11-16 14:19:43 +00:00
|
|
|
def send_new_app_email(email, name):
|
2019-12-16 17:36:59 +00:00
|
|
|
send_email(
|
2019-11-16 14:19:43 +00:00
|
|
|
email,
|
2020-01-11 21:33:25 +00:00
|
|
|
f"Any question/feedback for SimpleLogin {name}?",
|
2020-02-03 06:00:58 +00:00
|
|
|
render("com/new-app.txt", name=name),
|
|
|
|
render("com/new-app.html", name=name),
|
2019-11-16 14:19:43 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
|
2019-11-16 14:26:50 +00:00
|
|
|
def send_test_email_alias(email, name):
|
2019-12-16 17:36:59 +00:00
|
|
|
send_email(
|
2019-11-16 14:26:50 +00:00
|
|
|
email,
|
2020-01-11 21:33:25 +00:00
|
|
|
f"This email is sent to {email}",
|
2020-02-03 06:00:58 +00:00
|
|
|
render("transactional/test-email.txt", name=name, alias=email),
|
|
|
|
render("transactional/test-email.html", name=name, alias=email),
|
2019-11-16 14:26:50 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
|
2020-01-16 21:06:36 +00:00
|
|
|
def send_cannot_create_directory_alias(user, alias, directory):
|
|
|
|
"""when user cancels their subscription, they cannot create alias on the fly.
|
|
|
|
If this happens, send them an email to notify
|
|
|
|
"""
|
|
|
|
send_email(
|
|
|
|
user.email,
|
|
|
|
f"Alias {alias} cannot be created",
|
2020-02-03 06:00:58 +00:00
|
|
|
render(
|
2020-02-02 14:49:22 +00:00
|
|
|
"transactional/cannot-create-alias-directory.txt",
|
2020-01-16 21:06:36 +00:00
|
|
|
name=user.name,
|
|
|
|
alias=alias,
|
|
|
|
directory=directory,
|
|
|
|
),
|
2020-02-03 06:00:58 +00:00
|
|
|
render(
|
2020-02-02 14:49:22 +00:00
|
|
|
"transactional/cannot-create-alias-directory.html",
|
2020-01-16 21:06:36 +00:00
|
|
|
name=user.name,
|
|
|
|
alias=alias,
|
|
|
|
directory=directory,
|
|
|
|
),
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
def send_cannot_create_domain_alias(user, alias, domain):
|
|
|
|
"""when user cancels their subscription, they cannot create alias on the fly with custom domain.
|
|
|
|
If this happens, send them an email to notify
|
|
|
|
"""
|
|
|
|
send_email(
|
|
|
|
user.email,
|
|
|
|
f"Alias {alias} cannot be created",
|
2020-02-03 06:00:58 +00:00
|
|
|
render(
|
2020-02-02 14:49:38 +00:00
|
|
|
"transactional/cannot-create-alias-domain.txt",
|
|
|
|
name=user.name,
|
|
|
|
alias=alias,
|
|
|
|
domain=domain,
|
2020-01-16 21:06:36 +00:00
|
|
|
),
|
2020-02-03 06:00:58 +00:00
|
|
|
render(
|
2020-02-02 14:49:22 +00:00
|
|
|
"transactional/cannot-create-alias-domain.html",
|
2020-01-16 21:27:45 +00:00
|
|
|
name=user.name,
|
|
|
|
alias=alias,
|
|
|
|
domain=domain,
|
2020-01-16 21:06:36 +00:00
|
|
|
),
|
|
|
|
)
|
|
|
|
|
|
|
|
|
2020-06-10 10:15:57 +00:00
|
|
|
def send_email(to_email, subject, plaintext, html=None):
|
2019-12-09 20:21:40 +00:00
|
|
|
if NOT_SEND_EMAIL:
|
|
|
|
LOG.d(
|
2019-12-22 15:58:07 +00:00
|
|
|
"send email with subject %s to %s, plaintext: %s",
|
2019-12-09 20:21:40 +00:00
|
|
|
subject,
|
|
|
|
to_email,
|
|
|
|
plaintext,
|
|
|
|
)
|
|
|
|
return
|
|
|
|
|
2020-02-23 07:38:53 +00:00
|
|
|
LOG.d("send email to %s, subject %s", to_email, subject)
|
|
|
|
|
2020-03-03 09:48:55 +00:00
|
|
|
if POSTFIX_SUBMISSION_TLS:
|
|
|
|
smtp = SMTP(POSTFIX_SERVER, 587)
|
|
|
|
smtp.starttls()
|
|
|
|
else:
|
2020-05-21 18:43:03 +00:00
|
|
|
smtp = SMTP(POSTFIX_SERVER, POSTFIX_PORT or 25)
|
2020-02-22 13:39:45 +00:00
|
|
|
|
2020-06-10 10:15:57 +00:00
|
|
|
msg = MIMEMultipart("alternative")
|
|
|
|
msg.attach(MIMEText(plaintext, "text"))
|
2020-06-10 10:18:39 +00:00
|
|
|
|
|
|
|
if not html:
|
|
|
|
html = plaintext.replace("\n", "<br>")
|
|
|
|
msg.attach(MIMEText(html, "html"))
|
2019-11-15 13:11:51 +00:00
|
|
|
|
|
|
|
msg["Subject"] = subject
|
2020-01-28 02:29:04 +00:00
|
|
|
msg["From"] = f"{SUPPORT_NAME} <{SUPPORT_EMAIL}>"
|
2019-11-15 13:11:51 +00:00
|
|
|
msg["To"] = to_email
|
2019-11-16 14:19:43 +00:00
|
|
|
|
2019-11-16 21:20:48 +00:00
|
|
|
msg_id_header = make_msgid()
|
|
|
|
msg["Message-ID"] = msg_id_header
|
|
|
|
|
|
|
|
date_header = formatdate()
|
|
|
|
msg["Date"] = date_header
|
|
|
|
|
2019-12-17 16:48:06 +00:00
|
|
|
# add DKIM
|
|
|
|
email_domain = SUPPORT_EMAIL[SUPPORT_EMAIL.find("@") + 1 :]
|
|
|
|
add_dkim_signature(msg, email_domain)
|
|
|
|
|
2020-04-02 16:08:50 +00:00
|
|
|
msg_raw = msg.as_bytes()
|
2020-06-10 11:55:47 +00:00
|
|
|
if SENDER:
|
|
|
|
smtp.sendmail(SENDER, to_email, msg_raw)
|
|
|
|
else:
|
|
|
|
smtp.sendmail(SUPPORT_EMAIL, to_email, msg_raw)
|
2019-11-15 13:11:51 +00:00
|
|
|
|
|
|
|
|
2020-05-09 18:43:17 +00:00
|
|
|
def send_email_with_rate_control(
|
|
|
|
user: User,
|
|
|
|
alert_type: str,
|
|
|
|
to_email: str,
|
|
|
|
subject,
|
|
|
|
plaintext,
|
|
|
|
html=None,
|
2020-05-10 08:34:39 +00:00
|
|
|
max_alert_24h=MAX_ALERT_24H,
|
2020-05-09 18:43:17 +00:00
|
|
|
) -> bool:
|
|
|
|
"""Same as send_email with rate control over alert_type.
|
|
|
|
For now no more than _MAX_ALERT_24h alert can be sent in the last 24h
|
|
|
|
|
|
|
|
Return true if the email is sent, otherwise False
|
|
|
|
"""
|
|
|
|
to_email = to_email.lower().strip()
|
|
|
|
one_day_ago = arrow.now().shift(days=-1)
|
|
|
|
nb_alert = (
|
|
|
|
SentAlert.query.filter_by(alert_type=alert_type, to_email=to_email)
|
|
|
|
.filter(SentAlert.created_at > one_day_ago)
|
|
|
|
.count()
|
|
|
|
)
|
|
|
|
|
2020-05-10 08:37:56 +00:00
|
|
|
if nb_alert >= max_alert_24h:
|
2020-05-21 18:07:04 +00:00
|
|
|
LOG.warning(
|
2020-05-09 18:43:17 +00:00
|
|
|
"%s emails were sent to %s in the last 24h, alert type %s",
|
|
|
|
nb_alert,
|
|
|
|
to_email,
|
|
|
|
alert_type,
|
|
|
|
)
|
|
|
|
return False
|
|
|
|
|
|
|
|
SentAlert.create(user_id=user.id, alert_type=alert_type, to_email=to_email)
|
|
|
|
db.session.commit()
|
2020-06-10 10:15:57 +00:00
|
|
|
send_email(to_email, subject, plaintext, html)
|
2020-05-09 18:43:17 +00:00
|
|
|
return True
|
|
|
|
|
|
|
|
|
2020-03-17 10:51:40 +00:00
|
|
|
def get_email_local_part(address):
|
2019-12-30 17:18:10 +00:00
|
|
|
"""
|
|
|
|
Get the local part from email
|
|
|
|
ab@cd.com -> ab
|
|
|
|
"""
|
2020-03-17 10:51:40 +00:00
|
|
|
return address[: address.find("@")]
|
2019-12-30 17:18:10 +00:00
|
|
|
|
|
|
|
|
2020-03-17 10:51:40 +00:00
|
|
|
def get_email_domain_part(address):
|
2019-12-30 17:18:10 +00:00
|
|
|
"""
|
|
|
|
Get the domain part from email
|
|
|
|
ab@cd.com -> cd.com
|
|
|
|
"""
|
2020-04-16 07:43:14 +00:00
|
|
|
return address[address.find("@") + 1 :].strip().lower()
|
2019-12-30 17:18:10 +00:00
|
|
|
|
|
|
|
|
2020-01-07 18:47:26 +00:00
|
|
|
def add_dkim_signature(msg: Message, email_domain: str):
|
2020-02-07 15:03:04 +00:00
|
|
|
delete_header(msg, "DKIM-Signature")
|
2019-12-17 17:06:17 +00:00
|
|
|
|
2019-12-17 16:48:06 +00:00
|
|
|
# Specify headers in "byte" form
|
|
|
|
# Generate message signature
|
|
|
|
sig = dkim.sign(
|
2020-04-02 16:08:50 +00:00
|
|
|
msg.as_bytes(),
|
2019-12-17 16:48:06 +00:00
|
|
|
DKIM_SELECTOR,
|
|
|
|
email_domain.encode(),
|
|
|
|
DKIM_PRIVATE_KEY.encode(),
|
|
|
|
include_headers=DKIM_HEADERS,
|
|
|
|
)
|
|
|
|
sig = sig.decode()
|
|
|
|
|
|
|
|
# remove linebreaks from sig
|
|
|
|
sig = sig.replace("\n", " ").replace("\r", "")
|
2020-02-07 15:03:04 +00:00
|
|
|
msg["DKIM-Signature"] = sig[len("DKIM-Signature: ") :]
|
2020-01-07 18:46:57 +00:00
|
|
|
|
|
|
|
|
|
|
|
def add_or_replace_header(msg: Message, header: str, value: str):
|
2020-02-07 15:02:33 +00:00
|
|
|
"""
|
|
|
|
Remove all occurrences of `header` and add `header` with `value`.
|
|
|
|
"""
|
|
|
|
delete_header(msg, header)
|
|
|
|
msg[header] = value
|
2020-01-07 18:49:26 +00:00
|
|
|
|
|
|
|
|
|
|
|
def delete_header(msg: Message, header: str):
|
2020-01-08 11:42:25 +00:00
|
|
|
"""a header can appear several times in message."""
|
2020-02-07 14:56:55 +00:00
|
|
|
# inspired from https://stackoverflow.com/a/47903323/1428034
|
|
|
|
for i in reversed(range(len(msg._headers))):
|
|
|
|
header_name = msg._headers[i][0].lower()
|
|
|
|
if header_name == header.lower():
|
|
|
|
del msg._headers[i]
|
2020-01-22 09:13:58 +00:00
|
|
|
|
|
|
|
|
2020-03-14 21:24:02 +00:00
|
|
|
def delete_all_headers_except(msg: Message, headers: [str]):
|
|
|
|
headers = [h.lower() for h in headers]
|
|
|
|
|
|
|
|
for i in reversed(range(len(msg._headers))):
|
|
|
|
header_name = msg._headers[i][0].lower()
|
|
|
|
if header_name not in headers:
|
|
|
|
del msg._headers[i]
|
|
|
|
|
|
|
|
|
2020-03-17 10:51:40 +00:00
|
|
|
def email_belongs_to_alias_domains(address: str) -> bool:
|
2020-02-19 15:15:27 +00:00
|
|
|
"""return True if an email ends with one of the alias domains provided by SimpleLogin"""
|
2020-01-22 09:13:58 +00:00
|
|
|
for domain in ALIAS_DOMAINS:
|
2020-03-17 10:51:40 +00:00
|
|
|
if address.endswith("@" + domain):
|
2020-01-22 09:13:58 +00:00
|
|
|
return True
|
|
|
|
|
|
|
|
return False
|
2020-01-25 15:40:30 +00:00
|
|
|
|
|
|
|
|
2020-05-15 21:18:30 +00:00
|
|
|
def email_domain_can_be_used_as_mailbox(email: str) -> bool:
|
|
|
|
"""return True if an email can be used as a personal email. An email domain can be used if it is not
|
2020-01-25 15:40:30 +00:00
|
|
|
- one of ALIAS_DOMAINS
|
|
|
|
- one of custom domains
|
2020-05-15 21:18:30 +00:00
|
|
|
- disposable domain
|
2020-01-25 15:40:30 +00:00
|
|
|
"""
|
|
|
|
domain = get_email_domain_part(email)
|
|
|
|
if not domain:
|
|
|
|
return False
|
|
|
|
|
|
|
|
if domain in ALIAS_DOMAINS:
|
|
|
|
return False
|
|
|
|
|
|
|
|
from app.models import CustomDomain
|
|
|
|
|
|
|
|
if CustomDomain.get_by(domain=domain, verified=True):
|
2020-06-14 10:00:02 +00:00
|
|
|
LOG.d("domain %s is a SimpleLogin custom domain", domain)
|
2020-01-25 15:40:30 +00:00
|
|
|
return False
|
|
|
|
|
2020-04-27 16:17:50 +00:00
|
|
|
if is_disposable_domain(domain):
|
|
|
|
LOG.d("Domain %s is disposable", domain)
|
|
|
|
return False
|
|
|
|
|
|
|
|
# check if email MX domain is disposable
|
|
|
|
mx_domains = get_mx_domain_list(domain)
|
2020-04-27 21:08:34 +00:00
|
|
|
|
|
|
|
# if no MX record, email is not valid
|
|
|
|
if not mx_domains:
|
2020-06-14 10:00:02 +00:00
|
|
|
LOG.d("No MX record for domain %s", domain)
|
2020-04-27 21:08:34 +00:00
|
|
|
return False
|
|
|
|
|
2020-04-27 16:17:50 +00:00
|
|
|
for mx_domain in mx_domains:
|
|
|
|
if is_disposable_domain(mx_domain):
|
|
|
|
LOG.d("MX Domain %s %s is disposable", mx_domain, domain)
|
|
|
|
return False
|
|
|
|
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
|
|
def is_disposable_domain(domain):
|
2020-04-16 07:43:14 +00:00
|
|
|
for d in DISPOSABLE_EMAIL_DOMAINS:
|
|
|
|
if domain == d:
|
2020-04-27 16:17:50 +00:00
|
|
|
return True
|
2020-04-16 07:43:14 +00:00
|
|
|
# subdomain
|
|
|
|
if domain.endswith("." + d):
|
2020-04-27 16:17:50 +00:00
|
|
|
return True
|
2020-04-16 07:43:14 +00:00
|
|
|
|
2020-04-27 16:17:50 +00:00
|
|
|
return False
|
|
|
|
|
|
|
|
|
|
|
|
def get_mx_domain_list(domain) -> [str]:
|
|
|
|
"""return list of MX domains for a given email.
|
|
|
|
domain name ends *without* a dot (".") at the end.
|
|
|
|
"""
|
|
|
|
priority_domains = get_mx_domains(domain)
|
|
|
|
|
|
|
|
return [d[:-1] for _, d in priority_domains]
|
2020-02-10 16:14:36 +00:00
|
|
|
|
|
|
|
|
2020-05-15 21:18:30 +00:00
|
|
|
def personal_email_already_used(email: str) -> bool:
|
|
|
|
"""test if an email can be used as user email
|
2020-02-10 16:14:36 +00:00
|
|
|
"""
|
|
|
|
if User.get_by(email=email):
|
|
|
|
return True
|
|
|
|
|
|
|
|
return False
|
2020-03-08 09:05:13 +00:00
|
|
|
|
|
|
|
|
|
|
|
def mailbox_already_used(email: str, user) -> bool:
|
2020-05-07 19:47:11 +00:00
|
|
|
if Mailbox.get_by(email=email, user_id=user.id):
|
2020-03-08 09:05:13 +00:00
|
|
|
return True
|
|
|
|
|
|
|
|
# support the case user wants to re-add their real email as mailbox
|
|
|
|
# can happen when user changes their root email and wants to add this new email as mailbox
|
|
|
|
if email == user.email:
|
|
|
|
return False
|
|
|
|
|
|
|
|
return False
|
2020-03-14 15:34:23 +00:00
|
|
|
|
|
|
|
|
|
|
|
def get_orig_message_from_bounce(msg: Message) -> Message:
|
|
|
|
"""parse the original email from Bounce"""
|
|
|
|
i = 0
|
|
|
|
for part in msg.walk():
|
|
|
|
i += 1
|
|
|
|
|
|
|
|
# the original message is the 4th part
|
|
|
|
# 1st part is the root part, multipart/report
|
|
|
|
# 2nd is text/plain, Postfix log
|
|
|
|
# ...
|
|
|
|
# 7th is original message
|
|
|
|
if i == 7:
|
|
|
|
return part
|
2020-03-28 18:16:55 +00:00
|
|
|
|
|
|
|
|
2020-03-30 20:05:31 +00:00
|
|
|
def get_orig_message_from_spamassassin_report(msg: Message) -> Message:
|
|
|
|
"""parse the original email from Spamassassin report"""
|
|
|
|
i = 0
|
|
|
|
for part in msg.walk():
|
|
|
|
i += 1
|
|
|
|
|
|
|
|
# the original message is the 4th part
|
|
|
|
# 1st part is the root part, multipart/report
|
|
|
|
# 2nd is text/plain, SpamAssassin part
|
|
|
|
# 3rd is the original message in message/rfc822 content type
|
|
|
|
# 4th is original message
|
|
|
|
if i == 4:
|
|
|
|
return part
|
|
|
|
|
|
|
|
|
2020-03-28 18:16:55 +00:00
|
|
|
def get_addrs_from_header(msg: Message, header) -> [str]:
|
|
|
|
"""Get all addresses contained in `header`
|
|
|
|
Used for To or CC header.
|
|
|
|
"""
|
|
|
|
ret = []
|
|
|
|
header_content = msg.get_all(header)
|
|
|
|
if not header_content:
|
|
|
|
return ret
|
|
|
|
|
|
|
|
for addrs in header_content:
|
2020-06-01 19:14:23 +00:00
|
|
|
# force convert header to string, sometimes addrs is Header object
|
|
|
|
addrs = str(addrs)
|
2020-03-28 18:16:55 +00:00
|
|
|
for addr in addrs.split(","):
|
|
|
|
ret.append(addr.strip())
|
|
|
|
|
|
|
|
# do not return empty string
|
|
|
|
return [r for r in ret if r]
|
2020-03-30 20:05:31 +00:00
|
|
|
|
|
|
|
|
2020-07-23 09:11:43 +00:00
|
|
|
def get_spam_info(msg: Message, max_score=None) -> (bool, str):
|
2020-03-30 20:05:31 +00:00
|
|
|
"""parse SpamAssassin header to detect whether a message is classified as spam.
|
|
|
|
Return (is spam, spam status detail)
|
|
|
|
The header format is
|
|
|
|
```X-Spam-Status: No, score=-0.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID,
|
|
|
|
DKIM_VALID_AU,RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H2,SPF_PASS,
|
|
|
|
URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.2```
|
|
|
|
"""
|
|
|
|
spamassassin_status = msg["X-Spam-Status"]
|
|
|
|
if not spamassassin_status:
|
|
|
|
return False, ""
|
|
|
|
|
2020-07-23 09:11:43 +00:00
|
|
|
return get_spam_from_header(spamassassin_status, max_score=max_score)
|
|
|
|
|
|
|
|
|
|
|
|
def get_spam_from_header(spam_status_header, max_score=None) -> (bool, str):
|
|
|
|
"""get spam info from X-Spam-Status header
|
|
|
|
Return (is spam, spam status detail).
|
|
|
|
The spam_status_header has the following format
|
|
|
|
```No, score=-0.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID,
|
|
|
|
DKIM_VALID_AU,RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H2,SPF_PASS,
|
|
|
|
URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.2```
|
|
|
|
"""
|
2020-03-30 20:05:31 +00:00
|
|
|
# yes or no
|
2020-07-23 09:11:43 +00:00
|
|
|
spamassassin_answer = spam_status_header[: spam_status_header.find(",")]
|
|
|
|
|
|
|
|
if max_score:
|
|
|
|
# spam score
|
|
|
|
# get the score section "score=-0.1"
|
|
|
|
score_section = (
|
|
|
|
spam_status_header[spam_status_header.find(",") + 1 :].strip().split(" ")[0]
|
|
|
|
)
|
|
|
|
score = float(score_section[len("score=") :])
|
|
|
|
if score >= max_score:
|
2020-07-23 09:32:11 +00:00
|
|
|
LOG.warning("Spam score %s exceeds %s", score, max_score)
|
2020-07-23 09:11:43 +00:00
|
|
|
return True, spam_status_header
|
2020-03-30 20:05:31 +00:00
|
|
|
|
2020-07-23 09:11:43 +00:00
|
|
|
return spamassassin_answer.lower() == "yes", spam_status_header
|
2020-04-05 10:07:40 +00:00
|
|
|
|
|
|
|
|
|
|
|
def parseaddr_unicode(addr) -> (str, str):
|
|
|
|
"""Like parseaddr but return name in unicode instead of in RFC 2047 format
|
|
|
|
'=?UTF-8?B?TmjGoW4gTmd1eeG7hW4=?= <abcd@gmail.com>' -> ('Nhơn Nguyễn', "abcd@gmail.com")
|
|
|
|
"""
|
|
|
|
name, email = parseaddr(addr)
|
2020-04-05 10:56:17 +00:00
|
|
|
email = email.strip().lower()
|
2020-04-05 10:07:40 +00:00
|
|
|
if name:
|
2020-04-05 10:56:17 +00:00
|
|
|
name = name.strip()
|
2020-04-05 10:07:40 +00:00
|
|
|
decoded_string, charset = decode_header(name)[0]
|
|
|
|
if charset is not None:
|
2020-05-14 11:27:04 +00:00
|
|
|
try:
|
|
|
|
name = decoded_string.decode(charset)
|
|
|
|
except UnicodeDecodeError:
|
|
|
|
LOG.warning("Cannot decode addr name %s", name)
|
|
|
|
name = ""
|
2020-04-05 10:07:40 +00:00
|
|
|
else:
|
2020-04-05 10:56:17 +00:00
|
|
|
name = decoded_string
|
|
|
|
|
|
|
|
return name, email
|
2020-06-11 22:02:07 +00:00
|
|
|
|
|
|
|
|
|
|
|
def copy(msg: Message) -> Message:
|
|
|
|
"""return a copy of message"""
|
|
|
|
return email.message_from_bytes(msg.as_bytes())
|