Dillo v3.1.1-98-g318d1f14
|
Handling of HTTP AUTH takes place here. More...
#include <ctype.h>
#include "auth.h"
#include "msg.h"
#include "misc.h"
#include "dialog.hh"
#include "digest.h"
#include "../dlib/dlib.h"
Go to the source code of this file.
Typedefs | |
typedef int() | Auth_parse_token_value_callback_t(AuthParse_t *auth_parse, char *token, const char *value) |
Functions | |
void | a_Auth_init (void) |
Initialize the auth module. | |
static AuthParse_t * | Auth_parse_new (void) |
static void | Auth_parse_free (AuthParse_t *auth_parse) |
static int | Auth_path_is_inside (const char *path1, const char *path2, int len) |
static int | Auth_is_token_char (char c) |
Check valid chars. | |
static Dstr * | Auth_unquote_value (char **valuep) |
Unquote the content of a (potentially) quoted string. | |
static int | Auth_parse_token_value (AuthParse_t *auth_parse, char **auth, Auth_parse_token_value_callback_t *callback) |
Parse authentication challenge into token-value pairs and feed them into the callback function. | |
static int | Auth_parse_basic_challenge_cb (AuthParse_t *auth_parse, char *token, const char *value) |
static int | Auth_parse_digest_challenge_cb (AuthParse_t *auth_parse, char *token, const char *value) |
static void | Auth_parse_challenge_args (AuthParse_t *auth_parse, char **challenge, Auth_parse_token_value_callback_t *cb) |
static void | Auth_parse_challenge (AuthParse_t *auth_parse, char *challenge) |
static AuthHost_t * | Auth_host_by_url (const DilloUrl *url) |
Return the host that contains a URL, or NULL if there is no such host. | |
static AuthRealm_t * | Auth_realm_by_name (const AuthHost_t *host, const char *name) |
Search all realms for the one with the given name. | |
static AuthRealm_t * | Auth_realm_by_path (const AuthHost_t *host, const char *path) |
Search all realms for the one with the best-matching path. | |
static void | Auth_realm_delete (AuthRealm_t *realm) |
static int | Auth_realm_includes_path (const AuthRealm_t *realm, const char *path) |
static void | Auth_realm_add_path (AuthRealm_t *realm, const char *path) |
char * | a_Auth_get_auth_str (const DilloUrl *url, const char *request_uri) |
Return the authorization header for an HTTP query. | |
static int | Auth_do_auth_required (const AuthParse_t *auth_parse, const DilloUrl *url) |
Determine whether the user needs to authenticate. | |
static void | Auth_do_auth_dialog_cb (const char *user, const char *password, void *vData) |
static int | Auth_do_auth_dialog (const AuthParse_t *auth_parse, const DilloUrl *url) |
static int | Auth_do_auth (char *challenge, enum AuthParseHTTPAuthType_t type, const DilloUrl *url) |
Do authorization for an auth string. | |
int | a_Auth_do_auth (Dlist *challenges, const DilloUrl *url) |
Given authentication challenge(s), prepare authorization. | |
Variables | |
static Dlist * | auth_hosts |
Local data. | |
Handling of HTTP AUTH takes place here.
This implementation aims to follow RFC 2617: http://www.ietf.org/rfc/rfc2617.txt
Definition in file auth.c.
typedef int() Auth_parse_token_value_callback_t(AuthParse_t *auth_parse, char *token, const char *value) |
Given authentication challenge(s), prepare authorization.
Return: 0 on failure nonzero on success. A new query will be sent to the server.
Definition at line 671 of file auth.c.
References Auth_do_auth(), BASIC, DIGEST, dList_nth_data(), and dStrnAsciiCasecmp().
Referenced by Cache_auth_callback().
char * a_Auth_get_auth_str | ( | const DilloUrl * | url, |
const char * | request_uri | ||
) |
Return the authorization header for an HTTP query.
request_uri is a separate argument because we want it precisely as formatted in the request.
Definition at line 472 of file auth.c.
References a_Digest_authorization_hdr(), Auth_host_by_url(), Auth_realm_by_path(), AuthRealm_t::authorization, BASIC, DIGEST, dStrdup(), MSG, AuthRealm_t::type, and URL_PATH.
Referenced by Http_make_query_str().
void a_Auth_init | ( | void | ) |
Initialize the auth module.
Definition at line 59 of file auth.c.
References auth_hosts, and dList_new().
Referenced by main().
|
static |
Do authorization for an auth string.
Definition at line 646 of file auth.c.
References _MSG, Auth_do_auth_dialog(), Auth_do_auth_required(), Auth_parse_challenge(), Auth_parse_free(), and Auth_parse_new().
Referenced by a_Auth_do_auth().
|
static |
Definition at line 619 of file auth.c.
References _MSG, a_Dialog_user_password(), a_Url_dup(), a_Url_free(), Auth_do_auth_dialog_cb(), dFree(), DIGEST, dNew, dStrconcat(), and URL_HOST.
Referenced by Auth_do_auth().
|
static |
Definition at line 546 of file auth.c.
References a_Digest_compute_digest(), a_Digest_create_cnonce(), a_Misc_encode_base64(), AuthRealm_t::algorithm, Auth_host_by_url(), auth_hosts, Auth_realm_add_path(), Auth_realm_by_name(), Auth_realm_delete(), AuthRealm_t::authorization, BASIC, AuthRealm_t::cnonce, dFree(), DIGEST, dList_append(), dList_new(), dList_remove_fast(), dNew, dNew0, AuthRealm_t::domain, dStrconcat(), dStrdup(), dStrshred(), MSG, AuthRealm_t::name, AuthRealm_t::nonce, AuthRealm_t::nonce_count, AuthRealm_t::opaque, AuthRealm_t::paths, AuthRealm_t::qop, QOPNOTSET, AuthRealm_t::type, URL_AUTHORITY, URL_PATH, URL_SCHEME, and AuthRealm_t::username.
Referenced by Auth_do_auth_dialog().
|
static |
Determine whether the user needs to authenticate.
Definition at line 494 of file auth.c.
References _MSG, Auth_host_by_url(), Auth_realm_add_path(), Auth_realm_by_name(), Auth_realm_includes_path(), dFree(), DIGEST, dStrdup(), AuthRealm_t::nonce, URL_PATH, and URL_STR.
Referenced by Auth_do_auth().
|
static |
Return the host that contains a URL, or NULL if there is no such host.
Definition at line 357 of file auth.c.
References auth_hosts, dList_nth_data(), dStrAsciiCasecmp(), URL_AUTHORITY, and URL_SCHEME.
Referenced by a_Auth_get_auth_str(), Auth_do_auth_dialog_cb(), and Auth_do_auth_required().
|
static |
Check valid chars.
Return: 0 if invalid, 1 otherwise.
Definition at line 105 of file auth.c.
References d_isascii.
Referenced by Auth_parse_token_value(), and Auth_unquote_value().
|
static |
Definition at line 229 of file auth.c.
References dStrAsciiCasecmp(), dStrdup(), and MSG.
Referenced by Auth_parse_challenge().
|
static |
Definition at line 339 of file auth.c.
References Auth_parse_basic_challenge_cb(), Auth_parse_challenge_args(), Auth_parse_digest_challenge_cb(), DIGEST, and MSG.
Referenced by Auth_do_auth().
|
static |
Definition at line 305 of file auth.c.
References Auth_parse_token_value(), BASIC, DIGEST, and MSG.
Referenced by Auth_parse_challenge().
|
static |
Definition at line 242 of file auth.c.
References AUTH, dStrAsciiCasecmp(), dStrdup(), MD5, and MSG.
Referenced by Auth_parse_challenge().
|
static |
|
static |
Definition at line 64 of file auth.c.
References ALGORITHMNOTSET, dNew, QOPNOTSET, and TYPENOTSET.
Referenced by Auth_do_auth().
|
static |
Parse authentication challenge into token-value pairs and feed them into the callback function.
The parsing is aborted should the callback function return 0.
Return: 1 if the parse succeeds, 0 otherwise.
Definition at line 164 of file auth.c.
References _MSG, Auth_is_token_char(), Auth_unquote_value(), dStr_free(), MSG, MSG_WARN, and Dstr::str.
Referenced by Auth_parse_challenge_args().
|
static |
Definition at line 90 of file auth.c.
Referenced by Auth_realm_add_path(), Auth_realm_by_path(), and Auth_realm_includes_path().
|
static |
Definition at line 443 of file auth.c.
References Auth_path_is_inside(), dFree(), dList_append(), dList_nth_data(), dList_remove_fast(), dStrdup(), path(), and AuthRealm_t::paths.
Referenced by Auth_do_auth_dialog_cb(), and Auth_do_auth_required().
|
static |
Search all realms for the one with the given name.
Definition at line 373 of file auth.c.
References dList_nth_data(), and AuthRealm_t::name.
Referenced by Auth_do_auth_dialog_cb(), and Auth_do_auth_required().
|
static |
Search all realms for the one with the best-matching path.
Definition at line 389 of file auth.c.
References Auth_path_is_inside(), dList_nth_data(), path(), and AuthRealm_t::paths.
Referenced by a_Auth_get_auth_str().
|
static |
Definition at line 413 of file auth.c.
References AuthRealm_t::authorization, AuthRealm_t::cnonce, dFree(), dList_free(), dList_length(), dList_nth_data(), AuthRealm_t::domain, MSG, AuthRealm_t::name, AuthRealm_t::nonce, AuthRealm_t::opaque, AuthRealm_t::paths, and AuthRealm_t::username.
Referenced by Auth_do_auth_dialog_cb().
|
static |
Definition at line 431 of file auth.c.
References Auth_path_is_inside(), dList_nth_data(), path(), and AuthRealm_t::paths.
Referenced by Auth_do_auth_required().
|
static |
Unquote the content of a (potentially) quoted string.
Return: newly allocated unquoted content.
Arguments: valuep: pointer to a pointer to the first char.
Preconditions: *valuep points to a correctly quoted and escaped string.
Postconditions: *valuep points to the first not processed char.
Definition at line 125 of file auth.c.
References Auth_is_token_char(), dStr_append_c(), and dStr_new().
Referenced by Auth_parse_token_value().
|
static |
Local data.
Definition at line 54 of file auth.c.
Referenced by a_Auth_init(), Auth_do_auth_dialog_cb(), and Auth_host_by_url().