Compare commits

..

No commits in common. "6bd98d6792e5b1e73cad1adbf1869e3a4a3da925" and "31ab54478a7e23c8e2e8f0599127a6554ac4c688" have entirely different histories.

6 changed files with 6 additions and 43 deletions

View File

@ -19,9 +19,6 @@
* ✅ Streaming responses in slow operations like scaling down * ✅ Streaming responses in slow operations like scaling down
or building or building
* Make more things configurable / remove hardcoded stuff * Make more things configurable / remove hardcoded stuff
* ✅ Make server take options from file
* ✅ Make server take options from environment
* ✅ Make server password configurable
* admin/admin auth * admin/admin auth
* CD for binaries and images for at least arm64/x86 * CD for binaries and images for at least arm64/x86
* Multi-container docker logs [faaso logs -f FUNKO] * Multi-container docker logs [faaso logs -f FUNKO]

View File

@ -6,7 +6,7 @@
http://*:8888 { http://*:8888 {
forward_auth /admin/* http://127.0.0.1:3000 { forward_auth /admin/* http://127.0.0.1:3000 {
uri /auth uri http://127.0.0.1:3000
copy_headers { copy_headers {
Authorization Authorization
} }

View File

@ -26,7 +26,7 @@ shards:
docr: docr:
git: https://github.com/ralsina/docr.git git: https://github.com/ralsina/docr.git
version: 0.1.1+git.commit.98a20178d5ae1391f1cd56e372530de6aa2b1ebc version: 0.1.1+git.commit.18f15cc7111b1d0c63347c7cca07aee9ec87a7a8
exception_page: exception_page:
git: https://github.com/crystal-loot/exception_page.git git: https://github.com/crystal-loot/exception_page.git

View File

@ -1,5 +1,4 @@
require "cr-config" require "cr-config"
require "kemal-basic-auth"
class Config class Config
include CrConfig include CrConfig
@ -18,30 +17,3 @@ class Config
Config.set_instance config Config.set_instance config
end end
end end
class ConfigAuthHandler < Kemal::BasicAuth::Handler
only ["/auth"]
def call(context)
return call_next(context) unless only_match?(context)
super
end
def initialize
# Ignored, just make the compiler happy
@credentials = Kemal::BasicAuth::Credentials.new({"foo" => "bar"})
end
def authorize?(value) : String?
username, password = Base64.decode_string(value[BASIC.size + 1..-1]).split(":")
if username == "admin" && password == Config.instance.password
username
else
nil
end
end
end
# Tie auth to config
add_handler ConfigAuthHandler.new

View File

@ -6,11 +6,14 @@ require "./terminal.cr"
require "compress/gzip" require "compress/gzip"
require "crystar" require "crystar"
require "docr" require "docr"
require "kemal-basic-auth"
require "kemal" require "kemal"
require "uuid" require "uuid"
Config.load Config.load
basic_auth "admin", Config.instance.password
macro version macro version
"{{ `grep version shard.yml | cut -d: -f2` }}".strip() "{{ `grep version shard.yml | cut -d: -f2` }}".strip()
end end
@ -23,13 +26,4 @@ get "/version" do
"#{version}" "#{version}"
end end
get "/auth" do
end
get "/reload" do
Log.info { "Reloading configuration" }
Config.load
"Config reloaded"
end
Kemal.run Kemal.run

View File

@ -37,7 +37,7 @@ module Proxy
http://*:8888 { http://*:8888 {
forward_auth /admin/* http://127.0.0.1:3000 { forward_auth /admin/* http://127.0.0.1:3000 {
uri /auth uri http://127.0.0.1:3000
copy_headers { copy_headers {
Authorization Authorization
} }