Challenge: Adding a Secure Chat Channel

Test yourself by securing an online chat communication.

We'll cover the following

Overview

In the playground, at the end of the lesson, you must apply security to a SignalR channel by fulfilling the requirements below.

Requirements

The following playground contains a basic chat application. You can register under an arbitrary user name and send messages to any other users.

However, there is a problem with the application because, at the moment, it doesn't work. Nothing happens if you try to perform any actions, whether to register a user or send a message. This is because all SignalR hub endpoints only accept requests from authenticated users while the page is accessed anonymously. Therefore, your first goal is to figure out how to authenticate the user interface so all the calls to the SignalR hub are authenticated too.

The application has another problem. Although the security restrictions on the SignalR hub work, they haven't been implemented in the most efficient manner. You must explore the hub, figure out how the security enforcement elements can be refactored, and then perform them.

In the end, the security restrictions should remain functionally identical. All methods in the SignalR hub should remain accessible only to authenticated users.

Get hands-on with 1400+ tech skills courses.