Skip to content

Commit

Permalink
Don't use basic auth for heroku now
Browse files Browse the repository at this point in the history
  • Loading branch information
daviddenton committed Sep 20, 2024
1 parent a5fc858 commit 2eed477
Showing 1 changed file with 2 additions and 14 deletions.
16 changes: 2 additions & 14 deletions heroku-app/src/main/kotlin/http4kbox/HerokuServer.kt
Original file line number Diff line number Diff line change
@@ -1,26 +1,14 @@
package http4kbox

import org.http4k.client.HelidonClient
import org.http4k.config.Environment
import org.http4k.config.EnvironmentKey
import org.http4k.core.Credentials
import org.http4k.core.then
import org.http4k.filter.ServerFilters.BasicAuth
import org.http4k.config.Environment.Companion.ENV
import org.http4k.server.Helidon
import org.http4k.server.asServer
import java.time.Clock

// since we are running in a public environment, add credentials to the app
val BASIC_AUTH_CREDENTIALS = EnvironmentKey.map(String::toCredentials).required("BASIC_AUTH_CREDENTIALS")

fun main(args: Array<String>) {
val env = Environment.ENV

val port = if (args.isNotEmpty()) args[0].toInt() else 5000

BasicAuth("http4k", BASIC_AUTH_CREDENTIALS(env))
.then(Http4kBox(env, HelidonClient(), Clock.systemUTC()))
Http4kBox(ENV, HelidonClient(), Clock.systemUTC())
.asServer(Helidon(port)).start().block()
}

private fun String.toCredentials() = split(":").run { Credentials(get(0), get(1)) }

0 comments on commit 2eed477

Please sign in to comment.