QUESTION 2 OF 10

How do you prevent users from accessing other users' records?

Reveal the answer and explore the explanation.

02
MediumCore

How do you prevent users from accessing other users' records?

Answer
Answer

Authorize every object access using the verified identity and applicable permissions; never trust a client-supplied owner ID.

Practical example

Filter saved assessments by the authenticated user's identity.

PythonRelated concept example
def can_read(session, record):
    return bool(session) and session['user_id'] == record['user_id']
# In production, obtain session from verified authentication.

The caller cannot authorize access by supplying a different user ID.

Reference: Further reading ↗

Last 30 min revisionHigh-yield interview Q&As