Skip to content
This repository was archived by the owner on Dec 10, 2025. It is now read-only.

Commit 694366d

Browse files
committed
Merge remote-tracking branch 'origin/54-add-bearer-token-authentication-for-web-api' into 54-add-bearer-token-authentication-for-web-api
2 parents ac00dfd + 77fbc79 commit 694366d

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

surf-cloud-standalone/src/main/kotlin/dev/slne/surf/cloud/standalone/config/StandaloneConfig.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,16 @@ data class KtorConfig(
4242
) {
4343
companion object {
4444
private fun generateBearerToken(length: Int = 32): String {
45+
// The default token length of 32 provides a good balance between security and usability.
46+
// A minimum length of 16 is enforced to ensure sufficient entropy for security purposes.
4547
require(length >= 16) { "Token should be at least 16 characters long" }
4648

4749
val randomBytes = ByteArray(length)
4850
random.nextBytes(randomBytes)
4951

52+
// Base64 encoding is used to make the token URL-safe and compact while preserving randomness.
5053
val token = Base64.getUrlEncoder().withoutPadding().encodeToString(randomBytes)
51-
return "Bearer $token"
54+
return token
5255
}
5356
}
5457
}

0 commit comments

Comments
 (0)