-
Notifications
You must be signed in to change notification settings - Fork 10
Description
When doing development / debug / testing of oauth/openid flows - the interactive web browser portion finishes with a redirect to a URL that is meant to receive the authorisation code in a URL param (at which point it will go and do some code exchanges).
Scripting testing of this in something like bash is painful - but I think oneshot with very minimal additions could help out.
As a proof of concept - I used oneshot like this
oneshot -D -S 'echo "$QUERY_STRING"'
and set up my oauth redirect to http://127.0.0.1:8080
.
I initiated my oauth flow in bash, launched a browser to do the login portion, and see that the page then redirects to oneshot with a GET of
http://127.0.0.1:8080?code=ABCDEFGH&state=XYZ
(i.e. the browser shows the output of the shell/CGI and then exits .. code=ABCDEFGH&state=XYZ)
However, I have no way of getting that information out of the invocation of oneshot in my bash script. I was thinking of a series of command line flags that would instruct oneshot to print this information on the end of the request.
So something like
--echo-from-client query_string
where the sky is the limit for what details of the client could be shown. I'd possibly start with any of the variables that are in the environment of the CGI launch.
query_string
http_user_agent
remote_host
http_accept
So the expected invocation pattern would be
QUERY=$(oneshot -q -D -S 'echo "Thanks"' --echo-from-client query_string)
I realise this is a bit outside the box from what oneshot was intended for - but does fall into the category of things that I need a http server that only responds once for!