http - How to format header WWW-Authenticate when authentication fails -
i'm implementing rest api provides functionality authenticating users. authentication requires user send post request following data in body:
{ "useroremail": "spook", "passowrd": "test1234" }
if username , password match, user gets token server, while if don't, server returns 401 unauthorized, following header:
www-authenticate: credentials realm="http://localhost:9000/auth/users/credentials"
is header acceptable? realm
contains location user can try authenticate again.
it appears acceptable, maybe not optimal except under specific conditions. rfc1945:
the realm value (case-sensitive), in combination canonical root url of server being accessed, defines protection space. these realms allow protected resources on server partitioned set of protection spaces, each own authentication scheme and/or authorization database. realm value string, assigned origin server, may have additional semantics specific authentication scheme.
so, can, might paranoid multiple applications using same authentication , inadvertently cross-authenticating if share same realm name. better isolate realm application, on safe side.
Comments
Post a Comment