default to identity in url path, extend facebook tokens

This commit is contained in:
Anton Dyudin 2016-01-26 12:32:52 -08:00
parent c7196a689c
commit db981d4db3
4 changed files with 17 additions and 11 deletions

View File

@ -1716,7 +1716,7 @@
?>((~(nest ut p:!>(*sec-move)) %& p.b) ~)
=+ opt=|.((sa (turn a head)))
|-
?~ a ~|(allowed=*opt !!)
?~ a ~|(allowed=(opt) !!)
?: =(p.i.a -.q.b)
(q.i.a (spec b))
$(a t.a)
@ -1737,6 +1737,7 @@
%+ on-error dead-this |.
%- allow :~
give/do-give
send/(do-send %in)
redo/,_pump(..vi (give-html 200 ~ exit:xml))
==
::

View File

@ -37,7 +37,7 @@
::::
::
|= [dialog=[p=host q=path r=quay] code-exchange=path]
=+ state-usr=&
=+ state-usr=|
|_ [(bale keys) scope=(list cord)]
++ client-id cid:(decode-keys key)
++ client-secret cis:(decode-keys key)
@ -67,7 +67,7 @@
?~ refresh (otherwise a)
?: (lth expires (add now ~m1))
(otherwise a)
[%send toke-url (toke-req 'refresh_token' refresh-token/refresh ~)]
(toke-req 'refresh_token' refresh-token/refresh ~)
::
++ out-filtered
|= [tok=token aut=$+(hiss hiss)]
@ -86,7 +86,8 @@
|=(a=hiss %_(a q.q (~(add ja q.q.a) hed)))
::
++ toke-req
|= [grant-type=cord quy=quay] ^- moth
|= [grant-type=cord quy=quay] ^- [%send hiss]
:+ %send toke-url
:+ %post (mo ~[content-type/~['application/x-www-form-urlencoded']])
=- `(tact +:(tail:earn -))
%- fass
@ -100,7 +101,7 @@
++ in-code
|= a=quay ^- sec-move
=+ code=~|(%no-code (~(got by (mo a)) %code))
[%send toke-url (toke-req 'authorization_code' code/code ~)]
(toke-req 'authorization_code' code/code ~)
::
++ token-type 'token_type'^(cu cass sa):jo
++ expires-in 'expires_in'^ni:jo

View File

@ -9,9 +9,13 @@
++ out (out-quay:auth 'access_token'^access-token)
++ in in-code:auth
++ bak
%- (bak-parse-access:auth . expires-in.aut ~)
|= [access-token=token.aut expires-in=@u]
=+ token-expires=`@da`(add now.bal (mul ~s1 expires-in))
~& authenticated-until/token-expires :: XX handle timeout
+>.$(access-token access-token)
|= res=httr
=+ a=auth
?: (bad-response.a p.res) [%redo ~]
=+ ^- [access-token=@t expires-in=@u]
(grab-json.a res (ot:jo access-token expires-in ~):a)
?: (lth expires-in ^~((div ~d7 ~s1))) :: short-lived token
(toke-req:a 'fb_exchange_token' fb-exchange-token/access-token ~)
[[%redo ~] ..bak(access-token access-token)]
::++ wipe !!
--

View File

@ -4,7 +4,7 @@
::
=+ aut=(oauth2 [`/com/slack /oauth/authorize ~] /api/'oauth.access')
|_ [(bale keys:oauth2) tok=token.aut]
++ aut ~(. ^aut(state-usr |) +<- /client/admin)
++ aut ~(. ^aut +<- /client/admin)
++ out (out-quay:aut 'token'^tok)
++ in in-code:aut
++ bak ((bak-parse-access:aut . ~) |=(tok=token:aut +>(tok tok)))