Rewrite: done?
parent
fcf165de73
commit
db827359ee
24
src/authd.cr
24
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"
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
module AuthD
|
||||
class Exception < ::Exception
|
||||
end
|
||||
|
||||
class UserNotFound < ::Exception
|
||||
end
|
||||
|
||||
class AuthenticationInfoLacking < ::Exception
|
||||
end
|
||||
|
||||
class AdminAuthorizationException < ::Exception
|
||||
end
|
||||
end
|
13
src/main.cr
13
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"
|
||||
|
|
Loading…
Reference in New Issue