raop: Use the real URI for digest authentication rather than *

Yamaha MusicCast (or at least the RX-A880) seems to be stricter about
the URI here, as it rejects `*`. Examples, such as those documented by
OpenAirplay, use the real URI.
This commit is contained in:
James Le Cuirot 2022-10-11 23:27:16 +01:00 committed by Wim Taymans
parent f613922d0e
commit 4b0945bf01
3 changed files with 12 additions and 4 deletions

View file

@ -1219,7 +1219,7 @@ static int rtsp_do_auth(struct impl *impl, const struct spa_dict *headers)
spa_scnprintf(auth, sizeof(auth), "Basic %s", enc); spa_scnprintf(auth, sizeof(auth), "Basic %s", enc);
} }
else if (spa_streq(tokens[0], "Digest")) { else if (spa_streq(tokens[0], "Digest")) {
const char *realm, *nonce; const char *realm, *nonce, *url;
char h1[MD5_HASH_LENGTH+1]; char h1[MD5_HASH_LENGTH+1];
char h2[MD5_HASH_LENGTH+1]; char h2[MD5_HASH_LENGTH+1];
char resp[MD5_HASH_LENGTH+1]; char resp[MD5_HASH_LENGTH+1];
@ -1229,13 +1229,15 @@ static int rtsp_do_auth(struct impl *impl, const struct spa_dict *headers)
if (realm == NULL || nonce == NULL) if (realm == NULL || nonce == NULL)
goto error; goto error;
url = pw_rtsp_client_get_url(impl->rtsp);
MD5_hash(h1, "%s:%s:%s", DEFAULT_USER_NAME, realm, impl->password); MD5_hash(h1, "%s:%s:%s", DEFAULT_USER_NAME, realm, impl->password);
MD5_hash(h2, "OPTIONS:*"); MD5_hash(h2, "OPTIONS:%s", url);
MD5_hash(resp, "%s:%s:%s", h1, nonce, h2); MD5_hash(resp, "%s:%s:%s", h1, nonce, h2);
spa_scnprintf(auth, sizeof(auth), spa_scnprintf(auth, sizeof(auth),
"username=\"%s\", realm=\"%s\", nonce=\"%s\", uri=\"*\", response=\"%s\"", "username=\"%s\", realm=\"%s\", nonce=\"%s\", uri=\"%s\", response=\"%s\"",
DEFAULT_USER_NAME, realm, nonce, resp); DEFAULT_USER_NAME, realm, nonce, url, resp);
} }
else else
goto error; goto error;

View file

@ -133,6 +133,11 @@ void *pw_rtsp_client_get_user_data(struct pw_rtsp_client *client)
return client->user_data; return client->user_data;
} }
const char *pw_rtsp_client_get_url(struct pw_rtsp_client *client)
{
return client->url;
}
void pw_rtsp_client_add_listener(struct pw_rtsp_client *client, void pw_rtsp_client_add_listener(struct pw_rtsp_client *client,
struct spa_hook *listener, struct spa_hook *listener,
const struct pw_rtsp_client_events *events, void *data) const struct pw_rtsp_client_events *events, void *data)

View file

@ -57,6 +57,7 @@ struct pw_rtsp_client * pw_rtsp_client_new(struct pw_loop *main_loop,
void pw_rtsp_client_destroy(struct pw_rtsp_client *client); void pw_rtsp_client_destroy(struct pw_rtsp_client *client);
void *pw_rtsp_client_get_user_data(struct pw_rtsp_client *client); void *pw_rtsp_client_get_user_data(struct pw_rtsp_client *client);
const char *pw_rtsp_client_get_url(struct pw_rtsp_client *client);
void pw_rtsp_client_add_listener(struct pw_rtsp_client *client, void pw_rtsp_client_add_listener(struct pw_rtsp_client *client,
struct spa_hook *listener, struct spa_hook *listener,