Format code

This commit is contained in:
2026-05-16 23:08:09 +02:00
parent 81dd8045f2
commit d110df924e
562 changed files with 11025 additions and 10059 deletions
@@ -58,7 +58,7 @@ val SWPermissionCheck = createRouteScopedPlugin("SWAuth", ::SWAuthConfig) {
pluginConfig.apply {
on(AuthenticationChecked) { call ->
if (call.request.httpMethod in allowedMethods) {
if(mustAuth) {
if (mustAuth) {
val token = call.principal<SWAuthPrincipal>()
if (token == null) {
@@ -52,7 +52,8 @@ fun Application.configurePlugins() {
global {
rateLimiter(limit = 60, refillPeriod = 60.seconds)
requestKey {
it.request.headers["X-Forwarded-For"] ?: it.request.local.remoteHost
it.request.headers["X-Forwarded-For"]
?: it.request.local.remoteHost
}
requestWeight { applicationCall, _ ->
if (!applicationCall.request.headers.contains("X-Forwarded-For")) {
@@ -100,10 +101,12 @@ fun Application.configurePlugins() {
cookie.maxAgeInSeconds = 60 * 60 * 24 * 7
cookie.httpOnly = true
cookie.secure = true
transform(SessionTransportTransformerEncrypt(
config.sessionEncryptSecret.toByteArray(),
config.sessionSignSecret.toByteArray()
))
transform(
SessionTransportTransformerEncrypt(
config.sessionEncryptSecret.toByteArray(),
config.sessionSignSecret.toByteArray()
)
)
}
}
install(ContentNegotiation) {
@@ -25,5 +25,6 @@ import io.ktor.server.request.*
import java.util.*
fun ApplicationRequest.getUser(key: String = "id"): SteamwarUser? {
return SteamwarUser.get(call.parameters[key]?.let { catchException { UUID.fromString(it) } } ?: return null)
return SteamwarUser.get(call.parameters[key]?.let { catchException { UUID.fromString(it) } }
?: return null)
}