Skip to content

fix: correct EC2 auth filter profile name to match real production pr… - #80

Merged
weited merged 2 commits into
mainfrom
bugfix/9175-ec2-monitoring-auth-profile-mismatch
Sep 4, 2026
Merged

fix: correct EC2 auth filter profile name to match real production pr…#80
weited merged 2 commits into
mainfrom
bugfix/9175-ec2-monitoring-auth-profile-mismatch

Conversation

@weited

@weited weited commented Sep 4, 2026

Copy link
Copy Markdown
Collaborator

…ofile

Copilot AI lite review requested due to automatic review settings September 4, 2026 07:19

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Profile naming is now inconsistent across the codebase (e.g., remaining prod-based profile conditions), which risks unexpected profile-conditional behavior unless reconciled.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR aligns the EC2 monitoring authentication filter with the repository’s actual production Spring profile name (production) and adds a regression test to ensure the filter is enforced under that profile.

Changes:

  • Switch Ec2InstanceAuthenticationFilter from @Profile({"prod","edge"}) to @Profile({"production","edge"}).
  • Make filter initialization tolerant of a null configured authorised-instance list.
  • Add a Spring Boot integration test that runs with the production profile and asserts unauthorised behavior without PKCS7.
File summaries
File Description
src/test/java/au/org/aodn/oceancurrent/security/Ec2InstanceAuthenticationFilterProductionProfileTest.java Adds a production-profile integration test asserting monitoring auth is enforced.
src/main/java/au/org/aodn/oceancurrent/security/Ec2InstanceAuthenticationFilter.java Updates active profiles to production/edge and hardens whitelist initialization.
Dockerfile Updates documentation comment to reflect production profile naming.
Review details
  • Files reviewed: 3/3 changed files
  • Comments generated: 2
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

OpenApiConfig uses an invalid Spring profile expression operator (&&), which is likely to break profile evaluation or startup.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review details

Suppressed comments (1)

src/main/java/au/org/aodn/oceancurrent/security/Ec2InstanceAuthenticationFilter.java:59

  • When authorisedInstanceIds is missing/empty, the filter now silently starts with an empty whitelist, causing all authenticated requests to be rejected; this can hide a production misconfiguration. Consider logging a warning (or failing fast) when the whitelist is null/empty so the issue is visible.
        List<String> configuredIds = monitoringSecurityProperties.getAuthorisedInstanceIds();
        this.authorisedInstanceIds = configuredIds != null ? new HashSet<>(configuredIds) : Collections.emptySet();
        log.info("Initialized EC2 authentication filter with {} authorised instance IDs", authorisedInstanceIds.size());
  • Files reviewed: 9/9 changed files
  • Comments generated: 1
  • Review effort level: Lite

Comment on lines 13 to 15
@Configuration
@Profile("!prod && !test")
@Profile("!production && !test")
public class OpenApiConfig {
@weited
weited merged commit ee4b12a into main Sep 4, 2026
2 checks passed
@weited
weited deleted the bugfix/9175-ec2-monitoring-auth-profile-mismatch branch September 4, 2026 07:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants