feat(EM-39): Implement Spring Security Foundation and Authentication Configuration#163
Open
devin-ai-integration[bot] wants to merge 3 commits intofeat/microservices-migration-v5from
Conversation
…Configuration - Create ftgo-security-lib shared library with base SecurityFilterChain - Add spring-boot-starter-security to Gradle version catalog and service bundle - Configure stateless session management for microservices - Implement CORS configuration with externalized properties - Disable CSRF for stateless REST APIs - Secure actuator endpoints (health/info public, others authenticated) - Add JSON error responses for 401/403 (custom entry point and access denied handler) - Add SecurityExceptionHandlerFilter for consistent error handling - Add SecurityUtils utility class for common security operations - Add security profile configuration (application-security.yml) - Remove hardcoded credentials from application.properties, docker-compose.yml, and K8s manifests - Add comprehensive security integration tests (22 tests passing) Co-Authored-By: mason.batchelor <masonbatchelor81@gmail.com>
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
…39-security-foundation Resolve conflicts: keep fuller security lib implementation (subpackaged config/exception/util) over base branch's flat package skeleton. Incorporate base branch additions (observability, API gateway, openapi-lib, CI workflows, etc.). Co-Authored-By: mason.batchelor <masonbatchelor81@gmail.com>
Co-Authored-By: mason.batchelor <masonbatchelor81@gmail.com>
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.
Summary
Implements Phase 3 (Security Baseline) by creating a new
shared-libraries/ftgo-securitylibrary and adding Spring Security across the platform.New
ftgo-security-libprovides:FtgoBaseSecurityConfiguration: Bean-basedSecurityFilterChainwith stateless sessions, CSRF disabled, CORS from properties, HTTP Basic authFtgoSecurityProperties: Externalized config underftgo.security.*for CORS and public pathsFtgoAuthenticationEntryPoint/FtgoAccessDeniedHandler: JSON 401/403 error responsesSecurityExceptionHandlerFilter: Catches unexpected errors in the security filter chainSecurityUtils: Convenience methods for accessing the current security contextMETA-INF/spring/...AutoConfiguration.importsVersion catalog changes (
libs.versions.toml):spring-boot-starter-securityadded tospring-boot-servicebundle (all services get it)spring-security-testadded totestingbundleftgo-security-libadded to shared libraries sectionCredential externalization:
ftgo-application/application.properties: DB credentials now use${MYSQL_USERNAME}/${MYSQL_PASSWORD}env varsftgo-order-servicetest properties: same, with fallback defaultsdocker-compose.yml: credentials now require env vars (will fail without.envor exported vars)ftgo-mysql-deployment.yml: credentials now read fromftgo-db-credentialsSecret32 tests pass in the security lib (integration + unit).
Updates since last revision
Resolved merge conflicts with
feat/microservices-migration-v5, which had received observability infrastructure (Prometheus/Grafana), API gateway, new shared libraries (ftgo-common-jpa,ftgo-domain,ftgo-observability), and CI workflows since this branch was created.Key merge decisions:
net.chrisrichardson.ftgo.security.FtgoSecurityAutoConfiguration,SecurityExceptionHandler,SecurityUtils,FtgoSecurityProperties,FtgoAuthenticationEntryPoint) with this PR's more complete subpackaged implementation (config/,exception/,util/). The deleted files were a simpler scaffold added to the base branch by another PR.ftgo-common-jpa-lib,ftgo-domain-lib,micrometer,services:api-gateway, new CI workflowsbuild.gradle: addedftgo.testing-conventionsplugin,jackson.databinddependency (used by JSON error handlers)defaultCorsAllowsAllOrigins()→corsOriginsAreConfigurable()since mergedapplication.ymlsets specific origins instead of wildcard*Review & Testing Checklist for Human
net.chrisrichardson.ftgo.security(flat package) that were added by another PR on the base branch, replacing them with subpackaged equivalents underconfig/,exception/,util/. Verify the replacement classes have equivalent or better functionality (e.g.,@ConditionalOnProperty,@ConditionalOnWebApplication,@AutoConfigurationannotations). TheAutoConfiguration.importsnow points toFtgoBaseSecurityConfigurationinstead ofFtgoSecurityAutoConfiguration.spring-boot-starter-securitywas added to thespring-boot-servicebundle. Any service usinglibs.bundles.spring.boot.servicewill now get Spring Security on its classpath with default auto-config (all endpoints locked, random password in logs), since no service yet declares a dependency onftgo-security-lib. Verify this is the intended rollout strategy vs. having services opt-in explicitly.ftgo-application/application.properties:spring.datasource.password=${MYSQL_PASSWORD}has no fallback, unlike the order-service test props which use${MYSQL_PASSWORD:mysqlpw}. This will fail at startup if the env var is unset. Confirm this is intentional or add a dev default.docker-compose.ymlis now a breaking change for local dev: The${MYSQL_ROOT_PASSWORD:?...}syntax requires env vars to be set. Anyone runningdocker-compose upwithout an.envfile will get an error. Consider adding a sample.env.exampleor documenting the required vars.application.propertiesandapplication.ymlexist insrc/test/resources/for the security lib. The.yml(from base branch) overrides CORS defaults from.properties, which already caused a test adjustment. Verify there are no other subtle override conflicts../gradlew clean build test(excluding the pre-existing e2eeventuate-util-testfailure) to confirm no regressions after the merge, especially in modules that now have Spring Security on the classpath.Notes
ftgo-end-to-end-tests,ftgo-end-to-end-tests-common) have a pre-existing dependency issue witheventuate-util-test— unrelated to this PR.FtgoAuthenticationEntryPointandFtgoAccessDeniedHandlerinstantiate their ownObjectMapperrather than using the Spring-managed one. This is fine for error response bodies but won't include custom FTGO serializers (Money, DateTime).implementation project(":shared-libraries:ftgo-security")to theirbuild.gradlein a follow-up to activate the customFtgoBaseSecurityConfiguration(rather than Spring's defaults).Link to Devin session: https://app.devin.ai/sessions/6bf87ff50ed64676aecff85ab2fbb569
Requested by: @mbatchelor81