Skip to content
← Free FDE training guides

Free learning / 50-minute lab + optional token/context workshops

Identity 101: a login is not permission

Separate authentication, authorization and tenant scope. Follow a document through its access checks, then run five real local database cases before adding retrieval and agents. An optional workshop verifies real locally signed tokens before those reads.

No account needed. Use your own copy for writing and keep the original as a reference.

Engineering lab library / Run locally

See which requests may reach the data.

Predict five cases, compare the actual query and returned-row counts, then change one request input at a time. Keep trusted identity separate from generated arguments.

Real in-memory SQLite reads with fictional records. Identity verification is supplied as a fixture; no login, model, network or production database is used.

Search titles, outcomes and prerequisites, then narrow by runtime.

2 of 2 labs · All labs

  1. Start here / Real library, SDK or framework · Scripted inputs

    Token validation before document access

    Distinguish token rejection, missing action scope and a current document grant using actual local verification.

    Python 3.11+ · Pinned PyJWT + cryptography · Fictional tokens · No account

  2. Python 3.11+ · Standard library

    Document access and tenant scope

    Compare identity/scope/grant reads, then inspect actual context selection, accidental agreement and a removed read grant.

    Python 3.11+ standard library · No model, network or account

You sign in to a support application and ask an assistant to find a maintenance procedure. The assistant finds a close match. Before it reads the document, the application has another job: establish whose request this is and whether that person may read that particular document.

This original 50-minute lesson separates those decisions. Start with the visual, predict five cases, then run a small Python program that performs actual database queries. All organizations and records are fictional. No account, model or network connection is needed.

1. Start with the building badge

UNDERSTAND THE SYSTEM

Follow a document request through its access checks

A building badge identifies you; permission opens a particular room. Follow the same distinction in software: a verified caller, one active organization and a document read. These are authored lab cases with real local query behavior and a supplied identity fixture.

FOLLOW THE WORK

Watch one example, step by step.

6 authored stepsYou control the pace
01 / EXPLORE THE PARTSControls loading · written explanations below
Direction of information or workReturn / feedback

WHAT THIS PART DOES

Proposed request

A user or agent proposes a document ID. These arguments cannot grant a role or change the active organization.

CONNECTED TO
  • Propose a read: Access check
Read the full worked example
  1. 01
    Separate the two inputs

    The request names P-7; trusted context identifies U-7 in North. The document ID alone does not tell the application which organization's file is allowed.

    Before the first read: Request: P-7 · trusted workspace: North

  2. 02
    Read the permitted document

    The scoped query matches North/P-7 and U-7's read grant. South/P-7 is a different record even though the identifier matches.

    allowed case: 1 query · 1 permitted row · North checklist

  3. 03
    Stop without a caller

    The anonymous case has no verified caller context. The program cannot infer an identity from the requested document and returns before querying.

    anonymous case: No query · sign_in_required · no document

  4. 04
    Refuse a workspace claim

    The request asks for South while trusted context remains North. Even a person with membership in both organizations must use a separately verified workspace switch.

    claim-tenant case: No query · not_available · scope unchanged

  5. 05
    Check permission within North

    P-8 belongs to North, but U-7 has no read grant for it. The query returns zero rows. Being in the right organization is necessary but not sufficient.

    restricted case: 1 query · 0 rows · no incident notes

  6. 06
    Recheck after permission changes

    The revoked case first returns North/P-7, removes its read grant, then repeats the request. The second query returns no document; the earlier response remains an earlier observation.

    revoked case · second read: Current query: 0 rows · earlier response already delivered

Read the connections in plain English
  1. 01
    Proposed request → Access check

    Treat the requested document and optional tenant claim as untrusted input.

  2. 02
    Trusted context → Access check

    Use the verified active workspace, never a tenant selected by the model.

  3. 03
    Access check → Document query

    Bind the document ID and trusted scope as query parameters.

  4. 04
    Current read grant → Document query

    Join the document to the current caller's read grant in the same organization.

  5. 05
    Document query → Returned content

    No matching row means no document content is returned.

  6. 06
    Access check → Returned content

    Missing identity or a mismatched scope can stop before a document query.

Check your understanding: A valid North login asks for North/P-8. Must the application return it?

No. The caller still needs permission for that document and action. The restricted lab case has a valid supplied identity and matching organization, but its scoped query returns zero rows. Enforce that boundary before data enters model context.

A badge check establishes who you are. The lock on a room decides whether you may enter. If two companies occupy the building, having a valid badge does not give you access to both companies' files.

In software, authentication establishes a person or workload identity. Authorization decides whether that identity may perform an action on a resource. Tenant isolation keeps one organization's data and actions within its permitted scope. A tenant is often a customer organization in a shared application.

The analogy stops at the door: software may need to check every document request, background job and citation, even after sign-in. A person can belong to multiple organizations while working within one explicitly selected workspace.

For an FDE building an agent, this is practical architecture. The model can suggest a document to read. The application's trusted code determines who is asking and which records are available. An instruction such as “use the South tenant” cannot grant that authority. These responsibilities follow the OWASP authorization guidance.

2. Read the small access map

The exercise has two organizations, North and South, that both use document ID P-7. The same short identifier therefore names different records in different organizations.

RecordContentU-7 may read it?
North / P-7A fictional North checklistYes, in the North workspace
South / P-7A different fictional South checklistYes, in the South workspace
North / P-8Fictional internal incident notesNo

The supplied trusted context is U-7 in north. It represents the result of identity and workspace verification; this exercise does not implement that verification. The request's document_id is untrusted input. An optional tenant field is checked against the trusted scope and cannot switch it.

Three terms will help you read the code. A principal is the person or workload making the request. A grant is a recorded permission, such as U-7 being allowed to read North/P-7. A scoped query constrains the database read using that caller, active organization, requested document and allowed action.

2a. Verify a token for this API

The five-case database exercise below deliberately starts with a trusted identity fixture. This optional 25-minute workshop examines the preceding boundary: what makes an incoming token acceptable to this API in the first place?

A JSON Web Token (JWT) carries claims and, in this exercise, a digital signature. Decoding its claims is not verification. A signature protects the signed bytes; it does not encrypt them. An OAuth access token is used with a resource server, while an OpenID Connect ID token serves the client’s sign-in flow. Do not substitute one merely because both can be signed JWTs. Not every OAuth access token is a JWT.

Download fde-token-validation-lab.py and its companion fde-token-validation-requirements.txt. Use Python 3.11 or newer and an isolated environment. The initial package installation needs access to your approved package source. The exercise itself runs locally without a listener, cloud account, identity provider or model call.

Code example
python3 -m venv .venv
.venv/bin/python -m pip install -r fde-token-validation-requirements.txt
.venv/bin/python fde-token-validation-lab.py compare

On Windows use .venv\Scripts\python.exe instead of .venv/bin/python. The program generates temporary RSA keys in memory and genuinely signs fictional tokens. PyJWT validates them using a fixed trusted public key and RS256 algorithm. It never prints private keys or complete tokens. It changes neither the training platform’s authentication nor your computer’s certificate trust settings.

Read the configured contract before the results:

CheckQuestion it answers
Trusted key and allowed algorithmDoes this signature verify under the application’s chosen key and algorithm?
Issuer (iss)Is the token from the issuer this API expects?
Audience (aud)Is this API an intended recipient?
Token type (typ)Does it have the selected access-token profile, at+jwt?
Expiry and time claimsIs it within the accepted validity period?
Action scopeDoes the verified token include the complete documents:read scope?
Current resource grantMay this subject read North/P-7 now?

The application fixes these expectations. Incoming fields cannot choose a new trusted issuer, key or accepted algorithm. A subject is understood within its issuer’s context; client_id identifies a client and is not a grant to every record. North is still a separate application workspace fixture in this lab, not an organization selected by a model or token argument.

Predict each outcome before reading results:

CaseToken decisionDocument queryPermitted rows
validAcceptedExecutes1
signature-tamperedRejectedNot executed0
wrong-audienceRejected despite valid signatureNot executed0
wrong-typeRejected despite valid signatureNot executed0
expiredRejectedNot executed0
missing-scopeAccepted, action scope refusedNot executed0
valid-no-resource-grantAccepted, scope acceptedExecutes0
wrong-issuerRejected despite valid signatureNot executed0
future-nbfRejected before its validity beginsNot executed0

Inspect token_validation, validation_error, scope_check, query_executed, rows_returned and permitted. Refusal before a query is different from a real permission-constrained SQLite query returning no row. The local report explains these differences for learning; a public API should avoid leaking sensitive claim values or record existence through detailed error responses.

Change one condition. Preserve the original and edit a separate copy. Change only EXPECTED_AUDIENCE from urn:lockedin:training:documents to urn:lockedin:training:billing. Run compare again. Predict why valid is now refused and wrong-audience can pass. Other conditions, including scope and the current grant, still apply. The edit deliberately represents another intended resource server. It is not the fix for a documents API receiving the wrong token; obtain the correctly intended token through the authorized flow and restore the original verifier configuration.

This is a local verification and authorization experiment, not an OAuth server or SSO integration. It does not implement login, discovery, key rotation, remote revocation, delegated consent or production workspace selection. The selected profile follows the distinctions in RFC 9068 access-token validation and RFC 8725 validation guidance, checked 25 October 2026. An unexpired token still does not override a removed resource grant. The SQL experiment below makes that final boundary visible.

UNDERSTAND THE SYSTEM

A valid signature is only the first boundary

Follow four representative outcomes from the nine-case Python lab. These are worked examples; the browser does not receive or validate tokens. The downloadable exercise performs the signature and database checks locally.

FOLLOW THE WORK

Watch one example, step by step.

4 authored stepsYou control the pace
01 / EXPLORE THE PARTSControls loading · written explanations below
Direction of information or workReturn / feedback

WHAT THIS PART DOES

Signed token

A JSON Web Token carries claims. Its signature protects the signed bytes against undetected changes under the chosen key; it does not encrypt those claims. This lab creates fictional tokens locally and never prints them.

CONNECTED TO
  • Verify: This API's verifier
Read the full worked example
  1. 01
    Read the permitted document

    The locally signed access token is accepted for the documents API, includes documents:read and identifies U-7. The fixed North workspace and current P-7 grant admit one row. A legitimate success is essential alongside refusals.

    VALID: Token accepted · 1 permitted row

  2. 02
    Reject another recipient

    The signature and issuer are valid, but the token names the billing API. The documents API refuses it before scope or document lookup. Sharing an issuer or signing key does not make APIs interchangeable recipients.

    WRONG AUDIENCE: Wrong audience · no document query

  3. 03
    Stop before the query

    This token passes validation for the documents API, but has no documents:read scope. The action check refuses it before the database read. Token validity and permission for this operation are separate observations.

    MISSING SCOPE: Missing scope · no document query

  4. 04
    Check the current grant

    The token and read scope pass, but this case has no current North/P-7 read grant for U-7. The real SQLite query executes and returns zero rows. An earlier token does not create a missing resource permission.

    NO RESOURCE GRANT: Token accepted · 0 permitted rows

Read the connections in plain English
  1. 01
    Signed token → This API's verifier

    Apply this API's trusted policy, not instructions from the incoming claims.

  2. 02
    This API's verifier → Requested action

    Pass verified claims to the action check only after all token checks succeed.

  3. 03
    Requested action → Current record grant

    Action scope permits asking the current resource policy; it does not bypass it.

  4. 04
    Current record grant → Permitted result

    Return only the document admitted by the current permission-constrained query.

Check your understanding: A token is correctly signed for another API. Should you accept it because the issuer is familiar?

No. This API must validate its intended audience under trusted configuration. Obtain the right token through the authorized flow; disabling audience verification changes the boundary rather than fixing the request.

3. Run five access cases

Coming from the landing-page example? After these five reads, run the source-to-context comparison to reproduce the North/South selection and challenge an accidentally correct result.

Download fde-identity-boundary-lab.py into an empty practice folder. Use Python 3.11 or newer. The program creates a fresh in-memory SQLite database for each run and closes it afterward; it does not write files or open a listener.

Before running each command, predict whether a query will execute and whether any document text will return.

Code example
python3 --version
python3 fde-identity-boundary-lab.py allowed
python3 fde-identity-boundary-lab.py anonymous
python3 fde-identity-boundary-lab.py claim-tenant
python3 fde-identity-boundary-lab.py restricted
python3 fde-identity-boundary-lab.py revoked

Inspect trusted_context_fixture, untrusted_request and each observation's query_executed, rows_returned and response. These are local teaching traces, not production error responses or a model transcript.

CaseExpected observationWhat it teaches
allowedOne query, one permitted row, North checklistCaller, organization, document and read grant all match.
anonymousNo query; sign_in_requiredThere is no verified caller context to authorize.
claim-tenantNo query; not_availableAsking for South cannot change the trusted North workspace.
restrictedQuery returns zero rows; not_availableBeing in North does not grant access to every North document.
revokedFirst read succeeds; the next returns zero rowsRemoving the grant affects the next access check, even for the same caller.

In revoked, the program retains the first observation so you can compare it with the second. Revocation prevents the later read; it cannot erase information already delivered. This single-process example does not test concurrent requests, cached responses or distributed revocation.

3a. Run the source-to-context comparison

Optional 20-minute extension. Keep the same standalone Python file. This moves the landing page's illustrated source decision into actual SQLite reads. It still makes no model call or generated answer, and supplies identity and candidate order as fixtures. The first two candidates match the landing-page illustration; a third, restricted North/P-8, supports the changed case below. Candidate identities are proposed metadata, not a permission receipt or a search-ranking result.

Predict the context packet for both paths before opening each report:

Code example
python3 fde-identity-boundary-lab.py context-selection > context-original.json
python3 fde-identity-boundary-lab.py context-selection --candidate-order north-first > context-north-first.json
python3 fde-identity-boundary-lab.py context-selection --north-grant revoked > context-revoked.json
python3 fde-identity-boundary-lab.py context-selection --candidate-order restricted-first > context-restricted-first.json

Each command runs two independently reset in-memory databases with the same inputs. deliberately_unchecked directly reads its first proposed workspace/document without checking current workspace or grants. That is an intentionally broken teaching comparison over fictional rows. scoped passes candidates through the existing read_document function until the first allowed source is found; refused bodies are not put in its context. Both paths stop after their first returned source. This is a one-source policy, not a complete retrieval strategy.

Supplied conditionDeliberately unchecked contextScoped contextReceiving question
South/P-7, North/P-7, North/P-8; both P-7 grants presentSouth/P-7: checklist SNorth/P-7: checklist NDid trusted North scope survive the proposed South identity?
Same records/grants, North/P-7 comes firstNorth/P-7: checklist NNorth/P-7: checklist NDid the same text come through the same checks?
Original order, North/P-7 grant removed before each pathSouth/P-7: checklist SEmptyWas another workspace used to fill the missing permitted context?
North/P-8 comes first; both P-7 grants presentNorth/P-8: restricted incident-note fixtureNorth/P-7: checklist NWas active-workspace membership confused with document permission?

Inspect candidates, trusted_context_fixture, paths, each path's attempts, sql_reads, context and unattempted_candidates. The SQLite trace callback records SELECT statements actually executed after fixture preparation. A foreign-workspace candidate is refused before a scoped body query. A North candidate without its read grant produces an actual permission-constrained query with zero returned rows. Those are different observations.

In the original scoped path, South is refused, North/P-7 returns one row and North/P-8 is unattempted. Do not report that last candidate as rejected or inspected. With North/P-7's grant removed, both North reads return zero permitted rows and the scoped packet stays empty. The South read grant still exists; it cannot switch the active workspace or fill the packet. In restricted-first, North/P-8's refusal shows why a workspace filter alone would be insufficient.

north-first is the adversarial control: both paths produce the same North text even though the broken path has no authorization check. Inspect its direct SELECT and then remove North's grant while retaining north-first. A correct body in one run does not establish a safe mechanism. These are sequential local reads; current permitted context also does not establish model faithfulness, verified login, source freshness, cache invalidation or race-free revocation.

Receive it as a pair. Builder A predicts and runs the original comparison. Receiver B locates the actual body, SQL and unattempted candidate without replacing A's account. Swap roles for north-first, then agree one changed-grant run. Each participant keeps their own prediction, exact command/file/version, observed context and query references, assistance and correction. Solo practice remains self-review. The application owner receives the access-path question, the search owner receives candidate-order/coverage questions, and the identity/source owners receive current-principal and grant-ordering evidence requests. A pod lead agrees the next bounded receiving test; this exercise grants no deployment permission, qualification or client placement.

UNDERSTAND THE SYSTEM

Follow the source that actually enters context

Four authored comparisons explain the downloadable SQLite experiment. Candidate order and identity are supplied fixtures. The browser runs no query or model; each unchecked/scoped comparison starts from separate memory databases.

FOLLOW THE WORK

Watch one example, step by step.

4 authored stepsYou control the pace
01 / EXPLORE THE PARTSControls loading · written explanations below
Direction of information or workReturn / feedback

WHAT THIS PART DOES

Candidate identities

The packet supplies workspace-qualified identities in an authored order. It is not a relevance ranking or document-body permission receipt.

CONNECTED TO
  • Bypass checks: Unchecked body read
  • Propose identity: Current read boundary
Read the full worked example
  1. 01
    Keep the question and candidates fixed

    With South/P-7 first, the unchecked path returns checklist S. The scoped path refuses South before a body query and reads North/P-7 for checklist N. North/P-8 remains unattempted after that first permitted source.

    south-first / North grant present: Unchecked: South/P-7 · scoped: North/P-7

  2. 02
    Expose accidental agreement

    Put North/P-7 first. Both paths return its text, but only the scoped path ran the permission-constrained read. One matching output does not establish the mechanism; inspect SQL and then remove the grant.

    north-first / North grant present: Same North text · different checks

  3. 03
    Remove the current North grant

    Return to South-first order and remove North/P-7's read grant before each path. The broken path still returns South. The scoped path refuses South and gets zero permitted rows for both North candidates, leaving its packet empty.

    south-first / North grant revoked: Unchecked: South/P-7 · scoped: empty

  4. 04
    Separate workspace from document permission

    Put restricted North/P-8 first. The unchecked path returns its incident-note fixture. The scoped path receives zero permitted rows for P-8, refuses South, then admits North/P-7. Being in North is not permission for every North record.

    restricted-first / North grant present: Unchecked: North/P-8 · scoped: North/P-7

Read the connections in plain English
  1. 01
    Candidate identities → Unchecked body read

    The teaching comparison performs a direct read for the first supplied identity.

  2. 02
    Unchecked body read → Actual context packet

    Its returned source can belong to another workspace or lack the current read grant.

  3. 03
    Candidate identities → Current read boundary

    A candidate proposes a record; it does not grant permission to use its text.

  4. 04
    Trusted fixture scope → Current read boundary

    Keep the trusted active workspace and current subject/read grant together.

  5. 05
    Current read boundary → Actual context packet

    Only an allowed source read contributes text; a refused candidate is not a fallback.

  6. 06
    Actual context packet → Receiving engineer

    Compare actual context with the SQL and decisions that produced it.

Check your understanding: If both paths return the North checklist once, is the unchecked path safe?

No. A supplied order can make an unchecked read look correct. The foreign-workspace, revoked-grant and restricted-record comparisons expose its missing boundary. Current permitted context still does not prove a model used that source faithfully or that a real identity/concurrency policy has been verified.

4. See where the boundary is enforced

Open the read_document function. It receives trusted principal separately from the proposed request. Without a principal it returns before querying. A mismatched tenant claim also returns before querying. The remaining read joins documents to current grants and constrains the result by organization, document, caller and action.

Code example
SELECT d.id, d.text FROM documents AS d
JOIN grants AS g ON g.tenant = d.tenant AND g.document_id = d.id
WHERE d.tenant = ? AND d.id = ? AND g.subject = ? AND g.action = 'read'

The values are bound as query parameters. The organization comes from trusted context. The document ID is an input to a permission-constrained lookup; knowing it is not sufficient to retrieve it. A missing document and a document with no matching grant both produce not_available without returning document text.

This is application-enforced query scoping. SQLite is not independently applying row-level tenant policy here, and a different unrestricted query could bypass the example's function. A production design must cover every path, including search, citations, exports, workers and caches. The OWASP multi-tenant guidance is a starting point for examining those paths.

5. Change one input and explain the result

Make two separate copies of the original file. Preserve the original for comparison.

In the first copy, find the line marked Experiment A. Change only "south" to "north", then run claim-tenant using that copy's filename. It should return North/P-7. You changed the requested organization to match the existing workspace; you did not grant South access or switch workspaces.

In the second copy, find the line marked Experiment B. Change only "P-8" to "P-7", then run restricted. It should return North/P-7 because the supplied read grant covers that record. P-8 remains restricted.

Save your predicted and observed results. Point to the exact comparison or query condition responsible. If you cannot explain why the result changed, revisit the access map before adding a framework.

5a. Prove the grant belongs to this workspace

A database join pairs rows according to the conditions you supply. Our composite key uses more than one field: (tenant, id) identifies a document. North/P-7 and South/P-7 are different resources. A grant must refer to the same resource, caller and action; matching only the short document ID is insufficient.

Run a second experiment using the same downloaded file:

Code example
python3 fde-identity-boundary-lab.py compare-joins

It creates four independent, fictional in-memory cases and compares the existing guarded read with an intentionally broken query. No real identity, service or customer database is involved. Both paths use bound parameters and select d.tenant from the supplied trusted context. The meaningful difference is here:

Code example
-- Complete relationship in the guarded query:
JOIN grants AS g ON g.tenant = d.tenant AND g.document_id = d.id

-- Deliberately broken relationship, for this local comparison only:
JOIN grants AS g ON g.document_id = d.id

Both still check the requested document ID, caller and read action. Bound parameters keep supplied values from becoming SQL syntax; they do not add a missing authorization relationship. Filtering the document to North does not automatically constrain the grant to North.

Predict each pair of row counts before inspecting the JSON. The broken path uses fetchall() so a duplicate match cannot disappear behind fetchone(). Its document_tenant and grant_tenant fields are synthetic teaching diagnostics, not a recommended public error response.

CaseTrusted workspaceRemaining read grantsGuarded rowsMissing-binding rows
both-read-grantsNorthNorth and South12
south-grant-onlyNorthSouth only01
south-workspaceSouthSouth only11
no-read-grantsNorthNone00

In the first case, the broken query returns the same North text twice, once with each grant. In the second, North's permission is gone but South's grant still matches North/P-7. Inspect document_tenant: north beside grant_tenant: south. The trusted workspace has not changed; the query has misapplied permission from another workspace to a North document. It does not return South's document.

The South control changes the supplied trusted context in a separate fixture, representing a workspace switch that a real application would have to verify. An untrusted tenant argument still cannot make that switch in the original five cases. The final refusal is necessary but insufficient: even the broken query refuses when no grants exist. Keep positive and discriminating negative cases together.

Repair the relationship, not the presentation

Make one separate copy of the original file. In compare_join_binding, restore g.tenant = d.tenant AND to the deliberately broken JOIN. Keep the four cases and their data unchanged. Predict missing-binding row counts of 1, 0, 1, 0, then run that copy and compare. Its report field retains the original label, so record the actual edit with your output. The guarded results should stay unchanged.

Explain why adding DISTINCT would leave the second case's unauthorized single row intact. Explain why taking just the first row would conceal the first case's extra match. Neither change restores the permission relationship.

The deletions and reads occur sequentially on one connection per case. SQLite lets that connection see its own preceding changes. This is not evidence of cross-connection propagation, race-free revocation, cache invalidation or recall of previously delivered content. The policy is enforced by application queries; the lab does not configure database row-level security. A real deployment must verify every receiving path and the chosen permission-change ordering policy.

Primary reading checked 25 October 2026:

UNDERSTAND THE SYSTEM

A tenant filter is only half of this access check.

Compare two real SQLite reads over fictional documents. Both filter the document to the trusted workspace; only one binds the permission to that same workspace. The four cases are reproduced by the free lab. Caller verification is supplied, not performed.

FOLLOW THE WORK

Watch one example, step by step.

4 authored stepsYou control the pace
01 / EXPLORE THE PARTSControls loading · written explanations below
Direction of information or workReturn / feedback

WHAT THIS PART DOES

Caller + grant facts

U-7 has a supplied active workspace. North and South each have a different document named P-7. A grant includes subject, tenant, document and action. These facts are fixtures, not a login or permission inferred by a model.

CONNECTED TO
  • Bind scope: Match the full grant
  • Same inputs: Omit one relationship
Read the full worked example
  1. 01
    Both read grants exist

    The guarded North read returns one row. The broken join matches both North and South grants to North/P-7, returning two rows containing the same North text. The duplicate exposes an extra permission relationship; it is not merely a display defect.

    LOCAL SQLITE · BOTH READ GRANTS: Guarded: 1 row · missing binding: 2 rows

  2. 02
    Only South permission remains

    Remove the North read grant in a fresh fixture while North remains active. The guarded read returns no content. The broken join still returns North/P-7 using South's remaining grant. The workspace did not switch, and South's document was not returned: the wrong grant authorized the North read.

    LOCAL SQLITE · SOUTH GRANT ONLY: Guarded: 0 rows · missing binding: 1 row

  3. 03
    Use the legitimate South scope

    A separate fixture supplies South as the verified active workspace, with only the South grant remaining. Both queries return South/P-7. This positive control shows that a person with authorized South access can read there. Editing an untrusted tenant argument is not the same operation.

    LOCAL SQLITE · SOUTH WORKSPACE: Guarded: 1 row · missing binding: 1 row

  4. 04
    Remove all read grants

    Both queries return no rows in this fresh North fixture. That negative case alone would miss the broken join. Keep allowed and wrong-tenant-grant cases in the same regression set; a test suite containing only refusals cannot establish useful authorization.

    LOCAL SQLITE · NO READ GRANTS: Guarded: 0 rows · missing binding: 0 rows

Read the connections in plain English
  1. 01
    Caller + grant facts → Match the full grant

    Use the supplied trusted workspace and the complete grant relationship.

  2. 02
    Match the full grant → Guarded result

    Only a permitted row can return content through the guarded path.

  3. 03
    Caller + grant facts → Omit one relationship

    Keep the caller, requested document and database facts unchanged between the two queries.

  4. 04
    Omit one relationship → Inspect every match

    Count all matching rows and compare the tenant on each side of the join.

Check your understanding: Would DISTINCT, fetchone() or parameterized SQL repair the missing permission relationship?

No. They address duplicate presentation, retrieval size or how values enter a statement. None requires a grant to belong to the selected document's tenant. Preserve the complete authorization relationship and test the otherwise-valid mismatched-grant case. This is a local application-query demonstration, not database row-level security or a production audit.

6. Carry this into an agent workflow

Sketch a request from a signed-in user through an agent's read_procedure tool to a data service. Draw trusted caller context on a separate path from generated tool arguments. Mark where a document can first enter model context.

Now give the model a highly relevant result from the other organization. Explain why it must be excluded before the model receives its content. Then remove the user's read grant and consider a previously cached answer or a queued job. Identify the current permission check each path would need; neither path is implemented by this exercise.

Keep a small evidence sheet: five predictions, actual query and row counts, the two edited-copy outcomes, your data-flow sketch and one remaining production gap. Have another person explain why a valid login can still produce not_available.

6a. Observe database-enforced row policies

The SQLite exercise above enforces access in application queries. To inspect a separate database policy boundary, use the optional PostgreSQL role-security workshop. It runs ten actual PostgreSQL 17 cases in a disposable local container, including owner/BYPASSRLS behavior, write refusal and permissive policies combining with OR. Keep the supplied connection identity distinct from verified application authentication. A receiver reruns an ordinary and a denied operation and names the remaining pool, function or export checks.

7. Continue into protected retrieval engineering

Continue in the authorized Academy lesson, Keep retrieval inside the right boundary, to add source freshness, cache scope, citation access and a receiving-team design task. The existing agent-engineering workbook provides a deeper context-building exercise.

Primary references checked 21 October 2026: OWASP Authorization Cheat Sheet and OWASP Multi-Tenant Security Cheat Sheet. The lab and lesson are original LockedIn Labs material. They do not establish a production security assessment or vendor certification.

7. Separate candidate coverage from current-source access

The optional retrieval-limit workshop uses actual in-memory SQLite FTS5 ranking. Compare an empty late-filter result with available permitted sources, then change the candidate limit and one current grant or source revision. Retain the separate body-read decision and receiving action; a smaller packet does not justify using a rejected source. The exercise is sequential and lexical, not an ANN, authentication or concurrency proof.

A first tool-boundary exercise

For a first tool-design session, use the separate tool-boundary and receiving worksheet. Allow 45 minutes plus setup as a foundation route; it is not another requirement inside the guide's 50-minute core. It uses the existing five standard-library access cases and complete-grant comparison, with no model, account, package install or MCP connection.

Map operation, arguments, trusted context, resource permission and safe output before running. Preserve the useful North read as well as refusals, distinguish a query returning no permitted row from a query never executed, and retain the first observation after grant removal. The worksheet then asks a receiving engineer to locate the actual predicate and specify an unimplemented equipment update with separate write authority, conflict, duplicate and uncertain-outcome controls. Each person keeps their own command, explanation and assistance.

The existing grant relationship diagram explains why parameterization and a document-tenant filter do not repair a missing grant-tenant join. The deeper tool-boundaries foundations lesson retains normal Academy access. These local reads do not establish real identity verification, MCP interoperability, concurrent revocation or production write authorization.

Before you move on

Keep the evidence of your work.

  • Five access predictions compared with actual local query and row counts.
  • Two changed-copy results separating requested inputs from trusted scope.
  • A data-flow sketch and an untested cache or background-job boundary.

Keep these in your own working copy. Reading this page does not save work or record completion.

Suggested next free session

Data 101: a document, a record and a searchable copy

Separate stored documents, changing records and searchable copies before building retrieval. This is a suggested sequence; choose the practice that addresses your current gap.

Open the next free guide

Free account

Give your practice a home.

Try a role exercise with account drafts and a downloadable worksheet. Keep the files you made in this guide in your own working copy.

Create a free learning account

Guided training · by application

Build toward a program.

Request structured lessons and a training seat. Scope, schedule, feedback arrangements and tuition are confirmed in writing before you commit.

Explore a training application
Have Academy access?

Use your existing training seat to open worked explanations and practice in the related lesson. Creating a free account does not grant a seat.

Open the related Academy lesson →
Back to top ↑