diff --git a/.gitignore b/.gitignore index beccb30..09ea058 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,5 @@ /galaxy.roles/ /ansible-vault-password-file *.retry + +test_smtp.py diff --git a/files/apps/gramps/docker-compose.yml b/files/apps/gramps/docker-compose.yml index 191fcd3..797237a 100644 --- a/files/apps/gramps/docker-compose.yml +++ b/files/apps/gramps/docker-compose.yml @@ -15,6 +15,12 @@ services: GRAMPSWEB_CELERY_CONFIG__broker_url: "redis://grampsweb_redis:6379/0" GRAMPSWEB_CELERY_CONFIG__result_backend: "redis://grampsweb_redis:6379/0" GRAMPSWEB_RATELIMIT_STORAGE_URI: redis://grampsweb_redis:6379/1 + GRAMPSWEB_EMAIL_HOST: "${POSTBOX_HOST}" + GRAMPSWEB_EMAIL_PORT: "${POSTBOX_PORT}" + GRAMPSWEB_EMAIL_HOST_USER: "${POSTBOX_USER}" + GRAMPSWEB_EMAIL_HOST_PASSWORD: "${POSTBOX_PASS}" + GRAMPSWEB_EMAIL_USE_TLS: "false" + GRAMPSWEB_DEFAULT_FROM_EMAIL: "gramps@vakhrushev.me" GUNICORN_NUM_WORKERS: 4 # media storage at s3 GRAMPSWEB_MEDIA_BASE_DIR: "s3://av-gramps-media-storage" diff --git a/generate.py b/generate.py new file mode 100644 index 0000000..8c7d0b7 --- /dev/null +++ b/generate.py @@ -0,0 +1,47 @@ +#!/usr/bin/env python3 + +import hmac +import hashlib +import base64 +import argparse +import sys + +# These values are required to calculate the signature. Do not change them. +DATE = "20230926" +SERVICE = "postbox" +MESSAGE = "SendRawEmail" +REGION = "ru-central1" +TERMINAL = "aws4_request" +VERSION = 0x04 + + +def sign(key, msg): + return hmac.new(key, msg.encode("utf-8"), hashlib.sha256).digest() + + +def calculate_key(secret_access_key): + signature = sign(("AWS4" + secret_access_key).encode("utf-8"), DATE) + signature = sign(signature, REGION) + signature = sign(signature, SERVICE) + signature = sign(signature, TERMINAL) + signature = sign(signature, MESSAGE) + signature_and_version = bytes([VERSION]) + signature + smtp_password = base64.b64encode(signature_and_version) + return smtp_password.decode("utf-8") + + +def main(): + if sys.version_info[0] < 3: + raise Exception("Must be using Python 3") + + parser = argparse.ArgumentParser( + description="Convert a Secret Access Key to an SMTP password." + ) + parser.add_argument("secret", help="The Secret Access Key to convert.") + args = parser.parse_args() + + print(calculate_key(args.secret)) + + +if __name__ == "__main__": + main() diff --git a/playbook-app-gramps.yml b/playbook-app-gramps.yml index b8a7b1e..a6567f6 100644 --- a/playbook-app-gramps.yml +++ b/playbook-app-gramps.yml @@ -40,6 +40,10 @@ SECRET_KEY: '{{ gramps.secret_key }}' AWS_ACCESS_KEY_ID: '{{ gramps.aws_access_key_id }}' AWS_SECRET_ACCESS_KEY: '{{ gramps.aws_secret_access_key }}' + POSTBOX_HOST: '{{ postbox.host }}' + POSTBOX_PORT: '{{ postbox.port }}' + POSTBOX_USER: '{{ postbox.user }}' + POSTBOX_PASS: '{{ postbox.pass }}' - name: 'Run application with docker compose' community.docker.docker_compose_v2: diff --git a/vars/vars.yml b/vars/vars.yml index fc3b783..9a78aca 100644 --- a/vars/vars.yml +++ b/vars/vars.yml @@ -1,61 +1,69 @@ $ANSIBLE_VAULT;1.1;AES256 -36633164616665656332353931383339663033323235656335343234363164633266303764663938 -6665373565313439386334363833393337326237313532650a366465633265313765373035616331 -30626533343763376566313466303765373235343839333866643162623561323031356334656537 -6663633735393236310a376364613430313661313338313539383434323163343865373335383666 -31343431343432316364366333333539626466333332303537393235373063373561653530333237 -65333262613932303135393238666264373834313239303264386161323436653436373930306136 -66643039613030346434663038343030393939313434393965636636353264393535316132306139 -63616663633664666439653364316365356633333137663138343062346664336663666537386331 -30313335643062383965333461633433376432393931613432363931373435323431383462313939 -31353264636635303637333362343437393837646137376638373938363963303539633764353061 -63363861333438346230393065663763346131663731346362383635616633373134616131643866 -36303038656130633462643739323763313832663939613630653632386433633138353862353765 -31613033333865383038643639646530373536656163376166366333346463623432313663353835 -30613236343465346336343734663466646533303632393937336330656563626166333534646165 -61653539326437636234393934323335363433663762646462326236323138653739623163373930 -65656332643963383261613039393636646362663531383865623533363035633562636137613066 -33383866393062303934333130333133386331653436663462656235366362666634646237363639 -30333264633137366264336235323164303332616336353136613232383062623533346463303232 -37336262613638616333376564386632356265396162383761396332636136653961663166633132 -64363666633063356539663833363635633435396136303264343666393131326132303366376233 -35316132363637303461396432353132383838653736353965663131663031393261303538346438 -37356563646663643937323337326239393834663464653532613039313335356231663734636332 -38383635356632353132663439303264383733366631366666316434383465393931613261613661 -38613031376430636366366363626465336236306633363836616264396635623633646164383563 -39623564623537343033376161363238363265643664393234313563623830633135653162366466 -30373161346464623331393934383839336336396666303934303336636431346664326133313566 -37346234343835636664663037333333353131343735303537376134663136323162306363343034 -66393539663638353930363663323938353961343730333963313432333538643432333630663663 -37363233303262633538663064636631343938343666353036636566303761343734373537323539 -62323866396639313139383930363732363630373032336565346230313264366138386465636237 -30616565306462623331363661353965616639393338616133363332613931626539646438346430 -64646561346264343531616334623135373361663338653339346633316438393433373665363533 -34393239393062383066383632346431386333653461356164356462633065373930626233323831 -35626563316139303164336533653765623539396335663138366539666136623038366337343039 -36323337646662626334363366343139666234363134323165303864643239356631333631343265 -33373461346234316566323837373962613934626232643262653761643039303965363839306463 -65663632613266646630343064326239633933613062623433356337663931633330313338653862 -65373538613335636339633466646431333338356563386230653164626265633637333865333131 -32643437336633613536326361663636323039346562333464653161663936623964383539633239 -32396635393733633035613032333065346232616635373663356163386635393761653665343463 -32643738343536376566663635303235373764313363323330356631343336353635306531666134 -61363364666339373531366337366562646131303463303633303333303436366134646231643636 -63303139636336376439646465353530643261356336326665313665616364323432333939323133 -37623561383630366236636533336436366230393035623836373035343034323065386666316539 -61396439646564333766383561326136323434376465623061386664383137333934636536356166 -36666166623038363262626166613262336635303632353536663238333834303331316339316463 -35623866383535613236616330346161396462386130356465363566616630326662393632633962 -36643532333935373832323966666634353332616135396265613461306137323233643330656461 -38313134313165623133663235373034386334616231653930366432346532656562353238343831 -65643965386664333731373036623732613734393837356162366534306536393638326632396265 -66623631613134393762653264653466613164663463616165633639323635363561643439373834 -36616438666665333532626462663664353332623266396466313333666638373861386239616663 -63646266633635646563393935616266373566656334336139383638666361363332343939643964 -62373530343332313135316131386461373464623966323534643661346532373438653233366635 -61303461306464353165373030626165333737356539303663346164623634326463303032343431 -64366361336539303138313232393435396537656138363365653538663131666439643761643964 -36303164316334623565316538623062323032346135313631666565623838326632303963383938 -64346436373634633733323639303434663664316430633836646664623231306233303038633362 -63316330663263373633353736346265373366326561303731623335653265373661373133363630 -38346530653531393133 +31326232656538373331333566386562333865623563313931366165353939633431323062333663 +3463313831316433383162383933623262636231356331370a393231393536653164653361663232 +31626661623334636263336534323261336237323935336366366161366665336537383634653265 +6563386130326531610a626463323739626531653731336366626139396331393531623232623332 +32383937656365666239306565666232613361616439633438316636356433393139616663663433 +39336631663633313362623263626237313839356562656462323235626433386138313132643732 +30656165663362316433306438376266363530313539323338336563333365366465366530396465 +30633431643563356131656332313564663963356662616235306333393137383135326665646530 +30343131646430626462626563366133386639643033386130383063656434326634346532396636 +33393165626535643731616535396431656435343032333539623538663632333462666339323839 +66613463366665616165613832333931356139303835323363346564343539643062373963633263 +39653533356533393530346263623930396339336630383661316163303232326135663761366534 +64383766326134386462666662633965336135313064326536316332646364623430303838333737 +33633332616231666434613532363963646433303531343362636232363232353161343735616533 +37383064353839336436663134653237303962616132393534366234633338616634396536666338 +34633237623662353066613936373862383264393931343830656563316662393133363536363331 +65636531663838383538656339386134373762636164343630353232303639393130663035353335 +36333461613031663435656465633934613934363238313462656234313833616234663265343436 +39336635633232396130623166326662376234663632346437303131366534356439306238343764 +30653732313266613430626637636235393831323237653665346238373363303439656438393436 +35343464656164303565393430663930653764303761633737636532313964383037313665333064 +35393466316462323566626235313637313136323331626134663863636534363666396236663132 +31616164316666303465653863656536666331363433363163333566343338386130616333333364 +61633331633965383834356630343237653466626237656164643435343433626434366331346531 +36343165626664363039663439363236346466343061656137663932363962373639646339363164 +32623265303762343833343535333463613138356336643563323435356431616366653539643065 +32623639663137356262623131353135333630643435323462643032663061653066636662323233 +36636364396465653637396464336161303761633366303339653834323036633666373630343762 +34383734346436633962636131353235346462636632373461376265633365383861396262303032 +37376434626637616437613364336536666431663434313238373333303362383538623962396262 +30323334643064343237663862373034663338356430393935336131663634646130363733393164 +33383832633630396434386339313331363035383634616463383363386433643334623331326261 +33333463353133306530333937646238633831376165373735363462353263333930396264383039 +30666239313237613437363635333863663137633961336235313036306335373166633465303239 +31636135323965623836383231396535366263636164363737313761613531613633303461386533 +66653230323962626539343338336533333435323565616536643436336534323730373864666366 +39356330643562393434363032373338373363383565643934383464363634353435383731636534 +36313031373365393236363735636234616134646334306266643336376336343464623534663766 +62376330353232376232346337323562306437303631303833383430666638393835663033326135 +31333166386632663564383637373266333961353139333662303333636439393835363630363539 +61623435396638653937343866373165623530373664633665333962376235646163373762373734 +62373262393562643737653965636462323065343530626132393834633361623531333361613337 +62653966343863623666326463356130643766346638656436643738613032333462663061346335 +33373263303438383236353733343766356338323231663161303830333663366232386461643730 +37306663373262633635326338633136313938666230343334353735313731626363316436336130 +66643264313239343334323362303165643966383661653239373731306433346465613839616261 +33313438623235343366636630373963626664356531313934363035303137613465663434333265 +65393665626539623232616336663832346265613934313666616266383537613066343930656237 +62653935663234376634316433396631363232396337393165323131633632303330646538613330 +30356361336432346435366537386362363630306333386131336663623661376163373039663461 +33353936346462633732376132393339363334313137303965313762366439306361383963636130 +37366336666330323665653266343662383065396563633238313564363863633165326166666634 +61366666383236646161306465376635336334343461656436643161363038323534636632363464 +65666133613437303931333534643235393438323138346130333338316233386536306238323463 +64613335366430653766343061326361646339613363356563623466343466343930323032303532 +61636561383531643664613833376636316364366166653365616336336564353130356564323331 +33383934323166633338316265636363343232663033623732636636373437363837643237653464 +63393436313836616335373562666532353338313035663632363265653162303233333566333538 +61613563636234343433323635303462646362383763346264393734386130313362333736623236 +33613237663064616330303733373434386538633463626332633534376465376135336230346366 +38306135376539303131663237623764633633653933336162663636346361356664323565396430 +38643262326132333832653536663535363136646336333236373661346431326430333161613535 +65316438626436336235353765363233663131333063333330323731366266393466313062323539 +30393564383430373661613737343634306138393566623830636633616430313531653736303739 +30373439626362653639313162306237396330396633303761353635396235666333643339393061 +35313535613264366435386338306633396631643838313962643334326236386237363935376531 +36626338366136306631623235346138356132666632613466623132353161396464646539376665 +31623862316466343435