update dependencies
This commit is contained in:
@@ -5,17 +5,18 @@ application {
|
|||||||
mainClass.set("com.infendro.account.ApplicationKt")
|
mainClass.set("com.infendro.account.ApplicationKt")
|
||||||
}
|
}
|
||||||
|
|
||||||
repositories {
|
|
||||||
maven("https://git.infendro.com/api/packages/Infendro/maven")
|
|
||||||
mavenCentral()
|
|
||||||
}
|
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
|
alias(libs.plugins.infendro)
|
||||||
alias(libs.plugins.kotlin)
|
alias(libs.plugins.kotlin)
|
||||||
alias(libs.plugins.ktor)
|
alias(libs.plugins.ktor)
|
||||||
alias(libs.plugins.serialization)
|
alias(libs.plugins.serialization)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
maven("https://git.infendro.com/api/packages/Infendro/maven")
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation(libs.ktor.server)
|
implementation(libs.ktor.server)
|
||||||
implementation(libs.ktor.server.cio)
|
implementation(libs.ktor.server.cio)
|
||||||
@@ -31,16 +32,18 @@ dependencies {
|
|||||||
implementation(libs.exposed.jdbc)
|
implementation(libs.exposed.jdbc)
|
||||||
implementation(libs.migration)
|
implementation(libs.migration)
|
||||||
implementation(libs.postgres)
|
implementation(libs.postgres)
|
||||||
implementation(libs.random)
|
implementation(libs.prng)
|
||||||
implementation(libs.otp)
|
implementation(libs.otp)
|
||||||
implementation(libs.kdf)
|
implementation(libs.kdf)
|
||||||
implementation(libs.hash)
|
implementation(libs.hash)
|
||||||
|
implementation(libs.bytearray)
|
||||||
implementation(libs.encoding)
|
implementation(libs.encoding)
|
||||||
implementation(libs.logback)
|
implementation(libs.logback)
|
||||||
}
|
}
|
||||||
|
|
||||||
kotlin {
|
kotlin {
|
||||||
compilerOptions {
|
compilerOptions {
|
||||||
|
freeCompilerArgs.add("-opt-in=kotlin.ExperimentalUnsignedTypes")
|
||||||
freeCompilerArgs.add("-opt-in=kotlin.time.ExperimentalTime")
|
freeCompilerArgs.add("-opt-in=kotlin.time.ExperimentalTime")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,17 +1,20 @@
|
|||||||
[versions]
|
[versions]
|
||||||
kotlin = "2.2.10"
|
infendro = "1.0.0"
|
||||||
ktor = "3.2.3"
|
kotlin = "2.2.21"
|
||||||
|
ktor = "3.3.3"
|
||||||
exposed = "0.61.0"
|
exposed = "0.61.0"
|
||||||
migration = "1.1.0"
|
migration = "1.1.0"
|
||||||
postgres = "42.7.5"
|
postgres = "42.7.8"
|
||||||
random = "1.0.0"
|
prng = "1.2.0"
|
||||||
otp = "1.1.1"
|
otp = "1.2.0"
|
||||||
kdf = "1.0.3"
|
kdf = "1.0.3"
|
||||||
hash = "1.2.2"
|
hash = "1.3.2"
|
||||||
encoding = "1.1.0"
|
bytearray = "1.2.4"
|
||||||
logback = "1.5.18"
|
encoding = "1.2.0"
|
||||||
|
logback = "1.5.22"
|
||||||
|
|
||||||
[plugins]
|
[plugins]
|
||||||
|
infendro = { id = "com.infendro.plugin", version.ref = "infendro" }
|
||||||
kotlin = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
|
kotlin = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
|
||||||
ktor = { id = "io.ktor.plugin", version.ref = "ktor" }
|
ktor = { id = "io.ktor.plugin", version.ref = "ktor" }
|
||||||
serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" }
|
serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" }
|
||||||
@@ -30,13 +33,14 @@ ktor-server-validation = { module = "io.ktor:ktor-server-request-validation", ve
|
|||||||
exposed = { module = "org.jetbrains.exposed:exposed-core", version.ref = "exposed" }
|
exposed = { module = "org.jetbrains.exposed:exposed-core", version.ref = "exposed" }
|
||||||
exposed-dao = { module = "org.jetbrains.exposed:exposed-dao", version.ref = "exposed" }
|
exposed-dao = { module = "org.jetbrains.exposed:exposed-dao", version.ref = "exposed" }
|
||||||
exposed-jdbc = { module = "org.jetbrains.exposed:exposed-jdbc", version.ref = "exposed" }
|
exposed-jdbc = { module = "org.jetbrains.exposed:exposed-jdbc", version.ref = "exposed" }
|
||||||
migration = { module = "com.infendro:ktor-migration", version.ref = "migration" }
|
migration = { module = "com.infendro:migration-ktor", version.ref = "migration" }
|
||||||
postgres = { module = "org.postgresql:postgresql", version.ref = "postgres" }
|
postgres = { module = "org.postgresql:postgresql", version.ref = "postgres" }
|
||||||
|
|
||||||
random = { module = "com.infendro:random", version.ref = "random" }
|
prng = { module = "com.infendro:prng", version.ref = "prng" }
|
||||||
otp = { module = "com.infendro:otp", version.ref = "otp" }
|
otp = { module = "com.infendro:otp", version.ref = "otp" }
|
||||||
kdf = { module = "com.infendro:kdf", version.ref = "kdf" }
|
kdf = { module = "com.infendro:kdf", version.ref = "kdf" }
|
||||||
hash = { module = "com.infendro:hash", version.ref = "hash" }
|
hash = { module = "com.infendro:hash", version.ref = "hash" }
|
||||||
|
bytearray = { module = "com.infendro:bytearray", version.ref = "bytearray" }
|
||||||
encoding = { module = "com.infendro:encoding", version.ref = "encoding" }
|
encoding = { module = "com.infendro:encoding", version.ref = "encoding" }
|
||||||
|
|
||||||
logback = { module = "ch.qos.logback:logback-classic", version.ref = "logback" }
|
logback = { module = "ch.qos.logback:logback-classic", version.ref = "logback" }
|
||||||
|
|||||||
@@ -1 +1,7 @@
|
|||||||
rootProject.name = "backend"
|
rootProject.name = "backend"
|
||||||
|
|
||||||
|
pluginManagement.repositories {
|
||||||
|
maven("https://git.infendro.com/api/packages/Infendro/maven")
|
||||||
|
gradlePluginPortal()
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,13 +1,15 @@
|
|||||||
package com.infendro.account.util
|
package com.infendro.account.util
|
||||||
|
|
||||||
import com.infendro.encoding.Hex
|
import com.infendro.bytearray.decodeToString
|
||||||
import com.infendro.hash.SHA256
|
import com.infendro.bytearray.encodeToUByteArray
|
||||||
|
import com.infendro.encoding.Base16
|
||||||
|
import com.infendro.hash.sha2.`SHA-256`
|
||||||
|
|
||||||
object Hasher {
|
object Hasher {
|
||||||
fun hash(
|
fun hash(
|
||||||
value: String,
|
value: String,
|
||||||
): String {
|
): String {
|
||||||
val bytes = SHA256.hash(value.toByteArray())
|
val bytes = `SHA-256`.hash(value.encodeToUByteArray())
|
||||||
return Hex.encode(bytes).decodeToString()
|
return Base16.encode(bytes).decodeToString()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,15 +1,18 @@
|
|||||||
package com.infendro.account.util
|
package com.infendro.account.util
|
||||||
|
|
||||||
|
import com.infendro.bytearray.decodeToString
|
||||||
|
import com.infendro.bytearray.encodeToUByteArray
|
||||||
import com.infendro.encoding.Base32
|
import com.infendro.encoding.Base32
|
||||||
import com.infendro.hash.SHA256
|
import com.infendro.hash.sha2.`SHA-256`
|
||||||
import com.infendro.otp.SecretGenerator
|
import com.infendro.otp.SecretGenerator
|
||||||
import com.infendro.otp.TOTP
|
import com.infendro.otp.TOTP
|
||||||
import kotlin.time.Clock
|
import kotlin.time.Clock
|
||||||
import kotlin.time.Duration.Companion.seconds
|
import kotlin.time.Duration.Companion.seconds
|
||||||
|
|
||||||
object OTP {
|
object OTP {
|
||||||
|
private val generator = SecretGenerator(`SHA-256`)
|
||||||
private val totp = TOTP(
|
private val totp = TOTP(
|
||||||
function = SHA256,
|
function = `SHA-256`,
|
||||||
length = 8,
|
length = 8,
|
||||||
period = 30.seconds,
|
period = 30.seconds,
|
||||||
)
|
)
|
||||||
@@ -18,12 +21,12 @@ object OTP {
|
|||||||
secret: String,
|
secret: String,
|
||||||
otp: String,
|
otp: String,
|
||||||
): Boolean {
|
): Boolean {
|
||||||
val bytes = Base32.decode(secret.toByteArray())
|
val bytes = Base32.decode(secret.encodeToUByteArray())
|
||||||
return totp.verify(bytes, Clock.System.now(), otp)
|
return totp.verify(bytes, Clock.System.now(), otp)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun generateSecret(): String {
|
fun generateSecret(): String {
|
||||||
val bytes = SecretGenerator.generate(totp.hotp.function)
|
val bytes = generator.generate()
|
||||||
return Base32.encode(bytes).decodeToString()
|
return Base32.encode(bytes).decodeToString()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,26 +1,28 @@
|
|||||||
package com.infendro.account.util
|
package com.infendro.account.util
|
||||||
|
|
||||||
import com.infendro.encoding.Hex
|
import com.infendro.bytearray.decodeToString
|
||||||
import com.infendro.hash.SHA256
|
import com.infendro.bytearray.encodeToUByteArray
|
||||||
|
import com.infendro.encoding.Base16
|
||||||
|
import com.infendro.hash.sha2.`SHA-256`
|
||||||
import com.infendro.kdf.PBKDF2
|
import com.infendro.kdf.PBKDF2
|
||||||
import com.infendro.random.PRNG
|
import com.infendro.random.csprng.CSPRNG
|
||||||
|
|
||||||
object SecureHasher {
|
object SecureHasher {
|
||||||
private val random = PRNG.HMAC
|
private val random = CSPRNG.HMAC(`SHA-256`)
|
||||||
private val kdf = PBKDF2(SHA256)
|
private val kdf = PBKDF2(`SHA-256`)
|
||||||
|
|
||||||
fun hash(
|
fun hash(
|
||||||
value: String,
|
value: String,
|
||||||
salt: String,
|
salt: String,
|
||||||
): String {
|
): String {
|
||||||
val value = value.encodeToByteArray()
|
val value = value.encodeToByteArray()
|
||||||
val salt = Hex.decode(salt.encodeToByteArray())
|
val salt = Base16.decode(salt.encodeToUByteArray())
|
||||||
return kdf.hash(value, salt, 100_000, 32)
|
return kdf.hash(value, salt, 100_000, 32)
|
||||||
.let { Hex.encode(it).decodeToString() }
|
.let { Base16.encode(it).decodeToString() }
|
||||||
}
|
}
|
||||||
|
|
||||||
fun generateSalt(): String {
|
fun generateSalt(): String {
|
||||||
return random.nextBytes(16)
|
return random.nextBytes(16)
|
||||||
.let { Hex.encode(it).decodeToString() }
|
.let { Base16.encode(it).decodeToString() }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +1,15 @@
|
|||||||
package com.infendro.account.util
|
package com.infendro.account.util
|
||||||
|
|
||||||
import com.infendro.encoding.Hex
|
import com.infendro.bytearray.decodeToString
|
||||||
import com.infendro.random.PRNG
|
import com.infendro.encoding.Base16
|
||||||
|
import com.infendro.hash.sha2.`SHA-256`
|
||||||
|
import com.infendro.random.csprng.CSPRNG
|
||||||
|
|
||||||
object TokenGenerator {
|
object TokenGenerator {
|
||||||
private val random = PRNG.HMAC
|
private val random = CSPRNG.HMAC(`SHA-256`)
|
||||||
|
|
||||||
fun generate(): String {
|
fun generate(): String {
|
||||||
return random.nextBytes(32)
|
return random.nextBytes(32)
|
||||||
.let { Hex.encode(it).decodeToString() }
|
.let { Base16.encode(it).decodeToString() }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user