Primitive WIP UI added, useful mostly for debug.
This commit is contained in:
parent
0fb17f3be6
commit
02c1d06dd1
16
src/main.cr
16
src/main.cr
@ -1,6 +1,7 @@
|
|||||||
require "uuid"
|
require "uuid"
|
||||||
require "option_parser"
|
require "option_parser"
|
||||||
require "openssl"
|
require "openssl"
|
||||||
|
require "colorize"
|
||||||
|
|
||||||
require "jwt"
|
require "jwt"
|
||||||
require "ipc"
|
require "ipc"
|
||||||
@ -324,6 +325,14 @@ class AuthD::Service
|
|||||||
@users_per_uid.get? token_payload.uid.to_s
|
@users_per_uid.get? token_payload.uid.to_s
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def info(message)
|
||||||
|
STDOUT << ":: ".colorize(:green) << message.colorize(:white) << "\n"
|
||||||
|
end
|
||||||
|
|
||||||
|
def error(message)
|
||||||
|
STDOUT << "!! ".colorize(:red) << message.colorize(:red) << "\n"
|
||||||
|
end
|
||||||
|
|
||||||
def run
|
def run
|
||||||
##
|
##
|
||||||
# Provides a JWT-based authentication scheme for service-specific users.
|
# Provides a JWT-based authentication scheme for service-specific users.
|
||||||
@ -339,11 +348,16 @@ class AuthD::Service
|
|||||||
begin
|
begin
|
||||||
request = Request.from_ipc event.message
|
request = Request.from_ipc event.message
|
||||||
|
|
||||||
|
info "<< #{request.class.name.sub /^Request::/, ""}"
|
||||||
|
|
||||||
response = handle_request request, event.connection
|
response = handle_request request, event.connection
|
||||||
|
|
||||||
|
info ">> #{response.class.name.sub /^Response::/, ""}"
|
||||||
|
|
||||||
event.connection.send response
|
event.connection.send response
|
||||||
rescue e
|
rescue e
|
||||||
STDERR.puts "error: #{e.message}"
|
error "!! #{e.message}"
|
||||||
|
event.connection.send Response::Error.new e.message
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user