Implementation of the authentication feature for the Okta JWT verifier.
Written in Kotlin with ❤️
Install the Authentication feature in your application and call okta()
install(Authentication){
okta("https://{yourOktaDomain}/oauth2/default", "api://default", name="apiV1"){
connectionTimeout = 1000
readTimeout = 1000
realm = "Ktor Server"
}
}
Then put your routes in the according auth name:
routing {
route("whatev") { ... }
route("api){
authenticate("apiV1"){
route("v1"){ ... }
}
}
}
Add the JitPack.io repository to the project build.grade
:
repositories {
maven { url 'https://jitpack.io' }
}
Then import the latest version in the build.gradle
of the modules you need:
dependencies {
implementation 'com.github.lamba92:ktor-okta-jwt:{latest_version}'
}
If using Gradle Kotlin DSL:
repositories {
maven(url = "https://jitpack.io")
}
...
dependencies {
implementation("com.github.lamba92", "ktor-okta-jwt", "{latest_version}")
}
For Maven:
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
...
<dependency>
<groupId>com.github.Lamba92</groupId>
<artifactId>ktor-okta-jwt</artifactId>
<version>{latest_version}</version>
</dependency>