1
0
Fork 0
mirror of https://github.com/PaperMC/Paper.git synced 2025-01-31 03:50:36 +01:00

Add velocity forwarding secret env override ()

Previously, the velocity forwarding secret could only be configured via
the configuration option in the global paper configuration.
This makes configuring/passing such a value rather difficult for
containerized/orchestrated servers as these configuration files are
usually part of the server data volume itself and hence cannot be
sourced from a secret.

This commit enables administrators to define the PAPER_VELOCITY_SECRET
environment variable, which will override any potentially configured
velocity secret.
This commit is contained in:
Oliver Janka 2024-09-22 20:25:27 +02:00
parent e371c168d8
commit 36472a9173

View file

@ -594,7 +594,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+
+ @PostProcess
+ private void postProcess() {
+ if (this.enabled && this.secret.isEmpty()) {
+ if (!this.enabled) return;
+
+ final String environmentSourcedVelocitySecret = System.getenv("PAPER_VELOCITY_SECRET");
+ if (environmentSourcedVelocitySecret != null && !environmentSourcedVelocitySecret.isEmpty()) {
+ this.secret = environmentSourcedVelocitySecret;
+ }
+
+ if (this.secret.isEmpty()) {
+ LOGGER.error("Velocity is enabled, but no secret key was specified. A secret key is required. Disabling velocity...");
+ this.enabled = false;
+ }