Securing your .NET Minimal API with JSON Web Tokens (JWT)

Athan Bonis
11 min readJun 30, 2023

Securing a Web Service, was from the beginning of the Internet a crucial and required step before someone exposes the service to the public audience. The same requirement exists also nowadays, and it will exist until the last day of the technology.

Wouldn’t then be great to learn how can we secure our .NET Web API with a very nice approach like JSON Web Tokens?

But what really are the JSON Web Tokens? I Like to think of JWT as a digital passport that carries important details about a user. This digital passport can be validated and trusted by different parts of the system since they are digitally signed by it and thus can be verified.

Stay on the line, to see how we will build a digital passport like this!

In my previous post, I talked about how the Mediator Pattern concepts can help you deal with Cross-Cutting Concerns and have your code clean and fresh.

If you want to have a more comprehensive picture of the journey until this article — about .NET Minimal APIs — you can also read the two previous articles that complete the puzzle:

--

--

Athan Bonis

Ηighly motivated Software Engineer. I have a strong passion for problem-solving and learning new technologies, targeting to produce clean and structured code.