Log requested scopes when auth is denied
What does this MR do and why?
In production, we are seeing some log messages show that
authentication in the meta.auth_fail_reason field was denied for the
requested scopes even though the API request succeeded.
It's possible that auth was requested for one set of scopes,
but succeeded for another. This commit adds
meta.auth_fail_requested_scopes to better understand which
scopes were not available.
References
Relates to #505746 (closed)
How to set up and validate locally
- Create a personal access token with
read_repositoryaccess (or anything without:apiand:read_api). 2 In your GDK, make acurlrequest with a token to the users endpoint:
curl -H "PRIVATE-TOKEN: fail" http://gdk.test:3000/api/v4/users
- Check
gitlab/log/api_jsonfor fields such as:
"meta.auth_fail_reason": "insufficient_scope",
"meta.auth_fail_token_id": "PersonalAccessToken/2",
"meta.auth_fail_requested_scopes": "read_user api read_api",
Edited by Stan Hu