[Improvement] Add params to Challenge
See original GitHub issueAt the moment, Challenge
only contains the auth scheme name and realm. To provide authentication other than Basic
, this is not enough. For instance, for Digest
auth, there are various parameters which have to be parsed and processed.
I suggest to improve the Challenge
class so that it contains not only auth scheme name and realm, but also a list of auth parameters, so that implementors don’t have to parse WWW-Authenticate
again and can use okhttp’s Challenge
instead, which would reduce redundancy. Logically, it sounds reasonable for me that a HTTP framework prepares authentication challenges in a way that they’re already usable by authenticators.
For a suggested layout of Challenge
, please have a look at this HttpUtils.AuthScheme. It contains the auth scheme name, parsed unnamed parameters and parsed named parameters.
For a suggested parsing algorithm of WWW-Authenticate
that generates such parameterized challenge instances, please see HttpUtils.parseWwwAuthenticate and its tests. It handles challenges without parameters, with RFC-compliant parameters (param=value
), and with unnamed parameters (like used in Negotiate
).
Issue Analytics
- State:
- Created 7 years ago
- Reactions:1
- Comments:7 (5 by maintainers)
Top GitHub Comments
Yes, the dav4android methods are designed to be independent of the actual authentication method.
To implement my suggestion, I’d
Challenge
to also store unnamed and named parameters so that authenticators can useresponse.challanges()
to get all required information without parsing headers itself;List<Challenge> parseChallenges(Headers responseHeaders, String challengeHeader)
method so that it extracts name and parameters fromchallengeHeader
.Fixed by https://github.com/square/okhttp/pull/4252