Go to the documentation of this file.00001 #ifndef HEADER_CURL_SASL_H
00002 #define HEADER_CURL_SASL_H
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include <curl/curl.h>
00026
00027 struct Curl_easy;
00028 struct connectdata;
00029
00030
00031 #define SASL_MECH_LOGIN (1 << 0)
00032 #define SASL_MECH_PLAIN (1 << 1)
00033 #define SASL_MECH_CRAM_MD5 (1 << 2)
00034 #define SASL_MECH_DIGEST_MD5 (1 << 3)
00035 #define SASL_MECH_GSSAPI (1 << 4)
00036 #define SASL_MECH_EXTERNAL (1 << 5)
00037 #define SASL_MECH_NTLM (1 << 6)
00038 #define SASL_MECH_XOAUTH2 (1 << 7)
00039 #define SASL_MECH_OAUTHBEARER (1 << 8)
00040
00041
00042 #define SASL_AUTH_NONE 0
00043 #define SASL_AUTH_ANY ~0U
00044 #define SASL_AUTH_DEFAULT (SASL_AUTH_ANY & ~SASL_MECH_EXTERNAL)
00045
00046
00047 #define SASL_MECH_STRING_LOGIN "LOGIN"
00048 #define SASL_MECH_STRING_PLAIN "PLAIN"
00049 #define SASL_MECH_STRING_CRAM_MD5 "CRAM-MD5"
00050 #define SASL_MECH_STRING_DIGEST_MD5 "DIGEST-MD5"
00051 #define SASL_MECH_STRING_GSSAPI "GSSAPI"
00052 #define SASL_MECH_STRING_EXTERNAL "EXTERNAL"
00053 #define SASL_MECH_STRING_NTLM "NTLM"
00054 #define SASL_MECH_STRING_XOAUTH2 "XOAUTH2"
00055 #define SASL_MECH_STRING_OAUTHBEARER "OAUTHBEARER"
00056
00057
00058 typedef enum {
00059 SASL_STOP,
00060 SASL_PLAIN,
00061 SASL_LOGIN,
00062 SASL_LOGIN_PASSWD,
00063 SASL_EXTERNAL,
00064 SASL_CRAMMD5,
00065 SASL_DIGESTMD5,
00066 SASL_DIGESTMD5_RESP,
00067 SASL_NTLM,
00068 SASL_NTLM_TYPE2MSG,
00069 SASL_GSSAPI,
00070 SASL_GSSAPI_TOKEN,
00071 SASL_GSSAPI_NO_DATA,
00072 SASL_OAUTH2,
00073 SASL_OAUTH2_RESP,
00074 SASL_CANCEL,
00075 SASL_FINAL
00076 } saslstate;
00077
00078
00079 typedef enum {
00080 SASL_IDLE,
00081 SASL_INPROGRESS,
00082 SASL_DONE
00083 } saslprogress;
00084
00085
00086 struct SASLproto {
00087 const char *service;
00088 int contcode;
00089 int finalcode;
00090 size_t maxirlen;
00091 CURLcode (*sendauth)(struct connectdata *conn,
00092 const char *mech, const char *ir);
00093
00094 CURLcode (*sendcont)(struct connectdata *conn, const char *contauth);
00095
00096 void (*getmessage)(char *buffer, char **outptr);
00097
00098 };
00099
00100
00101 struct SASL {
00102 const struct SASLproto *params;
00103 saslstate state;
00104 unsigned int authmechs;
00105 unsigned int prefmech;
00106 unsigned int authused;
00107 bool resetprefs;
00108 bool mutual_auth;
00109 bool force_ir;
00110 };
00111
00112
00113 #define sasl_mech_equal(line, wordlen, mech) \
00114 (wordlen == (sizeof(mech) - 1) / sizeof(char) && \
00115 !memcmp(line, mech, wordlen))
00116
00117
00118
00119 void Curl_sasl_cleanup(struct connectdata *conn, unsigned int authused);
00120
00121
00122 unsigned int Curl_sasl_decode_mech(const char *ptr,
00123 size_t maxlen, size_t *len);
00124
00125
00126 CURLcode Curl_sasl_parse_url_auth_option(struct SASL *sasl,
00127 const char *value, size_t len);
00128
00129
00130 void Curl_sasl_init(struct SASL *sasl, const struct SASLproto *params);
00131
00132
00133 bool Curl_sasl_can_authenticate(struct SASL *sasl, struct connectdata *conn);
00134
00135
00136 CURLcode Curl_sasl_start(struct SASL *sasl, struct connectdata *conn,
00137 bool force_ir, saslprogress *progress);
00138
00139
00140 CURLcode Curl_sasl_continue(struct SASL *sasl, struct connectdata *conn,
00141 int code, saslprogress *progress);
00142
00143 #endif