Comparison

mod_http_oauth2/mod_http_oauth2.lua @ 5426:f75d95f27da7

mod_http_oauth2: Add function for filtering roles
author Kim Alvefur <zash@zash.se>
date Sun, 07 May 2023 19:07:52 +0200
parent 5425:3b30635d215c
child 5427:d69c10327d6d
comparison
equal deleted inserted replaced
5425:3b30635d215c 5426:f75d95f27da7
112 return claims, roles, unknown; 112 return claims, roles, unknown;
113 end 113 end
114 114
115 local function can_assume_role(username, requested_role) 115 local function can_assume_role(username, requested_role)
116 return usermanager.user_can_assume_role(username, module.host, requested_role); 116 return usermanager.user_can_assume_role(username, module.host, requested_role);
117 end
118
119 local function user_assumable_roles(username, requested_roles)
120 return array.filter(requested_roles, function(role)
121 return can_assume_role(username, role);
122 end);
117 end 123 end
118 124
119 local function select_role(username, requested_roles) 125 local function select_role(username, requested_roles)
120 if requested_roles then 126 if requested_roles then
121 for _, requested_role in ipairs(requested_roles) do 127 for _, requested_role in ipairs(requested_roles) do