From 6bfe0d7df40e7e66e3a61ca2d612868dcaf1af89 Mon Sep 17 00:00:00 2001 From: Stavros Kois <47820033+stavros-k@users.noreply.github.com> Date: Mon, 25 Dec 2023 14:52:00 +0200 Subject: [PATCH] fix(invidious): automatically create hmac key (#16523) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit **Description** ⚒️ Fixes #16366 **⚙️ Type of change** - [ ] ⚙️ Feature/App addition - [ ] 🪛 Bugfix - [ ] ⚠️ Breaking change (fix or feature that would cause existing functionality to not work as expected) - [ ] 🔃 Refactor of current code **🧪 How Has This Been Tested?** **📃 Notes:** **✔️ Checklist:** - [ ] ⚖️ My code follows the style guidelines of this project - [ ] 👀 I have performed a self-review of my own code - [ ] #️⃣ I have commented my code, particularly in hard-to-understand areas - [ ] 📄 I have made corresponding changes to the documentation - [ ] ⚠️ My changes generate no new warnings - [ ] 🧪 I have added tests to this description that prove my fix is effective or that my feature works - [ ] ⬆️ I increased versions for any altered app according to semantic versioning **➕ App addition** If this PR is an app addition please make sure you have done the following. - [ ] 🪞 I have opened a PR on [truecharts/containers](https://github.com/truecharts/containers) adding the container to TrueCharts mirror repo. - [ ] 🖼️ I have added an icon in the Chart's root directory called `icon.png` --- _Please don't blindly check all the boxes. Read them and only check those that apply. Those checkboxes are there for the reviewer to see what is this all about and the status of this PR with a quick glance._ --------- Signed-off-by: Stavros Kois <47820033+stavros-k@users.noreply.github.com> --- charts/stable/invidious/Chart.yaml | 2 +- charts/stable/invidious/questions.yaml | 7 ------- charts/stable/invidious/templates/_config.tpl | 12 ++++++++++-- charts/stable/invidious/templates/common.yaml | 6 +++--- charts/stable/invidious/values.yaml | 5 ++--- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/charts/stable/invidious/Chart.yaml b/charts/stable/invidious/Chart.yaml index ac119fa2383..a996f1944d3 100644 --- a/charts/stable/invidious/Chart.yaml +++ b/charts/stable/invidious/Chart.yaml @@ -1,7 +1,7 @@ kubeVersion: '>=1.24.0-0' apiVersion: v2 name: invidious -version: 7.0.12 +version: 7.0.13 appVersion: latest description: Open source alternative front-end to YouTube. home: https://truecharts.org/charts/stable/invidious diff --git a/charts/stable/invidious/questions.yaml b/charts/stable/invidious/questions.yaml index f6029faee76..fcc2a35538c 100644 --- a/charts/stable/invidious/questions.yaml +++ b/charts/stable/invidious/questions.yaml @@ -346,13 +346,6 @@ questions: schema: type: boolean default: false - - variable: hmac_key - label: HMAC Key - description: HMAC signing key used for CSRF tokens and pubsub subscriptions verification. A random key must be generated and placed here. - schema: - type: string - private: true - default: "" - variable: dmca_content label: DMCA Content description: List of video IDs where the "download" widget must be disabled, in order to comply with DMCA requests. diff --git a/charts/stable/invidious/templates/_config.tpl b/charts/stable/invidious/templates/_config.tpl index c0867f71b49..05c49f3be47 100644 --- a/charts/stable/invidious/templates/_config.tpl +++ b/charts/stable/invidious/templates/_config.tpl @@ -1,5 +1,12 @@ {{/* Define the configmap */}} -{{- define "invidious.config" -}} +{{- define "invidious.secret" -}} + +{{- $secretName := printf "%s-invidious-secret" (include "tc.v1.common.lib.chart.names.fullname" .) -}} + +{{- $hmac := randAlphaNum 64 -}} +{{- with (lookup "v1" "Secret" .Release.Namespace $secretName) -}} + {{- $hmac = (index .data "HMAC_KEY") | b64dec -}} +{{- end -}} {{- $vNet := .Values.invidious.network }} {{- $vLog := .Values.invidious.logging }} @@ -17,6 +24,7 @@ {{- $vUserMisc := .Values.invidious.default_user_preferences.miscellaneous }} enabled: true data: + HMAC_KEY: {{ $hmac }} INVIDIOUS_CONFIG: | # Database check_tables: true @@ -85,7 +93,7 @@ data: # Miscellaneaous banner: {{ $vMisc.banner }} use_pubsub_feeds: {{ $vMisc.use_pubsub_feeds }} - hmac_key: {{ $vMisc.hmac_key }} + hmac_key: {{ $hmac }} {{- if $vMisc.dmca_content }} dmca_content: {{- range $vMisc.dmca_content }} diff --git a/charts/stable/invidious/templates/common.yaml b/charts/stable/invidious/templates/common.yaml index 572b59322e4..e349f5c1fb6 100644 --- a/charts/stable/invidious/templates/common.yaml +++ b/charts/stable/invidious/templates/common.yaml @@ -2,9 +2,9 @@ {{- include "tc.v1.common.loader.init" . }} {{/* Render configmap for invidious */}} -{{- $configmapFile := include "invidious.config" . | fromYaml -}} -{{- if $configmapFile -}} - {{- $_ := set .Values.configmap "invidious-config" $configmapFile -}} +{{- $secretFile := include "invidious.secret" . | fromYaml -}} +{{- if $secretFile -}} + {{- $_ := set .Values.secret "invidious-secret" $secretFile -}} {{- end -}} {{/* Render the templates */}} diff --git a/charts/stable/invidious/values.yaml b/charts/stable/invidious/values.yaml index bc53115734b..3c5402cf449 100644 --- a/charts/stable/invidious/values.yaml +++ b/charts/stable/invidious/values.yaml @@ -64,8 +64,8 @@ workload: startup: type: http envFrom: - - configMapRef: - name: invidious-config + - secretRef: + name: invidious-secret invidious: network: inbound: @@ -110,7 +110,6 @@ invidious: miscellaneous: banner: "" use_pubsub_feeds: false - hmac_key: "" dmca_content: [] cache_annotations: false playlist_length_limit: 500