MYTHOSAI

Offline learning workbooks · Fictional cases

An object-authorisation unit test

Show why successful login is not sufficient permission to read somebody else’s resource.

What this miniature lab demonstrates

Show why successful login is not sufficient permission to read somebody else’s resource.

Set up a harmless offline test

Requires Python 3. Run only on your own computer in a text console. No packages, accounts, network connections, malware, production logs or cloud credentials are required. Copy the example into a file or download the runnable script. The script includes assertions that fail if the expected behaviour changes.

# All principals and resources are invented; no server is contacted.
records = {101: {"owner": "alice"}, 102: {"owner": "bob"}}
def may_read(user, record_id, approved_support=False):
    if record_id not in records:
        return False
    if records[record_id]["owner"] == user:
        return True
    return user == "support" and approved_support

cases = [("alice", 101, False, True), ("alice", 102, False, False),
         ("support", 102, False, False), ("support", 102, True, True)]
for user, record, approved, expected in cases:
    actual = may_read(user, record, approved)
    assert actual == expected
    print(user, record, "allow" if actual else "deny")

Output from the bundled script

The following text was generated by running this exact script in an offline Python environment during package validation. It is not a product or attacker simulation result.

alice 101 allow
alice 102 deny
support 102 deny
support 102 allow

Interpretation and limits

This model distinguishes the signed-in principal, resource ownership and an explicitly approved support exception. It does not implement a real identity provider or prove production authorisation.

Questions to discuss

Why must each document request check ownership on the server, even when the user is already authenticated?

To practise further, open the identity labs learning track and download a three-case CSV from any individual guide. Those records are fictional and deliberately contain an ambiguous case for analysis.

Primary sources

Scope: An illustrative educational model tested for deterministic output; no real-world security effectiveness or deployed vulnerability assessment is claimed. If a command, API or framework changes, follow the current official documentation and obtain approval before changes to real systems.