Compare commits
2 Commits
31ab54478a
...
6bd98d6792
Author | SHA1 | Date | |
---|---|---|---|
6bd98d6792 | |||
7dd5248a6e |
3
TODO.md
3
TODO.md
@ -19,6 +19,9 @@
|
|||||||
* ✅ 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]
|
||||||
|
@ -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 http://127.0.0.1:3000
|
uri /auth
|
||||||
copy_headers {
|
copy_headers {
|
||||||
Authorization
|
Authorization
|
||||||
}
|
}
|
||||||
|
@ -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.18f15cc7111b1d0c63347c7cca07aee9ec87a7a8
|
version: 0.1.1+git.commit.98a20178d5ae1391f1cd56e372530de6aa2b1ebc
|
||||||
|
|
||||||
exception_page:
|
exception_page:
|
||||||
git: https://github.com/crystal-loot/exception_page.git
|
git: https://github.com/crystal-loot/exception_page.git
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
require "cr-config"
|
require "cr-config"
|
||||||
|
require "kemal-basic-auth"
|
||||||
|
|
||||||
class Config
|
class Config
|
||||||
include CrConfig
|
include CrConfig
|
||||||
@ -17,3 +18,30 @@ 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
|
||||||
|
@ -6,14 +6,11 @@ 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
|
||||||
@ -26,4 +23,13 @@ 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
|
||||||
|
@ -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 http://127.0.0.1:3000
|
uri /auth
|
||||||
copy_headers {
|
copy_headers {
|
||||||
Authorization
|
Authorization
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user