Auth still in progress
This commit is contained in:
@@ -52,6 +52,5 @@ class AESCryptograph : Cryptograph {
|
||||
companion object {
|
||||
private val CIPHER = "AES/ECB/PKCS5Padding"
|
||||
private val ALGORITHM = "AES"
|
||||
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,6 @@
|
||||
package org.jeudego.pairgoth.util
|
||||
|
||||
object Randomizer {
|
||||
private val validChars = ('a'..'z') + ('A'..'Z') + ('0'..'9')
|
||||
fun randomString(length: Int) = CharArray(length) { validChars.random() }.concatToString()
|
||||
}
|
@@ -0,0 +1,18 @@
|
||||
package org.jeudego.pairgoth.web
|
||||
|
||||
import org.jeudego.pairgoth.util.Randomizer
|
||||
import java.lang.RuntimeException
|
||||
|
||||
|
||||
// a randomly generated secret shared by the API and View webapps
|
||||
val sharedSecret: String by lazy {
|
||||
BaseWebappManager.properties.getProperty("auth.shared_secret") ?: when (BaseWebappManager.properties.getProperty("mode")) {
|
||||
"standalone" -> Randomizer.randomString(16)
|
||||
else -> when (BaseWebappManager.properties.getProperty("auth")) {
|
||||
"none" -> " ".repeat(16)
|
||||
else -> throw RuntimeException("missing property auth.shared_secret")
|
||||
}
|
||||
}.also {
|
||||
if (it.length != 16) throw RuntimeException("shared secret must be 16 ascii chars long")
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user