The first is the "proper" way, via Authorization headers. The second, less proper, but still acceptable (by reason of extensibility) is session cookies.
@ton.yeung right. The advantage of cookies is its automatic, the browser handles it, the javascript cant touch it, and its well understood.
@ton.yeung right, but cookies are still a well-enough understood and accepted mechanism that they can be used by any client that speaks HTTP.
@ton.yeung not necessarily. I am not sure at all you should go that way... there is a lot more implementation complexity.
and too many ways to get it wrong.
with cookies, its pretty much built in, you just need to wire it up.
@ton.yeung the client? yeah.
doesnt matter what, any of your clients will be calling your API over HTTP - they can simply manage the cookies themselves.
@ton.yeung after the login call, it would read out the cookie from the response, and set it on every request...
@ton.yeung I think thats fair enough.
wouldnt be that much different saying "we use this Authorization header, deal wit it"...
but business-wise, you'd be better off discussing specific possible clients, see what they need, work it for them .
@ton.yeung talked to anyone specific?
@ton.yeung yeah, exactly. Probably simpler than the header... there are some clients where that would be tricky.
@ton.yeung "authentication". but yeah.
note that asp.net webapi is not automatically tied to the asp.net server - there is no implicit "session" or anything like that. so you'll need to wire that up explicitly.
@ton.yeung no, keep that on the server, in the session. the cookie should be just the session id.
@ton.yeung right, exactly.
@ton.yeung sfunny, right before you came along we were having a long discussion about when the two are conflated or confused.
its funny, because its so rare that we have a serious security discussion here, and now we have two right in a row, about similar topic...
session id == authn token.
@ton.yeung not a good idea. usually.
@ton.yeung are you sure? I'm familiar with it creating a standard session id...
anyway, I've gotta go. maybe someone else here can help, if you need anything more... good luck .