﻿
{"id":15657,"date":"2020-05-07T22:48:16","date_gmt":"2020-05-07T22:48:16","guid":{"rendered":"https:\/\/www.gencayyildiz.com\/blog\/?p=15657"},"modified":"2020-05-07T22:48:16","modified_gmt":"2020-05-07T22:48:16","slug":"asp-net-core-rate-limit-ile-api-guvencesi-saglama","status":"publish","type":"post","link":"https:\/\/www.gencayyildiz.com\/blog\/asp-net-core-rate-limit-ile-api-guvencesi-saglama\/","title":{"rendered":"Asp.NET Core &#8211; Rate Limit \u0130le API G\u00fcvencesi Sa\u011flama"},"content":{"rendered":"<div id=\"fb-root\"><\/div>\n<p>Merhaba,<\/p>\n<p>Asp.NET Core API ile tasarlanm\u0131\u015f bir endpoint&#8217;in normal \u015fartlarda s\u00fcrekli istek alabilecek olarak d\u0131\u015f d\u00fcnyaya a\u00e7\u0131k bir \u015fekilde tasarlanmas\u0131 kadar do\u011fal bir\u015fey olmasa gerek. Lakin bu durum fiili olarak k\u00f6t\u00fc niyetli ki\u015filer taraf\u0131ndan s\u00fcrekli eyleme d\u00f6n\u00fc\u015ft\u00fcr\u00fclebilir ve <em>Denial Of Service Attack(DOS Attack)<\/em> ve hatta <em>Distributed Denial Of Service Attack(DDOS Attack)<\/em> dedi\u011fimiz sald\u0131r\u0131larla kar\u015f\u0131 kar\u015f\u0131ya kal\u0131nmas\u0131na sebebiyet verebilir.<\/p>\n<p><em>Nedir bu DOS\/DDOS Attack sald\u0131r\u0131lar\u0131?<\/em> diye sorarsan\u0131z e\u011fer \u015f\u00f6yle \u00f6zetleyebiliriz;<br \/>\n<a href=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2020\/05\/Asp.NET-Core-Rate-Limit-\u0130le-API-G\u00fcvencesi-Sa\u011flama.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignleft size-medium wp-image-15658\" src=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2020\/05\/Asp.NET-Core-Rate-Limit-\u0130le-API-G\u00fcvencesi-Sa\u011flama-300x227.jpg\" alt=\"Asp.NET Core - Rate Limit \u0130le API G\u00fcvencesi Sa\u011flama\" width=\"300\" height=\"227\" srcset=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2020\/05\/Asp.NET-Core-Rate-Limit-\u0130le-API-G\u00fcvencesi-Sa\u011flama-300x227.jpg 300w, https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2020\/05\/Asp.NET-Core-Rate-Limit-\u0130le-API-G\u00fcvencesi-Sa\u011flama-768x581.jpg 768w, https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2020\/05\/Asp.NET-Core-Rate-Limit-\u0130le-API-G\u00fcvencesi-Sa\u011flama.jpg 836w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><br \/>\nK\u00f6t\u00fc niyetli ki\u015filer taraf\u0131ndan d\u0131\u015f d\u00fcnyaya kar\u015f\u0131 istek hacmi her daim a\u00e7\u0131k olan bir API tespit edildi\u011fi taktirde, bir ka\u00e7 client veya client g\u00f6revi g\u00f6recek tehlikeli(compromised) yaz\u0131l\u0131m e\u015fli\u011finde ilgili API&#8217;a aral\u0131ks\u0131z istek g\u00f6ndererek hedef sunucuyu \u00e7\u00f6kertmek veya servisi hizmet veremez hale getirmek ama\u00e7l\u0131 yap\u0131lan sald\u0131r\u0131 \u00e7e\u015fitidir. B\u00f6ylece ilgili sunucu hizmetlere kar\u015f\u0131l\u0131k veremeyecek yahut gecikmeli \u00e7al\u0131\u015facak hale getirildi\u011fi taktirde kullan\u0131c\u0131lara ya yava\u015f sonu\u00e7 d\u00f6n\u00fclecek ya da kullan\u0131c\u0131lar taraf\u0131ndan eri\u015filemeyecektir.<\/p>\n<p>\u0130\u015fte b\u00f6yle bir senaryoyla kar\u015f\u0131la\u015fmamak i\u00e7in API&#8217;lar\u0131m\u0131za d\u0131\u015f d\u00fcnyadan gelecek isteklerin s\u0131n\u0131r\u0131n\u0131 belirtmemiz gerekmektedir. Bunun i\u00e7in <strong>Rate Limit<\/strong> belirtilerek bu olas\u0131 sald\u0131r\u0131dan rahat\u00e7a korunulabilir. Rate Limit; uygulaman\u0131za G\u00fcvenlik ve \u00d6l\u00e7eklendirilebilirlik getirecektir. <u>G\u00fcvenlik<\/u> getirecektir \u00e7\u00fcnk\u00fc uygulaman\u0131z DOS\/DDOS gibi sald\u0131r\u0131lardan korunmu\u015f olacakt\u0131r. <u>\u00d6l\u00e7eklendirilebilirlik<\/u> getirecektir \u00e7\u00fcnk\u00fc;<\/p>\n<p><span style=\"color: blue;\">1<\/span> saatte <span style=\"color: red;\">100<\/span> adet iste\u011fi <span style=\"color: orange;\">1<\/span> saniyede<br \/>\nkar\u015f\u0131layan uygulama yine<br \/>\n<span style=\"color: blue;\">1<\/span> saatte <span style=\"color: red;\">1.000.000<\/span> iste\u011fi <span style=\"color: orange;\">1<\/span> saniyede<br \/>\nkar\u015f\u0131layabilecektir.<\/p>\n<p>\u0130\u015fte bu tutarl\u0131l\u0131k \u00f6l\u00e7eklendirilebilirli\u011fin sonucudur. E\u011fer ki, DOS\/DDOS sald\u0131r\u0131lar\u0131ndan herhangi biri ger\u00e7ekle\u015ftirilirse uygulamadaki \u00f6l\u00e7eklendirilebilirlik bozulacak ve kimi kullan\u0131c\u0131ya 1 saniyede d\u00f6nen response&#8217;un bir di\u011ferine d\u00f6nmesi saniyeler ve hatta dakikalar s\u00fcrebilecektir.<\/p>\n<p>Rate Limit, API uygulamas\u0131na belirli bir s\u00fcre zarf\u0131nda ne kadar istek yap\u0131labilece\u011fini, hangi IP&#8217;lerin bundan muaf tutulabilece\u011fini vs. belirleyebilmekte ve b\u00f6ylece uygulamam\u0131z\u0131n istek hacmini kontrol etmemizi sa\u011flayabilmektedir. Bunun i\u00e7in bizlere <strong>IP Rate Limit<\/strong> ve <strong>Client ID Rate Limit<\/strong> olmak \u00fczere iki farkl\u0131 yakla\u015f\u0131m sunmaktad\u0131r.<\/p>\n<table>\n<thead>\n<tr>\n<th>IP Rate Limit<\/th>\n<th>Client ID Rate Limit<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td style=\"width:50%;vertical-align:top;\">Belirtilen IP&#8217;ler d\u0131\u015f\u0131ndan gelen t\u00fcm requestlere s\u0131n\u0131rlama getirir. Belirtilenleri bu s\u0131n\u0131rlamalardan muaf tutar.<\/p>\n<p>Uygulamada static IP&#8217;ler varsa kesinlikle bu yakla\u015f\u0131m tercih edilmelidir.\n<\/td>\n<td>Gelen request header bilgisinde belirli bir key &#8211; value de\u011ferine g\u00f6re kontrol sa\u011flar. Kontrol neticesinde e\u011fer e\u015fle\u015fme varsa ilgili iste\u011fi yapan s\u0131n\u0131rlamadan muaf tutulur. Aksi taktirde t\u00fcm requestlere s\u0131n\u0131rlama getirilir.<\/p>\n<p>Uygulamada static IP&#8217;ler yoksa bu yakla\u015f\u0131m kullan\u0131labilir. Lakin dikkat edilmesi gereken husus \u015fudur ki; k\u00f6t\u00fc niyetli ki\u015filer key &#8211; value de\u011ferlerini bir \u015fekilde if\u015fa ederlerse uygulama tekrardan mevzu bahis sald\u0131r\u0131lara maruz kalabilir. O y\u00fczden m\u00fcmk\u00fcn mertebe IP Rate Limit tercih edilmelidir.\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3 style=\"color:purple;\">Rate Limit Yap\u0131lanmas\u0131 ve Konfig\u00fcrasyonu<\/h3>\n<p>Uygulaman\u0131zda Rate Limit konfig\u00fcrasyonunu sa\u011flayabilmek i\u00e7in custom bir middleware yazabilir ya da <a href=\"https:\/\/github.com\/stefanprodan\/AspNetCoreRateLimit\/\" rel=\"noopener noreferrer\" target=\"_blank\">AspNetCoreRateLimit<\/a> k\u00fct\u00fcphanesini kullanabilirsiniz. Bu k\u00fct\u00fcphane ile uygulamam\u0131zdaki Rate Limit konfig\u00fcrasyonunun hepsini &#8216;appsettings.json&#8217; dosyas\u0131ndan uygulayabilir ve rahatl\u0131kla y\u00f6netebilirsiniz. Bizler de bu i\u00e7eri\u011fimizde ilgili k\u00fct\u00fcphane \u00fczerinden seyredece\u011fiz&#8230;<\/p>\n<p>\u0130lk olarak \u00f6rnek bir Asp.NET Core API uygulamas\u0131 olu\u015ftural\u0131m ve yapabilece\u011fimiz s\u0131n\u0131rs\u0131z iste\u011fi fiilen inceleyelim&#8230;<br \/>\n<a href=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2020\/05\/Asp.NET-Core-Rate-Limit-\u0130le-API-G\u00fcvencesi-Sa\u011flama.gif\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2020\/05\/Asp.NET-Core-Rate-Limit-\u0130le-API-G\u00fcvencesi-Sa\u011flama.gif\" alt=\"Asp.NET Core - Rate Limit \u0130le API G\u00fcvencesi Sa\u011flama\" width=\"800\" height=\"426\" class=\"aligncenter size-full wp-image-15690\" \/><\/a><br \/>\nG\u00f6r\u00fcld\u00fc\u011f\u00fc \u00fczere rate limit&#8217;i belirtilmemi\u015f bir uygulamaya k\u0131sa aral\u0131kta elimizle manuel olacak bir \u015fekilde onlarca defa istek g\u00f6nderebilmekteyiz, gelin art\u0131k zararl\u0131 yaz\u0131l\u0131mlarla bu iste\u011fin ne kadar seri yap\u0131labilece\u011fini siz d\u00fc\u015f\u00fcn\u00fcn&#8230;<\/p>\n<p>Art\u0131k bu bilgiler \u0131\u015f\u0131\u011f\u0131nda gelin API uygulamam\u0131za nas\u0131l rate limit&#8217;in uygunland\u0131\u011f\u0131n\u0131 ad\u0131m ad\u0131m inceleyerek, g\u00f6relim. Her\u015feyden \u00f6nce yakla\u015f\u0131mdan ba\u011f\u0131ms\u0131z bir \u015fekilde ilk olarak uygulamam\u0131za &#8216;<em>AspNetCoreRateLimit<\/em>&#8216; k\u00fct\u00fcphanesini entegre ederek ba\u015flayal\u0131m.<br \/>\n<a href=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2020\/05\/Asp.NET-Core-Rate-Limit-\u0130le-API-G\u00fcvencesi-Sa\u011flama-1.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2020\/05\/Asp.NET-Core-Rate-Limit-\u0130le-API-G\u00fcvencesi-Sa\u011flama-1.jpg\" alt=\"Asp.NET Core - Rate Limit \u0130le API G\u00fcvencesi Sa\u011flama\" width=\"456\" height=\"200\" class=\"aligncenter size-full wp-image-15697\" srcset=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2020\/05\/Asp.NET-Core-Rate-Limit-\u0130le-API-G\u00fcvencesi-Sa\u011flama-1.jpg 456w, https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2020\/05\/Asp.NET-Core-Rate-Limit-\u0130le-API-G\u00fcvencesi-Sa\u011flama-1-300x132.jpg 300w\" sizes=\"auto, (max-width: 456px) 100vw, 456px\" \/><\/a><\/p>\n<p>Bu a\u015famadan sonra art\u0131k yakla\u015f\u0131m bazl\u0131 inceleme ger\u00e7ekle\u015ftirebiliriz.<\/p>\n<h4>IP Rate Limit Yakla\u015f\u0131m\u0131<\/h4>\n<p>Asp.NET Core uygulamas\u0131nda IP bazl\u0131 Rate Limit uygulayabilmek i\u00e7in \u00f6ncelikle &#8216;Startup.cs&#8217; dosyas\u0131nda a\u015fa\u011f\u0131daki konfig\u00fcrasyonlar\u0131n ger\u00e7ekle\u015ftirilmesi gerekmektedir.<\/p>\n<ol>\n<li>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\n            services.AddOptions();\r\n<\/pre>\n<p>Rate Limit&#8217;e dair olan t\u00fcm konfig\u00fcrasyonlar\u0131n &#8216;appsettings.json&#8217; dosyas\u0131nda tutulaca\u011f\u0131ndan dolay\u0131 buradaki yap\u0131land\u0131rmay\u0131 \u00f6ncelikle uygulamaya y\u00fcklememiz gerekmektedir.\n<\/li>\n<li>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\n            services.AddMemoryCache();\r\n<\/pre>\n<p>S\u00fcre\u00e7te yap\u0131lan istekler neticesinde limit durum bilgilerini cache&#8217;de tutmak i\u00e7in memory cache&#8217;i aktifle\u015ftiriyoruz.\n<\/li>\n<li>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\n            services.Configure&lt;IpRateLimitOptions&gt;(Configuration.GetSection(&quot;IpRateLimiting&quot;));\r\n<\/pre>\n<p>&#8216;appsettings.json&#8217; dosyas\u0131nda tan\u0131mlanan genel konfig\u00fcrasyon ayarlar\u0131n\u0131 y\u00fckl\u00fcyoruz.\n<\/li>\n<li>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\n            services.Configure&lt;IpRateLimitPolicies&gt;(Configuration.GetSection(&quot;IpRateLimitPolicies&quot;));\r\n<\/pre>\n<p>&#8216;appsettings.json&#8217; dosyas\u0131nda tan\u0131mlanm\u0131\u015f IP kurallar\u0131n\u0131 ve politikalar\u0131n\u0131 y\u00fckl\u00fcyoruz.\n<\/li>\n<li>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\n            services.AddSingleton&lt;IIpPolicyStore, MemoryCacheIpPolicyStore&gt;();\r\n            services.AddSingleton&lt;IRateLimitCounterStore, MemoryCacheRateLimitCounterStore&gt;();\r\n<\/pre>\n<p>Politika ve verilerin memory&#8217;de tutulaca\u011f\u0131n\u0131 bildiriyoruz.\n<\/li>\n<li>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\n            services.AddHttpContextAccessor();\r\n<\/pre>\n<p>ClientId ve ClientIp \u00e7\u00f6z\u00fcmleri i\u00e7in kullanaca\u011f\u0131m\u0131z HttpContextAccessor servisini uygulamaya dahil ediyoruz.\n<\/li>\n<li>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\n            services.AddSingleton&lt;IRateLimitConfiguration, RateLimitConfiguration&gt;();\r\n<\/pre>\n<p>Rate limit i\u00e7in t\u00fcm yap\u0131lanmalar\u0131 organize bir \u015fekilde in\u015fa eden ana servisi ekliyoruz.\n<\/li>\n<li>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\n            app.UseIpRateLimiting();\r\n<\/pre>\n<p>Son olarakta &#8216;UseIpRateLimiting&#8217; middleware&#8217;ini kullanarak Ip Rate Limit operasyonunu devreye sokuyoruz.\n<\/li>\n<\/ol>\n<p>Nihai olarka &#8216;Startup.cs&#8217; dosyas\u0131n\u0131 a\u015fa\u011f\u0131daki gibi in\u015fa etmi\u015f oluyoruz.<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\n    public class Startup\r\n    {\r\n        IConfiguration Configuration;\r\n        public Startup(IConfiguration configuration)\r\n        {\r\n            Configuration = configuration;\r\n        }\r\n        public void ConfigureServices(IServiceCollection services)\r\n        {\r\n            services.AddOptions();\r\n            services.AddMemoryCache();\r\n            services.Configure&lt;IpRateLimitOptions&gt;(Configuration.GetSection(&quot;IpRateLimiting&quot;));\r\n            services.Configure&lt;IpRateLimitPolicies&gt;(Configuration.GetSection(&quot;IpRateLimitPolicies&quot;));\r\n            services.AddSingleton&lt;IIpPolicyStore, MemoryCacheIpPolicyStore&gt;();\r\n            services.AddSingleton&lt;IRateLimitCounterStore, MemoryCacheRateLimitCounterStore&gt;();\r\n            services.AddHttpContextAccessor();\r\n            services.AddSingleton&lt;IRateLimitConfiguration, RateLimitConfiguration&gt;();\r\n            services.AddControllers();\r\n        }\r\n\r\n        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)\r\n        {\r\n            if (env.IsDevelopment())\r\n                app.UseDeveloperExceptionPage();\r\n            app.UseIpRateLimiting();\r\n            app.UseRouting();\r\n            app.UseEndpoints(endpoints =&gt; endpoints.MapControllers());\r\n        }\r\n    }\r\n<\/pre>\n<p>Bu ad\u0131mdan sonra art\u0131k &#8216;appsettings.json&#8217; dosyas\u0131nda a\u015fa\u011f\u0131daki konfig\u00fcrasyonlara ge\u00e7ebiliriz.<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\n  &quot;IpRateLimiting&quot;: {\r\n    &quot;EnableEndpointRateLimiting&quot;: true,\r\n    &quot;StackBlockedRequests&quot;: false,\r\n    &quot;HttpStatusCode&quot;: 429,\r\n    &quot;IpWhitelist&quot;: &#x5B; &quot;127.0.0.12&quot; ],\r\n    &quot;EndpointWhitelist&quot;: &#x5B; &quot;*:\/api\/customers&quot; ],\r\n    &quot;GeneralRules&quot;: &#x5B;\r\n      {\r\n        &quot;Endpoint&quot;: &quot;*&quot;,\r\n        &quot;Period&quot;: &quot;1s&quot;,\r\n        &quot;Limit&quot;: 2\r\n      },\r\n      {\r\n        &quot;Endpoint&quot;: &quot;*:\/api\/products&quot;,\r\n        &quot;Period&quot;: &quot;10s&quot;,\r\n        &quot;Limit&quot;: 5\r\n      }\r\n    ]\r\n  }\r\n<\/pre>\n<ol>\n<li>\n<strong>IpRateLimiting<\/strong><br \/>\n&#8216;Startup.cs&#8217; dosyas\u0131nda 3. ad\u0131mda olu\u015fturdu\u011fumuz &#8216;IpRateLimitOptions&#8217; t\u00fcr\u00fcnden konfig\u00fcrasyona kar\u015f\u0131l\u0131k gelen alan\u0131 tarif etmektedir. T\u00fcm rate limit ayarlamalar\u0131n\u0131 bu de\u011fer i\u00e7erisinde belirtece\u011fiz.\n<\/li>\n<li>\n<strong>EnableEndpointRateLimiting<\/strong><br \/>\nUygulamada endpoint seviyesinde rate limit uygulayabilmek i\u00e7in &#8216;true&#8217; de\u011ferini veriyoruz. &#8216;false&#8217; de\u011ferini verdi\u011finiz taktirde limitlerin hepsi global olarak uygulanacak ve endpointlerin hepsi i\u00e7in ge\u00e7erli olacakt\u0131r.\n<\/li>\n<li>\n<strong>StackBlockedRequests<\/strong><br \/>\nBu \u00f6zelli\u011fe bir misal ile yakla\u015f\u0131rsak daha do\u011fru olacakt\u0131r. Varsayal\u0131m ki; uygulaman\u0131za dakikada 60, saatte ise 1000 adet request gelebilece\u011fini belirttiniz. Dakika i\u00e7erisinde 60&#8217;\u0131n \u00fczerinde gelen requestlerin ge\u00e7erli olup olmamas\u0131n\u0131 i\u015fte bu &#8216;StackBlockedRequests&#8217; \u00f6zelli\u011fiyle belirliyorsunuz. &#8216;true&#8217; de\u011ferini verirseniz dakika s\u0131n\u0131r\u0131n\u0131 a\u015fan t\u00fcm requestler saat s\u0131n\u0131r\u0131nda d\u00fc\u015f\u00fclecek aksi taktirde(false) dakika ve saat kendi s\u0131n\u0131rlar\u0131nda de\u011ferlendirilecektir.\n<\/li>\n<li>\n<strong>HttpStatusCode<\/strong><br \/>\nRate limit a\u015f\u0131ld\u0131\u011f\u0131 taktirde hangi t\u00fcr durum kodu d\u00f6nd\u00fcr\u00fclece\u011fi belirtilmektedir. &#8216;429&#8217; standart olarak rate limit hatas\u0131d\u0131r.\n<\/li>\n<li>\n<strong>IpWhitelist<\/strong><br \/>\nRate limitten muaf tutulacak IP adreslerini belirtiyoruz.\n<\/li>\n<li>\n<strong>EndpointWhitelist<\/strong><br \/>\nRate limitten muaf tutulacak endpointleri belirtiyoruz. Burada <code style=\"color:blue;\"><strong style=\"color:red;\">http_function<\/strong>:\/<strong>endpoint<\/strong><\/code> format\u0131na dikkat etmenizi \u00f6neririm. E\u011fer ki herhangi bir HTTP fonksiyonu belirtilmeyecekse * ifadesi kullan\u0131larak t\u00fcm\u00fc ifade edilebilir.\n<\/li>\n<li>\n<strong>GeneralRules<\/strong><br \/>\nGenel rate limit kurallar\u0131n\u0131 belirtiyoruz.<\/p>\n<p>\u0130\u00e7erisinde &#8216;Endpoint&#8217;, &#8216;Period&#8217; ve &#8216;Limit&#8217; bilgilerini bar\u0131nd\u0131ran nesneler ile rate limit ayarlar\u0131 girilmekte ve istek hacmi belirtilmektedir. Her bir nesne bir HTTP iste\u011fine uygun olarak tasarlanmaktad\u0131r.<\/p>\n<ul>\n<li><strong style=\"font-size:12px;\">&#8216;Endpoint&#8217;<\/strong>, rate limit uygulanacak endpointi ifade etmektedir. A\u015fa\u011f\u0131daki formatlardan herhangi birinde de\u011fer alabilmektedir;<br \/>\n<code>*<\/code> : T\u00fcm endpointlere kar\u015f\u0131l\u0131k gelmektedir.<br \/>\n<code>*:\/api\/products<\/code> : \/api\/products endpointindeki herhangi bir HTTP t\u00fcr\u00fcnden actiona kar\u015f\u0131l\u0131k gelmektedir.<br \/>\n<code>*:\/api\/products\/*<\/code> : \u0130lgili endpointteki t\u00fcm actionlara kar\u015f\u0131l\u0131k gelmektedir.\n<\/li>\n<li><strong style=\"font-size:12px;\">&#8216;Period&#8217;<\/strong>, belirtilen rate limitin ne kadar s\u00fcreli\u011fine ge\u00e7erli oldu\u011funu tutmaktad\u0131r.<br \/>\n<code>s : Saniye<br \/>\nm : Dakika<br \/>\nh : Saat<\/code>\n<\/li>\n<li><strong style=\"font-size:12px;\">&#8216;Limit&#8217;<\/strong>, rate limit de\u011feridir.<\/li>\n<\/ul>\n<p>Yukar\u0131da tan\u0131mlanan kurallar\u0131 ele al\u0131rsak e\u011fer;<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\n      {\r\n        &quot;Endpoint&quot;: &quot;*&quot;,\r\n        &quot;Period&quot;: &quot;1s&quot;,\r\n        &quot;Limit&quot;: 2\r\n      },\r\n      {\r\n        &quot;Endpoint&quot;: &quot;*:\/api\/products&quot;,\r\n        &quot;Period&quot;: &quot;10s&quot;,\r\n        &quot;Limit&quot;: 5\r\n      }\r\n<\/pre>\n<p>Uygulamadaki t\u00fcm endpointlerin &#8216;1&#8217; saniyede en fazla &#8216;2&#8217; request alaca\u011f\u0131n\u0131 ve &#8216;\/api\/products&#8217; endpointine g\u00f6nderilen t\u00fcm HTTP isteklerinde ise &#8217;10&#8217; saniyede &#8216;5&#8217; request alaca\u011f\u0131n\u0131 ifade etmektedir.\n<\/li>\n<\/ol>\n<p>T\u00fcm bu i\u015flemlerden sonra &#8216;Program.cs&#8217; dosyas\u0131nda IP politikalar\u0131n\u0131n a\u015fa\u011f\u0131daki gibi seed edilmesi gerekmektedir.<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\n        async public static Task Main(string&#x5B;] args)\r\n        {\r\n            using IHost webHost = CreateHostBuilder(args).Build();\r\n            IIpPolicyStore IpPolicy = webHost.Services.GetRequiredService&lt;IIpPolicyStore&gt;();\r\n            await IpPolicy.SeedAsync();\r\n            await webHost.RunAsync();\r\n        }\r\n<\/pre>\n<p>Yap\u0131lan bu \u00e7al\u0131\u015fmay\u0131 test edersek e\u011fer;<br \/>\n<a href=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2020\/05\/Asp.NET-Core-Rate-Limit-\u0130le-API-G\u00fcvencesi-Sa\u011flama-1.gif\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2020\/05\/Asp.NET-Core-Rate-Limit-\u0130le-API-G\u00fcvencesi-Sa\u011flama-1.gif\" alt=\"Asp.NET Core - Rate Limit \u0130le API G\u00fcvencesi Sa\u011flama\" width=\"350\" height=\"350\" class=\"alignleft size-full wp-image-15729\" \/><\/a><br \/>\nYandaki g\u00f6rseli incelerken yap\u0131lan istek neticesinde gelen header&#8217;a g\u00f6z atarsan\u0131z e\u011fer uygulanan kural\u0131n periyoduna kar\u015f\u0131l\u0131k gelen <em style=\"color:orange;\">&#8216;X-Rate-Limit-Limit&#8217;<\/em> de\u011ferini, kalan istek adedine kar\u015f\u0131l\u0131k gelen <em style=\"color:orange;\">&#8216;X-Rate-Limit-Remaining&#8217;<\/em> de\u011ferini ve kural\u0131n hangi tarihe kadar ge\u00e7erli oldu\u011funu ifade eden <em style=\"color:orange;\">&#8216;X-Rate-Limit-Reset&#8217;<\/em> de\u011ferini g\u00f6receksiniz. Kuralda belirtilen istek hacmi a\u015f\u0131ld\u0131\u011f\u0131 taktirde <em style=\"color:orange;\">&#8216;Retry-After&#8217;<\/em> de\u011feri ile bir sonraki iste\u011fin ne kadarl\u0131k bir periyot sonras\u0131nda yap\u0131laca\u011f\u0131 da bildirilmektedir. Dolay\u0131s\u0131yla belirtilen kurallar \u00e7er\u00e7evesinde uygulamaya gelen istekler bu \u015fekilde s\u0131n\u0131rland\u0131r\u0131lmakta ve g\u00fcvenlik sa\u011flanmaktad\u0131r.<\/p>\n<p><strong>RateLimitPolicies \u0130le Genel Kurallar\u0131 Ge\u00e7ersiz K\u0131lmak<\/strong><br \/>\n&#8216;Startup.cs&#8217; dosyas\u0131na 4. ad\u0131mda ekledi\u011fimiz &#8216;IpRateLimitPolicies&#8217; konfig\u00fcrasyonuna kar\u015f\u0131l\u0131k \u00f6zelle\u015ftirilmi\u015f rate limit politikalar\u0131n\u0131 a\u015fa\u011f\u0131daki gibi tan\u0131mlayabilirsiniz.<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\n  &quot;IpRateLimitPolicies&quot;: {\r\n    &quot;IpRules&quot;: &#x5B;\r\n      {\r\n        &quot;Ip&quot;: &quot;::1&quot;,\r\n        &quot;Rules&quot;: &#x5B;\r\n          {\r\n            &quot;Endpoint&quot;: &quot;*&quot;,\r\n            &quot;Period&quot;: &quot;10m&quot;,\r\n            &quot;Limit&quot;: 1500\r\n          }\r\n        ]\r\n      },\r\n      {\r\n        &quot;Ip&quot;: &quot;192.168.24.25&quot;,\r\n        &quot;Rules&quot;: &#x5B;\r\n          {\r\n            &quot;Endpoint&quot;: &quot;*:\/api\/products&quot;,\r\n            &quot;Period&quot;: &quot;55s&quot;,\r\n            &quot;Limit&quot;: 21\r\n          },\r\n          {\r\n            &quot;Endpoint&quot;: &quot;Get:\/api\/employees&quot;,\r\n            &quot;Period&quot;: &quot;21h&quot;,\r\n            &quot;Limit&quot;: 100000\r\n          }\r\n        ]\r\n      }\r\n    ]\r\n  }\r\n<\/pre>\n<ol>\n<li>\n<strong>IpRateLimitPolicies<\/strong><br \/>\nBiraz \u00f6nce bahsedildi\u011fi gibi &#8216;Startup.cs&#8217;de &#8216;IpRateLimitPolicies&#8217; t\u00fcr\u00fcne kar\u015f\u0131l\u0131k olu\u015fturulan konfig\u00fcrasyondur.\n<\/li>\n<li>\n<strong>IpRules<\/strong><br \/>\nIP bazl\u0131 tan\u0131mlanacak olan kurallar\u0131 i\u00e7erisinde bar\u0131nd\u0131ran koleksiyondur. Nesnel olarak i\u00e7erisinde olu\u015fturulacak kurala ait ip de\u011ferini tutacak olan &#8216;Ip&#8217; ve bu ip de\u011ferine ait kurallar\u0131 ta\u015f\u0131yacak olan &#8216;Rules&#8217; \u00f6zelliklerini bar\u0131nd\u0131ran nesneler tutmaktad\u0131r. Yukar\u0131daki \u00f6rne\u011fi inceleyip misal olarak &#8216;192.168.24.25&#8217; IP de\u011ferine sahip olan client\u0131 ele al\u0131rsak e\u011fer biri &#8216;prodocuts&#8217; bir di\u011feri de &#8217;employees&#8217; olmak \u00fczere iki endpointe&#8217;de istek geldi\u011finde s\u0131ras\u0131yla &#8217;55&#8217; saniyede &#8217;21&#8217; istek, &#8217;21&#8217; saatte ise &#8216;100000&#8217; istek yapabilecek bir hacme sahip olaca\u011f\u0131 belirtilmi\u015ftir.\n<\/li>\n<\/ol>\n<p>&#8216;appsettings.json&#8217; dosyas\u0131 i\u00e7erisinde tan\u0131mlanan bu &#8216;IpRateLimiting&#8217; ile &#8216;IpRateLimitPolicies&#8217; konfig\u00fcrasyonlar\u0131n\u0131 b\u00fct\u00fcnsel a\u00e7\u0131dan g\u00f6rebilmek i\u00e7in nihai i\u00e7eri\u011fi komple a\u015fa\u011f\u0131ya alal\u0131m.<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\n  &quot;IpRateLimiting&quot;: {\r\n    &quot;EnableEndpointRateLimiting&quot;: true,\r\n    &quot;StackBlockedRequests&quot;: false,\r\n    &quot;HttpStatusCode&quot;: 429,\r\n    &quot;IpWhitelist&quot;: &#x5B; &quot;127.0.0.12&quot; ],\r\n    &quot;EndpointWhitelist&quot;: &#x5B; &quot;*:\/api\/customers&quot; ],\r\n    &quot;GeneralRules&quot;: &#x5B;\r\n      {\r\n        &quot;Endpoint&quot;: &quot;*&quot;,\r\n        &quot;Period&quot;: &quot;1s&quot;,\r\n        &quot;Limit&quot;: 2\r\n      },\r\n      {\r\n        &quot;Endpoint&quot;: &quot;*:\/api\/products&quot;,\r\n        &quot;Period&quot;: &quot;10s&quot;,\r\n        &quot;Limit&quot;: 5\r\n      }\r\n    ]\r\n  },\r\n  &quot;IpRateLimitPolicies&quot;: {\r\n    &quot;IpRules&quot;: &#x5B;\r\n      {\r\n        &quot;Ip&quot;: &quot;::1&quot;,\r\n        &quot;Rules&quot;: &#x5B;\r\n          {\r\n            &quot;Endpoint&quot;: &quot;*&quot;,\r\n            &quot;Period&quot;: &quot;10m&quot;,\r\n            &quot;Limit&quot;: 1500\r\n          }\r\n        ]\r\n      },\r\n      {\r\n        &quot;Ip&quot;: &quot;192.168.24.25&quot;,\r\n        &quot;Rules&quot;: &#x5B;\r\n          {\r\n            &quot;Endpoint&quot;: &quot;*:\/api\/products&quot;,\r\n            &quot;Period&quot;: &quot;55s&quot;,\r\n            &quot;Limit&quot;: 21\r\n          },\r\n          {\r\n            &quot;Endpoint&quot;: &quot;Get:\/api\/employees&quot;,\r\n            &quot;Period&quot;: &quot;21h&quot;,\r\n            &quot;Limit&quot;: 100000\r\n          }\r\n        ]\r\n      }\r\n    ]\r\n  }\r\n<\/pre>\n<blockquote><p><em style=\"color:green;\">Rate limit konfig\u00fcrasyonlar\u0131nda \u00f6zel ya da genel farketmeksizin kurallar a\u00e7\u0131s\u0131ndan t\u00fcmdengelimsel bir kontrol s\u00f6z konusudur.<\/em><\/p><\/blockquote>\n<p><strong>Limit A\u015f\u0131ld\u0131\u011f\u0131nda Verilecek Mesajlar\u0131 QuotaExceededResponse \u0130le \u00d6zelle\u015ftirme<\/strong><br \/>\nBir endpointe yap\u0131lan istek neticesinde rate limit hacmi a\u015f\u0131l\u0131yorsa e\u011fer a\u015fa\u011f\u0131daki hatay\u0131 d\u00f6nd\u00fcrecektir;<\/p>\n<div style=\"text-align:center;color:red;\">\n<strong>API calls quota exceeded! maximum admitted 2 per 3s.<\/strong>\n<\/div>\n<p>Sizler iste\u011finiz do\u011frultusunda QuotaExceededResponse \u00f6zelli\u011fi ile hatalar\u0131 \u00f6zelle\u015ftirebilirsiniz. Bunun i\u00e7in ilgili \u00f6zelli\u011fin &#8216;IpRateLimiting&#8217; alan\u0131 i\u00e7erisinde a\u015fa\u011f\u0131daki gibi tan\u0131mlanmas\u0131 yeterlidir.<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\n    &quot;QuotaExceededResponse&quot;: {\r\n      &quot;Content&quot;: &quot;{{ \\&quot;message\\&quot;: \\&quot;istek limiti asilmistir.\\&quot;, \\&quot;details\\&quot;: \\&quot;kota asildi. {1} basina {0} istek yapabilirsiniz. lutfen {2} saniye icerisinde tekrar deneyiniz.\\&quot; }}&quot;,\r\n      &quot;ContentType&quot;: &quot;application\/json&quot;,\r\n      &quot;StatusCode&quot;: 429\r\n    }\r\n<\/pre>\n<p>Yukar\u0131daki kodu detayland\u0131r\u0131rsak e\u011fer;<\/p>\n<ul>\n<li><strong>Content<\/strong><br \/>\nLimit a\u015f\u0131m\u0131 durumunda kullan\u0131c\u0131ya verilecek olan mesaj\u0131 bar\u0131nd\u0131ran \u00f6zelliktir. Mesaj i\u00e7erisinde s\u00fcsl\u00fc parantez ile yap\u0131lan bildiriler a\u015fa\u011f\u0131daki \u00f6zelliklere kar\u015f\u0131l\u0131k gelmektedir.<br \/>\n{0} : Limit<br \/>\n{1} : Periyot<br \/>\n{2} : Kalan s\u00fcre(Retry-After)\n<\/li>\n<li><strong>ContentType<\/strong><br \/>\nMesaj\u0131n format\u0131n\u0131 bildirmektedir.\n<\/li>\n<li><strong>StatusCode<\/strong><br \/>\nHata kodunu 429 de\u011feriyle rate limit a\u015f\u0131m\u0131 oldu\u011funu bildirmektedir.\n<\/li>\n<\/ul>\n<p>Yap\u0131lan bu konfig\u00fcrasyon neticesinde istek hacminin a\u015f\u0131ld\u0131\u011f\u0131 esnada a\u015fa\u011f\u0131daki g\u00f6rseldeki gibi mesaj al\u0131nacakt\u0131r.<br \/>\n<a href=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2020\/05\/Asp.NET-Core-Rate-Limit-\u0130le-API-G\u00fcvencesi-Sa\u011flama-2.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2020\/05\/Asp.NET-Core-Rate-Limit-\u0130le-API-G\u00fcvencesi-Sa\u011flama-2.jpg\" alt=\"Asp.NET Core - Rate Limit \u0130le API G\u00fcvencesi Sa\u011flama\" width=\"811\" height=\"396\" class=\"aligncenter size-full wp-image-15762\" srcset=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2020\/05\/Asp.NET-Core-Rate-Limit-\u0130le-API-G\u00fcvencesi-Sa\u011flama-2.jpg 811w, https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2020\/05\/Asp.NET-Core-Rate-Limit-\u0130le-API-G\u00fcvencesi-Sa\u011flama-2-300x146.jpg 300w, https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2020\/05\/Asp.NET-Core-Rate-Limit-\u0130le-API-G\u00fcvencesi-Sa\u011flama-2-768x375.jpg 768w\" sizes=\"auto, (max-width: 811px) 100vw, 811px\" \/><\/a><\/p>\n<p>Evet&#8230; IP Rate Limit ile istek hacminin konfig\u00fcrasyonunun nas\u0131l ger\u00e7ekle\u015ftirildi\u011fini g\u00f6rm\u00fc\u015f olduk. \u015eimdi s\u0131ra Client ID Rate Limit yap\u0131lanmas\u0131n\u0131 incelemeye gelmi\u015ftir.<\/p>\n<h3 style=\"color:purple;\">Client ID Rate Limit Yap\u0131lanmas\u0131 ve Konfig\u00fcrasyonu<\/h3>\n<p>Client Id Rate Limit ger\u00e7ekle\u015ftirebilmek i\u00e7in \u00f6ncelikle &#8216;Startup.cs&#8217; dosyas\u0131nda a\u015fa\u011f\u0131daki gibi konfig\u00fcrasyonlar\u0131n ger\u00e7ekle\u015ftirilmesi gerekmektedir.<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\n    public class Startup\r\n    {\r\n        IConfiguration Configuration;\r\n        public Startup(IConfiguration configuration)\r\n        {\r\n            Configuration = configuration;\r\n        }\r\n        public void ConfigureServices(IServiceCollection services)\r\n        {\r\n            services.AddOptions();\r\n            services.AddMemoryCache();\r\n            services.Configure&lt;ClientRateLimitOptions&gt;(Configuration.GetSection(&quot;ClientRateLimiting&quot;));\r\n            services.Configure&lt;ClientRateLimitPolicies&gt;(Configuration.GetSection(&quot;ClientRateLimitPolicies&quot;));\r\n            services.AddSingleton&lt;IClientPolicyStore, MemoryCacheClientPolicyStore&gt;();\r\n            services.AddSingleton&lt;IRateLimitCounterStore, MemoryCacheRateLimitCounterStore&gt;();\r\n            services.AddHttpContextAccessor();\r\n            services.AddSingleton&lt;IRateLimitConfiguration, RateLimitConfiguration&gt;();\r\n            services.AddControllers();\r\n        }\r\n\r\n        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)\r\n        {\r\n            if (env.IsDevelopment())\r\n                app.UseDeveloperExceptionPage();\r\n            app.UseClientRateLimiting();\r\n            app.UseRouting();\r\n            app.UseEndpoints(endpoints =&gt; endpoints.MapControllers());\r\n        }\r\n    }\r\n<\/pre>\n<p>Dikkat edilirse bu konfig\u00fcrasyonlar\u0131n her biri &#8216;IP Rate Limit&#8217;in muadili olan &#8216;Client ID Rate Limit&#8217; kar\u015f\u0131l\u0131klar\u0131d\u0131r.<\/p>\n<p>Ayr\u0131ca &#8216;Program.cs&#8217;, i\u00e7erisinde ip rate limit i\u00e7in yap\u0131lan konfig\u00fcrasyonlar olmaks\u0131z\u0131n sade bir \u015fekilde tasarlanm\u0131\u015f olmas\u0131 gerekmektedir.<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\n        async public static Task Main(string&#x5B;] args)\r\n        {\r\n            CreateHostBuilder(args).Build().Run();\r\n        }\r\n<\/pre>\n<p>Bu i\u015flemlerden sonra &#8216;appsettings.json&#8217; i\u00e7eri\u011fine gelirsek e\u011fer;<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\n  &quot;ClientRateLimiting&quot;: {\r\n    &quot;EnableEndpointRateLimiting&quot;: true,\r\n    &quot;StackBlockedRequests&quot;: false,\r\n    &quot;HttpStatusCode&quot;: 429,\r\n    &quot;IpWhitelist&quot;: &#x5B; &quot;127.0.0.12&quot; ],\r\n    &quot;EndpointWhitelist&quot;: &#x5B; &quot;*:\/api\/customers&quot; ],\r\n    &quot;ClientIdHeader&quot;: &quot;x-clientId&quot;,\r\n    &quot;ClientWhiteList&quot;: &#x5B; &quot;client-1&quot; ],\r\n    &quot;GeneralRules&quot;: &#x5B;\r\n      {\r\n        &quot;Endpoint&quot;: &quot;*&quot;,\r\n        &quot;Period&quot;: &quot;3s&quot;,\r\n        &quot;Limit&quot;: 2\r\n      },\r\n      {\r\n        &quot;Endpoint&quot;: &quot;*:\/api\/products&quot;,\r\n        &quot;Period&quot;: &quot;10s&quot;,\r\n        &quot;Limit&quot;: 5\r\n      }\r\n    ],\r\n    &quot;QuotaExceededResponse&quot;: {\r\n      &quot;Content&quot;: &quot;{{ \\&quot;message\\&quot;: \\&quot;istek limiti asilmistir.\\&quot;, \\&quot;details\\&quot;: \\&quot;kota asildi. {1} basina {0} istek yapabilirsiniz. lutfen {2} saniye icerisinde tekrar deneyiniz.\\&quot; }}&quot;,\r\n      &quot;ContentType&quot;: &quot;application\/json&quot;,\r\n      &quot;StatusCode&quot;: 429\r\n    }\r\n  },\r\n  &quot;ClientRateLimitPolicies&quot;: {\r\n    &quot;IpRules&quot;: &#x5B;\r\n      {\r\n        &quot;Ip&quot;: &quot;::1&quot;,\r\n        &quot;Rules&quot;: &#x5B;\r\n          {\r\n            &quot;Endpoint&quot;: &quot;*&quot;,\r\n            &quot;Period&quot;: &quot;4s&quot;,\r\n            &quot;Limit&quot;: 3\r\n          }\r\n        ]\r\n      },\r\n      {\r\n        &quot;Ip&quot;: &quot;192.168.24.25&quot;,\r\n        &quot;Rules&quot;: &#x5B;\r\n          {\r\n            &quot;Endpoint&quot;: &quot;*:\/api\/products&quot;,\r\n            &quot;Period&quot;: &quot;55s&quot;,\r\n            &quot;Limit&quot;: 21\r\n          },\r\n          {\r\n            &quot;Endpoint&quot;: &quot;Get:\/api\/employees&quot;,\r\n            &quot;Period&quot;: &quot;21h&quot;,\r\n            &quot;Limit&quot;: 100000\r\n          }\r\n        ]\r\n      }\r\n    ]\r\n  }\r\n<\/pre>\n<p>\u015feklinde in\u015fa edilmesi yeterlidir. Burada istek yapacak olan client\u0131n; header\u0131nda, 7. sat\u0131rdaki &#8216;ClientIdHeader&#8217; alan\u0131ndaki &#8216;x-clientId&#8217; key&#8217;ine kar\u015f\u0131l\u0131k 8. sat\u0131rdaki &#8216;ClientWhiteList&#8217; alan\u0131ndaki &#8216;client-1&#8217; valuesu bulundu\u011fu taktirde rate limit konfig\u00fcrasyonlar\u0131ndan muaf tutulaca\u011f\u0131n\u0131 aksi taktirde t\u00fcm isteklerde belirtilen s\u0131n\u0131rl\u0131l\u0131klar\u0131n uygulanaca\u011f\u0131n\u0131 bildirmi\u015f bulunmaktay\u0131z.<\/p>\n<p><a href=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2020\/05\/Asp.NET-Core-Rate-Limit-\u0130le-API-G\u00fcvencesi-Sa\u011flama-2.gif\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2020\/05\/Asp.NET-Core-Rate-Limit-\u0130le-API-G\u00fcvencesi-Sa\u011flama-2.gif\" alt=\"Asp.NET Core - Rate Limit \u0130le API G\u00fcvencesi Sa\u011flama\" width=\"800\" height=\"481\" class=\"aligncenter size-full wp-image-15776\" \/><\/a><\/p>\n<p>Evet&#8230; G\u00f6r\u00fcld\u00fc\u011f\u00fc \u00fczere client, header\u0131nda konfig\u00fcrasyondaki ilgili bilgilerle e\u015fle\u015fen key &#8211; value de\u011ferlerine sahip istek g\u00f6nderdi\u011fi taktirde rate limitten muaf tutulmaktad\u0131r. Burada i\u00e7eri\u011fimizin ilk parafraflar\u0131nda de\u011findi\u011fimiz bir duruma tekrardan temas etmemiz gerekirse e\u011fer o da key &#8211; value de\u011ferlerinin k\u00f6t\u00fc niyetli kullan\u0131c\u0131lar taraf\u0131ndan elde edilmesi Client Id Rate Limit&#8217;e ra\u011fmen bir zaafiyet do\u011furacak ve neticede DOS\/DDOS sald\u0131r\u0131lar\u0131yla kar\u015f\u0131la\u015fma olas\u0131 ihtimali artacakt\u0131r.<\/p>\n<p>O y\u00fczden static IP&#8217;lerin s\u00f6z konusu oldu\u011fu t\u00fcm \u00e7al\u0131\u015fmalarda IP Rate Limit yakla\u015f\u0131m\u0131n\u0131n tercih edilmesini \u015fiddetle tavsiye ederim&#8230;<\/p>\n<p>B\u00f6ylece Asp.NET Core WEB API uygulamalar\u0131nda t\u00fcm a\u00e7\u0131lar\u0131yla Rate Limit konfig\u00fcrasyonlar\u0131n\u0131n nas\u0131l ger\u00e7ekle\u015ftirildi\u011fini incelemi\u015f olduk. Umar\u0131m s\u0131k\u0131lmadan t\u00fcketirsiniz \ud83d\ude42<\/p>\n<p>\u0130lgilenenlerin faydalanmas\u0131 dile\u011fiyle&#8230;<br \/>\nSonraki yaz\u0131lar\u0131mda g\u00f6r\u00fc\u015fmek \u00fczere&#8230;<br \/>\n\u0130yi \u00e7al\u0131\u015fmalar&#8230;<\/p>\n<p>Not : \u00d6rnek projeyi indirmek i\u00e7in <a href=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2020\/05\/RateLimitExample.zip\">buraya<\/a> t\u0131klay\u0131n\u0131z.<\/p>\n<!-- AddThis Advanced Settings generic via filter on the_content --><!-- AddThis Share Buttons generic via filter on the_content -->","protected":false},"excerpt":{"rendered":"<p>Merhaba, Asp.NET Core API ile tasarlanm\u0131\u015f bir endpoint&#8217;in normal \u015fartlarda s\u00fcrekli istek alabilecek olarak d\u0131\u015f d\u00fcnyaya a\u00e7\u0131k bir \u015fekilde tasarlanmas\u0131 kadar do\u011fal bir\u015fey olmasa gerek. Lakin bu durum fiili olarak k\u00f6t\u00fc niyetli ki\u015filer taraf\u0131ndan&#46;&#46;&#46;<!-- AddThis Advanced Settings generic via filter on get_the_excerpt --><!-- AddThis Share Buttons generic via filter on get_the_excerpt --><\/p>\n","protected":false},"author":1,"featured_media":15783,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3102,3103],"tags":[3494,3500,3498,3493,3497,3496,3499,3495],"class_list":["post-15657","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-asp-net-core","category-asp-net-core-3-1","tag-asp-net-core-rate-limit","tag-client-id-rate-limit","tag-ddos-attack","tag-denial-of-service-attack","tag-distributed-denial-of-service-attack","tag-dos-attack","tag-ip-rate-limit","tag-rate-limit"],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/posts\/15657","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/comments?post=15657"}],"version-history":[{"count":118,"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/posts\/15657\/revisions"}],"predecessor-version":[{"id":15782,"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/posts\/15657\/revisions\/15782"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/media\/15783"}],"wp:attachment":[{"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/media?parent=15657"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/categories?post=15657"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/tags?post=15657"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}