00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef AUTH_MODULE_H
00026
00027 #define AUTH_MODULE_H
00028
00037 #ifndef SU_TAG_H
00038 #include <sofia-sip/su_tag.h>
00039 #endif
00040 #ifndef SU_WAIT_H
00041 #include <sofia-sip/su_wait.h>
00042 #endif
00043 #ifndef MSG_TYPES_H
00044 #include <sofia-sip/msg_types.h>
00045 #endif
00046 #ifndef URL_H
00047 #include <sofia-sip/url.h>
00048 #endif
00049 #ifndef URL_TAG_H
00050 #include <sofia-sip/url_tag.h>
00051 #endif
00052
00053 SOFIA_BEGIN_DECLS
00054
00055 typedef struct auth_mod_t auth_mod_t;
00057 typedef struct auth_status_t auth_status_t;
00058
00059 #ifdef AUTH_MAGIC_T
00060 typedef AUTH_MAGIC_T auth_magic_t;
00061 #else
00062 typedef void auth_magic_t;
00063 #endif
00064
00066 typedef struct auth_scheme const auth_scheme_t;
00067
00069 typedef struct auth_plugin_t auth_plugin_t;
00071 typedef struct auth_splugin_t auth_splugin_t;
00073 typedef struct auth_uplugin_t auth_uplugin_t;
00074
00076 typedef void auth_callback_t(auth_magic_t *, auth_status_t *);
00077
00096 struct auth_status_t
00097 {
00098 su_home_t as_home[1];
00100 int as_status;
00101 char const *as_phrase;
00102 char const *as_user;
00103 char const *as_display;
00105 url_t const *as_user_uri;
00106 char const *as_ident;
00107 unsigned as_profile;
00109 su_addrinfo_t *as_source;
00111 char const *as_realm;
00112 char const *as_domain;
00113 char const *as_uri;
00114 char const *as_pdomain;
00115 char const *as_method;
00117 void const *as_body;
00118 int as_bodylen;
00120 msg_time_t as_nonce_issued;
00121 unsigned as_blacklist;
00122 unsigned as_anonymous:1;
00123 unsigned as_stale:1;
00124 unsigned as_allow:1;
00125 unsigned as_nextnonce:1;
00126 unsigned :0;
00127
00128 msg_header_t *as_response;
00129 msg_header_t *as_info;
00130 msg_header_t *as_match;
00134 auth_magic_t *as_magic;
00135 auth_callback_t*as_callback;
00139 auth_splugin_t *as_plugin;
00140 };
00141
00149 typedef struct auth_challenger
00150 {
00151 int ach_status;
00152 char const *ach_phrase;
00153 msg_hclass_t *ach_header;
00154 msg_hclass_t *ach_info;
00155 } auth_challenger_t;
00156
00157 SOFIAPUBVAR char const auth_internal_server_error[];
00158
00159 #define AUTH_STATUS_INIT \
00160 {{ SU_HOME_INIT(auth_status_t) }, 500, auth_internal_server_error, NULL }
00161
00162 #define AUTH_STATUS_DEINIT(as) \
00163 su_home_deinit(as->as_home)
00164
00165 #define AUTH_RESPONSE_INIT(as) AUTH_STATUS_INIT
00166 #define AUTH_RESPONSE_DEINIT(as) AUTH_STATUS_DEINIT(as)
00167
00168 SOFIAPUBFUN int auth_mod_register_plugin(auth_scheme_t *asch);
00169
00170 SOFIAPUBFUN auth_mod_t *auth_mod_create(su_root_t *root,
00171 tag_type_t, tag_value_t, ...);
00172 SOFIAPUBFUN void auth_mod_destroy(auth_mod_t *);
00173
00174 SOFIAPUBFUN auth_mod_t *auth_mod_ref(auth_mod_t *am);
00175 SOFIAPUBFUN void auth_mod_unref(auth_mod_t *am);
00176
00177 SOFIAPUBFUN auth_status_t *auth_status_init(void *, int size);
00178 SOFIAPUBFUN auth_status_t *auth_status_init_with(void *, int size,
00179 int status,
00180 char const *phrase);
00181
00182 SOFIAPUBFUN auth_status_t *auth_status_new(su_home_t *);
00183
00184 SOFIAPUBFUN auth_status_t *auth_status_ref(auth_status_t *as);
00185
00186 SOFIAPUBFUN void auth_status_unref(auth_status_t *as);
00187
00188 SOFIAPUBFUN void auth_mod_verify(auth_mod_t *am,
00189 auth_status_t *as,
00190 msg_auth_t *credentials,
00191 auth_challenger_t const *ach);
00192
00193 SOFIAPUBFUN void auth_mod_challenge(auth_mod_t *am,
00194 auth_status_t *as,
00195 auth_challenger_t const *ach);
00196
00197 SOFIAPUBFUN void auth_mod_authorize(auth_mod_t *am,
00198 auth_status_t *as,
00199 auth_challenger_t const *ach);
00200
00201 SOFIAPUBFUN void auth_mod_cancel(auth_mod_t *am, auth_status_t *as);
00202
00203
00204
00205
00206 typedef enum {
00207 auth_server,
00208 auth_proxy,
00209 auth_proxy_consume,
00210 auth_consume
00211 } auth_kind_t;
00212
00213 SOFIAPUBFUN void auth_mod_method(auth_mod_t *am,
00214 auth_status_t *as,
00215 msg_auth_t *credentials,
00216 auth_challenger_t const *ach);
00217
00218 SOFIAPUBFUN void auth_mod_check_client(auth_mod_t *am,
00219 auth_status_t *as,
00220 msg_auth_t *credentials,
00221 auth_challenger_t const *ach);
00222
00223 SOFIAPUBFUN void auth_mod_challenge_client(auth_mod_t *am,
00224 auth_status_t *as,
00225 auth_challenger_t const *ach);
00226
00227 #ifdef SIP_H
00228 SOFIAPUBFUN void auth_mod_check(auth_mod_t *am,
00229 auth_status_t *as,
00230 sip_t const *sip,
00231 auth_kind_t proxy);
00232 #endif
00233
00234 #ifdef HTTP_H
00235 SOFIAPUBFUN const char *auth_mod_check_http(auth_mod_t *am,
00236 auth_status_t *as,
00237 http_t const *http,
00238 auth_kind_t proxy);
00239 #endif
00240
00241
00242
00243
00244 #define AUTHTAG_ANY() authtag_any, ((tag_value_t)0)
00245 SOFIAPUBVAR tag_typedef_t authtag_any;
00246
00248 #define AUTHTAG_MODULE(x) authtag_module, authtag_module_v((x))
00249 SOFIAPUBVAR tag_typedef_t authtag_module;
00250
00251 #define AUTHTAG_MODULE_REF(x) authtag_module_ref, authtag_module_vr((&x))
00252 SOFIAPUBVAR tag_typedef_t authtag_module_ref;
00253
00254 #if SU_HAVE_INLINE
00255 static inline tag_value_t authtag_module_v(auth_mod_t *v) {
00256 return (tag_value_t)v;
00257 }
00258 static inline tag_value_t authtag_module_vr(auth_mod_t **vp) {
00259 return (tag_value_t)vp;
00260 }
00261 #else
00262 #define authtag_module_v(v) ((tag_value_t)(v))
00263 #define authtag_module_vr(v) ((tag_value_t)(v))
00264 #endif
00265
00267 #define AUTHTAG_METHOD(x) authtag_method, tag_str_v((x))
00268 SOFIAPUBVAR tag_typedef_t authtag_method;
00269
00270 #define AUTHTAG_METHOD_REF(x) authtag_method_ref, tag_str_vr((&x))
00271 SOFIAPUBVAR tag_typedef_t authtag_method_ref;
00272
00274 #define AUTHTAG_REALM(x) authtag_realm, tag_str_v((x))
00275 SOFIAPUBVAR tag_typedef_t authtag_realm;
00276
00277 #define AUTHTAG_REALM_REF(x) authtag_realm_ref, tag_str_vr((&x))
00278 SOFIAPUBVAR tag_typedef_t authtag_realm_ref;
00279
00281 #define AUTHTAG_OPAQUE(x) authtag_opaque, tag_str_v((x))
00282 SOFIAPUBVAR tag_typedef_t authtag_opaque;
00283
00284 #define AUTHTAG_OPAQUE_REF(x) authtag_opaque_ref, tag_str_vr((&x))
00285 SOFIAPUBVAR tag_typedef_t authtag_opaque_ref;
00286
00288 #define AUTHTAG_DB(x) authtag_db, tag_str_v((x))
00289 SOFIAPUBVAR tag_typedef_t authtag_db;
00290
00291 #define AUTHTAG_DB_REF(x) authtag_db_ref, tag_str_vr((&x))
00292 SOFIAPUBVAR tag_typedef_t authtag_db_ref;
00293
00295 #define AUTHTAG_QOP(x) authtag_qop, tag_str_v((x))
00296 SOFIAPUBVAR tag_typedef_t authtag_qop;
00297
00298 #define AUTHTAG_QOP_REF(x) authtag_qop_ref, tag_str_vr((&x))
00299 SOFIAPUBVAR tag_typedef_t authtag_qop_ref;
00300
00302 #define AUTHTAG_ALGORITHM(x) authtag_algorithm, tag_str_v((x))
00303 SOFIAPUBVAR tag_typedef_t authtag_algorithm;
00304
00305 #define AUTHTAG_ALGORITHM_REF(x) authtag_algorithm_ref, tag_str_vr((&x))
00306 SOFIAPUBVAR tag_typedef_t authtag_algorithm_ref;
00307
00309 #define AUTHTAG_EXPIRES(x) authtag_expires, tag_uint_v((x))
00310 SOFIAPUBVAR tag_typedef_t authtag_expires;
00311
00312 #define AUTHTAG_EXPIRES_REF(x) authtag_expires_ref, tag_uint_vr((&x))
00313 SOFIAPUBVAR tag_typedef_t authtag_expires_ref;
00314
00316 #define AUTHTAG_NEXT_EXPIRES(x) authtag_next_expires, tag_uint_v((x))
00317 SOFIAPUBVAR tag_typedef_t authtag_next_expires;
00318
00319 #define AUTHTAG_NEXT_EXPIRES_REF(x) \
00320 authtag_next_expires_ref, tag_uint_vr((&x))
00321 SOFIAPUBVAR tag_typedef_t authtag_next_expires_ref;
00322
00324 #define AUTHTAG_BLACKLIST(x) authtag_blacklist, tag_uint_v((x))
00325 SOFIAPUBVAR tag_typedef_t authtag_blacklist;
00326
00327 #define AUTHTAG_BLACKLIST_REF(x) authtag_blacklist_ref, tag_uint_vr((&x))
00328 SOFIAPUBVAR tag_typedef_t authtag_blacklist_ref;
00329
00331 #define AUTHTAG_FORBIDDEN(x) authtag_forbidden, tag_bool_v((x))
00332 SOFIAPUBVAR tag_typedef_t authtag_forbidden;
00333
00334 #define AUTHTAG_FORBIDDEN_REF(x) authtag_forbidden_ref, tag_bool_vr((&x))
00335 SOFIAPUBVAR tag_typedef_t authtag_forbidden_ref;
00336
00338 #define AUTHTAG_ANONYMOUS(x) authtag_anonymous, tag_bool_v((x))
00339 SOFIAPUBVAR tag_typedef_t authtag_anonymous;
00340
00341 #define AUTHTAG_ANONYMOUS_REF(x) authtag_anonymous_ref, tag_bool_vr((&x))
00342 SOFIAPUBVAR tag_typedef_t authtag_anonymous_ref;
00343
00345 #define AUTHTAG_FAKE(x) authtag_fake, tag_bool_v((x))
00346 SOFIAPUBVAR tag_typedef_t authtag_fake;
00347
00348 #define AUTHTAG_FAKE_REF(x) authtag_fake_ref, tag_bool_vr((&x))
00349 SOFIAPUBVAR tag_typedef_t authtag_fake_ref;
00350
00352 #define AUTHTAG_HSS(x) authtag_hss, tag_ptr_v((x))
00353 SOFIAPUBVAR tag_typedef_t authtag_hss;
00354
00355 #define AUTHTAG_HSS_REF(x) authtag_hss_ref, tag_ptr_vr((&x), (x))
00356 SOFIAPUBVAR tag_typedef_t authtag_hss_ref;
00357
00359 #define AUTHTAG_REMOTE(x) authtag_remote, urltag_url_v((x))
00360 SOFIAPUBVAR tag_typedef_t authtag_remote;
00361
00362 #define AUTHTAG_REMOTE_REF(x) authtag_remote_ref, urltag_url_vr((&x))
00363 SOFIAPUBVAR tag_typedef_t authtag_remote_ref;
00364
00366 #define AUTHTAG_ALLOW(x) authtag_allow, tag_str_v((x))
00367 SOFIAPUBVAR tag_typedef_t authtag_allow;
00368
00369 #define AUTHTAG_ALLOW_REF(x) authtag_allow_ref, tag_str_vr((&x))
00370 SOFIAPUBVAR tag_typedef_t authtag_allow_ref;
00371
00373 #define AUTHTAG_FAKE(x) authtag_fake, tag_bool_v((x))
00374 SOFIAPUBVAR tag_typedef_t authtag_fake;
00375
00376 #define AUTHTAG_FAKE_REF(x) authtag_fake_ref, tag_bool_vr((&x))
00377 SOFIAPUBVAR tag_typedef_t authtag_fake_ref;
00378
00380 #define AUTHTAG_MASTER_KEY(x) authtag_master_key, tag_str_v((x))
00381 SOFIAPUBVAR tag_typedef_t authtag_master_key;
00382
00383 #define AUTHTAG_MASTER_KEY_REF(x) authtag_master_key_ref, tag_str_vr((&x))
00384 SOFIAPUBVAR tag_typedef_t authtag_master_key_ref;
00385
00387 #define AUTHTAG_CACHE_USERS(x) authtag_cache_users, tag_uint_v((x))
00388 SOFIAPUBVAR tag_typedef_t authtag_cache_users;
00389
00390 #define AUTHTAG_CACHE_USERS_REF(x) authtag_cache_users_ref, tag_uint_vr((&x))
00391 SOFIAPUBVAR tag_typedef_t authtag_cache_users_ref;
00392
00394 #define AUTHTAG_CACHE_ERRORS(x) authtag_cache_errors, tag_uint_v((x))
00395 SOFIAPUBVAR tag_typedef_t authtag_cache_errors;
00396
00397 #define AUTHTAG_CACHE_ERRORS_REF(x) authtag_cache_errors_ref, tag_uint_vr((&x))
00398 SOFIAPUBVAR tag_typedef_t authtag_cache_errors_ref;
00399
00400 SOFIA_END_DECLS
00401
00402 #endif