better token type

This commit is contained in:
Anton Dyudin 2016-03-10 11:47:21 -08:00
parent 302c004032
commit cf33f64f81

View File

@ -4,7 +4,7 @@
:: ::
|% |%
++ keys cord:{key/@t sec/@t} :: app key pair ++ keys cord:{key/@t sec/@t} :: app key pair
++ token $@(req/@t {pub/@t sec/@t}) :: pending/authorized ++ token $@($~ {req/? pub/@t sec/@t}) :: none/request/authorized
++ quay-enc (list tape):quay :: partially rendered query string ++ quay-enc (list tape):quay :: partially rendered query string
-- --
:: ::
@ -132,36 +132,37 @@
== ==
:: ::
:: ::
:: post with blank user-secret, used in token exhcange flow
++ post-no-secret
|= {url/purl auq/quay} ^- {$send hiss}
?^ oauth-token ~|(%should-use-token !!)
[%send (add-auth '' auq url %post *math ~)]
::
++ toke-url ++ toke-url
|= quy/quay ^- purl |= quy/quay ^- purl
%_ dialog-url %_ dialog-url
r (fass ?~(usr quy [screen-name+usr quy])) r (fass ?~(usr quy [screen-name+usr quy]))
== ==
:: ::
++ exhange-token `hiss`[exchange-url %post *math ~]
++ request-token `hiss`[token-reqs-url %post *math ~]
::
:: use token to sign authorization header. requires: :: use token to sign authorization header. requires:
:: ++ res (res-handle-reqt handle-token) :: take request token :: ++ res (res-handle-reqt handle-token) :: take request token
:: ++ bak (res-save-access handle-token) :: obtained access token :: ++ bak (res-save-access handle-token) :: obtained access token
++ out-math ++ out-math
^- $-(hiss $%({$send hiss} {$show purl})) ^- $-(hiss $%({$send hiss} {$show purl}))
?: =('' oauth-token) :: XX ?~ ?~ oauth-token
_(post-no-secret token-reqs-url oauth-callback+oauth-callback ~) _[%send (add-auth [oauth-callback+oauth-callback]~ request-token)]
?@ oauth-token ?: req.oauth-token
_[%show (toke-url oauth-token+req.oauth-token ~)] _[%show (toke-url oauth-token+pub.oauth-token ~)]
=+ auq=[oauth-token+pub.oauth-token]~
|= a/hiss ^- {$send hiss} |= a/hiss ^- {$send hiss}
[%send (add-auth sec.oauth-token auq a)] [%send (add-auth [oauth-token+pub.oauth-token]~ a)]
:: ::
++ in-oauth-token ++ in-oauth-token
|= a/quay ^- sec-move |= a/quay ^- sec-move
~| no-token+a ?. ?=({{$'oauth_token' @} $~} a)
?> ?=({{$'oauth_token' @} $~} a) ~|(no-token+a !!)
(post-no-secret exchange-url a) ?~ oauth-token
~|(%no-secret-for-token !!)
?. =(q.i.a pub.oauth-token)
~| wrong-token+[id=usr tok=q.i.a]
~|(%multiple-tokens-unsupported !!)
[%send (add-auth [oauth-token+pub.oauth-token]~ exhange-token)]
:: ::
+- bak-save-access +- bak-save-access
|= handle/$-(token _done) |= handle/$-(token _done)
@ -181,7 +182,7 @@
+- res-handle-reqt +- res-handle-reqt
|= handle/$-(token _done) |= handle/$-(token _done)
?~ oauth-token ?~ oauth-token
(res-save-reqt . handle) (res-save-reqt handle)
res-give res-give
:: ::
+- res-save-reqt +- res-save-reqt
@ -194,11 +195,11 @@
:: ::
:: ::
++ add-auth ++ add-auth
|= $: token-secret/@t |= $: auq/quay :: extra oauth parameters
auq/quay :: extra oauth parameters
hiz/{purl meth hed/math (unit octs)} hiz/{purl meth hed/math (unit octs)}
== ==
^- hiss ^- hiss
~& add-auth+(earn -.hiz)
=< %_ hiz =< %_ hiz
hed (~(add ja hed.hiz) %authorization authorization) hed (~(add ja hed.hiz) %authorization authorization)
== ==
@ -236,6 +237,7 @@
(sifo (swap 3 (hmac (swap 3 signing-key) (crip bay)))) (sifo (swap 3 (hmac (swap 3 signing-key) (crip bay))))
:: ::
++ signing-key ++ signing-key
=+ token-secret=?~(oauth-token '' pub.oauth-token)
%- crip %- crip
%- join-urle :~ %- join-urle :~
(trip consumer-secret) (trip consumer-secret)