Client: permissions implemented.
parent
bfbfa79b62
commit
9ce976afc6
|
@ -103,7 +103,7 @@ module AuthD
|
||||||
parse_message [Response::UserAdded], read
|
parse_message [Response::UserAdded], read
|
||||||
end
|
end
|
||||||
|
|
||||||
def mod_user(uid_or_login : Int32 | String, password : String? = nil, email : String? = nil)
|
def mod_user(uid_or_login : UserID, password : String? = nil, email : String? = nil)
|
||||||
request = Request::ModUser.new uid_or_login
|
request = Request::ModUser.new uid_or_login
|
||||||
|
|
||||||
request.password = password if password
|
request.password = password if password
|
||||||
|
@ -113,14 +113,14 @@ module AuthD
|
||||||
parse_message [Response::UserEdited], read
|
parse_message [Response::UserEdited], read
|
||||||
end
|
end
|
||||||
|
|
||||||
def check_permission(user : Int32, service_name : String, resource_name : String)
|
def check_permission(user : UserID, service_name : String, resource_name : String)
|
||||||
request = Request::CheckPermission.new user, service_name, resource_name
|
request = Request::CheckPermission.new user, service_name, resource_name
|
||||||
send_now request
|
send_now request
|
||||||
parse_message [Response::PermissionCheck], read
|
parse_message [Response::PermissionCheck], read
|
||||||
end
|
end
|
||||||
|
|
||||||
def set_permission(uid : Int32, service : String, resource : String, permission : User::PermissionLevel)
|
def set_permission(user : UserID, service : String, resource : String, permission : User::PermissionLevel)
|
||||||
request = Request::SetPermission.new uid, service, resource, permission
|
request = Request::SetPermission.new user, service, resource, permission
|
||||||
send_now request
|
send_now request
|
||||||
parse_message [Response::PermissionSet], read
|
parse_message [Response::PermissionSet], read
|
||||||
end
|
end
|
||||||
|
|
|
@ -183,22 +183,30 @@ class Actions
|
||||||
def permission_check
|
def permission_check
|
||||||
args = Context.args.not_nil!
|
args = Context.args.not_nil!
|
||||||
user, application, resource = args[0..2]
|
user, application, resource = args[0..2]
|
||||||
# pp! user, application, resource
|
|
||||||
|
|
||||||
# TODO: login.
|
|
||||||
res = @authd.check_permission user.to_i, application, resource
|
res = @authd.check_permission user.to_i, application, resource
|
||||||
puts res
|
case res
|
||||||
|
when Response::PermissionCheck
|
||||||
|
s = res.service
|
||||||
|
r = res.resource
|
||||||
|
u = res.user
|
||||||
|
p = res.permission
|
||||||
|
Baguette::Log.info "app #{s} resource #{r} user #{u}: #{p}"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def permission_set
|
def permission_set
|
||||||
args = Context.args.not_nil!
|
args = Context.args.not_nil!
|
||||||
user, application, resource, permission = args[0..3]
|
user, application, resource, permission = args[0..3]
|
||||||
# pp! user, application, resource, permission
|
|
||||||
|
|
||||||
# TODO: login.
|
|
||||||
perm = AuthD::User::PermissionLevel.parse(permission)
|
perm = AuthD::User::PermissionLevel.parse(permission)
|
||||||
res = @authd.set_permission user.to_i, application, resource, perm
|
res = @authd.set_permission user.to_i, application, resource, perm
|
||||||
puts res
|
case res
|
||||||
|
when Response::PermissionSet
|
||||||
|
s = res.service
|
||||||
|
r = res.resource
|
||||||
|
u = res.user
|
||||||
|
p = res.permission
|
||||||
|
Baguette::Log.info "app #{s} resource #{r} user #{u}: #{p}"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -233,6 +241,8 @@ def main
|
||||||
actions.the_call[Context.command].call
|
actions.the_call[Context.command].call
|
||||||
rescue e
|
rescue e
|
||||||
Baguette::Log.info "The command is not recognized (or implemented)."
|
Baguette::Log.info "The command is not recognized (or implemented)."
|
||||||
|
Baguette::Log.info "Exception: #{e}."
|
||||||
|
pp! e
|
||||||
end
|
end
|
||||||
|
|
||||||
# authd disconnection
|
# authd disconnection
|
||||||
|
|
Loading…
Reference in New Issue