fix: make certificate automation deployable and restrict it to core and above - #131
Open
Kanavpreet-Singh wants to merge 3 commits into
Open
Conversation
The certificate APIs, template APIs and the certificate portal were reachable without any authentication, which allowed anyone to issue certificates and to start the mass mail job from the ACM account. Also stops tracking target/, so build output no longer shows up as changes.
Kanavpreet-Singh
force-pushed
the
fix/gmail-credentials-from-env
branch
from
August 15, 2026 15:24
c2e67a6 to
a5f8604
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
1. Gmail credentials cannot be supplied in a deployment
MassMailServiceread the Gmail client ID and secret fromsrc/main/resources/secret.json. That file is gitignored, so it is absent from the repository and from the jar our Docker image builds. Certificate mailing works on a machine that happens to have the file locally, and always fails once deployed.validateGmailConfigstartup check is kept, rewritten to validate the properties rather thansecret.json.Requires four environment variables, all stored as secrets:
GMAIL_CLIENT_ID,GMAIL_CLIENT_SECRET,GMAIL_REFRESH_TOKEN,GMAIL_USER_EMAIL.2. The certificate APIs were reachable without authentication
/api/certificates/**,/api/templates/**and/uiwere grantedpermitAllwith no@PreAuthorize. With no token it was possible to create certificates, upload a template, import a CSV and start the mass mail job, which on a public deployment would let anyone send email from the ACM account.Added
@PreAuthorize(Constants.HAS_ROLE_CORE_AND_ABOVE)to the three controllers, matching the roles that manage events, and declared at class level so a new endpoint is not left open by accident.Verified against a local run, every endpoint that previously answered anonymously with
200now returns403, while/healthand other public endpoints are unchanged.Also stops tracking
target/, so build output no longer shows as pending changes.Note on
/uiThe portal is a server rendered page with no login of its own, and the project authenticates with a bearer token header, so
/uiin a browser now returns403. It needs a login flow before it can be used that way. Leaving it public was not a safe alternative since it can start the mass mail job, but happy to change the approach if you would prefer it keep working in the browser short term.