forked from SteamWar/SteamWar
Format code
This commit is contained in:
@@ -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)
|
||||
}
|
||||
Reference in New Issue
Block a user