move path check to app access manager

This commit is contained in:
gowthaman.b
2023-11-11 11:41:47 +05:30
parent dc0a59fcf2
commit ea14212337
2 changed files with 8 additions and 12 deletions

View File

@@ -103,17 +103,6 @@ fun main(args: Array<String>) {
NaiveRateLimit.requestPerTimeUnit(ctx, appConfig.rateLimit().getOrDefault(30), TimeUnit.MINUTES) // throws if rate limit is exceeded
//allow only alpha, numeric, hypen, underscore, dot in paths
val regex = Regex("^[a-zA-Z0-9\\-_\\.]+$")
ctx.path().split("/")
.dropWhile { it.isEmpty() }
.forEach {
if (!it.matches(regex)) {
throw IllegalArgumentException()
}
}
val authToken = ctx.header("Authorization")?.replace("Bearer ", "")
?.replace("Bearer: ", "")
?.trim() ?: throw UnauthorizedResponse()