mirror of
https://forge.fsky.io/lda/Parsee.git
synced 2026-03-13 15:05:11 +00:00
[MOD] HMAC-based mediachecking
This commit is contained in:
parent
692cb8aa6f
commit
39cc04fc2e
6 changed files with 115 additions and 9 deletions
|
|
@ -2,27 +2,41 @@
|
|||
|
||||
#include <Cytoplasm/Memory.h>
|
||||
#include <Cytoplasm/Str.h>
|
||||
#include <Cytoplasm/Log.h>
|
||||
|
||||
#include <Matrix.h>
|
||||
#include <Parsee.h>
|
||||
#include <AS.h>
|
||||
|
||||
#include <string.h>
|
||||
|
||||
RouteHead(RouteMedia, arr, argp)
|
||||
{
|
||||
ParseeHttpArg *args = argp;
|
||||
HttpClientContext *cctx;
|
||||
HashMap *reqh;
|
||||
HashMap *reqh, *params;
|
||||
char *server = ArrayGet(arr, 0);
|
||||
char *identi = ArrayGet(arr, 1);
|
||||
char *path, *key, *val;
|
||||
char *hmac, *chkmak = NULL;
|
||||
|
||||
params = HttpRequestParams(args->ctx);
|
||||
hmac = HashMapGet(params, "hmac");
|
||||
|
||||
/* TODO: Make it check the DB for its validicity. "Purging" would be useful.
|
||||
*/
|
||||
if (!server || !identi)
|
||||
{
|
||||
char *concat = StrConcat(3, server, "/", identi);
|
||||
chkmak = ParseeHMACS(args->data->id, concat);
|
||||
Free(concat);
|
||||
}
|
||||
if (!server || !identi || !hmac || !StrEquals(hmac, chkmak))
|
||||
{
|
||||
Free(chkmak);
|
||||
HttpResponseStatus(args->ctx, HTTP_BAD_REQUEST);
|
||||
return MatrixCreateError("M_NOT_YET_UPLOADED", "No server/identifier");
|
||||
}
|
||||
Free(chkmak);
|
||||
|
||||
server = HttpUrlEncode(server);
|
||||
identi = HttpUrlEncode(identi);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue