-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Start work in a auth lib to be used in the api scaffold
- Loading branch information
1 parent
41ce6f2
commit 05775ab
Showing
6 changed files
with
86 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
### Authenticator Tool | ||
|
||
Tool to handle API authentication flows, including JWT token generation, validation, and management. | ||
|
||
### Roadmap | ||
|
||
- [ ] Create a Notion space to manage this project | ||
- [ ] Finish building the AI scaffold suggestion | ||
- [ ] Discover how to publish the library | ||
- [ ] Discover how to use a local version of the library | ||
- [ ] Add the library to the API project | ||
- [ ] Implement an authentication flow in the API using the Auth library | ||
|
||
|
||
### References | ||
- [My Notion JSON Web Tokens](https://www.notion.so/fernando-avanzo/Doc-JSON-Web-Tokens-125b3def3e7c80099293f2b8ec520b9b?pvs=4) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
plugins { | ||
kotlin("jvm") version "2.0.21" | ||
`maven-publish` | ||
} | ||
|
||
group = "avanzo.ktor.auth" | ||
version = "1.0.0" | ||
|
||
repositories { | ||
mavenCentral() | ||
} | ||
|
||
dependencies { | ||
implementation("io.ktor:ktor-server-auth:2.3.0") | ||
implementation("io.ktor:ktor-server-auth-jwt:2.3.0") | ||
testImplementation(kotlin("test")) | ||
} | ||
|
||
publishing { | ||
publications { | ||
create<MavenPublication>("mavenJava") { | ||
from(components["java"]) | ||
} | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
authenticator/src/main/kotlin/avanzo/ktor/auth/JwtConfig.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package avanzo.ktor.auth | ||
|
||
import com.auth0.jwt.algorithms.Algorithm | ||
|
||
|
||
data class JwtConfig( | ||
val realm: String, | ||
val issuer: String, | ||
val secret: String, | ||
val audience: String, | ||
val expiration: Long // in milliseconds | ||
) { | ||
val algorithm: Algorithm = Algorithm.HMAC256(secret) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# Scripts to help with boring tasks |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#!/bin/bash | ||
set -euo pipefail | ||
|
||
declare -r ROOT="$HOME/Projects/ktor-api-scaffold" | ||
declare module=${1-"invalid path"} | ||
|
||
|
||
if [ "$module" != "invalid path" ]; then | ||
# Rest of your commands go here | ||
declare -r module="$ROOT/$module" | ||
|
||
if [ -d "$module" ]; then | ||
# Run your remaining commands here | ||
mkdir -p "$module/src/main/kotlin" | ||
mkdir -p "$module/src/main/resources" | ||
mkdir -p "$module/src/test/kotlin" | ||
mkdir -p "$module/src/test/resources" | ||
|
||
else | ||
echo "Error: The provided path '$module' is not a valid folder." | ||
exit 1 | ||
fi | ||
|
||
else | ||
echo "Path invalid" | ||
exit 1 | ||
fi |