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