Authentication in Ktor Server using form data

Aleksei Novikov
4 min readJun 6, 2020

Ktor is a modern asynchronous web framework using Kotlin language. It includes a bunch of features and can be a server or a client, and both at the same time.

It follows a popular tendency to be lightweight and gain its functionality including features explicitly. It makes you feel that you are in full control and “magic” doesn’t happen.

Like other features, authentication is one of them and must be included and enabled explicitly. So, today, we will take a look at how to implement a simple login and user session functionality to keep control and secure our endpoints.

First of all, let's create a new Gradle project and add some Ktor’s dependencies to get it to provide us everything we are going to need.

Now, when we have all the dependencies included, let’s start to configure our application. We start with main and application module:

--

--