Skip to content

Latest commit

 

History

History
37 lines (21 loc) · 1.67 KB

README.md

File metadata and controls

37 lines (21 loc) · 1.67 KB

SwaggerUIAuthorization

NuGet Version NuGet Downloads

Summary

If your API endpoints require authentication and authorization, it makes sense to integrate those rules into your Swagger documentation. With the SwaggerUIAuthorization package, you can seamlessly control access to SwaggerUI, ensuring that only authenticated users with appropriate permissions can view documentation their roles have access to. This package leverages .NET's authentication and authorization mechanisms, aligning with the rules already established within your application.

Features

  • Authentication and authorization dependent rendering of swagger documentation
  • The same rules that .NET has defined for an AuthorizeAttribute applies
    • Comma separated roles are evaluated on an OR basis
    • Multiple AuthorizeAttribute's are evaluated on an AND basis
    • An AllowAnonymousAttribute bypasses all authorization

Limitations

The schema displayed at the bottom of an api using SwaggerUI is force hidden internally using the following code:

options.DefaultModelsExpandDepth(-1);

Installation

SwaggerUIAuthorization is available on NuGet.

dotnet add package SwaggerUIAuthorization

Docs

SwaggerUIAuthorization

Examples

WebApiWithCustomLogin
WebApiWithMicrosoftIdentity