Skip to content

Commit

Permalink
Merge pull request #126 from andacata/feat/125-report_not_encoded_aut…
Browse files Browse the repository at this point in the history
…horization_token

feat(auth): Report back if the auth token cannot be Base64-decoded
  • Loading branch information
lilgallon authored Aug 2, 2024
2 parents c083557 + cd8f87c commit 2db9c13
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,13 @@ fun HttpRequest.parseAuthorizationHeader() = getHeader(Header.AUTHORIZATION)
}
}
?.removePrefix("Token ")
?.decodeBase64()
?.let {
try {
it.decodeBase64()
} catch (e: Exception) {
throw HttpException(HttpStatus.BAD_REQUEST, "${Header.AUTHORIZATION} token cannot be decoded")
}
}
?: throw HttpException(HttpStatus.UNAUTHORIZED, "${Header.AUTHORIZATION} header missing")

/**
Expand Down

0 comments on commit 2db9c13

Please sign in to comment.