<?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 Mert Savaş on Medium]]></title>
        <description><![CDATA[Stories by Mert Savaş on Medium]]></description>
        <link>https://medium.com/@mertsavas?source=rss-2990220f4257------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*VlJ00ACsjMllZxzK</url>
            <title>Stories by Mert Savaş on Medium</title>
            <link>https://medium.com/@mertsavas?source=rss-2990220f4257------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 25 Nov 2026 02:38:10 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@mertsavas/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[JWT Authentication In .NET Core Web API Project]]></title>
            <link>https://medium.com/berkut-teknoloji/jwt-authentication-in-net-core-web-api-project-a6774118f6e5?source=rss-2990220f4257------2</link>
            <guid isPermaLink="false">https://medium.com/p/a6774118f6e5</guid>
            <category><![CDATA[net-core]]></category>
            <category><![CDATA[microservices]]></category>
            <category><![CDATA[jwt]]></category>
            <dc:creator><![CDATA[Mert Savaş]]></dc:creator>
            <pubDate>Sat, 08 Jan 2022 12:41:45 GMT</pubDate>
            <atom:updated>2022-01-20T11:32:29.928Z</atom:updated>
            <content:encoded><![CDATA[<h3>JWT Authentication In .NET Core Web API Project</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Qs0xTkSScYXvp2Tf.png" /></figure><p>Hello everyone! In this article, i’m going to show you how to implement JWT authentication in .NET Core Web API project. Have a nice reading ❤</p><p><strong>What is JWT?</strong></p><p>JSON Web Token (JWT) is an open standard defined in RFC 7519 based on JSON, which enables data exchange and verification between parties.</p><p>JSON Web Tokens generally consist of three parts; Header, Payload, and Signature. These parts are seperated by dots(“.”) and it looks like “aaa.bbb.ccc”.</p><p>Header specifies which algorithm will be used in the signature to be created. Example: {“alg”:”HS256&quot;, “typ”: “JWT”}</p><p>Payload contains previously given unique information between the parties. Example: {“username”: “admin”, “pass”: “123&quot;, “iat”:1422779638}</p><p>“<strong>iat</strong>” is the information containing the creation time of the key.</p><p>Signature, on the other hand, is the structure that emerges when the header and payload are encoded with base64url and combined with a dot, and then encrypted with a secret key.</p><p>Finally, the token is formed by combining the three parts and encoding the signature with base64url.</p><p>Token looks like the following, eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c</p><p>Tokens can be decoded through<a href="https://jwt.io/"> </a>web page called <a href="https://jwt.io/"><strong>jwt.io</strong></a></p><p>We talked about JWT in general terms. Let’s start to code our project now.</p><h3>.NET Core JWT Authentication Project Structure</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/434/1*0ct38_gIbaZX2VUnraFRjQ.png" /></figure><p>First, project requires two packages. We can install them using <strong>NuGet</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/877/1*OH888ITzIYtHAYc_ih_ZaQ.png" /></figure><blockquote><strong>Configuration of JWT Settings in Startup.cs</strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qdRb4dv9OG3ELbskvDfmUQ.png" /></figure><p>The values of the model we created with the name <strong>JwtSettings</strong> come from the values we specified in the <strong>appsettings.json</strong> file. We generate our basic token definitions in the <strong>tokenValidationParameters </strong>object. We add these definitions and <strong>DefaultAuthenticateScheme </strong>to our service that will provide authentication. We determine which authenticate scheme the authorize methods will use and the part that invalid requests will return 401 by using the settings given in <strong>services.AddAuthorization() </strong>method.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/708/1*LdvEPgjS-yn9hJfTkMKcJA.png" /></figure><p>Hmac-sha256 requires a key size of at least ‘128’ bits. However, size of <strong>SecurityKey </strong>can’t be less than 128 bits.</p><p>After writing the code block on the code block, we can call this method in the <strong>ConfigureServices </strong>method.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/670/1*Gds6IMlG9SDCkhNn8dCdlQ.png" /></figure><p>Finally, to use the Authorize tag, we need to add this usage in the <strong>Configure</strong> method.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/857/1*HGFpG11QKW-8Sg5SDzSbhQ.png" /></figure><p>Now, we are ready to code authentication part.</p><blockquote><strong>Controller</strong></blockquote><p>First of all, we create a list from the entity named <strong>User </strong>in <strong>UserController</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/967/1*uWtbjoKCcV55AhjGxyJJ8Q.png" /></figure><p>Then we define the configuration in the constructor to send it to the method that will provide authentication.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/943/1*BAwY5FhLtFf2-U8gyRWTKw.png" /></figure><blockquote><strong>Login</strong></blockquote><p>Next is to write the <strong>Login </strong>method. This method allows anonymous requests. We specify the model containing <strong>Username</strong> and <strong>Password</strong> as our request model.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/928/1*poIBHHVEI3RLQg6vVXPwhQ.png" /></figure><p>We are looking for user in userList with username and password in request. If there is a user, we create the token from the <strong>CreateToken </strong>method.</p><p>The codes we need to write in this method are in the picture below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5T-rWyXnQeCdnmHteOzLsg.png" /></figure><p>We send an email as a claim into the token for later use.</p><blockquote><strong>GetUser</strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/759/1*w5_w-w8j2sSVv9wIU4Fbng.png" /></figure><p>This method is an authorize method. So it does not allow anonymous requests. The method expects a <strong>Bearer </strong>token in the request header.</p><p>We send the token from the header to the <strong>DecodeToken </strong>method, and if it is a valid token, we get the email that the token holds in the claim. Then we find the user in the <strong>userList</strong> with this email.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/888/1*_gv43qqUNimj5C1tCyXoXQ.png" /></figure><blockquote><strong>Snapshots</strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*j-1kr4A5OAnCuv7l3wD8tg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ujdcbv-py8unMNvQeXKEyw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*b4XPPdsRmFzuFbmu1rNluA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*H7WVnULcjJ2MxKIerN1Ulg.png" /></figure><p><strong>Conclusion</strong></p><p>JWT provides a safe way of transmitting information between multiple parties in form of JSON object. It is a modern solution of authenticating user. By using JWT Authentication, we can secure our web services.</p><p>Today, I tried to share some information about JWT in .NET Core which I believe it may be helpful for some other developers. I hope you enjoyed it. You can take a look the repository on <a href="https://github.com/dev-Mjollnir/JwtAuthDemo"><strong>Github</strong></a>.</p><p>Good bye ❤</p><blockquote><strong>References</strong></blockquote><p><a href="https://jwt.io/introduction">JSON Web Token Introduction - jwt.io</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a6774118f6e5" width="1" height="1" alt=""><hr><p><a href="https://medium.com/berkut-teknoloji/jwt-authentication-in-net-core-web-api-project-a6774118f6e5">JWT Authentication In .NET Core Web API Project</a> was originally published in <a href="https://medium.com/berkut-teknoloji">Berkut Teknoloji</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[In-Memory Cache: Use of Memory Caching In .NET Core]]></title>
            <link>https://medium.com/berkut-teknoloji/in-memory-cache-use-of-memory-caching-in-net-core-41d99153ebd0?source=rss-2990220f4257------2</link>
            <guid isPermaLink="false">https://medium.com/p/41d99153ebd0</guid>
            <category><![CDATA[c-sharp-programming]]></category>
            <category><![CDATA[in-memory-cache]]></category>
            <category><![CDATA[net-core-5]]></category>
            <category><![CDATA[caching]]></category>
            <dc:creator><![CDATA[Mert Savaş]]></dc:creator>
            <pubDate>Sat, 25 Dec 2021 11:37:00 GMT</pubDate>
            <atom:updated>2022-01-11T14:40:27.239Z</atom:updated>
            <content:encoded><![CDATA[<h3>In-Memory Cache: Use of Memory Caching In .NET Core</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*tauXGn9EI1caQQgV" /></figure><p>Hello everyone! Today, we’re going to look at the use of in-memory caching in .NET Core. Have a nice reading ❤</p><h3><strong>What is In-Memory Caching?</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/438/1*0TV3FCs0C0RHP_F9-0GRDQ.png" /></figure><p>In-Memory Caching is a method used to provide faster response to incoming requests. When a request is made to retrieve data for the second time, applications can retrieve data from the cache rather than from the original source, such as a database. In this way, data will be accessed faster. The main reason for this method is, as you can see from the figure below, accessing the cache is faster than accessing mass storage or even RAM. We can develop faster and more efficient applications with the use of In-Memory Caching.</p><blockquote><strong>Data Caching</strong></blockquote><p>Data Caching means caching data from a data source such as a web service, database or file, etc. As long as the cache doesn’t expire, we can retrieve data from the cache. When the cache expires, we retrieve the data from the used data source and write it to the cache.</p><blockquote><strong>Some Terms That We May Need To Know</strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/571/1*bRunFHRuOou35I1OZYkq-g.png" /></figure><ul><li><strong>Cache Hit: </strong>Cache hit is the status of the requested data being in the cache.</li><li><strong>Cache Miss: </strong>Cache miss is the case that the requested data is not in the cache. In this case, we send a request to the data source and fetch data from there. We write the data from the data source back into the cache.</li></ul><h3><strong>In-Memory Cache In .NET Core</strong></h3><p>In .NET Core, we are able to write data to cache, read or delete our data from the cache using the interface named <strong>IMemoryCache </strong>in the <strong>Microsoft.Extensions.Caching.Memory library</strong>.</p><p>We may want to expire the data in some cases or prevent it from consuming more memory so that it does not render our application inoperable. We can achieve this by using the <strong>MemoryCacheEntryOptions </strong>class.</p><ul><li><strong>AbsoluteExpiration:</strong> It ensures that the data stored in the cache is destroyed at the end of the specified time.</li><li><strong>ExpirationTokens:</strong> It uses a token instance to expire the cache entry.</li><li><strong>Priority: </strong>Determines the order in which data is deleted to free memory, based on the CacheItemPriority enum value(Low, Normal, High, NeverRemove).</li><li><strong>Size:</strong> It determines the size of the cache entry value.</li><li><strong>SlidingExpiration:</strong> It determines how long the cache entry can be inactive (e.g. not accessed) before it will be removed. When we access the cache entry before it is removed, the entry lifetime will be extended. This will not extend the entry lifetime beyond the absolute expiration (if set).</li></ul><p>Now let’s look at how In-Memory Cache is used on the sample project.</p><blockquote><strong>Implementation</strong></blockquote><p>First, let’s enable <strong>Memory Cache</strong> in the <strong>ConfigureServices</strong> method in the <strong>startup.cs</strong> class by adding <strong>services.AddMemoryCache()</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/689/1*Qq-apVOn3yGoOoIZAiYoAA.png" /></figure><p>Then, let’s go back to our related controller and inject the IMemoryCache interface in the constructor.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/692/1*m5Gr0qmg5iktWOkGqAdn-w.png" /></figure><p>Now we are ready to use ‘In-Memory Cache’. Let this example project be a project that allows us to search for a city by plate code.</p><p><strong>Methods</strong></p><blockquote><strong>Storing Data In Cache</strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/669/1*gBgpALdkuDkhlB0p9wKgWQ.png" /></figure><p>As seen on the picture above for the cache entry options, we give the AbsoluteExpiration time of the entry value to 1 hour, the SlidingExpiration time to 10 minutes if it is not accessed within a certain time, and the priority to high. Then we set the plate code as the key , the city information as the value and the cacheExpiryOptions object as the MemoryCacheEntryOptions.</p><blockquote><strong>Fetcing Data From Cache</strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/625/1*eRsgokELphtePCftu0Hd8A.png" /></figure><p>We send the plate code as the key to pull the data from the cache. If it finds the data in the cache, we set the returned data to value.</p><blockquote>Removing Data From Cache</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/660/1*Xgm4hsd5gTb5Lew4kJT81g.png" /></figure><p>We may want to remove data from cache before it is self-destructed. For these cases, we can easily implement this code block in our code base.</p><p>In this article, I tried to explain and apply in-memory caching as best that I could. I hope you enjoyed it. Bye ❤</p><blockquote>References</blockquote><ul><li><a href="https://docs.microsoft.com/tr-tr/aspnet/core/performance/caching/memory?view=aspnetcore-6.0">ASP.NET Core &#39;de önbellek belleği</a></li><li><a href="https://www.c-sharpcorner.com/article/asp-net-core-in-memory-caching/">ASP.NET Core - In Memory Caching</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=41d99153ebd0" width="1" height="1" alt=""><hr><p><a href="https://medium.com/berkut-teknoloji/in-memory-cache-use-of-memory-caching-in-net-core-41d99153ebd0">In-Memory Cache: Use of Memory Caching In .NET Core</a> was originally published in <a href="https://medium.com/berkut-teknoloji">Berkut Teknoloji</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Should We Use NoSQL Instead Of SQL? If Yes, When?]]></title>
            <link>https://medium.com/berkut-teknoloji/should-we-use-nosql-instead-of-sql-if-yes-when-3b6e1e81e73?source=rss-2990220f4257------2</link>
            <guid isPermaLink="false">https://medium.com/p/3b6e1e81e73</guid>
            <dc:creator><![CDATA[Mert Savaş]]></dc:creator>
            <pubDate>Tue, 21 Dec 2021 13:55:04 GMT</pubDate>
            <atom:updated>2022-04-14T14:56:33.600Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/799/0*lGbyfsDazVek7gOh.jpg" /></figure><p>In this article, I tried to share my knowledge about NoSQL and SQL databases. I hope, you will enjoy it!</p><p><strong>What is SQL?</strong></p><p>SQL is Structured Query Language, which is a language for managing and designing data in a relational database. It is commonly used to operate databases for CRUD operations, such as create, read, update and delete. Relational Database Management Systems like MySQL, Oracle, MS Access, PostgreSQL and SQL Server use SQL as their standard database language. Moreover, some different dialects are used to describe these management systems, such as</p><ul><li>MS SQL -&gt; T-SQL</li><li>Oracle -&gt; PL/SQL</li></ul><p><strong>What is NoSQL?</strong></p><p>NoSQL databases (also known as “Not only SQL”) are non-relational and non-tabular databases. NoSQL databases store the data differently than SQL databases. There are many implementation types of NoSQL databases. The most common examples are key-value, wide-column, document, and graph. I’m going to mention about the most popular ones.</p><p><strong>Key-Value Store </strong>(Redis, Riak, Oracle NoSQL, Apache Cassandra)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/698/0*JBqa8kU9LwDrX8uD.png" /></figure><p>Key-Value databases are the most popular and simplest amongst NoSQL databases. We can store the data as JSON, integer, string, or array with a key which is given as a reference. In this type, generally map or dictionary data structures are used.</p><p>Benefits of using this implementation can be described as having rapid storage of data and having integrated caching feature, which allows users to store/retrieve data as quickly as possible. The major advantages for the key-value store are speed and simplicity. The disadvantage is being difficult to perform advanced queries aside from basic CRUD operations. When the stored data increases, maintenance of unique keys becomes more difficult.</p><p><strong>Column-Based Store </strong>(Apache Hbase, MariaDB, Cassandra)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/707/0*75YMOD3h5tqy0jr1.png" /></figure><p>Column-based databases store data in columns rather than rows. Relational databases store data in rows and data properties as column headers. Row-based and column-based databases use SQL as their query language. Column-based databases perform the queries faster than a row-based databases. But write operations may take longer to complete. The overall benefits of a column-based database include data compression, high performance with aggregate functions. However, vast number of insert and delete operations might have a negative impact on performance, especially if the table has plenty of columns.</p><p><strong>Document-Based Store </strong>(MongoDB, CosmosDB, DynamoDB)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/824/1*pRq08iLNwsGJSgvXM1ykJw.png" /></figure><p>A document-based store database designed to store and query data as JSON or like PDF, XML and Word documents. Document-based databases help developers to store and query data in a database by using the same document model they use in their project that makes easier for development. However, they are also limited to advanced queries and does not allow any joins. A modification that includes two collections will require you to run two separate queries. Furthermore, one of the major disadvantages is security lacks.</p><p><strong>What are the differences between SQL and NoSQL?</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/934/1*QLJlH9LunhzugOq0rE3-UA.png" /></figure><blockquote><strong>When do we use NoSQL or SQL?</strong></blockquote><p><strong>SQL database is more advantageous when</strong></p><ul><li>You need to perform flexible queries</li><li>You need to store structured data</li><li>Your access patterns aren’t defined</li><li>You need to enforce field constraints</li><li>You need to store relational data</li></ul><p><strong>NoSQL database is more advantageous when</strong></p><ul><li>Performance is crucial to your project</li><li>You need low latency</li><li>You need to store unstructured data</li><li>Your access patterns are defined</li><li>You don’t need to store relational data</li></ul><p><strong>Thanks for reading! Bye </strong>❤</p><blockquote><strong>References</strong></blockquote><ul><li><a href="https://www.couchbase.com/resources/why-nosql">NoSQL Databases</a></li><li><a href="https://academind.com/tutorials/sql-vs-nosql">SQL vs NoSQL</a></li><li><a href="https://www.mongodb.com/nosql-explained">What Is NoSQL? NoSQL Databases Explained</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3b6e1e81e73" width="1" height="1" alt=""><hr><p><a href="https://medium.com/berkut-teknoloji/should-we-use-nosql-instead-of-sql-if-yes-when-3b6e1e81e73">Should We Use NoSQL Instead Of SQL? If Yes, When?</a> was originally published in <a href="https://medium.com/berkut-teknoloji">Berkut Teknoloji</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>