diff options
Diffstat (limited to 'src/include/microhttpd.h')
-rw-r--r-- | src/include/microhttpd.h | 328 |
1 files changed, 327 insertions, 1 deletions
diff --git a/src/include/microhttpd.h b/src/include/microhttpd.h index 67f26bc3..e8e4da07 100644 --- a/src/include/microhttpd.h +++ b/src/include/microhttpd.h | |||
@@ -96,7 +96,7 @@ extern "C" | |||
96 | * they are parsed as decimal numbers. | 96 | * they are parsed as decimal numbers. |
97 | * Example: 0x01093001 = 1.9.30-1. | 97 | * Example: 0x01093001 = 1.9.30-1. |
98 | */ | 98 | */ |
99 | #define MHD_VERSION 0x00097518 | 99 | #define MHD_VERSION 0x00097519 |
100 | 100 | ||
101 | /* If generic headers don't work on your platform, include headers | 101 | /* If generic headers don't work on your platform, include headers |
102 | which define 'va_list', 'size_t', 'ssize_t', 'intptr_t', 'off_t', | 102 | which define 'va_list', 'size_t', 'ssize_t', 'intptr_t', 'off_t', |
@@ -4334,6 +4334,331 @@ MHD_destroy_post_processor (struct MHD_PostProcessor *pp); | |||
4334 | */ | 4334 | */ |
4335 | #define MHD_INVALID_NONCE -1 | 4335 | #define MHD_INVALID_NONCE -1 |
4336 | 4336 | ||
4337 | /** | ||
4338 | * The flag indicating non-session algorithm types, | ||
4339 | * like 'MD5' or 'SHA-256'. | ||
4340 | * @note Available since #MHD_VERSION 0x00097519 | ||
4341 | */ | ||
4342 | #define MHD_DIGEST_AUTH_ALGO3_NON_SESSION (1 << 6) | ||
4343 | |||
4344 | /** | ||
4345 | * The flag indicating session algorithm types, | ||
4346 | * like 'MD5-sess' or 'SHA-256-sess'. | ||
4347 | * @note Available since #MHD_VERSION 0x00097519 | ||
4348 | */ | ||
4349 | #define MHD_DIGEST_AUTH_ALGO3_SESSION (1 << 7) | ||
4350 | |||
4351 | /** | ||
4352 | * Digest algorithm identification | ||
4353 | * @warning Do not be confused with #MHD_DigestAuthAlgorithm, | ||
4354 | * which uses other values! | ||
4355 | * @note Available since #MHD_VERSION 0x00097519 | ||
4356 | */ | ||
4357 | enum MHD_DigestAuthAlgo3 | ||
4358 | { | ||
4359 | /** | ||
4360 | * Unknown or wrong algorithm type. | ||
4361 | * Used in struct MHD_DigestAuthInfo to indicate client value that | ||
4362 | * cannot by identified. | ||
4363 | */ | ||
4364 | MHD_DIGEST_AUTH_ALGO3_INVALID = 0, | ||
4365 | /** | ||
4366 | * The 'MD5' algorithm. | ||
4367 | */ | ||
4368 | MHD_DIGEST_AUTH_ALGO3_MD5 = | ||
4369 | (1 << 0) | MHD_DIGEST_AUTH_ALGO3_NON_SESSION, | ||
4370 | /** | ||
4371 | * The 'MD5-sess' algorithm. | ||
4372 | * Not supported by MHD. | ||
4373 | */ | ||
4374 | MHD_DIGEST_AUTH_ALGO3_MD5_SESSION = | ||
4375 | (1 << 0) | MHD_DIGEST_AUTH_ALGO3_SESSION, | ||
4376 | /** | ||
4377 | * The 'SHA-256' algorithm. | ||
4378 | */ | ||
4379 | MHD_DIGEST_AUTH_ALGO3_SHA256 = | ||
4380 | (1 << 1) | MHD_DIGEST_AUTH_ALGO3_NON_SESSION, | ||
4381 | /** | ||
4382 | * The 'SHA-256-sess' algorithm. | ||
4383 | * Not supported by MHD. | ||
4384 | */ | ||
4385 | MHD_DIGEST_AUTH_ALGO3_SHA256_SESSION = | ||
4386 | (1 << 1) | MHD_DIGEST_AUTH_ALGO3_SESSION, | ||
4387 | /** | ||
4388 | * The 'SHA-512-256' (SHA-512/256) algorithm. | ||
4389 | * Not supported by MHD. | ||
4390 | */ | ||
4391 | MHD_DIGEST_AUTH_ALGO3_SHA512_256 = | ||
4392 | (1 << 2) | MHD_DIGEST_AUTH_ALGO3_NON_SESSION, | ||
4393 | /** | ||
4394 | * The 'SHA-512-256-sess' (SHA-512/256 session) algorithm. | ||
4395 | * Not supported by MHD. | ||
4396 | */ | ||
4397 | MHD_DIGEST_AUTH_ALGO3_SHA512_256_SESSION = | ||
4398 | (1 << 2) | MHD_DIGEST_AUTH_ALGO3_SESSION, | ||
4399 | /** | ||
4400 | * Any non-session algorithm, MHD will choose. | ||
4401 | */ | ||
4402 | MHD_DIGEST_AUTH_ALGO3_ANY_NON_SESSION = | ||
4403 | (0x3F) | MHD_DIGEST_AUTH_ALGO3_NON_SESSION, | ||
4404 | /** | ||
4405 | * Any session algorithm, MHD will choose. | ||
4406 | * Not supported by MHD. | ||
4407 | */ | ||
4408 | MHD_DIGEST_AUTH_ALGO3_ANY_SESSION = | ||
4409 | (0x3F) | MHD_DIGEST_AUTH_ALGO3_SESSION, | ||
4410 | /** | ||
4411 | * Any algorithm, MHD will choose. | ||
4412 | */ | ||
4413 | MHD_DIGEST_AUTH_ALGO3_ANY = | ||
4414 | (0x3F) | MHD_DIGEST_AUTH_ALGO3_NON_SESSION | MHD_DIGEST_AUTH_ALGO3_SESSION | ||
4415 | } _MHD_FLAGS_ENUM; | ||
4416 | |||
4417 | /** | ||
4418 | * The type of username used by client in Digest Authorization header | ||
4419 | * | ||
4420 | * @note Available since #MHD_VERSION 0x00097519 | ||
4421 | */ | ||
4422 | enum MHD_DigestAuthUsernameType | ||
4423 | { | ||
4424 | /** | ||
4425 | * No username parameter in in Digest Authorization header. | ||
4426 | * This should be treated as an error. | ||
4427 | */ | ||
4428 | MHD_DIGEST_AUTH_UNAME_TYPE_MISSING = 0, | ||
4429 | /** | ||
4430 | * The 'username' parameter is used to specify the username. | ||
4431 | */ | ||
4432 | MHD_DIGEST_AUTH_UNAME_TYPE_STANDARD = 1, | ||
4433 | /** | ||
4434 | * The username is specified by 'username*' parameter with | ||
4435 | * the extended notation (see RFC 5987 #section-3.2.1). | ||
4436 | * The only difference between standard and extended types is | ||
4437 | * the way how username value is encoded in the header. | ||
4438 | */ | ||
4439 | MHD_DIGEST_AUTH_UNAME_TYPE_EXTENDED = 2, | ||
4440 | /** | ||
4441 | * The username provided in form of 'userhash' as | ||
4442 | * specified by RFC 7616 #section-3.4.4. | ||
4443 | */ | ||
4444 | MHD_DIGEST_AUTH_UNAME_TYPE_USERHASH = 3, | ||
4445 | /** | ||
4446 | * The invalid combination of username parameters are used by client. | ||
4447 | * Either: | ||
4448 | * * both 'username' and 'username*' are used | ||
4449 | * * 'username*' is used with 'userhash=true' | ||
4450 | * * 'username*' used with invalid extended notation | ||
4451 | * * 'username' is not hexadecimal digits, while 'userhash' set to 'true' | ||
4452 | */ | ||
4453 | MHD_DIGEST_AUTH_UNAME_TYPE_INVALID = 15 | ||
4454 | } _MHD_FIXED_ENUM; | ||
4455 | |||
4456 | /** | ||
4457 | * The QOP ('quality of protection') types. | ||
4458 | * @note Available since #MHD_VERSION 0x00097519 | ||
4459 | */ | ||
4460 | enum MHD_DigestAuthQOP | ||
4461 | { | ||
4462 | /** | ||
4463 | * Invalid/unknown QOP. | ||
4464 | * Used in struct MHD_DigestAuthInfo to indicate client value that | ||
4465 | * cannot by identified. | ||
4466 | */ | ||
4467 | MHD_DIGEST_AUTH_QOP_INVALID = 0, | ||
4468 | /** | ||
4469 | * No QOP value. | ||
4470 | */ | ||
4471 | MHD_DIGEST_AUTH_QOP_NONE = 1 << 0, | ||
4472 | /** | ||
4473 | * The 'auth' QOP type. | ||
4474 | */ | ||
4475 | MHD_DIGEST_AUTH_QOP_AUTH = 1 << 1, | ||
4476 | /** | ||
4477 | * The 'auth-int' QOP type. | ||
4478 | * Not supported by MHD. | ||
4479 | */ | ||
4480 | MHD_DIGEST_AUTH_QOP_AUTH_INT = 1 << 2 | ||
4481 | } _MHD_FLAGS_ENUM; | ||
4482 | |||
4483 | /** | ||
4484 | * The invalid value of 'nc' parameter in client Digest Authorization header. | ||
4485 | * @note Available since #MHD_VERSION 0x00097519 | ||
4486 | */ | ||
4487 | #define MHD_DIGEST_AUTH_INVALID_NC_VALUE (0) | ||
4488 | |||
4489 | /** | ||
4490 | * Information from Digest Authorization client's header. | ||
4491 | * | ||
4492 | * All buffers pointed by any struct members are freed when #MHD_free() is | ||
4493 | * called for pointer to this structure. | ||
4494 | * | ||
4495 | * Application may modify buffers as needed until #MHD_free() is called for | ||
4496 | * pointer to this structure | ||
4497 | * @note Available since #MHD_VERSION 0x00097519 | ||
4498 | */ | ||
4499 | struct MHD_DigestAuthInfo | ||
4500 | { | ||
4501 | /** | ||
4502 | * The algorithm as defined by client. | ||
4503 | * Set automatically to MD5 if not specified by client. | ||
4504 | * No "group" (ALGO3_ANY) values are used. | ||
4505 | * @warning Do not be confused with #MHD_DigestAuthAlgorithm, | ||
4506 | * which uses other values! | ||
4507 | */ | ||
4508 | enum MHD_DigestAuthAlgo3 algo; | ||
4509 | /** | ||
4510 | * The type of username used by client. | ||
4511 | */ | ||
4512 | enum MHD_DigestAuthUsernameType uname_type; | ||
4513 | /** | ||
4514 | * The username string. | ||
4515 | * Valid only if username is standard, extended, or userhash. | ||
4516 | * For userhash this is unqoted string without decoding of the | ||
4517 | * hexadecimal digits (as provided by client). | ||
4518 | * If extended notation is used, this string is pct-decoded string | ||
4519 | * with charset and language tag removed (i.e. it is original username | ||
4520 | * extracted from the extended notation). | ||
4521 | * This can be NULL is username is missing or invalid. | ||
4522 | */ | ||
4523 | char *username; | ||
4524 | /** | ||
4525 | * The length of the @a username. | ||
4526 | * When the @a username is NULL, this member is always zero. | ||
4527 | */ | ||
4528 | size_t username_len; | ||
4529 | /** | ||
4530 | * The userhash decoded to binary form. | ||
4531 | * Used only if username type is userhash, always NULL otherwise. | ||
4532 | * @warning this is a binary data, no zero termination | ||
4533 | */ | ||
4534 | uint8_t *userhash_bin; | ||
4535 | /** | ||
4536 | * The number of bytes pointed by the @a userhash_bin. | ||
4537 | * When the @a userhash_bin is NULL, this member is always zero. | ||
4538 | */ | ||
4539 | size_t userhash_bin_size; | ||
4540 | /** | ||
4541 | * The 'opaque' parameter value, as specified by client. | ||
4542 | * NULL if not specified by client. | ||
4543 | */ | ||
4544 | char *opaque; | ||
4545 | /** | ||
4546 | * The length of the @a opaque. | ||
4547 | * When the @a opaque is NULL, this member is always zero. | ||
4548 | */ | ||
4549 | size_t opaque_len; | ||
4550 | /** | ||
4551 | * The 'realm' parameter value, as specified by client. | ||
4552 | * NULL if not specified by client. | ||
4553 | */ | ||
4554 | char *realm; | ||
4555 | /** | ||
4556 | * The length of the @a realm. | ||
4557 | * When the @a realm is NULL, this member is always zero. | ||
4558 | */ | ||
4559 | size_t realm_len; | ||
4560 | /** | ||
4561 | * The 'qop' parameter value. | ||
4562 | */ | ||
4563 | enum MHD_DigestAuthQOP qop; | ||
4564 | /** | ||
4565 | * The length of the 'cnonce' parameter value, including possible | ||
4566 | * backslash-escape characters. | ||
4567 | * 'cnonce' is used in hash calculation, which is CPU-intensive procedure. | ||
4568 | * An applicaion may want to reject too large cnonces to limit the CPU load. | ||
4569 | * A few kilobytes is a reasonable limit, typically cnonce is just 32-160 | ||
4570 | * characters long. | ||
4571 | */ | ||
4572 | size_t cnonce_len; | ||
4573 | /** | ||
4574 | * The nc parameter value. | ||
4575 | * Can be used by application to limit the number of nonce re-uses. If @ nc | ||
4576 | * is higher than application wants to allow, then fail response with | ||
4577 | * 'stale=true' could be used to ask force client to get the fresh 'nonce'. | ||
4578 | * If not specified by client or does not have hexadecimal digits only, the | ||
4579 | * value is #MHD_DIGEST_AUTH_INVALID_NC_VALUE. | ||
4580 | */ | ||
4581 | uint32_t nc; | ||
4582 | }; | ||
4583 | |||
4584 | /** | ||
4585 | * Get information about Digest Authorization client's header. | ||
4586 | * | ||
4587 | * @param connection The MHD connection structure | ||
4588 | * @return NULL if no valid Digest Authorization header is used in the request; | ||
4589 | * a pointer to the structure with information if the valid request | ||
4590 | * header found, free using #MHD_free(). | ||
4591 | * @note Available since #MHD_VERSION 0x00097519 | ||
4592 | * @ingroup authentication | ||
4593 | */ | ||
4594 | _MHD_EXTERN struct MHD_DigestAuthInfo * | ||
4595 | MHD_digest_auth_get_request_info3 (struct MHD_Connection *connection); | ||
4596 | |||
4597 | |||
4598 | /** | ||
4599 | * Information from Digest Authorization client's header. | ||
4600 | * | ||
4601 | * All buffers pointed by any struct members are freed when #MHD_free() is | ||
4602 | * called for pointer to this structure. | ||
4603 | * | ||
4604 | * Application may modify buffers as needed until #MHD_free() is called for | ||
4605 | * pointer to this structure | ||
4606 | * @note Available since #MHD_VERSION 0x00097519 | ||
4607 | */ | ||
4608 | struct MHD_DigestAuthUsernameInfo | ||
4609 | { | ||
4610 | /** | ||
4611 | * The type of username used by client. | ||
4612 | * The 'invalid' and 'missing' types are not used in this structure, | ||
4613 | * instead NULL is returned by #MHD_digest_auth_get_username3(). | ||
4614 | */ | ||
4615 | enum MHD_DigestAuthUsernameType uname_type; | ||
4616 | /** | ||
4617 | * The username string. | ||
4618 | * Valid only if username is standard, extended, or userhash. | ||
4619 | * For userhash this is unqoted string without decoding of the | ||
4620 | * hexadecimal digits (as provided by client). | ||
4621 | * If extended notation is used, this string is pct-decoded string | ||
4622 | * with charset and language tag removed (i.e. it is original username | ||
4623 | * extracted from the extended notation). | ||
4624 | * This can be NULL is username is missing or invalid. | ||
4625 | */ | ||
4626 | char *username; | ||
4627 | /** | ||
4628 | * The length of the @a username. | ||
4629 | * When the @a username is NULL, this member is always zero. | ||
4630 | */ | ||
4631 | size_t username_len; | ||
4632 | /** | ||
4633 | * The userhash decoded to binary form. | ||
4634 | * Used only if username type is userhash, always NULL if not used. | ||
4635 | * @warning this is a binary data, no zero termination | ||
4636 | */ | ||
4637 | uint8_t *userhash_bin; | ||
4638 | /** | ||
4639 | * The number of bytes pointed by the @a userhash_bin. | ||
4640 | * When the @a userhash_bin is NULL, this member is always zero. | ||
4641 | */ | ||
4642 | size_t userhash_bin_size; | ||
4643 | }; | ||
4644 | |||
4645 | /** | ||
4646 | * Get the username from Digest Authorization client's header. | ||
4647 | * | ||
4648 | * @param connection The MHD connection structure | ||
4649 | * @return NULL if no valid Digest Authorization header is used in the request, | ||
4650 | * or no username parameter is present in the header, or username is | ||
4651 | * provided incorrectly by client (see description for | ||
4652 | * #MHD_DIGEST_AUTH_UNAME_TYPE_INVALID); | ||
4653 | * a pointer structure with information if the valid request header | ||
4654 | * found, free using #MHD_free(). | ||
4655 | * @sa MHD_digest_auth_get_request_info3() provides more complete information | ||
4656 | * @note Available since #MHD_VERSION 0x00097519 | ||
4657 | * @ingroup authentication | ||
4658 | */ | ||
4659 | _MHD_EXTERN struct MHD_DigestAuthUsernameInfo * | ||
4660 | MHD_digest_auth_get_username3 (struct MHD_Connection *connection); | ||
4661 | |||
4337 | 4662 | ||
4338 | /** | 4663 | /** |
4339 | * Get the username from the authorization header sent by the client | 4664 | * Get the username from the authorization header sent by the client |
@@ -4341,6 +4666,7 @@ MHD_destroy_post_processor (struct MHD_PostProcessor *pp); | |||
4341 | * @param connection The MHD connection structure | 4666 | * @param connection The MHD connection structure |
4342 | * @return NULL if no username could be found, a pointer | 4667 | * @return NULL if no username could be found, a pointer |
4343 | * to the username if found, free using #MHD_free(). | 4668 | * to the username if found, free using #MHD_free(). |
4669 | * @deprecated use MHD_digest_auth_get_username3() | ||
4344 | * @ingroup authentication | 4670 | * @ingroup authentication |
4345 | */ | 4671 | */ |
4346 | _MHD_EXTERN char * | 4672 | _MHD_EXTERN char * |