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:
Ceikry 2022-07-30 16:03:31 +00:00 committed by Ryan
parent e3623e16ec
commit 75a81f0df6
7 changed files with 11246 additions and 19 deletions

View file

@ -232,5 +232,11 @@ class ServerConstants {
@JvmField
var PRELOAD_MAP = false
@JvmField
var USE_AUTH = false
@JvmField
var PERSIST_ACCOUNTS = false
}
}

View file

@ -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
}

View file

@ -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) }
}
}

View file

@ -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)
}

View file

@ -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()

View file

@ -6,7 +6,13 @@ write_logs = true
msip = "127.0.0.1"
#preload the map (Increases memory usage by 2GB but makes game ticks smoother)
preload_map = false
#--------Note: If both of the below are false, no database is required to run the server.--------------
#true = login requires password to be correct, passwords are hashed before stored. false = login does not care about the correctness of a password.
use_auth = false #NOTE: THIS MUST BE SET TO TRUE IN PRODUCTION!
#true - account data (credits, playtime, etc) is persisted, false - account data is purely temporary
#NOTE: this does not affect actual save data, like stats, inventory, etc.
persist_accounts = false #NOTE: THIS MUST BE SET TO TRUE IN PRODUCTION!
#------------------------------------------------------------------------------------------------------
[database]
database_name = "global"

File diff suppressed because one or more lines are too long