authd_configuration
This commit is contained in:
parent
795bfd1187
commit
8ece44ced1
@ -50,9 +50,6 @@ end
|
|||||||
|
|
||||||
class Baguette::Configuration
|
class Baguette::Configuration
|
||||||
class FileStorage < Base
|
class FileStorage < Base
|
||||||
property authd_key : String = "nico-nico-nii" # Default authd key, as per the specs. :eyes:
|
|
||||||
property authd_key_file : String? = nil
|
|
||||||
|
|
||||||
property max_file_size : UInt64 = 10_000_000 # default, 10 MB
|
property max_file_size : UInt64 = 10_000_000 # default, 10 MB
|
||||||
property storage : String = "files/"
|
property storage : String = "files/"
|
||||||
property db_reindex : Bool = false
|
property db_reindex : Bool = false
|
||||||
@ -231,6 +228,19 @@ class FileStorage::Service < IPC::Server
|
|||||||
|
|
||||||
simulation, no_configuration, configuration_file = Baguette::Configuration.option_parser
|
simulation, no_configuration, configuration_file = Baguette::Configuration.option_parser
|
||||||
|
|
||||||
|
# Authd configuration.
|
||||||
|
authd_configuration = if no_configuration
|
||||||
|
Baguette::Log.info "do not load a configuration file."
|
||||||
|
Baguette::Configuration::Auth.new
|
||||||
|
else
|
||||||
|
# Configuration file is for altideald.
|
||||||
|
Baguette::Configuration::Auth.get || Baguette::Configuration::Auth.new
|
||||||
|
end
|
||||||
|
if key_file = authd_configuration.shared_key_file
|
||||||
|
authd_configuration.shared_key = File.read(key_file).chomp
|
||||||
|
end
|
||||||
|
|
||||||
|
# FileStoraged configuration.
|
||||||
configuration = if no_configuration
|
configuration = if no_configuration
|
||||||
Baguette::Log.info "do not load a configuration file."
|
Baguette::Log.info "do not load a configuration file."
|
||||||
Baguette::Configuration::FileStorage.new
|
Baguette::Configuration::FileStorage.new
|
||||||
@ -240,10 +250,6 @@ class FileStorage::Service < IPC::Server
|
|||||||
|
|
||||||
Baguette::Context.verbosity = configuration.verbosity
|
Baguette::Context.verbosity = configuration.verbosity
|
||||||
|
|
||||||
if key_file = configuration.authd_key_file
|
|
||||||
configuration.authd_key = File.read(key_file).chomp
|
|
||||||
end
|
|
||||||
|
|
||||||
OptionParser.parse do |parser|
|
OptionParser.parse do |parser|
|
||||||
parser.banner = "usage: filestoraged [options]"
|
parser.banner = "usage: filestoraged [options]"
|
||||||
|
|
||||||
@ -278,7 +284,7 @@ class FileStorage::Service < IPC::Server
|
|||||||
parser.on "-k file",
|
parser.on "-k file",
|
||||||
"--key file",
|
"--key file",
|
||||||
"Reads the authentication key from the provided file." do |file|
|
"Reads the authentication key from the provided file." do |file|
|
||||||
configuration.authd_key = File.read(file).chomp
|
authd_configuration.shared_key = File.read(file).chomp
|
||||||
end
|
end
|
||||||
|
|
||||||
parser.on "-h", "--help", "Displays this help and exits." do
|
parser.on "-h", "--help", "Displays this help and exits." do
|
||||||
@ -288,12 +294,13 @@ class FileStorage::Service < IPC::Server
|
|||||||
end
|
end
|
||||||
|
|
||||||
if simulation
|
if simulation
|
||||||
|
pp! authd_configuration
|
||||||
pp! configuration
|
pp! configuration
|
||||||
exit 0
|
exit 0
|
||||||
end
|
end
|
||||||
|
|
||||||
::FileStorage::Service.new(configuration.storage,
|
::FileStorage::Service.new(configuration.storage,
|
||||||
configuration.authd_key,
|
authd_configuration.shared_key,
|
||||||
configuration.db_reindex).tap do |service|
|
configuration.db_reindex).tap do |service|
|
||||||
|
|
||||||
service.base_timer = configuration.ipc_timer
|
service.base_timer = configuration.ipc_timer
|
||||||
|
Loading…
Reference in New Issue
Block a user