File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ # JWT Kotlin Multiplatform - KTOR Server Example
2+
3+ This module contains a simple example for how to use the jwt-kt library for signing and verifying JWTs using an ECDSA key pair and JSON Web Keys.
4+
5+ ## Run
6+
7+ Start the server:
8+ ``` shell
9+ .\g radlew :examples:ktor-server:jvmRun
10+ ```
11+
12+ ### Test
13+
14+ #### JWKS Endpoint:
15+ ``` shell
16+ curl -v http://localhost:8080/.well-known/jwt/jwks.json
17+ ```
18+
19+ #### Login:
20+ ``` shell
21+ curl -v -X POST -H " Content-Type: application/json" http://localhost:8080/login -d ' {"username":"username", "password":"password"}'
22+ ```
23+
24+ This will return an access token.
25+
26+ #### Authenticated Route
27+
28+ Replace ` <TOKEN> ` with the access token from the previous step:
29+ ``` shell
30+ curl -H " Authorization: Bearer <TOKEN>" http://localhost:8080/hello
31+ ```
32+
33+ This should return an HTTPS 200 response. During the lifetime of the token (5 minutes) and an http 401 after expiry.
Original file line number Diff line number Diff line change @@ -19,6 +19,10 @@ kotlin {
1919 mainClass.set(" com.appstractive.ApplicationKt" )
2020 }
2121 }
22+
23+ mainRun {
24+ mainClass.set(" com.appstractive.ApplicationKt" )
25+ }
2226 }
2327
2428 linuxX64().apply {
You can’t perform that action at this time.
0 commit comments