Add DB-backed application tokens for the update endpoint

This commit is contained in:
2026-08-05 18:30:20 +02:00
parent 60e196a03e
commit 710594efda
14 changed files with 591 additions and 10 deletions
@@ -75,6 +75,22 @@ class CreateWarpEngineTables < ActiveRecord::Migration[8.0]
t.index [ :software_id, :position ]
end
create_table :application_tokens do |t|
t.string :name, limit: 128, null: false
t.string :owner_type, limit: 128, null: false
t.bigint :owner_id, null: false
t.string :token_digest, limit: 64, null: false
t.string :token_prefix, limit: 12, null: false
t.json :scopes
t.datetime :expires_at, precision: 3
t.datetime :last_used_at, precision: 3
t.datetime :deleted_at, precision: 3
t.timestamps precision: 3, null: true
t.index :token_digest, unique: true
t.index [ :owner_type, :owner_id ]
t.index :deleted_at
end
create_table :downloads do |t|
t.string :file_path, null: false
t.references :release, foreign_key: { on_delete: :nullify }, index: false
@@ -9,6 +9,14 @@ Rails.application.config.to_prepare do
# Beállítatlan secret esetén az endpoint minden kérést elutasít.
# c.update_secret = ENV["UPDATE_SECRET"]
# A /update hitelesítési forrása — kizárólagos választás:
# :env — a fenti shared secret érvényes (default)
# :database — csak DB-tárolt WarpEngine::ApplicationToken érvényes
# ("update" scope-pal); a shared secret ilyenkor NEM működik.
# A :database módhoz kötelező a tokenek tulajdonos-osztálya is:
# c.update_secret_source = :database
# c.application_token_owner_class = "AdminUser"
# Ha a host modelljei is hivatkoznak katalógus-képekre, regisztráld őket,
# hogy az admin Images oldal orphan-detektálása figyelembe vegye:
# c.image_owners = [