Way back in June I was brainstorming about ideas for decentralized authentication. Here’s a summary of the requirements I wanted:
- Competely stateless servers. Servers that host browser applications and restful services would not have to store usernames, passwords, or permission metadata (roles allowed).
- Servers would not have to handshake with an Identity Provider (IDP). An HTTP request should contain all the information a server needs to authenticate and authorize a client.
- A single web request can spawn complex authenticated and authorized interactions between underlying distributed web services. This single web request would have all the metadata needed to invoke these complex underlying interactions between distributed services.
Unifying Interactions With Cookies
The problem with the protocol discussed in my previous blog was that it relied on new headers being transmitted between the client and server. This sort of mechanism just wouldn’t work with browser-based applications. Why? Well, a browser isn’t going to know how to transmit and process new headers. The only way to get a browser to store and forward metadata is via a cookie. Most browser-based apps already use a session cookie to authenticate users (after a log-in of course). There’s no reason we couldn’t re-use the digital signature techniques discussed in my previous blog with cookies. Here’s how it could work:
- Browser points to example.com
- example.com redirects browser to idp.com (the identity provider)
- User logins into the IDP
- IDP redirects back to example.com. The forward URL has all security metadata needed for the request, digitally signed (a query parameter would have the signature). The amazon url signing technique could be used.
- Example.com would authenticate and authorize based on the query parameters of the forward URL and also verify the signature.
- Example.com would send back a set of cookies that contained all the security metadata expressed as cookie name/value pairs. A special digital signature cookie would be used to sign them all so that on subsequent requests, the server could verify all the information stored in these cookies.
Step #4 might be problematic as the URLs could get quite large. Who knows if a browser barfs on absurdly long URLs. In this cast we could do a double form-post. IDP could response from a successful login with an HTML Form whose target is Example.com. This form would have all hidden fields within it containing security metadata. One particulr form parameter would have a digital signature (I think SAML HTTP bindings work like this).
One vulnerability here is the cross-site scripting hack. Most website already have this vulnerability I believe, so using existing techniques would be best. I’m not sure how website solve this particular problem, but the HttpOnly flag could be used with each session cookie. Javascript apps could have their javascript dynamically generated by the server and include the necessary code to manually apply and send the appropriate cookies. Another thing that might mitigate things, is to include a timestamp with the cookies. The application server would check for stale timestamps and with each request reset the digitally signed cookies with a new timestamp.
Non-Browser Clients Use Cookies Too
For non-browser clients, they could use a simpler RESTful protocol to obtain a signed URL or the set of signed form parameters. There’s also no reason they couldn’t get a set of signed cookies instead of either of these approaches.
Leave a Reply