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

Commit 77fbc79

Browse files
twisti-devCopilot
andauthored
Update surf-cloud-standalone/src/main/kotlin/dev/slne/surf/cloud/standalone/config/StandaloneConfig.kt
Co-authored-by: Copilot <[email protected]>
1 parent c523b6d commit 77fbc79

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,14 @@ 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)
5154
return token
5255
}

0 commit comments

Comments
 (0)