yading@11: /* yading@11: * HTTP authentication yading@11: * Copyright (c) 2010 Martin Storsjo yading@11: * yading@11: * This file is part of FFmpeg. yading@11: * yading@11: * FFmpeg is free software; you can redistribute it and/or yading@11: * modify it under the terms of the GNU Lesser General Public yading@11: * License as published by the Free Software Foundation; either yading@11: * version 2.1 of the License, or (at your option) any later version. yading@11: * yading@11: * FFmpeg is distributed in the hope that it will be useful, yading@11: * but WITHOUT ANY WARRANTY; without even the implied warranty of yading@11: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU yading@11: * Lesser General Public License for more details. yading@11: * yading@11: * You should have received a copy of the GNU Lesser General Public yading@11: * License along with FFmpeg; if not, write to the Free Software yading@11: * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA yading@11: */ yading@11: yading@11: #ifndef AVFORMAT_HTTPAUTH_H yading@11: #define AVFORMAT_HTTPAUTH_H yading@11: yading@11: /** yading@11: * Authentication types, ordered from weakest to strongest. yading@11: */ yading@11: typedef enum HTTPAuthType { yading@11: HTTP_AUTH_NONE = 0, /**< No authentication specified */ yading@11: HTTP_AUTH_BASIC, /**< HTTP 1.0 Basic auth from RFC 1945 yading@11: * (also in RFC 2617) */ yading@11: HTTP_AUTH_DIGEST, /**< HTTP 1.1 Digest auth from RFC 2617 */ yading@11: } HTTPAuthType; yading@11: yading@11: typedef struct DigestParams { yading@11: char nonce[300]; /**< Server specified nonce */ yading@11: char algorithm[10]; /**< Server specified digest algorithm */ yading@11: char qop[30]; /**< Quality of protection, containing the one yading@11: * that we've chosen to use, from the yading@11: * alternatives that the server offered. */ yading@11: char opaque[300]; /**< A server-specified string that should be yading@11: * included in authentication responses, not yading@11: * included in the actual digest calculation. */ yading@11: char stale[10]; /**< The server indicated that the auth was ok, yading@11: * but needs to be redone with a new, non-stale yading@11: * nonce. */ yading@11: int nc; /**< Nonce count, the number of earlier replies yading@11: * where this particular nonce has been used. */ yading@11: } DigestParams; yading@11: yading@11: /** yading@11: * HTTP Authentication state structure. Must be zero-initialized yading@11: * before used with the functions below. yading@11: */ yading@11: typedef struct HTTPAuthState { yading@11: /** yading@11: * The currently chosen auth type. yading@11: */ yading@11: HTTPAuthType auth_type; yading@11: /** yading@11: * Authentication realm yading@11: */ yading@11: char realm[200]; yading@11: /** yading@11: * The parameters specifiec to digest authentication. yading@11: */ yading@11: DigestParams digest_params; yading@11: /** yading@11: * Auth ok, but needs to be resent with a new nonce. yading@11: */ yading@11: int stale; yading@11: } HTTPAuthState; yading@11: yading@11: void ff_http_auth_handle_header(HTTPAuthState *state, const char *key, yading@11: const char *value); yading@11: char *ff_http_auth_create_response(HTTPAuthState *state, const char *auth, yading@11: const char *path, const char *method); yading@11: yading@11: #endif /* AVFORMAT_HTTPAUTH_H */