# Topic 14: Application and API Security

**Fictional Northstar case · self-paced · 45–90 minutes plus optional setup**

## Opening question
Can a signed-in user read somebody else’s record?

## Explain
Applications expose functions and data through interfaces. Authentication tells an application who is calling; authorization must also check the requested object and action. An API key should not be embedded in a public client or repository. Input validation, parameterized database queries, error handling and dependency management reduce different classes of risk and require separate verification.

## Supporting technologies
- **HTTP and APIs:** Methods, routes, status codes and payloads form the interface.
- **Object authorization:** Check access for each requested resource.
- **Secrets:** Keep credentials out of public clients and source history.
- **Input and dependencies:** Validate boundaries and use maintained components.

## Scenario
A mock Northstar API stores records for synthetic users u01 and u02. User u01 requests both records.

```text
caller,resource_owner,action,expected
u01,u01,read,allow
u01,u02,read,deny
u01,u01,delete,deny
```

## Hands-on procedure
1. Describe the expected role and object checks for each request.
2. Write pseudocode that authenticates the caller and verifies ownership before returning data.
3. Evaluate the three synthetic requests; include an unauthenticated request as a fourth case.
4. Create a mock response log using synthetic identifiers and no tokens.
5. Review a fictional configuration containing PLACEHOLDER_ONLY instead of a real secret; explain where actual secrets would be stored.
6. Document limits: paper or mock tests do not establish live application security.

## Expected reasoning and limits
Only the owner read is allowed. A valid login must not grant cross-user access or deletion privileges. No live target is tested.

## Best practices
- Enforce authorization server-side on every object and action.
- Use parameterized queries and explicit input constraints.
- Avoid logging sensitive payloads and credentials.
- Test denied cases and dependency updates in an isolated environment.

## Vendors, projects and learning
- [Microsoft](https://learn.microsoft.com/en-us/entra/identity/): Application identity and authorization learning
- [PortSwigger](https://portswigger.net/web-security): Web Security Academy training
- [OWASP](https://owasp.org/www-project-api-security/): Community application/API security guidance, not a vendor

## Optional technical extension
Use a deliberately vulnerable application only in an isolated authorized training lab. Prefer official guided exercises; never test unrelated public APIs.

## Career practice
Relevant role families to investigate: Application support analyst, Junior developer, Application security trainee. No current vacancy or hiring requirement is asserted.

Interview: What is the difference between authentication and object-level authorization?

## Sources
- [OWASP API Security](https://owasp.org/www-project-api-security/)

## Portfolio evidence
Use the [portfolio guide](../guides/portfolio.md). Submit original input, decisions, tests, actual results, limitations and source attribution. Clearly label modeled, planned and performed work.

## Suggested prerequisites
Topic 2, Topic 11
