kemal-basic-auth icon indicating copy to clipboard operation
kemal-basic-auth copied to clipboard

Credentials now accumulates entries

Open maiha opened this issue 9 years ago • 2 comments

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.runtime method that keeps singleton instance object. This looks like well known INSTANCE technic except instantiating it lazily due to add_handler stuff.
  • basic_auth is now a simple proxy to the runtime. 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.

maiha avatar Jan 18 '17 01:01 maiha

Hey @maiha, thanks a lot for your PR 👍 I'll review it soon as i've just seen this 😄

sdogruyol avatar Feb 07 '17 14:02 sdogruyol

Hm

xhyrom avatar Aug 06 '22 18:08 xhyrom