Updates for new libipc APIs.

This commit is contained in:
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
class Client < IPC::Client
class Client < IPC::Connection
property key : String
def initialize
@ -80,7 +80,7 @@ module AuthD
response = read
if response.type == ResponseTypes::Ok.value.to_u8
if response.user_type == ResponseTypes::Ok.value.to_u8
response.payload
else
nil
@ -95,7 +95,7 @@ module AuthD
response = read
if response.type == ResponseTypes::Ok.value.to_u8
if response.user_type == ResponseTypes::Ok.value.to_u8
User.from_json response.payload
else
nil
@ -107,7 +107,7 @@ module AuthD
response = read
if response.type == ResponseTypes::Ok.value.to_u8
if response.user_type == ResponseTypes::Ok.value.to_u8
User.from_json response.payload
else
nil
@ -135,8 +135,8 @@ module AuthD
response = read
pp! response.type
case ResponseTypes.new response.type.to_i
pp! response.user_type
case ResponseTypes.new response.user_type.to_i
when ResponseTypes::Ok
AuthD::User.from_json response.payload
else
@ -160,7 +160,7 @@ module AuthD
response = read
case ResponseTypes.new response.type.to_i
case ResponseTypes.new response.user_type.to_i
when ResponseTypes::Ok
true
else

View File

@ -11,9 +11,9 @@ require "./passwd.cr"
extend AuthD
class IPC::RemoteClient
def send(type : ResponseTypes, payload : String)
send type.value.to_u8, payload
class IPC::Connection
def send(type : AuthD::ResponseTypes, payload : String)
send type.to_u8, payload
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.
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
when IPC::Event::Message
message = event.message
payload = message.payload
pp message
case RequestTypes.new message.type.to_i
case RequestTypes.new message.user_type.to_i
when RequestTypes::GetToken
begin
request = GetTokenRequest.from_json payload

View File

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