From a24c4da4b3e23fa675d6f5b41dc1997361803b5e Mon Sep 17 00:00:00 2001 From: Anton Dyudin Date: Wed, 6 Apr 2016 13:43:02 -0700 Subject: [PATCH] minimal basic-auth refactor --- lib/basic-auth.hoon | 35 +++++++++++++++++++++++++++-------- sec/com/github.hoon | 3 ++- 2 files changed, 29 insertions(+), 9 deletions(-) diff --git a/lib/basic-auth.hoon b/lib/basic-auth.hoon index c4e1bc9336..7caa7e56f0 100644 --- a/lib/basic-auth.hoon +++ b/lib/basic-auth.hoon @@ -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))] + -- +-- diff --git a/sec/com/github.hoon b/sec/com/github.hoon index c6d19453cd..9542df8a2f 100644 --- a/sec/com/github.hoon +++ b/sec/com/github.hoon @@ -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 --