add dojo support for multi-login

This commit is contained in:
Anton Dyudin 2016-01-27 13:58:28 -08:00
parent 9125a0003e
commit e02c79ca6c
4 changed files with 50 additions and 28 deletions

View File

@ -31,7 +31,7 @@
[%pill p=path] :: noun to unix pill
:: [%tree p=path] :: noun to unix tree
[%file p=beam] :: save to clay
[%http p=?(%post %put) q=purl] :: http outbound
[%http p=?(%post %put) q=iden r=purl] :: http outbound
[%poke p=goal] :: poke app
[%show p=?(0 1 2 3)] :: print val/type/twig
[%verb p=term] :: store variable
@ -40,8 +40,8 @@
$: p=@ud :: assembly index
q=dojo-build :: general build
== ::
++ dojo-build :: one ford step
$% [%ur p=purl] :: http GET request
++ dojo-build :: one arvo step
$% [%ur p=iden q=purl] :: http GET request
[%ge p=dojo-model] :: generator
[%dv p=path] :: core from source
[%ex p=twig] :: hoon expression
@ -86,7 +86,7 @@
++ card :: general card
$% [%diff %sole-effect sole-effect] ::
[%send wire [ship term] clap] ::
[%hiss wire [~ ~] %httr [%hiss hiss]] ::
[%hiss wire [~ iden] %httr [%hiss hiss]] ::
[%exec wire @p (unit ,[beak silk])] ::
[%deal wire sock term club] ::
[%info wire @p toro] ::
@ -164,8 +164,8 @@
;~(plug (cold %file tar) dp-beam)
;~(plug (cold %flat pat) (most fas qut))
;~(plug (cold %pill dot) (most fas sym))
;~(plug (cold %http lus) (easy %post) auri:epur)
;~(plug (cold %http hep) (easy %put) auri:epur)
;~(plug (cold %http lus) (easy %post) dp-iden-url)
;~(plug (cold %http hep) (easy %put) dp-iden-url)
(stag %show (cook ?(1 2 3) (cook lent (stun [1 3] wut))))
==
++ dp-hooves :: hoof list
@ -196,7 +196,7 @@
++ dp-build :: ++dojo-build
%+ knee *dojo-build |. ~+
;~ pose
;~(plug (cold %ur lus) auri:epur)
;~(plug (cold %ur lus) dp-iden-url)
;~(plug (cold %ge lus) dp-model)
;~(plug (cold %as pam) sym ;~(pfix ace dp-source))
;~(plug (cold %do cab) dp-twig ;~(pfix ace dp-source))
@ -218,6 +218,9 @@
=+ vez=(vang | dp-path)
(sear plex:vez (stag %clsg poor:vez))
::
++ dp-iden-url
(cook |=([a=(unit iden) b=purl] [(fall a *iden) b]) auru:epur)
::
++ dp-model ;~(plug dp-server dp-config) :: ++dojo-model
++ dp-path (tope he-beam) :: ++path
++ dp-server (stag 0 (most fas sym)) :: ++dojo-server
@ -264,10 +267,10 @@
(he-card(poy `+>+<(pux `way)) %exec way our.hid `[he-beak kas])
::
++ dy-eyre :: send work to eyre
|= [way=wire req=hiss]
|= [way=wire usr=iden req=hiss]
^+ +>+>
?> ?=(~ pux)
(he-card(poy `+>+<(pux `way)) %hiss way `~ %httr %hiss req)
(he-card(poy `+>+<(pux `way)) %hiss way `usr %httr %hiss req)
::
++ dy-stop :: stop work
^+ +>
@ -479,7 +482,7 @@
?> ?=(%mime p.cay)
=+ mim=;;(mime q.q.cay)
=+ maf=(~(add ja *math) content-type/(moon p.mim))
(dy-eyre /show [q.p.mad p.p.mad maf ~ q.mim])
(dy-eyre /show q.p.mad [r.p.mad p.p.mad maf ~ q.mim])
::
%show
%+ dy-print cay
@ -535,7 +538,7 @@
=+ `[@ bil=dojo-build]`a
|- ^- $& [_$ _$]
$? twig
$% [%ur purl]
$% [%ur iden purl]
[%dv path]
[%as mark _$]
[%do twig _$]
@ -658,7 +661,7 @@
%|
=+ hiz=;;(hiss +<.q.vax)
=. ..dy (he-diff %tan leaf/"< {(earn p.hiz)}" ~)
(dy-eyre(pro `(slap (slot 7 vax) cnzy/%q)) /scar hiz)
(dy-eyre(pro `(slap (slot 7 vax) cnzy/%q)) /scar ~. hiz)
==
::
++ dy-sigh-scar :: scraper result
@ -677,7 +680,7 @@
?> ?=(^ cud)
=+ bil=q.u.cud :: XX =*
?: ?=(%ur -.bil)
(dy-eyre /hand [p.bil %get ~ ~])
(dy-eyre /hand p.bil [q.bil %get ~ ~])
%- dy-ford
^- (pair path silk)
?- -.bil

View File

@ -3769,7 +3769,7 @@
++ rig
|= hom=tape
^- wall
?: (lte (lent hom) (sub edg tab))
?: & ::(lte (lent hom) (sub edg tab))
[(runt [tab ' '] hom) lug]
=> .(tab (add tab 2), edg (sub edg 2))
=+ mut=(trim (sub edg tab) hom)
@ -4606,6 +4606,7 @@
(mook (mink [sub fol] sky))
::
++ moop
::=< |= pon=(list ,[@ta *]) pon
|= pon=(list ,[@ta *]) ^+ pon
?~ pon ~
:- i.pon

View File

@ -1308,21 +1308,30 @@
++ aurf :: 2396 with fragment
%+ cook |=(a=purf a)
;~(plug auri (punt ;~(pfix hax (cook crip (star pque)))))
++ auru :: 2396 with maybe user
%+ cook
|= $: a=[p=? q=(unit iden) r=[(unit ,@ud) host]]
b=[pork quay]
==
^- (pair (unit iden) purl)
[q.a [[p.a r.a] b]]
::
;~ plug
;~(plug htts (punt ;~(sfix urt:ab pat)) thor)
;~(plug ;~(pose apat (easy *pork)) yque)
==
++ auri :: 2396 URL
%+ cook
|= a=purl
?.(?=(hoke r.p.a) a a(p.p &))
;~ plug
;~ plug
%+ sear
|= a=@t
^- (unit ,?)
?+(a ~ %http [~ %|], %https [~ %&])
;~(sfix scem ;~(plug col fas fas))
thor
==
;~(plug htts thor)
;~(plug ;~(pose apat (easy *pork)) yque)
==
++ htts
%+ sear ~(get by (mo http/| https/& ~))
;~(sfix scem ;~(plug col fas fas))
::
++ cock :: cookie
(most ;~(plug sem ace) ;~(plug toke ;~(pfix tis tosk)))
++ dlab :: 2396 domainlabel
@ -1820,9 +1829,10 @@
++ bale :: driver state
|* a=_,* :: %jael keys type
$: [our=ship now=@da eny=@uvI byk=beak] :: base info
[usr=span dom=(list ,@t)] :: req user, domain
[usr=iden dom=(list ,@t)] :: req user, domain
key=a :: secrets from %jael
== ::
++ iden span:?(~ @ta) :: username
++ sec-move :: driver effect
$% [%send p=hiss] :: http out
[%show p=purl] :: direct user to url
@ -2488,7 +2498,7 @@
++ kiss-eyre :: in request ->$
$% [%born ~] :: new unix process
[%crud p=@tas q=(list tank)] :: XX rethink
[%hiss p=(unit span) q=mark r=cage] :: outbound user req
[%hiss p=(unit iden) q=mark r=cage] :: outbound req
[%init p=@p] :: report install
[%them p=(unit hiss)] :: outbound request
[%they p=@ud q=httr] :: inbound response

View File

@ -4,12 +4,20 @@
::
|%
++ user-state ,[ber=token ref=refresh]:oauth2
++ auth-lon
|= lon=span
++ suffix-email
%+ cook welp
;~ plug
(star ;~(less pat prn))
;~(pose (plus prn) (easy "@gmail.com"))
==
::
++ auth-usr
|= usr=iden
=+ lon=(fall (slaw %t usr) usr)
=< .(state-usr &)
%- oauth2
=- [[`/com/google/accounts /o/oauth2/v2/auth -] /oauth2/v4/token]
:~ login-hint/?~(lon '' (cat 3 lon '@gmail.com'))
:~ login-hint/(crip (rash lon suffix-email))
access-type/%offline
response-type/%code
==
@ -19,7 +27,7 @@
::
|_ [bal=(bale keys:oauth2) user-state]
++ auth-re ~(. (re:auth .) ref |=(a=_ref +>(ref a)))
++ auth ~(. (auth-lon usr.bal) bal (scopes 'userinfo.email' 'plus.me' ~))
++ auth ~(. (auth-usr usr.bal) bal (scopes 'userinfo.email' 'plus.me' ~))
++ scopes
=+ scope=|=(b=@ta (endpoint:oauth2 dom.bal /auth/[b]))
|=(a=(list ,@ta) (turn a |=(b=@ta (crip (earn (scope b))))))