kemal-basic-auth
kemal-basic-auth copied to clipboard
Credentials now accumulates entries
Hi @sdogruyol !
I'm now heavily using basic_auth and it would be nice if we can call it in several times for independency of pages. This PR enables it.
# foo.cr
basic_auth "user1", "123"
get "/foo" do
...
# bar.cr
basic_auth "staff", "456"
get "/bar" do
...
Impact
- Added
HTTPBasicAuth.runtimemethod that keeps singleton instance object. This looks like well knownINSTANCEtechnic except instantiating it lazily due to add_handler stuff. -
basic_authis now a simple proxy to theruntime. Thus, we can accumulate entries.
I'm glad if you like this! I'll create a new PR soon for a limited page authorization. :smile:
Thanks.
Hey @maiha, thanks a lot for your PR 👍 I'll review it soon as i've just seen this 😄
Hm