feat: release pipeline and env-supplied server key (#82)
* build: move group and version to gradle.properties * ci: add release-please versioning and release pipeline * feat(server): load the root key from the environment * ci: publish key-free server archives on release
This commit is contained in:
1 parent
8bd065fcb4
commit
dfeabdc581
20 files changed
+291
-33
No files matched your search
@@ -8,10 +8,6 @@ plugins {
|
||||
alias(libs.plugins.ksp)
|
||||
}
|
||||
|
||||
group = "de.fiereu.openmmo"
|
||||
|
||||
version = "0.1.0"
|
||||
|
||||
application { mainClass.set("de.fiereu.openmmo.server.game.MainKt") }
|
||||
|
||||
jooqDb { packageName = "de.fiereu.openmmo.db.game" }
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
package de.fiereu.openmmo.server.game.config
|
||||
|
||||
import com.typesafe.config.Config
|
||||
import com.typesafe.config.ConfigFactory
|
||||
|
||||
private fun Config.stringOrNull(path: String): String? =
|
||||
if (hasPath(path)) getString(path) else null
|
||||
|
||||
object ConfigLoader {
|
||||
fun load(): GameServerConfig {
|
||||
val config = ConfigFactory.load()
|
||||
@@ -12,6 +16,8 @@ object ConfigLoader {
|
||||
port = config.getInt("server.port"),
|
||||
checksumSize = config.getInt("server.checksumSize"),
|
||||
rootKeyResource = config.getString("server.rootKeyResource"),
|
||||
rootKey = config.stringOrNull("server.rootKey"),
|
||||
rootKeyFile = config.stringOrNull("server.rootKeyFile"),
|
||||
sessionSecret = secret.toByteArray(Charsets.UTF_8),
|
||||
db =
|
||||
DbConfig(
|
||||
|
||||
@@ -7,6 +7,8 @@ data class GameServerConfig(
|
||||
val rootKeyResource: String,
|
||||
val sessionSecret: ByteArray,
|
||||
val db: DbConfig = DbConfig(),
|
||||
val rootKey: String? = null,
|
||||
val rootKeyFile: String? = null,
|
||||
) {
|
||||
override fun equals(other: Any?): Boolean =
|
||||
other is GameServerConfig &&
|
||||
@@ -14,6 +16,8 @@ data class GameServerConfig(
|
||||
port == other.port &&
|
||||
checksumSize == other.checksumSize &&
|
||||
rootKeyResource == other.rootKeyResource &&
|
||||
rootKey == other.rootKey &&
|
||||
rootKeyFile == other.rootKeyFile &&
|
||||
sessionSecret.contentEquals(other.sessionSecret) &&
|
||||
db == other.db
|
||||
|
||||
@@ -22,6 +26,8 @@ data class GameServerConfig(
|
||||
h = h * 31 + port
|
||||
h = h * 31 + checksumSize
|
||||
h = h * 31 + rootKeyResource.hashCode()
|
||||
h = h * 31 + rootKey.hashCode()
|
||||
h = h * 31 + rootKeyFile.hashCode()
|
||||
h = h * 31 + sessionSecret.contentHashCode()
|
||||
h = h * 31 + db.hashCode()
|
||||
return h
|
||||
|
||||
@@ -6,7 +6,7 @@ import dagger.Module
|
||||
import dagger.Provides
|
||||
import de.fiereu.openmmo.common.auth.SessionTokenVerifier
|
||||
import de.fiereu.openmmo.common.io.PemKeyLoader
|
||||
import de.fiereu.openmmo.common.io.resource
|
||||
import de.fiereu.openmmo.common.io.pemStream
|
||||
import de.fiereu.openmmo.server.game.config.GameServerConfig
|
||||
import de.fiereu.openmmo.server.game.script.ScriptRegistry
|
||||
import de.fiereu.openmmo.server.game.storage.CharacterRepository
|
||||
@@ -34,7 +34,8 @@ object GameServerModule {
|
||||
@Provides
|
||||
@Singleton
|
||||
fun rootKey(config: GameServerConfig): ECPrivateKey =
|
||||
PemKeyLoader.loadEcPrivate(resource(config.rootKeyResource))
|
||||
PemKeyLoader.loadEcPrivate(
|
||||
pemStream(config.rootKey, config.rootKeyFile, config.rootKeyResource))
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
|
||||
@@ -3,6 +3,8 @@ server {
|
||||
port = 7777
|
||||
checksumSize = 2
|
||||
rootKeyResource = "game.private.pem"
|
||||
rootKey = ${?OPENMMO_GAME_PRIVATE_KEY}
|
||||
rootKeyFile = ${?OPENMMO_GAME_PRIVATE_KEY_FILE}
|
||||
sessionSecret = "dev-only-secret-do-not-use-in-production"
|
||||
sessionSecret = ${?OPENMMO_SESSION_SECRET}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user