Auth Configurability Improvements
Decoupled the no-auth authenticator from dev_mode setting Decoupled the in-memory storage provider from dev_mode setting Decoupled the no_auth authenticator from the in-memory storage provider Bonus: included an extremely useful dump that lists all linked models/anims/gfx
This commit is contained in:
@@ -232,5 +232,11 @@ class ServerConstants {
|
||||
|
||||
@JvmField
|
||||
var PRELOAD_MAP = false
|
||||
|
||||
@JvmField
|
||||
var USE_AUTH = false
|
||||
|
||||
@JvmField
|
||||
var PERSIST_ACCOUNTS = false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
package rs09.auth
|
||||
|
||||
import core.game.node.entity.player.Player
|
||||
import rs09.storage.AccountStorageProvider
|
||||
import rs09.storage.InMemoryStorageProvider
|
||||
|
||||
class DevelopmentAuthenticator : AuthProvider<InMemoryStorageProvider>() {
|
||||
override fun configureFor(provider: InMemoryStorageProvider) {
|
||||
class DevelopmentAuthenticator : AuthProvider<AccountStorageProvider>() {
|
||||
override fun configureFor(provider: AccountStorageProvider) {
|
||||
storageProvider = provider
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package rs09.game.system
|
||||
|
||||
import rs09.ServerConstants
|
||||
import rs09.auth.AuthProvider
|
||||
import rs09.auth.DevelopmentAuthenticator
|
||||
import rs09.auth.ProductionAuthenticator
|
||||
@@ -11,17 +12,15 @@ object Auth {
|
||||
lateinit var authenticator: AuthProvider<*>
|
||||
lateinit var storageProvider: AccountStorageProvider
|
||||
|
||||
fun configureFor(devMode: Boolean) {
|
||||
if (devMode) {
|
||||
authenticator = DevelopmentAuthenticator()
|
||||
storageProvider = InMemoryStorageProvider()
|
||||
(authenticator as DevelopmentAuthenticator).configureFor(storageProvider as InMemoryStorageProvider)
|
||||
SystemLogger.logInfo("[AUTH] Using Development Authenticator with In-Memory Storage")
|
||||
} else {
|
||||
authenticator = ProductionAuthenticator()
|
||||
storageProvider = SQLStorageProvider()
|
||||
(authenticator as ProductionAuthenticator).configureFor(storageProvider as SQLStorageProvider)
|
||||
SystemLogger.logInfo("[AUTH] Using Production Authenticator with SQL Storage")
|
||||
}
|
||||
fun configure() {
|
||||
storageProvider = if (ServerConstants.PERSIST_ACCOUNTS)
|
||||
SQLStorageProvider()
|
||||
else
|
||||
InMemoryStorageProvider()
|
||||
|
||||
authenticator = if (ServerConstants.USE_AUTH)
|
||||
ProductionAuthenticator().also { it.configureFor(storageProvider) }
|
||||
else
|
||||
DevelopmentAuthenticator().also { it.configureFor(storageProvider) }
|
||||
}
|
||||
}
|
||||
@@ -121,6 +121,8 @@ object ServerConfigParser {
|
||||
ServerConstants.DISCORD_GE_WEBHOOK = data.getString("server.discord_webhook", "")
|
||||
ServerConstants.WATCHDOG_ENABLED = data.getBoolean("server.watchdog_enabled", true)
|
||||
ServerConstants.I_AM_A_CHEATER = data.getBoolean("world.i_want_to_cheat", false)
|
||||
ServerConstants.USE_AUTH = data.getBoolean("server.use_auth", true)
|
||||
ServerConstants.PERSIST_ACCOUNTS = data.getBoolean("server.persist_accounts", true)
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -165,10 +165,7 @@ object GameWorld {
|
||||
logInfo("Prompting ${settings?.name} Game World...")
|
||||
Cache.init(ServerConstants.CACHE_PATH)
|
||||
//go overboard with checks to make sure dev mode authenticator never triggers on live
|
||||
Auth.configureFor(
|
||||
settings!!.isDevMode
|
||||
&& ServerConstants.MS_SECRET_KEY == "2009scape_development"
|
||||
)
|
||||
Auth.configure()
|
||||
ConfigParser().prePlugin()
|
||||
ClassScanner.scanClasspath()
|
||||
ClassScanner.loadPureInterfaces()
|
||||
|
||||
Reference in New Issue
Block a user