[spring-boot]: generate PreAuthorize from OpenAPI security scopes - #24380
[spring-boot]: generate PreAuthorize from OpenAPI security scopes#24380JFCote wants to merge 9 commits into
Conversation
There was a problem hiding this comment.
Review completed against the latest diff
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
There was a problem hiding this comment.
All reported issues were addressed across 11 files (changes from recent commits).
Tip: Review your code locally with the cubic CLI to iterate faster.
Re-trigger cubic
There was a problem hiding this comment.
All reported issues were addressed across 7 files (changes from recent commits).
Tip: Review your code locally with the cubic CLI to iterate faster.
Re-trigger cubic
|
Let me know if there is anything else to fix and I will take care of it. |
|
@wing328 I added the requested lines. Let me know if something else is missing. |
Add opt-in Spring Boot support to translate OAuth2/OIDC security requirements into @PreAuthorize expressions, preserving OpenAPI AND/OR semantics. Also: enable method security with @EnableMethodSecurity add Spring Security dependency when enabled support configurable authority prefix (SCOPE_ by default) add documentation, tests, and a generated sample
9deb48a to
8c4aeb3
Compare
|
updated samples via cc7aa3e |
|
@JFCote did you have a chance to review the feedback from cubic-dev-ai? are those valid? |
|
circleci failure ignored as it's not related to this PR. |
|
@wing328 I did another pass. Let's see how it goes. I'm leaving on vacation but will check this when I come back. |
There was a problem hiding this comment.
All reported issues were addressed across 42 files (changes from recent commits).
Tip: Review your code locally with the cubic CLI to iterate faster.
Re-trigger cubic
Add opt-in Spring Boot support to translate OAuth2/OIDC security requirements
into @PreAuthorize expressions, preserving OpenAPI AND/OR semantics.
@cachescrubber (2022/02) @welshm (2022/02) @MelleD (2022/02) @atextor (2022/02) @manedev79 (2022/02) @javisst (2022/02) @borsch (2022/02) @banlevente (2022/02) @Zomzog (2022/09) @martin-mfg (2023/08) @KannaKim (2026/07)
PR checklist
Commit all changed files.
This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
These must match the expectations made by your contribution.
You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example
./bin/generate-samples.sh bin/configs/java*.IMPORTANT: Do NOT purge/delete any folders/files (e.g. tests) when regenerating the samples as manually written tests may be removed.
Summary by cubic
Adds opt-in generation of Spring Security
@PreAuthorizeannotations from OpenAPI OAuth2/OIDC scopes for Spring Boot. Preserves OpenAPI AND/OR semantics, enables method security, and includes a CI-built sample.useSpringSecurityPreAuthorize(Spring Boot only; errors if used with other libraries).@PreAuthorizewithhasAuthority()per scope; OR across requirements, AND within an entry; empty scopes →isAuthenticated(); escapes quotes in scope names.springSecurityAuthorityPrefix(defaultSCOPE_).security, falling back to top-levelsecuritywhen missing.@EnableMethodSecurity,@PreAuthorizeimport, andspring-boot-starter-securityin the generatedpom; docs and tests added; sample atsamples/server/others/springboot-pre-authorizewith configbin/configs/spring-boot-pre-authorize.yaml(built in CI).Written for commit 34d4b4c. Summary will update on new commits.