From da35c255444ba1fb1314cd6a7196f588c3b62344 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20Pich?= Date: Tue, 26 Sep 2023 23:46:50 +0200 Subject: [PATCH] Disable debug, add some logs in validate result response --- .github/workflows/deploy.yml | 2 +- .../io/github/wulkanowy/schools/integrity/TokenDecrypt.kt | 4 ---- .../io/github/wulkanowy/schools/integrity/ValidateCommand.kt | 2 -- .../kotlin/io/github/wulkanowy/schools/plugins/Routing.kt | 4 ++++ 4 files changed, 5 insertions(+), 7 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index f43a35a..2f4a7d1 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -13,7 +13,7 @@ jobs: - name: Create .env file uses: SpicyPizza/create-envfile@v2 with: - envkey_DEBUG: true + envkey_DEBUG: false envkey_DB_HOST: "db" envkey_TOKEN: ${{ secrets.TOKEN }} envkey_GOOGLE_APPLICATION_CREDENTIALS: "app/wulkanowy-gac.json" diff --git a/src/main/kotlin/io/github/wulkanowy/schools/integrity/TokenDecrypt.kt b/src/main/kotlin/io/github/wulkanowy/schools/integrity/TokenDecrypt.kt index 2639d39..9b07f86 100644 --- a/src/main/kotlin/io/github/wulkanowy/schools/integrity/TokenDecrypt.kt +++ b/src/main/kotlin/io/github/wulkanowy/schools/integrity/TokenDecrypt.kt @@ -8,7 +8,6 @@ import com.google.auth.http.HttpCredentialsAdapter import com.google.auth.oauth2.GoogleCredentials import com.google.common.collect.Lists import kotlinx.serialization.json.Json -import java.util.logging.Logger fun decryptToken(tokenString: String, playIntegrity: PlayIntegrity = getPlayIntegrity()): IntegrityVerdictPayload { val decodeTokenRequest = DecodeIntegrityTokenRequest().setIntegrityToken(tokenString) @@ -17,9 +16,6 @@ fun decryptToken(tokenString: String, playIntegrity: PlayIntegrity = getPlayInte .execute() .toPrettyString() - val log = Logger.getLogger("decryptToken") - log.info("Decrypted token: $returnString") - return Json.decodeFromString(returnString) } diff --git a/src/main/kotlin/io/github/wulkanowy/schools/integrity/ValidateCommand.kt b/src/main/kotlin/io/github/wulkanowy/schools/integrity/ValidateCommand.kt index e872a2a..4504935 100644 --- a/src/main/kotlin/io/github/wulkanowy/schools/integrity/ValidateCommand.kt +++ b/src/main/kotlin/io/github/wulkanowy/schools/integrity/ValidateCommand.kt @@ -1,7 +1,5 @@ package io.github.wulkanowy.schools.integrity -import java.util.logging.Logger - // Package name of the client application const val APPLICATION_PACKAGE_IDENTIFIER = "io.github.wulkanowy" diff --git a/src/main/kotlin/io/github/wulkanowy/schools/plugins/Routing.kt b/src/main/kotlin/io/github/wulkanowy/schools/plugins/Routing.kt index feb36c2..f035697 100644 --- a/src/main/kotlin/io/github/wulkanowy/schools/plugins/Routing.kt +++ b/src/main/kotlin/io/github/wulkanowy/schools/plugins/Routing.kt @@ -8,6 +8,8 @@ import io.ktor.server.application.* import io.ktor.server.request.* import io.ktor.server.response.* import io.ktor.server.routing.* +import java.util.logging.Level +import java.util.logging.Logger fun Application.configureRouting() { val loginEventDao = LoginEventDao() @@ -21,6 +23,7 @@ fun Application.configureRouting() { when (val result = validateCommand(request.data.uuid, integrityVerdict)) { ValidateResult.VALIDATE_SUCCESS -> { + Logger.getLogger("result").log(Level.INFO, "${request.data.uuid}: $result") loginEventDao.addLoginEvent(request.data) call.respond(status = HttpStatusCode.NoContent, "") } @@ -28,6 +31,7 @@ fun Application.configureRouting() { ValidateResult.VALIDATE_NONCE_NOT_FOUND, ValidateResult.VALIDATE_NONCE_MISMATCH, ValidateResult.VALIDATE_INTEGRITY_FAIL -> { + Logger.getLogger("result").log(Level.INFO, "${request.data.uuid}: $result") call.respond(status = HttpStatusCode.BadRequest, message = result.name) } }