Support HTTP digest authentication for the http manager interface.

(closes issue #10961)
 Reported by: ys
 Patches: 
       digest_auth_r148468_v5.diff uploaded by ys (license 281)
       SVN branch http://svn.digium.com/svn/asterisk/team/group/manager_http_auth
 Tested by: ys, twilson, tilghman
 Review: http://reviewboard.digium.com/r/223/
 Reviewed by: tilghman,russellb,mmichelson


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@190349 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Tilghman Lesher
2009-04-23 20:36:35 +00:00
parent 80b8d34377
commit ce6ebaef97
8 changed files with 1895 additions and 912 deletions

View File

@@ -32,8 +32,9 @@
#include "asterisk/time.h"
#include "asterisk/logger.h"
#include "asterisk/localtime.h"
#include "asterisk/stringfields.h"
/*!
/*!
\note \verbatim
Note:
It is very important to use only unsigned variables to hold
@@ -646,6 +647,33 @@ int ast_mkdir(const char *path, int mode);
#define ARRAY_LEN(a) (sizeof(a) / sizeof(0[a]))
/* Definition for Digest authorization */
struct ast_http_digest {
AST_DECLARE_STRING_FIELDS(
AST_STRING_FIELD(username);
AST_STRING_FIELD(nonce);
AST_STRING_FIELD(uri);
AST_STRING_FIELD(realm);
AST_STRING_FIELD(domain);
AST_STRING_FIELD(response);
AST_STRING_FIELD(cnonce);
AST_STRING_FIELD(opaque);
AST_STRING_FIELD(nc);
);
int qop; /* Flag set to 1, if we send/recv qop="quth" */
};
/*!
*\brief Parse digest authorization header.
*\return Returns -1 if we have no auth or something wrong with digest.
*\note This function may be used for Digest request and responce header.
* request arg is set to nonzero, if we parse Digest Request.
* pedantic arg can be set to nonzero if we need to do addition Digest check.
*/
int ast_parse_digest(const char *digest, struct ast_http_digest *d, int request, int pedantic);
#ifdef AST_DEVMODE
#define ast_assert(a) _ast_assert(a, # a, __FILE__, __LINE__, __PRETTY_FUNCTION__)
static void force_inline _ast_assert(int condition, const char *condition_str,