CLI parameters update for consistency.

This commit is contained in:
Philippe Pittoli 2024-12-10 20:35:55 +01:00
parent 09354d8e6d
commit d1e3a5f5f3
5 changed files with 46 additions and 16 deletions

View File

@ -1,6 +1,3 @@
.\" .Xr = application with a manual page
.\" . = application with a manual page
.\" Recent mdoc style:
.Dd 24 november 2024
.Dt "authd" 1
.Os Linux "(Ubuntu and Alpine)"
@ -21,7 +18,9 @@ daemon is a micro-service providing authentication and authorization services.
.Op Fl k Ar key-file
.Op Fl v Ar verbosity
.Op Fl -project Ar project-name
.Op Fl -storage Ar path
.Op Fl -storage-directory Ar path
.Op Fl -service-name Ar name
.Op Fl -recreate-indexes
.Op Fl t Ar account-activation-template
.Op Fl r Ar account-recovery-template
.Op Fl m Ar mailer
@ -115,9 +114,9 @@ String,
.Dq auth
.It Li recreate_indexes
Bool, false
.It Li storage
.It Li storage_directory
String,
.Pa ./storage
.Pa ./db-authd
.It Li registrations
Bool, false
.It Li require_email
@ -160,7 +159,13 @@ then
.It Li -h , --help
Show some help, but won't cover as much as the actual manual.
.
.It Li --storage No directory
.It Li --service-name No service_name
Service name (IPC).
.
.It Li --recreate-indexes
Recreate database indexes (symbolic links).
.
.It Li --storage-directory No directory
Directory in which to store users.
.
.It Li -k No file , Li --key-file No file

View File

@ -1,7 +1,14 @@
PASSWORD_FILE ?= /tmp/PASSWORD
DATA_DIRECTORY ?= /tmp/DATA-AUTHD
DATA_DIRECTORY ?= /tmp/db-authd
run-authd:; setup; $(Q)$(LOC)authd -k $(PASSWORD_FILE) -R -E --storage $(DATA_DIRECTORY)
run-authd: setup
@echo "running authd without reading the configuration file"
@# Usage example.
$(Q)$(LOC)authd -n -k $(PASSWORD_FILE) -R -E \
--storage-directory $(DATA_DIRECTORY) \
--recreate-indexes \
--service-name "auth"
# First user always is the admin.
add-first-user:; $(Q)$(LOC)authc bootstrap $(NAME) $(EMAIL)

View File

@ -4,7 +4,7 @@ class Baguette::Configuration
class Auth < IPC
property service_name : String = "auth"
property recreate_indexes : Bool = false
property storage : String = "storage"
property storage_directory : String = "db-authd"
property registrations : Bool = false
property require_email : Bool = false
property activation_template : String = "email-activation"

View File

@ -20,36 +20,54 @@ begin
OptionParser.parse do |parser|
parser.banner = "usage: authd [options]"
parser.on "--storage directory", "Directory in which to store users." do |directory|
configuration.storage = directory
parser.on "--storage-directory directory", "Directory in which to store users." do |directory|
Baguette::Log.info "Storage directory: #{directory}."
configuration.storage_directory = directory
end
parser.on "--service-name service_name", "Service name (IPC)." do |name|
Baguette::Log.info "Service name: #{name}."
configuration.service_name = name
end
parser.on "--recreate-indexes", "Recreate database indexes (symbolic links)." do
Baguette::Log.info "Recreate indexes."
configuration.recreate_indexes = true
end
parser.on "-k file", "--key-file file", "JWT key file" do |file_name|
Baguette::Log.info "Secret key: #{file_name}."
configuration.secret_key_file = file_name
configuration.secret_key = File.read(file_name).chomp
end
parser.on "-R", "--allow-registrations", "Allow user registration." do
Baguette::Log.info "Allow registrations."
configuration.registrations = true
end
parser.on "-E", "--require-email", "Require an email." do
Baguette::Log.info "Require an email address for registration."
configuration.require_email = true
end
parser.on "-t activation-template-name", "--activation-template name", "Email activation template." do |opt|
Baguette::Log.info "Activation template name: #{opt}."
configuration.activation_template = opt
end
parser.on "-r recovery-template-name", "--recovery-template name", "Email recovery template." do |opt|
Baguette::Log.info "Recovery template name: #{opt}."
configuration.recovery_template = opt
end
parser.on "-m mailer-exe", "--mailer mailer-exe", "Application to send registration emails." do |opt|
Baguette::Log.info "Mailer: #{opt}."
configuration.mailer_exe = opt
end
parser.on "-x key", "--read-only-profile-key key", "Marks a user profile key as being read-only." do |key|
Baguette::Log.info "Read-only key in user profiles: #{key}."
configuration.read_only_profile_keys.push key
end

View File

@ -17,13 +17,13 @@ class AuthD::Service < IPC
property logged_users : Hash(Int32, AuthD::User::Public)
# #{@configuration.storage}/last_used_uid
# #{@configuration.storage_directory}/last_used_uid
property last_uid_file : String
def initialize(@configuration)
super()
@users = DODB::Storage::Cached(User).new @configuration.storage
@users = DODB::Storage::Cached(User).new @configuration.storage_directory
@users_per_uid = @users.new_index "uid", &.uid.to_s
@users_per_login = @users.new_index "login", &.login
@users_per_email = @users.new_index "email" do |user|
@ -34,7 +34,7 @@ class AuthD::Service < IPC
end
end
@last_uid_file = "#{@configuration.storage}/last_used_uid"
@last_uid_file = "#{@configuration.storage_directory}/last_used_uid"
@logged_users = Hash(Int32, AuthD::User::Public).new