Names and certificates#
The zone cloud.hilling.de already exists in Route 53.
| Environment | Host |
|---|---|
| QA | taskfest-qa.cloud.hilling.de |
| Prod | taskfest.cloud.hilling.de |
Each is an A and AAAA alias record pointing at that environment's CloudFront distribution; alias records to CloudFront are not charged.
Two things that catch people, both worth knowing before building:
- The certificate must be in
us-east-1. CloudFront only accepts ACM certificates from that region, whatever region everything else lives in. The HTTP API answers on its own AWS name and needs none of ours. - The zone and the environments are in the same account, which is one of the reasons that decision was reverted — no cross-account role, no subdomain delegation, and ACM's DNS validation writes its record directly.
Alias records, not CNAMEs, and the cost difference is real though small here. Route 53 does
not charge for queries to an alias record that points at an AWS resource; a CNAME is a standard
record at $0.40 per million queries, and a CNAME pointing at another name in the same zone
is billed as two queries because the resolver has to ask twice. At demo traffic that is
fractions of a cent either way — but an alias is free, avoids the second lookup, and is the only
one of the two that would work at a zone apex. There is no case for the CNAME.
The Google OIDC configuration#
Fixed hostnames make these knowable now, so they can be set up once the environments exist.
The backend's callback is /api/auth/callback, the Quarkus backend's path, which the Go backend
kept, and /api/* routes through the same distribution, so the authorised redirect URIs are:
https://taskfest-qa.cloud.hilling.de/api/auth/callbackhttps://taskfest.cloud.hilling.de/api/auth/callback
This is manual configuration in the Google console and cannot be automated here.
What is built (#120), per environment:
- The client id is in
terraform.tfvars(google_client_id). It is not a secret — it travels in every sign-in redirect. Each environment has a web client of its own, in its own Google project, and a client secret of its own. An empty id keeps sign-in off in that environment. -
The client secret is
taskfest-<env>-google-client-secretin Secrets Manager. OpenTofu creates it empty; a person puts the value in, so it never passes through the repository or OpenTofu state:aws secretsmanager put-secret-value --secret-id taskfest-qa-google-client-secret \ --secret-string '<the client secret from the Google console>'The
apifunction's role may read that one secret, which the function reads at a cold start (TASKFEST_OIDC_GOOGLE_CLIENT_SECRET_ARN). It does not rotate by itself; after changing it, redeploy the release that runs, so that every instance starts afresh. About $0.40 a month. - Behind CloudFront and the HTTP API the backend does not build its callback from the request: it takes its own address fromTASKFEST_PUBLIC_ORIGIN,https://<hostname>, so Google is always asked to return to the registered redirect URI. - Who may sign in is decided in the Google console, on the Google Auth Platform's Audience page: in Testing, only the Google accounts listed as test users (at most 100); In production, anyone with a Google account (#607). With onlyopenid,emailandprofile, publishing needs no verification review. Without brand verification the consent screen shows the domain rather than the app's name and logo; brand verification usually takes two to three working days, and a later change to the branding needs it again. Going back to Testing is not described in Google's documentation: check the Audience page offers it before relying on it. qa gets a Google project of its own, kept in Testing, since the publishing status is a project's and not a client's; only prod's project is published, once qa has moved out of it (decision).
Sign in with Apple (#281)#
A further provider on the website, beside Google; its code is generic (authentication.md). prod only: Apple keeps no list of test users, so on qa it would let anyone in, and qa is for invited testers (decision). What Apple needs is made by hand in the Apple developer account, Certificates, Identifiers & Profiles:
- A Services ID for the website, with Sign in with Apple configured: the domain
taskfest.cloud.hilling.de, and as return URLhttps://taskfest.cloud.hilling.de/api/auth/callback/apple. - A key with Sign in with Apple: the
.p8file, downloadable once, its key id and the team id.
Then, in prod, in three steps, because an empty key would stop the function's every start:
apple_sign_ininterraform.tfvarswith the Services ID, key id and team id,offered = false; applied, it creates the secrettaskfest-prod-apple-signing-key, empty (about $0.40 a month).-
The key put in by hand, never through the repository or state:
aws secretsmanager put-secret-value --secret-id taskfest-prod-apple-signing-key \ --secret-string file://AuthKey_<key id>.p8 -
offered = true, applied: the function's settings name the provider. Then prod's backend is redeployed with the release it runs (deploy-serverless.yml), since only a deploy brings new settings to thelivealias (serverless.md); after it, the button appears. The deploy invokes the new version before it moveslive, so a key the function cannot read fails the deploy's check and leaves prod on the version it ran: the key is put right, oroffered = falseapplied, and nothing is rolled back by hand.
Push notifications (#277)#
The push function sends a change to a task to its owner's other devices, through APNs to an
iPhone and FCM to an Android phone (serverless.md,
decision). OpenTofu creates it in
both environments, with nothing to send with; what it needs from Apple and Google is made by hand,
per environment, and named in push_notifications in terraform.tfvars, where ios_offered and
android_offered switch each platform on and off on its own. None of those ids is a secret; the
APNs key is, and goes into Secrets Manager by hand. No AWS account id goes into the
repository or any public text: take it from the AWS console where a step below needs it.
The steps, in this order, since an empty key would stop the function's every start, and a Google provider can only trust a role that exists:
- The APNs key. In the Apple developer account, Certificates, Identifiers & Profiles →
Keys → +: Apple Push Notifications service (APNs), environment Production, key
restriction Topic Specific, the environment's bundle id (
de.hilling.taskfest,de.hilling.taskfest.qa). Download the.p8file, once, and note its key id; the team id is under Membership details. Both go intopush_notificationsasapns_key_idandapns_team_id, withios_offered = false; applied (env.sh up <env>), they create the secrettaskfest-<env>-apns-key, empty (about $0.40 a month). -
The key put in by hand, never through the repository or state:
aws secretsmanager put-secret-value --secret-id taskfest-<env>-apns-key \ --secret-string file://AuthKey_<key id>.p8 -
Google, in the environment's own Google project (prod
todolist-510513, qataskfest-qa), in the Google Cloud console. Workload Identity Federation trades the function's AWS credentials, those of its roletaskfest-<env>-push, which the apply above created, for a Google token; no Google key is stored. Following Google's workload identity federation with AWS (opens in a new tab):- Firebase on the project, if it is not yet: in the Firebase console, Add project and choose the existing Google Cloud project. Its Firebase project id is the project's id.
- The APIs, APIs & Services → Library: Identity and Access Management (IAM) API, Cloud Resource Manager API, IAM Service Account Credentials API, Security Token Service API and Firebase Cloud Messaging API.
-
A workload identity pool, IAM & Admin → Workload Identity Federation → Create pool, say
taskfest-aws; and in it a provider of type AWS, saytaskfest-<env>-push, with the AWS account id. Ids are 4 to 32 characters, and the pool's and the provider's cannot be changed later. Keep Google's default attribute mapping for AWS:google.subject = assertion.arn attribute.aws_role = assertion.arn.contains('assumed-role') ? assertion.arn.extract('{account_arn}assumed-role/') + 'assumed-role/' + assertion.arn.extract('assumed-role/{role_name}/') : assertion.arnwhich makes
attribute.aws_rolethe assumed role's ARN without its session name,arn:aws:sts::<AWS account id>:assumed-role/taskfest-<env>-push. The attribute condition admits that role alone, so nothing else in the AWS account can use the provider; mind the closing quote, which the console's error names only as a "token recognition error":attribute.aws_role == "arn:aws:sts::<AWS account id>:assumed-role/taskfest-<env>-push" -
A service account that may send, IAM & Admin → Service Accounts → Create service account,
push-606as in qa (an id has 6 to 30 characters, sopushis refused), sopush-606@<project id>.iam.gserviceaccount.com, and on the project, IAM & Admin → IAM → Grant access, the role Firebase Cloud Messaging API Admin (roles/firebasecloudmessaging.admin). No key for it. -
The role may act as it: open the pool by its name in Workload Identity Federation's list, then Grant access → Grant access using service account impersonation, the service account, Only identities matching the filter, attribute
aws_role, value the role's ARN as above, without quotes. Dismiss the offer of a configuration file: the function makes its own. That grants Workload Identity User (roles/iam.workloadIdentityUser) on the service account toprincipalSet://iam.googleapis.com/projects/<project number>/locations/global/workloadIdentityPools/<pool id>/attribute.aws_role/arn:aws:sts::<AWS account id>:assumed-role/taskfest-<env>-pushwith the project's number, not its id: IAM & Admin → Settings shows both.
-
The Google ids into
push_notifications:fcm_project_id, the project's id;google_project_number, digits;google_pool_idandgoogle_provider_id, as created;google_service_account, its email. Thenios_offered = trueandandroid_offered = true, applied: the function's settings name APNs and FCM, and the API's name the function (TASKFEST_PUSH_FUNCTION), with the leave to invoke it. The two are apart, so either platform can go first: iPhones after steps 1 and 2, Android after step 3.ios_offered = truewith no key in the secret would stop every start of the function, Android's pushes with it, which is why the key goes in first. - A redeploy of the release that runs (
deploy-serverless.yml), since only a deploy brings new settings to thelivealiases (serverless.md). It must be a release withpush.zip, the first after v1.8.4: the deploy leaves push alone for an older one, which never publishes a version of push with its settings. Until that first deploy, push'slivealias is still$LATEST, which takes the settings at the apply; nothing invokes it yet, since the API's code that hands a change to push comes with the same release aspush.zip, and an older API ignoresTASKFEST_PUSH_FUNCTION. The deploy checks the API alone, so a push function that cannot start shows only in its own log: change a task in the app on one phone, signed in on another, and look for the push, or forthe push settings are wrongorreading the secrets failedin/aws/lambda/taskfest-<env>-push; the alarmtaskfest-<env>-push-errorsmails on either.
Switching off is the same backwards, a platform at a time or both:
ios_offered = false,android_offered = falseor both, applied.- A redeploy of the release that runs, as in step 5 and from a release with
push.zipas there, which brings the settings without them to thelivealiases. Between the two, the version that serves still has the old settings while the roles already lack the leave: with both platforms off, the API logs anAccessDeniedfor each change it hands to push, which is harmless, since a push never fails a change; with iPhones off, a cold start of push fails on the APNs key it may no longer read, Android's pushes with it. So redeploy straight after the apply.
Never clear apns_key_id while a deployed version still names the secret: it deletes the
secret and the role's read of it, and every cold start of push fails until a deploy. Switch iPhones
off and redeploy first, then clear the ids and apply. The secret is kept for seven days after
(recovery_window_in_days), in case it was a mistake.
The test accounts' Cognito pool (qa)#
qa has a second sign-in provider beside Google: a Cognito user pool with two test accounts,
taskfest-test-one@example.com and taskfest-test-two@example.com, which the live tests sign in
with (#141, #190). Unlike the Google client, all of it is code (test-sign-in.tf):
- The pool admits no sign-ups and has no MFA: the accounts are the only ones there will ever
be, and a machine signs them in. Its hosted login page is Cognito's prefix domain,
taskfest-qa.auth.eu-central-1.amazoncognito.com— no certificate, no DNS. - The app client is confidential and returns to
https://taskfest-qa.cloud.hilling.de/api/auth/callback/cognito, the provider's own callback (#143). Cognito generates its secret, so it is in OpenTofu state (the decision), and theapifunction gets it in its settings. - The mobile app's client (#267) is public — an installed app cannot keep a secret — and returns
to the qa build's scheme,
de.hilling.taskfest.qa://oauthredirect, through the system browser with PKCE. The app drops its refresh tokens (#633). The backend accepts its ID tokens as bearer tokens because the function's settings name it (TASKFEST_OIDC_COGNITO_AUDIENCES); the qa build of the app is given the issuer and the client id from the outputstest_accounts_issuerandtest_accounts_app_client_id. - No password is stored anywhere. The accounts are created without one; the live-test run
sets a fresh random password before signing in, as the role
taskfest-qa-live-test, which may do nothing else (#144). - The backend offers the provider where the pool exists: the function's settings name it in
TASKFEST_AUTH_PROVIDERSand configure it (TASKFEST_OIDC_COGNITO_*). Its button reads Sign in with TaskFest test account, with the TaskFest mark.
The documentation site's own name#
Google's consent screen asks for an application home page, a privacy policy and terms of service,
all under the authorised domain hilling.de. They are the GitHub Pages site, under
https://taskfest-docs.cloud.hilling.de/: the home page is the rendered README, and
privacy.md and terms.md are linked from the footer of every page.
The name is a CNAME to guhilling.github.io, managed in the account/ root
(docs_hostname), and the repository's Pages settings name the same host, which is what makes
GitHub serve the site there and issue its certificate.