pat-lego opened a new pull request, #115:
URL: 
https://github.com/apache/jackrabbit-filevault-package-maven-plugin/pull/115

   ## What
   
   Adds an opt-in parameter to the `package` goal, 
`removeAnonymousFromAdministrativePrincipals` (property 
`vault.removeAnonymousFromAdministrativePrincipals`, default `false`).
   
   When it is enabled and an OSGi configuration of the Apache Jackrabbit Oak 
authorization configuration 
(`org.apache.jackrabbit.oak.security.authorization.AuthorizationConfigurationImpl`)
 below `jcr_root` lists the principal `anonymous` in 
`administrativePrincipals`, the packaged copy of that file has `anonymous` 
removed, the other principals stay in their order, and a warning is logged.
   
   ## Why
   
   Oak grants full permissions on the whole repository to every principal in 
`administrativePrincipals`. With `anonymous` in that list, every request 
without credentials would get those permissions. This lets a build make sure 
such a configuration never ends up in a package.
   
   ## How
   
   - `OsgiConfigurationFiles` reads and writes OSGi configuration files in the 
`.cfg.json` (Felix `cm.json`, with comments and type hints) and `.config` 
(Felix ConfigAdmin) formats. Both libraries are already on the plugin's 
classpath through `vault-validation`.
   - `AdministrativePrincipalsConfigurationTransformer` is a plexus-archiver 
`InputStreamTransformer`. `VaultMojo` sets it on the file sets below 
`jcr_root`, so only the copy written into the package changes and the source 
files are untouched. Files of other PIDs are passed through without being read.
   - The match is exact, like Oak's own check (`PermissionUtil.isAdminOrSystem` 
compares principal names with `Set.contains`). `Anonymous`, ` anonymous` or 
`anonymous-users` grant nothing to the anonymous principal, so they are left 
alone.
   - Oak accepts the value as an array, a collection (the `( ... )` syntax of 
`.config`) or a single String, so all three are handled. A single String 
`anonymous` removes the property.
   - Each warning is logged once per file, even though the archiver reads a 
file more than once.
   - A file that cannot be parsed is packaged unchanged, with a warning.
   - `VaultMojo.chainStreamTransformers` lets several such adjustments be 
combined on one file set.
   
   Not covered: `.cfg` files and `sling:OsgiConfig` nodes. A changed file is 
serialized again, so its comments and formatting are not kept. Unchanged files 
are copied byte for byte.
   
   Documented in `src/site/markdown/osgi.md` ("Adjusting Unsafe OSGi 
Configurations").
   
   Related: #114 (same approach for `sling.auth.anonymous.user=admin`). Both 
PRs add the identical `OsgiConfigurationFiles`, its test and `CapturingLog`, 
and the same `VaultMojo` hook, so whichever merges second only needs a small 
conflict resolution in `VaultMojo`, `VaultMojoTest` and `osgi.md`.
   
   ## Tests
   
   - `OsgiConfigurationFilesTest`: PID from file name, JSON with comments and 
type hints, `.config` format, write/read round trip for both formats, invalid 
input.
   - `AdministrativePrincipalsConfigurationTransformerTest`: removal in both 
formats with order kept, every occurrence removed, array that becomes empty, 
single String, `.config` collection, non-exact names kept byte for byte, other 
files not read, unparsable file kept, one warning per file, idempotent.
   - `VaultMojoTest`: transformer chaining order, nothing added by default, 
transformer added when enabled.
   - `AdministrativePrincipalsConfigurationIT` (new test project 
`osgi-configuration-tests/administrative-principals`): with the property 
enabled, `anonymous` is removed from the packaged `.cfg.json` and `.config`, a 
configuration without it is copied unchanged, the source is untouched, and 2 
warnings are logged. With the default, all files are copied unchanged.
   - Mutation check: 11 deliberate breakages (array not written back, 
case/trim-insensitive match, stop after the first occurrence, collection 
ignored, single String ignored, warn every time, rewrite and warn when nothing 
changed, fail on unparsable, always enabled (unit and IT), not wired for 
`jcr_root`) are each caught by at least one test.
   - Full `mvn clean verify` passes (unit tests, 85 ITs, RAT).


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to