JWT with ASP.NET Core

JSON Web Tokens are convenient ways to do authentication and authorization on the server.

Some of the benefits of JWTs are:

  • It can be consumed by a wider range of clients. In fact by any end-point who can understand HTTP (unline cookies which can be consumed mostly only by browsers).
  • You only query the database first time to retrieve them and then you keep using them to authenticate as well as authorize the user.
  • You can ask 3rd party identity providers to authenticate your users on your behalf and assign tokens to them.

In microservices architecture, you would probably have a separate Authorization service using Identity Server or such.

But .NET core can efficiently handle this task as well.

Let’s explore that.

Docker – Introduction

As developers, we used to install virtual machines to use as development sandbox or install software in the different environment or OS as our local machine. However, virtual machines consume a lot of our local resources and each installation required lots of efforts and time.

Containers, on the other hand, are much more flexible and faster, require a lot less local machine resource and are easier to distribute.

Practical React – Chapter 1

Hello React

The simplest way to create a React app is by adding React scripts to an HTML page.

You need to include react.js and react-dom.js to page Header (use the minified version when deploying to the production environment):

<script src="https://fb.me/react-0.14.3.js"></script>
<script src="https://fb.me/react-dom-0.14.3.js"></script>

Next, include your own app.js file at the bottom of your HTML page and before the closing Body tag.

<script src="./scripts/app.js"></script>

JavaScript bundling and minification in ASP.NET MVC

Continuing on JavaScript modules: file structure and unification to create a ASP.NET MVC bundle you should follow these steps:

Under “App_Start” folder add a new class and call it: “BundleConfig.cs”. Add a public method “RegisterBundles” to this class.

public class BundleConfig
{
    public static void RegisterBundles(BundleCollection bundles)
    {
         // code ...
    }
}

Magic of Polymorphism in Avoiding If conditions

You may have faced with situations that you need to make a lot of decisions based on an unknown (runtime) situation. You might have used if-then-else or switch-case statements to implement the code.

Probably the worst thing about conditional statements is that they are difficult to maintain. For any future changes, you have to come and alter the code.

Objects or entities should be open for extension, but closed for modification.

Open-closed Principle

Conditional statements are easy to write because that’s how our brains work but are often difficult to read. Especially when there are many conditions or when we make them nested.

Pagination


© 2019. All rights reserved.