pat-lego opened a new pull request, #114:
URL:
https://github.com/apache/jackrabbit-filevault-package-maven-plugin/pull/114
## What
Adds an opt-in parameter to the `package` goal, `removeAdminAsAnonymousUser`
(property `vault.removeAdminAsAnonymousUser`, default `false`).
When it is enabled and an OSGi configuration of the Apache Sling
authenticator (`org.apache.sling.engine.impl.auth.SlingAuthenticator`) below
`jcr_root` sets `sling.auth.anonymous.user` to `admin`, the packaged copy of
that file has `sling.auth.anonymous.user` and `sling.auth.anonymous.password`
removed, and a warning is logged. Sling then uses its default anonymous user.
## Why
`sling.auth.anonymous.user` names the repository user that requests without
credentials run as. Set to `admin`, every anonymous visitor gets administrator
privileges. 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`.
- `AnonymousUserConfigurationTransformer` 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 value matches `admin` ignoring case and surrounding spaces, because
user IDs are looked up case-insensitively.
- The password value is never logged. 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. Sling
would not apply it either, and the validators report it.
- `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").
## Tests
- `OsgiConfigurationFilesTest`: PID from file name, JSON with comments and
type hints, `.config` format, write/read round trip for both formats, invalid
input.
- `AnonymousUserConfigurationTransformerTest`: removal in both formats, case
and space variants, other users kept byte for byte, other files not read,
unparsable file kept, one warning per file, idempotent, password never logged.
- `VaultMojoTest`: transformer chaining order, nothing added by default,
transformer added when enabled.
- `OsgiConfigurationIT` (new test project
`osgi-configuration-tests/anonymous-user`): with the property enabled, `admin`
is removed from the packaged `.cfg.json` and `.config`, another user 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 (keep user, keep password,
case-sensitive, no trim, warn every time, fail on unparsable, log password,
swapped chain order, 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]