Updates for new libipc APIs.

ipc07
Luka Vandervelden 2019-06-05 22:30:29 +02:00
parent 49449956c3
commit d7f54062fc
3 changed files with 19 additions and 14 deletions

View File

@ -63,7 +63,7 @@ module AuthD
}) })
end end
class Client < IPC::Client class Client < IPC::Connection
property key : String property key : String
def initialize def initialize
@ -80,7 +80,7 @@ module AuthD
response = read response = read
if response.type == ResponseTypes::Ok.value.to_u8 if response.user_type == ResponseTypes::Ok.value.to_u8
response.payload response.payload
else else
nil nil
@ -95,7 +95,7 @@ module AuthD
response = read response = read
if response.type == ResponseTypes::Ok.value.to_u8 if response.user_type == ResponseTypes::Ok.value.to_u8
User.from_json response.payload User.from_json response.payload
else else
nil nil
@ -107,7 +107,7 @@ module AuthD
response = read response = read
if response.type == ResponseTypes::Ok.value.to_u8 if response.user_type == ResponseTypes::Ok.value.to_u8
User.from_json response.payload User.from_json response.payload
else else
nil nil
@ -135,8 +135,8 @@ module AuthD
response = read response = read
pp! response.type pp! response.user_type
case ResponseTypes.new response.type.to_i case ResponseTypes.new response.user_type.to_i
when ResponseTypes::Ok when ResponseTypes::Ok
AuthD::User.from_json response.payload AuthD::User.from_json response.payload
else else
@ -160,7 +160,7 @@ module AuthD
response = read response = read
case ResponseTypes.new response.type.to_i case ResponseTypes.new response.user_type.to_i
when ResponseTypes::Ok when ResponseTypes::Ok
true true
else else

View File

@ -11,9 +11,9 @@ require "./passwd.cr"
extend AuthD extend AuthD
class IPC::RemoteClient class IPC::Connection
def send(type : ResponseTypes, payload : String) def send(type : AuthD::ResponseTypes, payload : String)
send type.value.to_u8, payload send type.to_u8, payload
end end
end end
@ -46,14 +46,21 @@ passwd = Passwd.new authd_passwd_file, authd_group_file
## ##
# Provides a JWT-based authentication scheme for service-specific users. # Provides a JWT-based authentication scheme for service-specific users.
IPC::Service.new "auth" do |event| IPC::Service.new "auth" do |event|
client = event.client if event.is_a? IPC::Exception
puts "oh no"
pp! event
next
end
client = event.connection
case event case event
when IPC::Event::Message when IPC::Event::Message
message = event.message message = event.message
payload = message.payload payload = message.payload
pp message
case RequestTypes.new message.type.to_i case RequestTypes.new message.user_type.to_i
when RequestTypes::GetToken when RequestTypes::GetToken
begin begin
request = GetTokenRequest.from_json payload request = GetTokenRequest.from_json payload

View File

@ -38,8 +38,6 @@ class Passwd
if group.users.any? { |name| name == user.login } if group.users.any? { |name| name == user.login }
user.groups << group.name user.groups << group.name
end end
pp group
end end
end end