fix key management dedup

rewrite
Karchnu 2020-10-25 19:36:28 +01:00
parent 9524f969c4
commit d12c125c22
2 changed files with 11 additions and 14 deletions

View File

@ -11,10 +11,13 @@ class Baguette::Configuration
class Auth < Base class Auth < Base
include YAML::Serializable include YAML::Serializable
property login : String? property login : String? = nil
property pass : String? property pass : String? = nil
property shared_key : String? property shared_key : String = "nico-nico-nii" # Default authd key, as per the specs. :eyes:
property shared_key_file : String? property shared_key_file : String? = nil
def initialize
end
end end
end end

View File

@ -16,9 +16,6 @@ extend AuthD
class Baguette::Configuration class Baguette::Configuration
class Auth < Base class Auth < Base
property jwt_key : String = "nico-nico-nii" # Default authd key, as per the specs. :eyes:
property key_file : String? = nil
property storage : String = "storage" property storage : String = "storage"
property registrations : Bool = false property registrations : Bool = false
property require_email : Bool = false property require_email : Bool = false
@ -31,9 +28,6 @@ class Baguette::Configuration
property verbosity : Int32 = 3 property verbosity : Int32 = 3
property print_ipc_timer : Bool = false property print_ipc_timer : Bool = false
property ipc_timer : Int32 = 30_000 property ipc_timer : Int32 = 30_000
def initialize
end
end end
end end
@ -702,8 +696,8 @@ begin
Baguette::Context.verbosity = configuration.verbosity Baguette::Context.verbosity = configuration.verbosity
if key_file = configuration.key_file if key_file = configuration.shared_key_file
configuration.jwt_key = File.read(key_file).chomp configuration.shared_key = File.read(key_file).chomp
end end
OptionParser.parse do |parser| OptionParser.parse do |parser|
@ -714,7 +708,7 @@ begin
end end
parser.on "-K file", "--key-file file", "JWT key file" do |file_name| parser.on "-K file", "--key-file file", "JWT key file" do |file_name|
configuration.jwt_key = File.read(file_name).chomp configuration.shared_key = File.read(file_name).chomp
end end
parser.on "-R", "--allow-registrations" do parser.on "-R", "--allow-registrations" do
@ -752,7 +746,7 @@ begin
exit 0 exit 0
end end
AuthD::Service.new(configuration.storage, configuration.jwt_key).tap do |authd| AuthD::Service.new(configuration.storage, configuration.shared_key).tap do |authd|
authd.registrations_allowed = configuration.registrations authd.registrations_allowed = configuration.registrations
authd.require_email = configuration.require_email authd.require_email = configuration.require_email
authd.mailer_activation_url = configuration.activation_url authd.mailer_activation_url = configuration.activation_url