[PATCH phosphor-rest-server] Add a convenient/short logout command

Brad Bishop bradleyb at fuzziesquirrel.com
Fri Jun 17 22:57:03 AEST 2016


> On Jun 17, 2016, at 8:00 AM, OpenBMC Patches <openbmc-patches at stwcx.xyz> wrote:
> 
> From: Nan Li <bjlinan at cn.ibm.com>
> 
> With this patch, we can logout by:
>    curl -c cjar -b cjar -k https://BMC/logout
> Traditional/json format logout is retained.
> 
> Signed-off-by: Nan Li <bjlinan at cn.ibm.com>
> ---
> obmc-rest | 5 +++++
> 1 file changed, 5 insertions(+)
> 
> diff --git a/obmc-rest b/obmc-rest
> index e7dbbba..8750a1f 100644
> --- a/obmc-rest
> +++ b/obmc-rest
> @@ -411,6 +411,7 @@ class SessionHandler(MethodHandler):
>     ''' Handles the /login and /logout routes, manages
>     server side session store and session cookies.  '''
> 
> +    verbs = ['POST', 'GET']
>     rules = ['/login', '/logout']
>     login_str = "User '%s' logged %s"
>     bad_passwd_str = "Invalid username or password"
> @@ -460,6 +461,10 @@ class SessionHandler(MethodHandler):
>             request.get_cookie(
>                 'sid', secret=self.hmac_key))
> 
> +    def do_get(self, **kw):

I like what you are thinking here but we can’t do this.  A good rule of thumb when deciding if something can be a GET rather than POST is if everything would continue to work if the client cached the reply, which for logout clearly isn’t the case.

One thing that can be fixed with logout is right now you are required to pass post data like this:  ‘{“data”: []}’

It would be nice if we could get rid of that (but still do a post).

What I do to cut down on typing is create a .curlrc file and put all the options in there.

$cat ~/.curlrc

cookie = "/tmp/.cjar"
cookie-jar = "/tmp/.cjar”

Thats all I have in mine but you can add the other options too.  Check out the curl manpage.  

> +        if request.path == '/logout':
> +            return self.do_logout(**kw)
> +
>     def do_post(self, **kw):
>         if request.path == '/login':
>             return self.do_login(**kw)
> -- 
> 2.8.4
> 
> 
> _______________________________________________
> openbmc mailing list
> openbmc at lists.ozlabs.org
> https://lists.ozlabs.org/listinfo/openbmc


More information about the openbmc mailing list