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 isize_t 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 char const *auth_mod_name(auth_mod_t *am);
00178
00179 SOFIAPUBFUN auth_status_t *auth_status_init(void *, isize_t size);
00180 SOFIAPUBFUN auth_status_t *auth_status_init_with(void *, isize_t size,
00181 int status,
00182 char const *phrase);
00183
00184 SOFIAPUBFUN auth_status_t *auth_status_new(su_home_t *);
00185
00186 SOFIAPUBFUN auth_status_t *auth_status_ref(auth_status_t *as);
00187
00188 SOFIAPUBFUN void auth_status_unref(auth_status_t *as);
00189
00190 SOFIAPUBFUN void auth_mod_verify(auth_mod_t *am,
00191 auth_status_t *as,
00192 msg_auth_t *credentials,
00193 auth_challenger_t const *ach);
00194
00195 SOFIAPUBFUN void auth_mod_challenge(auth_mod_t *am,
00196 auth_status_t *as,
00197 auth_challenger_t const *ach);
00198
00199 SOFIAPUBFUN void auth_mod_authorize(auth_mod_t *am,
00200 auth_status_t *as,
00201 auth_challenger_t const *ach);
00202
00203 SOFIAPUBFUN void auth_mod_cancel(auth_mod_t *am, auth_status_t *as);
00204
00205
00206
00207
00208 typedef enum {
00209 auth_server,
00210 auth_proxy,
00211 auth_proxy_consume,
00212 auth_consume
00213 } auth_kind_t;
00214
00215 SOFIAPUBFUN void auth_mod_method(auth_mod_t *am,
00216 auth_status_t *as,
00217 msg_auth_t *credentials,
00218 auth_challenger_t const *ach);
00219
00220 SOFIAPUBFUN void auth_mod_check_client(auth_mod_t *am,
00221 auth_status_t *as,
00222 msg_auth_t *credentials,
00223 auth_challenger_t const *ach);
00224
00225 SOFIAPUBFUN void auth_mod_challenge_client(auth_mod_t *am,
00226 auth_status_t *as,
00227 auth_challenger_t const *ach);
00228
00229 #ifdef SIP_H
00230 SOFIAPUBFUN void auth_mod_check(auth_mod_t *am,
00231 auth_status_t *as,
00232 sip_t const *sip,
00233 auth_kind_t proxy);
00234 #endif
00235
00236 #ifdef HTTP_H
00237 SOFIAPUBFUN const char *auth_mod_check_http(auth_mod_t *am,
00238 auth_status_t *as,
00239 http_t const *http,
00240 auth_kind_t proxy);
00241 #endif
00242
00243
00244
00245
00246 #define AUTHTAG_ANY() authtag_any, ((tag_value_t)0)
00247 SOFIAPUBVAR tag_typedef_t authtag_any;
00248
00250 #define AUTHTAG_MODULE(x) authtag_module, authtag_module_v((x))
00251 SOFIAPUBVAR tag_typedef_t authtag_module;
00252
00253 #define AUTHTAG_MODULE_REF(x) authtag_module_ref, authtag_module_vr((&x))
00254 SOFIAPUBVAR tag_typedef_t authtag_module_ref;
00255
00256 #if SU_INLINE_TAG_CAST
00257 su_inline tag_value_t authtag_module_v(auth_mod_t *v) {
00258 return (tag_value_t)v;
00259 }
00260 su_inline tag_value_t authtag_module_vr(auth_mod_t **vp) {
00261 return (tag_value_t)vp;
00262 }
00263 #else
00264 #define authtag_module_v(v) ((tag_value_t)(v))
00265 #define authtag_module_vr(v) ((tag_value_t)(v))
00266 #endif
00267
00269 #define AUTHTAG_METHOD(x) authtag_method, tag_str_v((x))
00270 SOFIAPUBVAR tag_typedef_t authtag_method;
00271
00272 #define AUTHTAG_METHOD_REF(x) authtag_method_ref, tag_str_vr((&x))
00273 SOFIAPUBVAR tag_typedef_t authtag_method_ref;
00274
00276 #define AUTHTAG_REALM(x) authtag_realm, tag_str_v((x))
00277 SOFIAPUBVAR tag_typedef_t authtag_realm;
00278
00279 #define AUTHTAG_REALM_REF(x) authtag_realm_ref, tag_str_vr((&x))
00280 SOFIAPUBVAR tag_typedef_t authtag_realm_ref;
00281
00283 #define AUTHTAG_OPAQUE(x) authtag_opaque, tag_str_v((x))
00284 SOFIAPUBVAR tag_typedef_t authtag_opaque;
00285
00286 #define AUTHTAG_OPAQUE_REF(x) authtag_opaque_ref, tag_str_vr((&x))
00287 SOFIAPUBVAR tag_typedef_t authtag_opaque_ref;
00288
00290 #define AUTHTAG_DB(x) authtag_db, tag_str_v((x))
00291 SOFIAPUBVAR tag_typedef_t authtag_db;
00292
00293 #define AUTHTAG_DB_REF(x) authtag_db_ref, tag_str_vr((&x))
00294 SOFIAPUBVAR tag_typedef_t authtag_db_ref;
00295
00297 #define AUTHTAG_QOP(x) authtag_qop, tag_str_v((x))
00298 SOFIAPUBVAR tag_typedef_t authtag_qop;
00299
00300 #define AUTHTAG_QOP_REF(x) authtag_qop_ref, tag_str_vr((&x))
00301 SOFIAPUBVAR tag_typedef_t authtag_qop_ref;
00302
00304 #define AUTHTAG_ALGORITHM(x) authtag_algorithm, tag_str_v((x))
00305 SOFIAPUBVAR tag_typedef_t authtag_algorithm;
00306
00307 #define AUTHTAG_ALGORITHM_REF(x) authtag_algorithm_ref, tag_str_vr((&x))
00308 SOFIAPUBVAR tag_typedef_t authtag_algorithm_ref;
00309
00311 #define AUTHTAG_EXPIRES(x) authtag_expires, tag_uint_v((x))
00312 SOFIAPUBVAR tag_typedef_t authtag_expires;
00313
00314 #define AUTHTAG_EXPIRES_REF(x) authtag_expires_ref, tag_uint_vr((&x))
00315 SOFIAPUBVAR tag_typedef_t authtag_expires_ref;
00316
00318 #define AUTHTAG_NEXT_EXPIRES(x) authtag_next_expires, tag_uint_v((x))
00319 SOFIAPUBVAR tag_typedef_t authtag_next_expires;
00320
00321 #define AUTHTAG_NEXT_EXPIRES_REF(x) \
00322 authtag_next_expires_ref, tag_uint_vr((&x))
00323 SOFIAPUBVAR tag_typedef_t authtag_next_expires_ref;
00324
00326 #define AUTHTAG_MAX_NCOUNT(x) authtag_max_ncount, tag_uint_v((x))
00327 SOFIAPUBVAR tag_typedef_t authtag_max_ncount;
00328
00329 #define AUTHTAG_MAX_NCOUNT_REF(x) authtag_max_ncount_ref, tag_uint_vr((&x))
00330 SOFIAPUBVAR tag_typedef_t authtag_max_ncount_ref;
00331
00333 #define AUTHTAG_BLACKLIST(x) authtag_blacklist, tag_uint_v((x))
00334 SOFIAPUBVAR tag_typedef_t authtag_blacklist;
00335
00336 #define AUTHTAG_BLACKLIST_REF(x) authtag_blacklist_ref, tag_uint_vr((&x))
00337 SOFIAPUBVAR tag_typedef_t authtag_blacklist_ref;
00338
00340 #define AUTHTAG_FORBIDDEN(x) authtag_forbidden, tag_bool_v((x))
00341 SOFIAPUBVAR tag_typedef_t authtag_forbidden;
00342
00343 #define AUTHTAG_FORBIDDEN_REF(x) authtag_forbidden_ref, tag_bool_vr((&x))
00344 SOFIAPUBVAR tag_typedef_t authtag_forbidden_ref;
00345
00347 #define AUTHTAG_ANONYMOUS(x) authtag_anonymous, tag_bool_v((x))
00348 SOFIAPUBVAR tag_typedef_t authtag_anonymous;
00349
00350 #define AUTHTAG_ANONYMOUS_REF(x) authtag_anonymous_ref, tag_bool_vr((&x))
00351 SOFIAPUBVAR tag_typedef_t authtag_anonymous_ref;
00352
00354 #define AUTHTAG_HSS(x) authtag_hss, tag_ptr_v((x))
00355 SOFIAPUBVAR tag_typedef_t authtag_hss;
00356
00357 #define AUTHTAG_HSS_REF(x) authtag_hss_ref, tag_ptr_vr((&x), (x))
00358 SOFIAPUBVAR tag_typedef_t authtag_hss_ref;
00359
00361 #define AUTHTAG_REMOTE(x) authtag_remote, urltag_url_v((x))
00362 SOFIAPUBVAR tag_typedef_t authtag_remote;
00363
00364 #define AUTHTAG_REMOTE_REF(x) authtag_remote_ref, urltag_url_vr((&x))
00365 SOFIAPUBVAR tag_typedef_t authtag_remote_ref;
00366
00368 #define AUTHTAG_ALLOW(x) authtag_allow, tag_str_v((x))
00369 SOFIAPUBVAR tag_typedef_t authtag_allow;
00370
00371 #define AUTHTAG_ALLOW_REF(x) authtag_allow_ref, tag_str_vr((&x))
00372 SOFIAPUBVAR tag_typedef_t authtag_allow_ref;
00373
00375 #define AUTHTAG_FAKE(x) authtag_fake, tag_bool_v((x))
00376 SOFIAPUBVAR tag_typedef_t authtag_fake;
00377
00378 #define AUTHTAG_FAKE_REF(x) authtag_fake_ref, tag_bool_vr((&x))
00379 SOFIAPUBVAR tag_typedef_t authtag_fake_ref;
00380
00382 #define AUTHTAG_MASTER_KEY(x) authtag_master_key, tag_str_v((x))
00383 SOFIAPUBVAR tag_typedef_t authtag_master_key;
00384
00385 #define AUTHTAG_MASTER_KEY_REF(x) authtag_master_key_ref, tag_str_vr((&x))
00386 SOFIAPUBVAR tag_typedef_t authtag_master_key_ref;
00387
00389 #define AUTHTAG_CACHE_USERS(x) authtag_cache_users, tag_uint_v((x))
00390 SOFIAPUBVAR tag_typedef_t authtag_cache_users;
00391
00392 #define AUTHTAG_CACHE_USERS_REF(x) authtag_cache_users_ref, tag_uint_vr((&x))
00393 SOFIAPUBVAR tag_typedef_t authtag_cache_users_ref;
00394
00396 #define AUTHTAG_CACHE_ERRORS(x) authtag_cache_errors, tag_uint_v((x))
00397 SOFIAPUBVAR tag_typedef_t authtag_cache_errors;
00398
00399 #define AUTHTAG_CACHE_ERRORS_REF(x) authtag_cache_errors_ref, tag_uint_vr((&x))
00400 SOFIAPUBVAR tag_typedef_t authtag_cache_errors_ref;
00401
00402 SOFIA_END_DECLS
00403
00404 #endif