<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Thiago Miranda on Medium]]></title>
        <description><![CDATA[Stories by Thiago Miranda on Medium]]></description>
        <link>https://medium.com/@thiagomiranda_60010?source=rss-70c57e2a1594------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*NH5ZZPbArqAx70Op.</url>
            <title>Stories by Thiago Miranda on Medium</title>
            <link>https://medium.com/@thiagomiranda_60010?source=rss-70c57e2a1594------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 14:01:59 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@thiagomiranda_60010/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Basic Authentication in Swashbuckle.AspNetCore 5.0]]></title>
            <link>https://medium.com/@thiagomiranda_60010/basic-authentication-in-swashbuckle-aspnetcore-5-0-2ae8e97e54a1?source=rss-70c57e2a1594------2</link>
            <guid isPermaLink="false">https://medium.com/p/2ae8e97e54a1</guid>
            <category><![CDATA[net-core]]></category>
            <category><![CDATA[swagger]]></category>
            <category><![CDATA[c]]></category>
            <category><![CDATA[swashbuckle]]></category>
            <category><![CDATA[aspnetcore]]></category>
            <dc:creator><![CDATA[Thiago Miranda]]></dc:creator>
            <pubDate>Wed, 29 Jan 2020 21:12:16 GMT</pubDate>
            <atom:updated>2020-01-29T21:12:16.448Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/772/1*Ln2nyZIZ1YQ2VZuU8fzhAw.png" /><figcaption>Swagger, taken from <a href="https://docs.microsoft.com/pt-br/aspnet/core/tutorials/getting-started-with-swashbuckle?view=aspnetcore-3.1">Microsoft Docs</a></figcaption></figure><p>If you use Swagger in your .NET Core applications, you might have seen that Swashbuckle team has <a href="https://github.com/domaindrivendev/Swashbuckle.AspNetCore/releases/tag/v5.0.0">updated the NuGet package</a> 15 days ago (14/01, to be exactly, although there had some pre releases tracked).</p><p>This release had several break changes, that can be found in release notes mentioned in the link above. As it’s seen on Swashbuckle release summary, in the best case scenario, user’s could simply change the old objects with the new object models and simply run the project.</p><p>That didn’t happen to me, at least on the authorization process. I’ve been using Swashbuckle.AspNetCore packaged since early 2019’s in 4.0.1 version. In this scenario, the authentication scheme can be added to your controllers using the code snippet below and the code in this <a href="https://pastebin.com/gMVgArEZ">pastebin</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/762/1*ki0YUsWqgR8ZeSjmf27ctA.png" /><figcaption>Adding basic authentication to Swagger, Swashbuckle.AspNetCore 4.0.1</figcaption></figure><p>After the 5.0.0 release, the Swashbuckle.AspNetCore is using OpenAPI Object Models. You can find more information about those models <a href="https://swagger.io/blog/news/whats-new-in-openapi-3-0/">here</a>. Although the structure of security definitions is still the same, some changes has been made in the security workflow definition. You can find the code for both methods in this <a href="https://pastebin.com/pr0YvQM2">pastebin</a>.</p><p>In Swashbuckle.AspNetCore 5.0.0, we need to use the objects OpenApiSecurityScheme to define the security scheme used in the project and OpenApiSecurityRequirement to add a global security requirement. You can find more information about both objects in the <a href="https://github.com/domaindrivendev/Swashbuckle.AspNetCore/tree/v5.0.0#add-security-definitions-and-requirements">Swashbuckle’s GitHub page</a>.</p><p>The changes needed to add Basic Authentication to your project are shown in the code below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/632/1*K8fWP87oePhv6EjGa_EHqA.png" /><figcaption>Adding SecurityDefinition for Swagger, Swashbuckle.AspNetCore 5.0.0</figcaption></figure><p>In <strong>AddSecurityDefinition </strong>method, the type “basic” has been changed to “http”. To specify it’s using either bearer, basic or other, the <strong>Scheme </strong>attribute must be set.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/604/1*ip_jzWA4NSQMtCAl3mcctg.png" /><figcaption>Adding SecurityRequirement for Swagger, Swashbuckle.AspNetCore 5.0.0</figcaption></figure><p>In the <strong>AddSecurityRequirement </strong>method, the object <strong>OpenApiReference </strong>must be used, defining it’s attributes depending on which <strong>SecurityScheme </strong>is being used. You can find more information about the Security Scheme Object <a href="https://swagger.io/specification/#securitySchemeObject">here</a>.</p><p>If you’re using Bearer Authentication and wants to update your Swashbuckle.AspNetCore from version 4.x to 5.x, you can follow this <a href="https://stackoverflow.com/questions/56234504/migrating-to-swashbuckle-aspnetcore-version-5">StackOverflow post</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2ae8e97e54a1" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>