Add DB-backed application tokens for the update endpoint
This commit is contained in:
@@ -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 = [
|
||||
|
||||
@@ -4,16 +4,25 @@ module WarpEngine
|
||||
# label: String
|
||||
# image_ids: -> { Array<Integer> } — az owner által használt image id-k
|
||||
# usage_label: ->(image) { String vagy nil } — megjelenítendő címke, ha használja
|
||||
# update_secret_source: a /update endpoint hitelesítési forrása, kizárólagos.
|
||||
# :env — a shared secret (update_secret) érvényes, a DB-tokenek nem
|
||||
# :database — csak WarpEngine::ApplicationToken érvényes, a shared secret nem
|
||||
# application_token_owner_class: a tokenek kötelező tulajdonosának osztályneve
|
||||
# (pl. "AdminUser"); nil esetén a :database mód minden kérést elutasít.
|
||||
attr_accessor :file_container_path,
|
||||
:image_container_path,
|
||||
:update_secret,
|
||||
:update_secret_source,
|
||||
:application_token_owner_class,
|
||||
:image_owners
|
||||
|
||||
def initialize
|
||||
@file_container_path = ENV.fetch("FILE_CONTAINER_PATH", "/softwares")
|
||||
@image_container_path = ENV.fetch("IMAGE_CONTAINER_PATH", "/images")
|
||||
@update_secret = ENV["UPDATE_SECRET"]
|
||||
@image_owners = []
|
||||
@file_container_path = ENV.fetch("FILE_CONTAINER_PATH", "/softwares")
|
||||
@image_container_path = ENV.fetch("IMAGE_CONTAINER_PATH", "/images")
|
||||
@update_secret = ENV["UPDATE_SECRET"]
|
||||
@update_secret_source = :env
|
||||
@application_token_owner_class = nil
|
||||
@image_owners = []
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user