Signed-off-by: Martin Storsjö <martin@martin.st>
| ... | ... |
@@ -57,6 +57,9 @@ static void handle_digest_params(HTTPAuthState *state, const char *key, |
| 57 | 57 |
} else if (!strncmp(key, "qop=", key_len)) {
|
| 58 | 58 |
*dest = digest->qop; |
| 59 | 59 |
*dest_len = sizeof(digest->qop); |
| 60 |
+ } else if (!strncmp(key, "stale=", key_len)) {
|
|
| 61 |
+ *dest = digest->stale; |
|
| 62 |
+ *dest_len = sizeof(digest->stale); |
|
| 60 | 63 |
} |
| 61 | 64 |
} |
| 62 | 65 |
|
| ... | ... |
@@ -93,6 +96,7 @@ void ff_http_auth_handle_header(HTTPAuthState *state, const char *key, |
| 93 | 93 |
state->auth_type <= HTTP_AUTH_BASIC) {
|
| 94 | 94 |
state->auth_type = HTTP_AUTH_BASIC; |
| 95 | 95 |
state->realm[0] = 0; |
| 96 |
+ state->stale = 0; |
|
| 96 | 97 |
ff_parse_key_value(p, (ff_parse_key_val_cb) handle_basic_params, |
| 97 | 98 |
state); |
| 98 | 99 |
} else if (av_stristart(value, "Digest ", &p) && |
| ... | ... |
@@ -100,10 +104,13 @@ void ff_http_auth_handle_header(HTTPAuthState *state, const char *key, |
| 100 | 100 |
state->auth_type = HTTP_AUTH_DIGEST; |
| 101 | 101 |
memset(&state->digest_params, 0, sizeof(DigestParams)); |
| 102 | 102 |
state->realm[0] = 0; |
| 103 |
+ state->stale = 0; |
|
| 103 | 104 |
ff_parse_key_value(p, (ff_parse_key_val_cb) handle_digest_params, |
| 104 | 105 |
state); |
| 105 | 106 |
choose_qop(state->digest_params.qop, |
| 106 | 107 |
sizeof(state->digest_params.qop)); |
| 108 |
+ if (!av_strcasecmp(state->digest_params.stale, "true")) |
|
| 109 |
+ state->stale = 1; |
|
| 107 | 110 |
} |
| 108 | 111 |
} else if (!strcmp(key, "Authentication-Info")) {
|
| 109 | 112 |
ff_parse_key_value(value, (ff_parse_key_val_cb) handle_digest_update, |
| ... | ... |
@@ -237,6 +244,9 @@ char *ff_http_auth_create_response(HTTPAuthState *state, const char *auth, |
| 237 | 237 |
{
|
| 238 | 238 |
char *authstr = NULL; |
| 239 | 239 |
|
| 240 |
+ /* Clear the stale flag, we assume the auth is ok now. It is reset |
|
| 241 |
+ * by the server headers if there's a new issue. */ |
|
| 242 |
+ state->stale = 0; |
|
| 240 | 243 |
if (!auth || !strchr(auth, ':')) |
| 241 | 244 |
return NULL; |
| 242 | 245 |
|
| ... | ... |
@@ -41,6 +41,9 @@ typedef struct {
|
| 41 | 41 |
char opaque[300]; /**< A server-specified string that should be |
| 42 | 42 |
* included in authentication responses, not |
| 43 | 43 |
* included in the actual digest calculation. */ |
| 44 |
+ char stale[10]; /**< The server indicated that the auth was ok, |
|
| 45 |
+ * but needs to be redone with a new, non-stale |
|
| 46 |
+ * nonce. */ |
|
| 44 | 47 |
int nc; /**< Nonce count, the number of earlier replies |
| 45 | 48 |
* where this particular nonce has been used. */ |
| 46 | 49 |
} DigestParams; |
| ... | ... |
@@ -62,6 +65,10 @@ typedef struct {
|
| 62 | 62 |
* The parameters specifiec to digest authentication. |
| 63 | 63 |
*/ |
| 64 | 64 |
DigestParams digest_params; |
| 65 |
+ /** |
|
| 66 |
+ * Auth ok, but needs to be resent with a new nonce. |
|
| 67 |
+ */ |
|
| 68 |
+ int stale; |
|
| 65 | 69 |
} HTTPAuthState; |
| 66 | 70 |
|
| 67 | 71 |
void ff_http_auth_handle_header(HTTPAuthState *state, const char *key, |