pull cookie logic out in preparation for further wire-hoisting

This commit is contained in:
Anton Dyudin 2016-09-12 16:22:22 -07:00
parent 82794a40ff
commit 7c9ea092f1

View File

@ -1005,6 +1005,27 @@
%^ rsh 3 1 %^ rsh 3 1
(scot %p (@ (need (sky [151 %noun] %a pax)))) (scot %p (@ (need (sky [151 %noun] %a pax))))
:: ::
++ cookie-prefix (rsh 3 1 (scot %p our))
++ cookie-domain
|= hat/hart
^- cord
?- r.hat
{$| @} (cat 3 '; Domain=' (rsh 3 1 (scot %if p.r.hat)))
{$& $org $urbit *} '; Domain=.urbit.org'
{$& @ @ *} =- (rap 3 "; Domain={-}{i.p.r.hat ~}")
(turn (flop `path`t.p.r.hat) |=(a/knot (cat 3 a '.')))
{$& *} '' :: XX security?
==
::
++ set-cookie
|= {hat/hart key/@t val/@t}
%+ rap 3 :~
key '=' val
:: '; HttpOnly' ?.(sec '' '; Secure') :: XX security
(cookie-domain hat)
'; Path=/; HttpOnly'
==
::
:: ::
++ handle ++ handle
~% %eyre-h ..is ~ ~% %eyre-h ..is ~
@ -1373,7 +1394,7 @@
:: ::
$del $del
=. ..ya abut:yac =. ..ya abut:yac
=+ cug=[(set-cookie cookie-prefix '~')]~ =+ cug=[(set-cookie hat cookie-prefix '~')]~
[%| (give-json 200 cug (joba %ok %b &))] [%| (give-json 200 cug (joba %ok %b &))]
:: ::
$get $get
@ -1397,7 +1418,7 @@
== ==
~|(%auth-fail !!) ~|(%auth-fail !!)
=^ jon ..ya stat-json:(logon:yac him.ham) =^ jon ..ya stat-json:(logon:yac him.ham)
=. cug.yac :_(cug.yac (set-cookie %ship (scot %p him.ham))) =. cug.yac :_(cug.yac (set-cookie hat %ship (scot %p him.ham)))
(give-json 200 cug.yac jon) (give-json 200 cug.yac jon)
== ==
:: ::
@ -1412,26 +1433,6 @@
=+ yac=(new-ya u.ses) =+ yac=(new-ya u.ses)
[%| (give-html(..ya abet.yac) 401 cug.yac login-page:xml)] [%| (give-html(..ya abet.yac) 401 cug.yac login-page:xml)]
:: ::
++ cookie-prefix (rsh 3 1 (scot %p our))
++ cookie-domain
^- cord
?- r.hat
{$| @} (cat 3 '; Domain=' (rsh 3 1 (scot %if p.r.hat)))
{$& $org $urbit *} '; Domain=.urbit.org'
{$& @ @ *} =- (rap 3 "; Domain={-}{i.p.r.hat ~}")
(turn (flop `path`t.p.r.hat) |=(a/knot (cat 3 a '.')))
{$& *} '' :: XX security?
==
::
++ set-cookie
|= {key/@t val/@t}
%+ rap 3 :~
key '=' val
:: '; HttpOnly' ?.(sec '' '; Secure') :: XX security
cookie-domain
'; Path=/; HttpOnly'
==
++ need-ixor (oryx-to-ixor (need grab-oryx)) ++ need-ixor (oryx-to-ixor (need grab-oryx))
++ for-view ^+(ix (ire-ix need-ixor)) ++ for-view ^+(ix (ire-ix need-ixor))
:: ::
@ -1447,7 +1448,7 @@
(new-ya (rsh 3 1 (scot %p (end 6 1 ney)))) (new-ya (rsh 3 1 (scot %p (end 6 1 ney))))
~(. ya u.lig u.cyz(cug ~)) ~(. ya u.lig u.cyz(cug ~))
:: ::
++ new-ya |=(ses/hole (new:ya ses [(set-cookie cookie-prefix ses)]~)) ++ new-ya |=(ses/hole (new:ya ses hat))
-- --
:: ::
++ oryx-to-ixor |=(a/oryx (rsh 3 1 (scot %p (end 6 1 (shas %ire a))))) ++ oryx-to-ixor |=(a/oryx (rsh 3 1 (scot %p (end 6 1 (shas %ire a)))))
@ -1456,13 +1457,15 @@
=| {ses/hole cyst} =| {ses/hole cyst}
=* cyz -> =* cyz ->
|% |%
++ new |=({a/hole b/(list @t)} init(ses a, cug b)) ++ new |=({a/hole b/hart} (init(ses a) b))
++ abet ..ya(wup (~(put by wup) ses cyz)) ++ abet ..ya(wup (~(put by wup) ses cyz))
++ abut ..ya(wup (~(del by wup) ses)) ++ abut ..ya(wup (~(del by wup) ses))
++ init ++ init
%_ . |= hat/hart
%_ +>.$
him `@p`(mix anon (lsh 5 1 (rsh 5 1 (shaf %ship ses)))) him `@p`(mix anon (lsh 5 1 (rsh 5 1 (shaf %ship ses))))
lax now lax now
cug [(set-cookie hat cookie-prefix ses)]~
== ==
:: ::
++ foreign-auth ++ foreign-auth