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:
- forming url (oauth v2)
- confirm anti-forgery state token
Comments
Post a Comment