diff --git a/src/authd.cr b/src/authd.cr index e01350e..2b4d0b6 100644 --- a/src/authd.cr +++ b/src/authd.cr @@ -21,28 +21,8 @@ class Baguette::Configuration end end -module AuthD - class Exception < ::Exception - end - - class UserNotFound < ::Exception - end - - class AuthenticationInfoLacking < ::Exception - end - - # Not used for now. - class NotLoggedException < ::Exception - end - - # Not used for now. - class AuthorizationException < ::Exception - end - - # Not used for now. - class AdminAuthorizationException < ::Exception - end -end +# Requests and responses. +require "./exceptions" # Requests and responses. require "./network" diff --git a/src/exceptions.cr b/src/exceptions.cr new file mode 100644 index 0000000..f2f0a08 --- /dev/null +++ b/src/exceptions.cr @@ -0,0 +1,13 @@ +module AuthD + class Exception < ::Exception + end + + class UserNotFound < ::Exception + end + + class AuthenticationInfoLacking < ::Exception + end + + class AdminAuthorizationException < ::Exception + end +end diff --git a/src/main.cr b/src/main.cr index 4757f26..4d925fd 100644 --- a/src/main.cr +++ b/src/main.cr @@ -29,8 +29,6 @@ class Baguette::Configuration end end -require "./network" - # Provides a JWT-based authentication scheme for service-specific users. class AuthD::Service < IPC::Server property configuration : Baguette::Configuration::Auth @@ -94,15 +92,12 @@ class AuthD::Service < IPC::Server rescue e : UserNotFound Baguette::Log.error "#{request_name} user not found" AuthD::Response::Error.new "authorization error" - rescue e : AuthorizationException - Baguette::Log.error "#{request_name} authorization error" + rescue e : AuthenticationInfoLacking + Baguette::Log.error "#{request_name} lacking authentication info" AuthD::Response::Error.new "authorization error" rescue e : AdminAuthorizationException - Baguette::Log.error "#{request_name} no admin authorization" - AuthD::Response::Error.new "admin authorization error" - rescue e : NotLoggedException - Baguette::Log.error "#{request_name} user not logged" - AuthD::Response::Error.new "user not logged" + Baguette::Log.error "#{request_name} admin authentication failed" + AuthD::Response::Error.new "authorization error" rescue e Baguette::Log.error "#{request_name} generic error #{e}" AuthD::Response::Error.new "unknown error"