minimal basic-auth refactor

This commit is contained in:
Anton Dyudin 2016-04-06 13:43:02 -07:00
parent cff175cb8d
commit a24c4da4b3
2 changed files with 29 additions and 9 deletions

View File

@ -1,8 +1,27 @@
!:
=+ keys=@t
|= bal/(bale keys)
?~ key.bal
~|(%basic-auth-no-key ~_(leaf+"Run |init-auth-basic {<`path`dom.bal>}" !!))
=+ aut=authorization+(cat 3 'Basic ' key.bal)
~& aut=`{@tas @t}`aut
|=(a/hiss [%send %_(a q.q (~(add ja q.q.a) -.aut +.aut))])
:: Basic authentication
::
:::: /hoon/basic-auth/lib
::
|%
++ keys @t
--
::
::::
::
|_ bal/(bale keys)
++ auth-header
^- {term cord}
?~ key.bal
~_ leaf+"Run |init-auth-basic {<`path`dom.bal>}"
~|(%basic-auth-no-key !!)
[%authorization (cat 3 'Basic ' key.bal)]
::
++ standard
|%
++ out-adding-header
|= a/hiss ^- sec-move
=+ aut=auth-header
~& aut=aut
[%send %_(a q.q (~(add ja q.q.a) -.aut +.aut))]
--
--

View File

@ -5,5 +5,6 @@
/+ basic-auth
!:
|_ {bal/(bale keys:basic-auth) $~}
++ out (basic-auth bal)
++ aut ~(standard basic-auth bal)
++ out out-adding-header:aut
--