Skip to content

Commit

Permalink
Fix digest challenge support for Safari
Browse files Browse the repository at this point in the history
  • Loading branch information
Gene Gleyzer committed Nov 24, 2024
1 parent f2f6084 commit 982f05c
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions lib_web/src/main/x/web/security/DigestAuthenticator.x
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,15 @@ service DigestAuthenticator
if (!passed) {
// to cause the client to request the user for a name and password, we need to return an
// "Unauthorized" error code with a header that directs the client to use Digest auth
String nonce = toString(nonces.generate());
String nonce = toString(nonces.generate());
String[] challenges = new String[];

// Safari only supports "md5-sess" algorithm
// REVIEW CP: there is a chance they all drop it; should we limit the challenge to "md5"
Signer[] hashers = (request.userAgent?.indexOf("Safari") : False)
? [md5]
: this.hashers;

for (Signer hasher : hashers) {
challenges += $|Digest realm="{realm.name}",\
|qop="auth",\
Expand Down Expand Up @@ -458,7 +465,7 @@ service DigestAuthenticator
* @param s a String in the format defined by
* [RFC 5987](https://datatracker.ietf.org/doc/html/rfc5987)
*
* @return `True` iff the String contents were successfull decoded
* @return `True` iff the String contents were successfully decoded
* @return (conditional) the decoded String contents
*/
static conditional String decodeUtf8MimeHeader(String text) {
Expand Down

0 comments on commit 982f05c

Please sign in to comment.