Log the scopes an issuer's allowed_scopes strips from a token

Open Beginner friendly
#170 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
72/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Active
Tech stack
fastapi, python
Domain
backend, security

Research direction

Start by locating _filter_scopes and reading how it applies an issuer's allowed_scopes and how nearby logging includes the issuer and actor_id. Add debug-level logging for scopes dropped by the filter, then run the relevant tests for scope filtering and logging. Done when dropped scopes are logged with the issuer and request actor, without changing filtering behavior.

Written by the indexing model from the issue text.

Description

auth

What

_filter_scopes silently drops any scope in a token that the issuer's allowed_scopes does not match. When the caller is then refused, the log has access.denied with "requires scope: X", but nothing records that X was in the token and was stripped.

Effect

A misconfigured allow-list looks the same in the logs as a user who was never granted the scope, and diagnosing it means decoding the user's token by hand. It becomes more likely once Entra ID app roles arrive in roles and pass through the same filter (#85).

Fix

Log the dropped scopes in _filter_scopes, with the issuer, at debug level so it costs nothing until an operator turns it on. Scope names are not sensitive, and the line carries the request's actor_id like any other.

Dominant language
Python
Stars
0
Forks
3
Avg merge
23h
Merged PRs (30d)
70

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from ukaea/fds

All issues in ukaea/fds

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.