The Real Fullstack

The Broken Authorization

Every request is authenticated. So how did Alice read Bob's order?

工程师9 分钟调试实验室代码挑战
restspring-securityjavaoauth2

此挑战尚未翻译为简体中文,你正在阅读英文版本。

任务:Apply authorization checks so every legitimate request still works and none of the illegitimate ones does.背景 · 学习目标 ▾

Brightcart's orders API checks that requests carry a valid token. A security researcher reported that changing /orders/A-17 to /orders/B-42 returns another customer's order, including address and payment details. Support agents serve several tenants.

任务: Apply authorization checks so every legitimate request still works and none of the illegitimate ones does.

学习目标

  • Distinguish authentication from authorization.
  • Implement object-level and tenant-level checks.
  • Recognise security through obscurity.
模拟模拟数据

运行模拟以查看输出。

运行模拟
@GetMapping("/orders/{id}")public OrderDto get(@PathVariable String id, Authentication auth) {  return orders.findById(id).map(OrderDto::of).orElseThrow();   // authenticated ≠ authorized}