Skip to main content

3 posts tagged with "API"

REST design, versioning, OpenAPI documentation and the contract between server and client.

View All Tags

Change the id in the URL and Get Someone Else's Data? Stop IDOR in a Single Layer

· 14 min read
Nguyễn Huỳnh Minh Tiến
Middle Fullstack Developer @ Utop.vn
Summary

IDOR happens when an endpoint takes an id from the request and loads the record directly, checking only that the caller is logged in rather than that the caller has rights over that particular record. Switching ids to GUIDs or encrypting them does not fix the bug, because the id still leaks somewhere else. The fix is to force every query through a layer that binds it to ownership on the server, instead of scattering checks through individual controllers.

You have a perfectly ordinary endpoint: GET /api/orders/1043 returns order details. It sits behind [Authorize], only a valid token gets through, and in the UI a user can only click into their own orders.

Then somebody logs in with their real account, changes 1043 to 1044, and hits send. If the server returns someone else's order, that is an Insecure Direct Object Reference — IDOR for short. No payload, no technique, just one number changed.

What Is Scalar? Why Use Scalar Instead of Swagger UI in ASP.NET Core 10

· 9 min read
Nguyễn Huỳnh Minh Tiến
Middle Fullstack Developer @ Utop.vn
Summary

Scalar is an open-source API Reference UI that replaces Swagger UI, and it is what Microsoft recommends for ASP.NET Core from .NET 9 onward. Starting with .NET 9, Microsoft removed Swashbuckle (Swagger UI) from the default Web API template and replaced it with Microsoft.AspNetCore.OpenApi combined with Scalar. This post explains the reasoning behind that change, compares Scalar against Swagger UI feature by feature, and walks through setting Scalar up in ASP.NET Core 10 — both for a brand new project and as a migration from an existing one.

If you created a new ASP.NET Core Web API project on .NET 9 or .NET 10 and were surprised to find Swagger UI missing, you are not alone. Microsoft deliberately replaced Swashbuckle with a native OpenAPI pipeline, and Scalar is the UI recommended alongside it.

The Scalar API Reference interface on scalar.com

Các loại kiểm thử API: 9 loại, khác nhau ở đâu và chạy lúc nào

· 14 min read
Nguyễn Huỳnh Minh Tiến
Middle Fullstack Developer @ Utop.vn
Summary

Kiểm thử API là việc gửi request thẳng vào tầng API và kiểm tra response, thay vì thao tác qua giao diện. Nó nhanh hơn và ổn định hơn kiểm thử UI vì bỏ qua trình duyệt. Chín loại phổ biến trả lời chín câu hỏi khác nhau: smoke hỏi API có sống không, functional hỏi có đúng đặc tả không, integration hỏi các service ghép lại có đúng không, regression hỏi thay đổi mới có phá cái cũ không, load và stress hỏi chịu được bao nhiêu và sập thế nào, security hỏi có lỗ hổng không, UI hỏi dữ liệu hiển thị đúng không, fuzz hỏi đầu vào rác có làm sập không. Chúng không thay thế nhau.

Câu hỏi "nên dùng loại kiểm thử nào" hầu như luôn sai đề. Mỗi loại trả lời một câu hỏi riêng, và một hệ thống chạy thật thường cần nhiều loại cùng lúc ở những thời điểm khác nhau trong quy trình. Bài này xếp chín loại theo đúng câu hỏi mà chúng trả lời.