rest - Multiple Authentication Schemes and WWW-Authenticate Challenges -


i developing rest api supports multiple authentication schemes (oauth, bearer, , basic). when authorization header absent or contains unsupported scheme, service responds multiple www-authenticate headers:

www-authenticate: oauth realm="myrealm" www-authenticate: bearer realm="myrealm" www-authenticate: basic realm="myrealm" 

when request contains authorization header 1 of supported schemes invalid credentials, should service respond all supported www-authenticate schemes, or just scheme provided in request?

for example, if client provides:

authorization: bearer invalid 

should service respond bearer challenge?

www-authenticate: bearer realm="myrealm", error="invalid_token", error_description="token malformed or represents invalid credentials" 

or should respond www-authenticate challenges?

www-authenticate: bearer realm="myrealm", error="invalid_token", error_description="token malformed or represents invalid credentials" www-authenticate: oauth realm="myrealm" www-authenticate: basic realm="myrealm" 

edit: rfc 7235 seems provide suggestion, although not concrete. i've added answer accordingly.

although it's not strictly required, rfc 7235 seems suggest all supported authentication schemes should returned. provide information callers, provided able parse these headers properly.

4.1. www-authenticate

the "www-authenticate" header field indicates authentication scheme(s) , parameters applicable target resource.

www-authenticate = 1#challenge

a server generating 401 (unauthorized) response must send www-authenticate header field containing @ least 1 challenge. server may generate www-authenticate header field in other response messages indicate supplying credentials (or different credentials) might affect response.


Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -