From the course: Transitioning from Java to Kotlin
Unlock the full course today
Join today to access over 24,900 courses taught by industry experts.
Authenticating routes
From the course: Transitioning from Java to Kotlin
Authenticating routes
- [Instructor] We've added the ability to add items to our ProductDatabase. This is very helpful if you're an admin or other team member, but probably not something that should be publicly accessible to anyone. Let's take a look at how basic authentication works in Ktor, so that we may prevent unauthorized access to our endpoints for manipulating the database. Authentication in Ktor is another plugin. So, like other plugins, we'll start by adding the dependency to our project. So, we'll open our build.gradle file, and we will add in a new dependency for ktor-server-auth. And then, we will resync our project. And again, like other plugins, we will create an extension method to configure how authentication should work for our application. So, in our plugins package, we will create a new Kotlin file. And we will name this one Authentication. And we will create our basic extension step. And name the function…
Contents
-
-
-
-
-
-
-
(Locked)
Creating a new Ktor project6m 30s
-
(Locked)
Adding your first route5m 33s
-
(Locked)
Testing your local service6m 41s
-
(Locked)
Adding status pages7m 32s
-
(Locked)
Storing a list of products5m 42s
-
(Locked)
Returning typed responses11m 57s
-
(Locked)
Adding new products5m 38s
-
(Locked)
Authenticating routes7m 57s
-
(Locked)
Challenge: Return all active orders1m 35s
-
(Locked)
Solution: Return all active orders7m 4s
-
(Locked)
-