File tree Expand file tree Collapse file tree 1 file changed +10
-3
lines changed
src/main/kotlin/com/viaversion/aas/web Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -155,15 +155,22 @@ class WebLogin : WebState {
155155 private suspend fun handleSaveAccessToken (webClient : WebClient , obj : JsonObject ) {
156156 val accessToken = obj[" mc_access_token" ].asString
157157 val decodedToken = JWT .decode(accessToken)
158- assert (decodedToken.expiresAtAsInstant <= Instant .now())
159- assert (decodedToken.notBeforeAsInstant >= Instant .now())
158+ val now = Instant .now()
159+ if (now > decodedToken.expiresAtAsInstant) {
160+ throw IllegalArgumentException (" mc access token has expired" )
161+ }
162+ if (now < decodedToken.notBeforeAsInstant) {
163+ throw IllegalArgumentException (" mc access token notBefore is in the future" )
164+ }
160165 val expectedId = UUID .fromString(decodedToken.getClaim(" profiles" ).asMap()[" mc" ].toString())
161166
162167 val profile = AspirinServer .httpClient.get(" https://api.minecraftservices.com/minecraft/profile" ) {
163168 header(" Authorization" , " Bearer $accessToken " )
164169 }.body<JsonObject >()
165170 val uuid = parseUndashedId(profile[" id" ].asString)
166- assert (uuid == expectedId)
171+ if (uuid != expectedId) {
172+ throw IllegalStateException (" expected $expectedId == $uuid " )
173+ }
167174
168175 webClient.server.addAccessToken(uuid, accessToken)
169176 webLogger.info(" Received token: {} {}" , webClient.id, uuid)
You can’t perform that action at this time.
0 commit comments