security - Correct use of Google+ one-time login token -


in sample java code google+ server-side authentication there comment within code handling requests url /connect:

    // state one-time use token, in our     // simple case, want user able connect , disconnect     // without reloading page.  thus, demonstration, don't     // implement best practice.     //request.session().removeattribute("state"); 

the state attribute random sequence generated on page load of default route (/) , must presented ajax call /connect connect request succeed.

the comment implies improper state remain in session, has been commented out allow user log in , out repeatedly in example.

however, want user able log in , out @ will, without reloading page. if keep value state in session allowing exploit? should generating new state , updating somewhere in dom on /disconnect? or should different altogether?

in short, state value set in session used prevent cross-site-request-forgery (csrf/xsrf). in samples, have trusted path when performing oauth v2 flow specific scenario token validation redundant.

for more information state parameter can at:

related question , answer here.


Comments

Popular posts from this blog

curl - PHP fsockopen help required -

HTTP/1.0 407 Proxy Authentication Required PHP -

c# - Resource not found error -