You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@grails.apache.org by "codeconsole (via GitHub)" <gi...@apache.org> on 2026/08/08 23:55:56 UTC

[PR] Generate Spring Security wiring through the beans DSL [grails-core]

codeconsole opened a new pull request, #16119:
URL: https://github.com/apache/grails-core/pull/16119

   ## What
   
   The `spring-boot-starter-security` forge feature generated a separate `SecurityConfig` class and pulled it into the generated app with `@Import(SecurityConfig)`. This declares the same two beans through the `beans` DSL (#16019) on the generated `Application` class instead, and deletes the `SecurityConfig` template.
   
   A generated secured app now looks like this, with no `src/main/groovy/**/SecurityConfig.groovy`:
   
   ```groovy
   @CompileStatic
   @EnableWebSecurity
   class Application extends GrailsAutoConfiguration {
       static void main(String[] args) {
           GrailsApp.run(Application, args)
       }
   
       def beans = {
   
           bean(PasswordEncoder) {
               PasswordEncoderFactories.createDelegatingPasswordEncoder()
           }
   
           bean('filterChain', SecurityFilterChain) { HttpSecurity http ->
               http
                   .authorizeHttpRequests { it.anyRequest().permitAll() }
                   .formLogin { }
                   .logout { it.logoutSuccessUrl('/') }
               http.build()
           }
       }
   }
   ```
   
   The behaviour is unchanged — same two beans, same form login, same logout URL. It is one fewer generated file, and the security wiring sits where an application's other bean wiring goes.
   
   No dependency declaration is added to the generated build: `grails-core` already exports `grails-beans-dsl` as an `api` dependency, so the transform reaches any app that depends on `grails-core`.
   
   Applications generated without the feature are unaffected — `application.rocker.raw` renders byte-identical output for them.
   
   ## Also
   
   `user.rocker.raw` marks the `password` field with the `password` constraint, so scaffolding renders it masked rather than as plain text:
   
   ```groovy
   password blank: false, password: true
   ```
   
   ## Testing
   
   `SpringBootStarterSecuritySpec` is updated to assert the DSL in `Application.groovy` and that no `SecurityConfig.groovy` is generated, and covers the new constraint. The negative case asserts neither `def beans = {` nor `@EnableWebSecurity` appears without the feature.
   
   - `SpringBootStarterSecuritySpec` — 6/6 pass
   - Full `:grails-forge-core:test` — 322 tests, 0 failures, 1 skipped
   
   Rendered output was inspected directly for both the secured and unsecured variants.
   
   Not covered here: the tests assert on generated text, not on compiling and booting a generated project.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@grails.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Generate Spring Security wiring through the beans DSL [grails-core]

Posted by "testlens-app[bot] (via GitHub)" <gi...@apache.org>.
testlens-app[bot] commented on PR #16119:
URL: https://github.com/apache/grails-core/pull/16119#issuecomment-5230025959

   ## ✅ All tests passed ✅
   
   🏷️ Commit: 7fbe45e1807dff59933e1c917c65cbf266e9c697
   ▶️ Tests:  59145 executed
   ⚪️ Checks: 60/60 completed
   
   ---
   _Learn more about TestLens at [testlens.app](https://testlens.app)._
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@grails.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Generate Spring Security wiring through the beans DSL [grails-core]

Posted by "codecov[bot] (via GitHub)" <gi...@apache.org>.
codecov[bot] commented on PR #16119:
URL: https://github.com/apache/grails-core/pull/16119#issuecomment-5229035549

   ## [Codecov](https://app.codecov.io/gh/apache/grails-core/pull/16119?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
   :white_check_mark: All modified and coverable lines are covered by tests.
   :white_check_mark: Project coverage is 52.3497%. Comparing base ([`a1e526f`](https://app.codecov.io/gh/apache/grails-core/commit/a1e526fd021afede1ec93a83eee6597fa9c024f5?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`81a151c`](https://app.codecov.io/gh/apache/grails-core/commit/81a151cbcdb6b3b605d82d3743f66b09c5be4bc4?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
   :warning: Report is 19 commits behind head on 8.0.x.
   
   <details><summary>Additional details and impacted files</summary>
   
   
   
   [![Impacted file tree graph](https://app.codecov.io/gh/apache/grails-core/pull/16119/graphs/tree.svg?width=650&height=150&src=pr&token=qJrryhpk7u&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)](https://app.codecov.io/gh/apache/grails-core/pull/16119?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
   
   ```diff
   @@                Coverage Diff                 @@
   ##                8.0.x     #16119        +/-   ##
   ==================================================
   + Coverage     52.3431%   52.3497%   +0.0066%     
   - Complexity      18296      18302         +6     
   ==================================================
     Files            2036       2036                
     Lines           96347      96373        +26     
     Branches        16829      16836         +7     
   ==================================================
   + Hits            50431      50451        +20     
   - Misses          38492      38498         +6     
     Partials         7424       7424                
   ```
   [see 4 files with indirect coverage changes](https://app.codecov.io/gh/apache/grails-core/pull/16119/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
   </details>
   <details><summary> :rocket: New features to boost your workflow: </summary>
   
   - :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
   - :package: [JS Bundle Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
   </details>


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@grails.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Generate Spring Security wiring through the beans DSL [grails-core]

Posted by "codeconsole (via GitHub)" <gi...@apache.org>.
codeconsole merged PR #16119:
URL: https://github.com/apache/grails-core/pull/16119


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@grails.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Generate Spring Security wiring through the beans DSL [grails-core]

Posted by "testlens-app[bot] (via GitHub)" <gi...@apache.org>.
testlens-app[bot] commented on PR #16119:
URL: https://github.com/apache/grails-core/pull/16119#issuecomment-5229272369

   ## ✅ All tests passed ✅
   
   🏷️ Commit: 81a151cbcdb6b3b605d82d3743f66b09c5be4bc4
   ▶️ Tests:  58957 executed
   ⚪️ Checks: 60/60 completed
   
   ---
   _Learn more about TestLens at [testlens.app](https://testlens.app)._
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@grails.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org