liveBook · Manning

Security requirement

As explained in ASP.NET Core in Action, 3e

An OpenAPI security requirement is a declaration specifying which security schemes are required for an API or its operations.

An OpenAPI security requirement declares which security scheme an API or its operations require. In a JWT bearer setup, it connects the documented scheme to protected requests. section 25.5

Configure authentication documentation in two steps:

  • Define the scheme, such as bearer authentication, OAuth 2.0, or OpenID Connect. section 25.5
  • Add a security requirement to declare which endpoints use that scheme; applying it to the API protects the whole API. section 25.5
  • Swagger UI then provides an Authorize button, stores the entered Bearer token, and attaches it to later requests in the Authorization header. section 25.5

How ASP.NET Core in Action, 3e covers it

How deep it goes
Explains scheme definition, endpoint declaration, and resulting Swagger UI behavior, but does not detail authorization policy rules.
Examples
Uses a Swashbuckle JWT configuration and entering Bearer <token> through Swagger UI’s Authorize dialog.
What it assumes
Assumes an API using authentication and introduces the OpenAPI distinction between defining a scheme and requiring it.
What you can do after
Configure bearer authentication in Swashbuckle and test protected requests through Swagger UI.
How it connects
Connects OpenAPI security requirements with JWT bearer authentication, OAuth 2.0, OpenID Connect, Swashbuckle, and Swagger UI.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of ASP.NET Core in Action, 3e. The section links point to the parts of the book it draws on.