Commit d34aaa8c authored by Giorgenes Gelatti's avatar Giorgenes Gelatti

Refactor scim to improve code quality

parent 2b3ac7af
......@@ -45,16 +45,18 @@ module API
render_scim_error(EE::Gitlab::Scim::Conflict, message)
end
def check_access_to_group!(group)
token = Doorkeeper::OAuth::Token.from_request(current_request, *Doorkeeper.configuration.access_token_methods)
unauthorized! unless token && ScimOauthAccessToken.token_matches_for_group?(token, group)
end
def find_and_authenticate_group!(group_path)
group = find_group(group_path)
scim_not_found!(message: "Group #{group_path} not found") unless group
token = Doorkeeper::OAuth::Token.from_request(current_request, *Doorkeeper.configuration.access_token_methods)
unauthorized! unless token
scim_token = ScimOauthAccessToken.token_matches_for_group?(token, group)
unauthorized! unless scim_token
check_access_to_group!(group)
group
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment