1 /* saslplug.h -- API for SASL plug-ins
24 /* callback to lookup a sasl_callback_t for a connection
26 * conn -- the connection to lookup a callback for
27 * callbacknum -- the number of the callback
29 * pproc -- pointer to the callback function (set to NULL on failure)
30 * pcontext -- pointer to the callback context (set to NULL on failure)
33 * SASL_FAIL -- unable to find a callback of the requested type
34 * SASL_INTERACT -- caller must use interaction to get data
36 typedef int sasl_getcallback_t(sasl_conn_t *conn,
37 unsigned long callbackid,
41 /* The sasl_utils structure will remain backwards compatible unless
42 * the SASL_*_PLUG_VERSION is changed incompatibly
43 * higher SASL_UTILS_VERSION numbers indicate more functions are available
45 #define SASL_UTILS_VERSION 4
47 /* utility function set for plug-ins
49 typedef struct sasl_utils {
58 sasl_getopt_t *getopt;
60 /* allocation functions: */
61 sasl_malloc_t *malloc;
62 sasl_calloc_t *calloc;
63 sasl_realloc_t *realloc;
66 /* mutex functions: */
67 sasl_mutex_alloc_t *mutex_alloc;
68 sasl_mutex_lock_t *mutex_lock;
69 sasl_mutex_unlock_t *mutex_unlock;
70 sasl_mutex_free_t *mutex_free;
72 /* MD5 hash and HMAC functions */
73 void (*MD5Init)(MD5_CTX *);
74 void (*MD5Update)(MD5_CTX *, const unsigned char *text, unsigned int len);
75 void (*MD5Final)(unsigned char [16], MD5_CTX *);
76 void (*hmac_md5)(const unsigned char *text, int text_len,
77 const unsigned char *key, int key_len,
79 void (*hmac_md5_init)(HMAC_MD5_CTX *, const unsigned char *key, int len);
80 /* hmac_md5_update() is just a call to MD5Update on inner context */
81 void (*hmac_md5_final)(unsigned char [16], HMAC_MD5_CTX *);
82 void (*hmac_md5_precalc)(HMAC_MD5_STATE *,
83 const unsigned char *key, int len);
84 void (*hmac_md5_import)(HMAC_MD5_CTX *, HMAC_MD5_STATE *);
86 /* mechanism utility functions (same as above): */
87 int (*mkchal)(sasl_conn_t *conn, char *buf, unsigned maxlen,
89 int (*utf8verify)(const char *str, unsigned len);
90 void (*rand)(sasl_rand_t *rpool, char *buf, unsigned len);
91 void (*churn)(sasl_rand_t *rpool, const char *data, unsigned len);
93 /* This allows recursive calls to the sasl_checkpass() routine from
94 * within a SASL plug-in. This MUST NOT be used in the PLAIN mechanism
95 * as sasl_checkpass MAY be a front-end for the PLAIN mechanism.
96 * This is intended for use by the non-standard LOGIN mechanism and
97 * potentially by a future mechanism which uses public-key technology to
98 * set up a lightweight encryption layer just for sending a password.
100 int (*checkpass)(sasl_conn_t *conn,
101 const char *user, unsigned userlen,
102 const char *pass, unsigned passlen);
104 /* Access to base64 encode/decode routines */
105 int (*decode64)(const char *in, unsigned inlen,
106 char *out, unsigned outmax, unsigned *outlen);
107 int (*encode64)(const char *in, unsigned inlen,
108 char *out, unsigned outmax, unsigned *outlen);
111 void (*erasebuffer)(char *buf, unsigned len);
113 /* callback to sasl_getprop() and sasl_setprop() */
114 int (*getprop)(sasl_conn_t *conn, int propnum, const void **pvalue);
115 int (*setprop)(sasl_conn_t *conn, int propnum, const void *value);
117 /* callback function */
118 sasl_getcallback_t *getcallback;
120 /* format a message and then pass it to the SASL_CB_LOG callback
122 * use syslog()-style formatting (printf with %m as a human readable text
123 * (strerror()) for the error specified as the parameter).
124 * The implementation may use a fixed size buffer not smaller
125 * than 512 octets if it securely truncates the message.
127 * level is a SASL_LOG_* level (see sasl.h)
129 void (*log)(sasl_conn_t *conn, int level, const char *fmt, ...);
131 /* callback to sasl_seterror() */
132 void (*seterror)(sasl_conn_t *conn, unsigned flags, const char *fmt, ...);
134 /* spare function pointer */
135 int *(*spare_fptr)();
137 /* auxiliary property utilities */
138 struct propctx *(*prop_new)(unsigned estimate);
139 int (*prop_dup)(struct propctx *src_ctx, struct propctx **dst_ctx);
140 int (*prop_request)(struct propctx *ctx, const char **names);
141 const struct propval *(*prop_get)(struct propctx *ctx);
142 int (*prop_getnames)(struct propctx *ctx, const char **names,
143 struct propval *vals);
144 void (*prop_clear)(struct propctx *ctx, int requests);
145 void (*prop_dispose)(struct propctx **ctx);
146 int (*prop_format)(struct propctx *ctx, const char *sep, int seplen,
147 char *outbuf, unsigned outmax, unsigned *outlen);
148 int (*prop_set)(struct propctx *ctx, const char *name,
149 const char *value, int vallen);
150 int (*prop_setvals)(struct propctx *ctx, const char *name,
151 const char **values);
152 void (*prop_erase)(struct propctx *ctx, const char *name);
153 int (*auxprop_store)(sasl_conn_t *conn,
154 struct propctx *ctx, const char *user);
156 /* for additions which don't require a version upgrade; set to 0 */
157 int (*spare_fptr1)();
158 int (*spare_fptr2)();
162 * output parameters from SASL API
164 * created / destroyed by the glue code, though probably filled in
165 * by a combination of the plugin, the glue code, and the canon_user callback.
168 typedef struct sasl_out_params {
169 unsigned doneflag; /* exchange complete */
171 const char *user; /* canonicalized user name */
172 const char *authid; /* canonicalized authentication id */
174 unsigned ulen; /* length of canonicalized user name */
175 unsigned alen; /* length of canonicalized authid */
177 /* security layer information */
178 unsigned maxoutbuf; /* Maximum buffer size, which will
179 produce buffer no bigger than the
180 negotiated SASL maximum buffer size */
181 sasl_ssf_t mech_ssf; /* Should be set non-zero if negotiation of a
182 * security layer was *attempted*, even if
183 * the negotiation failed */
184 void *encode_context;
185 int (*encode)(void *context, const struct iovec *invec, unsigned numiov,
186 const char **output, unsigned *outputlen);
187 void *decode_context;
188 int (*decode)(void *context, const char *input, unsigned inputlen,
189 const char **output, unsigned *outputlen);
191 /* Pointer to delegated (client's) credentials, if supported by
192 the SASL mechanism */
195 /* for additions which don't require a version upgrade; set to 0 */
196 const void *gss_peer_name;
197 const void *gss_local_name;
198 const char *cbindingname; /* channel binding name from packet */
199 int (*spare_fptr1)();
200 int (*spare_fptr2)();
201 unsigned int cbindingdisp; /* channel binding disposition from client */
206 /* set to 0 initially, this allows a plugin with extended parameters
207 * to work with an older framework by updating version as parameters
215 /* Used by both client and server side plugins */
217 SASL_INFO_LIST_START = 0,
220 } sasl_info_callback_stage_t;
222 /******************************
223 * Channel binding macros **
224 ******************************/
227 SASL_CB_DISP_NONE = 0, /* client did not support CB */
228 SASL_CB_DISP_USED, /* client supports and used CB */
229 SASL_CB_DISP_WANT /* client supports CB, thinks server does not */
230 } sasl_cbinding_disp_t;
232 /* TRUE if channel binding is non-NULL */
233 #define SASL_CB_PRESENT(params) ((params)->cbinding != NULL)
234 /* TRUE if channel binding is marked critical */
235 #define SASL_CB_CRITICAL(params) (SASL_CB_PRESENT(params) && \
236 (params)->cbinding->critical)
238 /******************************
239 * Client Mechanism Functions *
240 ******************************/
243 * input parameters to client SASL plugin
245 * created / destroyed by the glue code
248 typedef struct sasl_client_params {
249 const char *service; /* service name */
250 const char *serverFQDN; /* server fully qualified domain name */
251 const char *clientFQDN; /* client's fully qualified domain name */
252 const sasl_utils_t *utils; /* SASL API utility routines --
253 * for a particular sasl_conn_t,
254 * MUST remain valid until mech_free is
256 const sasl_callback_t *prompt_supp; /* client callback list */
257 const char *iplocalport; /* server IP domain literal & port */
258 const char *ipremoteport; /* client IP domain literal & port */
260 unsigned servicelen; /* length of service */
261 unsigned slen; /* length of serverFQDN */
262 unsigned clen; /* length of clientFQDN */
263 unsigned iploclen; /* length of iplocalport */
264 unsigned ipremlen; /* length of ipremoteport */
266 /* application's security requirements & info */
267 sasl_security_properties_t props;
268 sasl_ssf_t external_ssf; /* external SSF active */
270 /* for additions which don't require a version upgrade; set to 0 */
271 const void *gss_creds; /* GSS credential handle */
272 const sasl_channel_binding_t *cbinding; /* client channel binding */
276 /* Canonicalize a user name from on-wire to internal format
277 * added rjs3 2001-05-23
278 * Must be called once user name aquired if canon_user is non-NULL.
279 * conn connection context
280 * in user name from wire protocol (need not be NUL terminated)
281 * len length of user name from wire protocol (0 = strlen(user))
282 * flags for SASL_CU_* flags
283 * oparams the user, authid, ulen, alen, fields are
284 * set appropriately after canonicalization/copying and
285 * authorization of arguments
287 * responsible for setting user, ulen, authid, and alen in the oparams
290 * default behavior is to strip leading and trailing whitespace, as
291 * well as allocating space for and copying the parameters.
295 * SASL_NOMEM -- out of memory
296 * SASL_BADPARAM -- invalid conn
297 * SASL_BADPROT -- invalid user/authid
299 int (*canon_user)(sasl_conn_t *conn,
300 const char *in, unsigned len,
302 sasl_out_params_t *oparams);
304 int (*spare_fptr1)();
306 unsigned int cbindingdisp;
307 unsigned int spare_int2;
310 /* flags field as passed to sasl_client_new */
313 /* set to 0 initially, this allows a plugin with extended parameters
314 * to work with an older framework by updating version as parameters
318 } sasl_client_params_t;
320 /* features shared between client and server */
321 /* These allow the glue code to handle client-first and server-last issues */
323 /* This indicates that the mechanism prefers to do client-send-first
324 * if the protocol allows it. */
325 #define SASL_FEAT_WANT_CLIENT_FIRST 0x0002
327 /* This feature is deprecated, instead, plugins should set *serverout to
328 * non-NULL and return SASL_OK intelligently to allow flexible use of
329 * server-last semantics */
330 /* #define SASL_FEAT_WANT_SERVER_LAST 0x0004 */
332 /* This feature is deprecated, instead plugins should correctly set
333 * SASL_FEAT_SERVER_FIRST as needed */
334 /* #define SASL_FEAT_INTERNAL_CLIENT_FIRST 0x0008 */
336 /* This indicates that the plugin is server-first only.
337 * Not defining either of SASL_FEAT_SERVER_FIRST or
338 * SASL_FEAT_WANT_CLIENT_FIRST indicates that the mechanism will take care
339 * of the client-first situation internally.
341 #define SASL_FEAT_SERVER_FIRST 0x0010
343 /* This plugin allows proxying */
344 #define SASL_FEAT_ALLOWS_PROXY 0x0020
346 /* Underlying mechanism uses GSS framing */
347 #define SASL_FEAT_GSS_FRAMING 0x0040
349 /* Underlying mechanism supports channel binding */
350 #define SASL_FEAT_CHANNEL_BINDING 0x0080
352 /* client plug-in features */
353 #define SASL_FEAT_NEEDSERVERFQDN 0x0001
355 /* a C object for a client mechanism
357 typedef struct sasl_client_plug {
359 const char *mech_name;
361 /* best mech additional security layer strength factor */
364 /* best security flags, as defined in sasl_security_properties_t */
365 unsigned security_flags;
367 /* features of plugin */
370 /* required prompt ids, NULL = user/pass only */
371 const unsigned long *required_prompts;
373 /* global state for mechanism */
376 /* create context for mechanism, using params supplied
377 * glob_context -- from above
378 * params -- params from sasl_client_new
379 * conn_context -- context for one connection
382 * SASL_NOMEM -- not enough memory
383 * SASL_WRONGMECH -- mech doesn't support security params
385 int (*mech_new)(void *glob_context,
386 sasl_client_params_t *cparams,
387 void **conn_context);
389 /* perform one step of exchange. NULL is passed for serverin on
393 * SASL_INTERACT -- user interaction needed to fill in prompts
394 * SASL_BADPROT -- server protocol incorrect/cancelled
395 * SASL_BADSERV -- server failed mutual auth
397 int (*mech_step)(void *conn_context,
398 sasl_client_params_t *cparams,
399 const char *serverin,
400 unsigned serverinlen,
401 sasl_interact_t **prompt_need,
402 const char **clientout,
403 unsigned *clientoutlen,
404 sasl_out_params_t *oparams);
406 /* dispose of connection context from mech_new
408 void (*mech_dispose)(void *conn_context, const sasl_utils_t *utils);
410 /* free all global space used by mechanism
411 * mech_dispose must be called on all mechanisms first
413 void (*mech_free)(void *glob_context, const sasl_utils_t *utils);
415 /* perform precalculations during a network round-trip
416 * or idle period. conn_context may be NULL
417 * returns 1 if action taken, 0 if no action taken
419 int (*idle)(void *glob_context,
421 sasl_client_params_t *cparams);
423 /* for additions which don't require a version upgrade; set to 0 */
424 int (*spare_fptr1)();
425 int (*spare_fptr2)();
426 } sasl_client_plug_t;
428 #define SASL_CLIENT_PLUG_VERSION 4
430 /* plug-in entry point:
431 * utils -- utility callback functions
432 * max_version -- highest client plug version supported
434 * out_version -- client plug version of result
435 * pluglist -- list of mechanism plug-ins
436 * plugcount -- number of mechanism plug-ins
439 * SASL_NOMEM -- failure
440 * SASL_BADVERS -- max_version too small
441 * SASL_BADPARAM -- bad config string
444 typedef int sasl_client_plug_init_t(const sasl_utils_t *utils,
447 sasl_client_plug_t **pluglist,
451 /* add a client plug-in
453 LIBSASL_API int sasl_client_add_plugin(const char *plugname,
454 sasl_client_plug_init_t *cplugfunc);
456 typedef struct client_sasl_mechanism
461 const sasl_client_plug_t *plug;
462 } client_sasl_mechanism_t;
464 typedef void sasl_client_info_callback_t (client_sasl_mechanism_t *m,
465 sasl_info_callback_stage_t stage,
468 /* Dump information about available client plugins */
469 LIBSASL_API int sasl_client_plugin_info (const char *mech_list,
470 sasl_client_info_callback_t *info_cb,
474 /********************
476 ********************/
478 /* log message formatting routine */
479 typedef void sasl_logmsg_p(sasl_conn_t *conn, const char *fmt, ...);
482 * input parameters to server SASL plugin
484 * created / destroyed by the glue code
487 typedef struct sasl_server_params {
488 const char *service; /* NULL = default service for user_exists
490 const char *appname; /* name of calling application */
491 const char *serverFQDN; /* server default fully qualified domain name
492 * (e.g., gethostname) */
493 const char *user_realm; /* realm for user (NULL = client supplied) */
494 const char *iplocalport; /* server IP domain literal & port */
495 const char *ipremoteport; /* client IP domain literal & port */
497 unsigned servicelen; /* length of service */
498 unsigned applen; /* length of appname */
499 unsigned slen; /* length of serverFQDN */
500 unsigned urlen; /* length of user_realm */
501 unsigned iploclen; /* length of iplocalport */
502 unsigned ipremlen; /* length of ipremoteport */
504 /* This indicates the level of logging desired. See SASL_LOG_*
507 * Plug-ins can ignore this and just pass their desired level to
508 * the log callback. This is primarily used to eliminate logging which
509 * might be a performance problem (e.g., full protocol trace) and
510 * to select between SASL_LOG_TRACE and SASL_LOG_PASS alternatives
514 const sasl_utils_t *utils; /* SASL API utility routines --
515 * for a particular sasl_conn_t,
516 * MUST remain valid until mech_free is
518 const sasl_callback_t *callbacks; /* Callbacks from application */
520 /* application's security requirements */
521 sasl_security_properties_t props;
522 sasl_ssf_t external_ssf; /* external SSF active */
524 /* Pointer to the function which takes the plaintext passphrase and
525 * transitions a user to non-plaintext mechanisms via setpass calls.
526 * (NULL = auto transition not enabled/supported)
528 * If passlen is 0, it defaults to strlen(pass).
529 * returns 0 if no entry added, 1 if entry added
531 int (*transition)(sasl_conn_t *conn, const char *pass, unsigned passlen);
533 /* Canonicalize a user name from on-wire to internal format
534 * added cjn 1999-09-21
535 * Must be called once user name acquired if canon_user is non-NULL.
536 * conn connection context
537 * user user name from wire protocol (need not be NUL terminated)
538 * ulen length of user name from wire protocol (0 = strlen(user))
539 * flags for SASL_CU_* flags
540 * oparams the user, authid, ulen, alen, fields are
541 * set appropriately after canonicalization/copying and
542 * authorization of arguments
544 * responsible for setting user, ulen, authid, and alen in the oparams
547 * default behavior is to strip leading and trailing whitespace, as
548 * well as allocating space for and copying the parameters.
552 * SASL_NOMEM -- out of memory
553 * SASL_BADPARAM -- invalid conn
554 * SASL_BADPROT -- invalid user/authid
556 int (*canon_user)(sasl_conn_t *conn,
557 const char *user, unsigned ulen,
559 sasl_out_params_t *oparams);
561 /* auxiliary property context (see definitions in prop.h)
562 * added cjn 2000-01-30
564 * NOTE: these properties are the ones associated with the
565 * canonicalized "user" (user to login as / authorization id), not
566 * the "authid" (user whose credentials are used / authentication id)
567 * Prefix the property name with a "*" if a property associated with
568 * the "authid" is interesting.
570 struct propctx *propctx;
572 /* for additions which don't require a version upgrade; set to 0 */
573 const void *gss_creds; /* GSS credential handle */
574 const sasl_channel_binding_t *cbinding; /* server channel binding */
577 int (*spare_fptr1)();
578 int (*spare_fptr2)();
583 /* flags field as passed to sasl_server_new */
586 /* set to 0 initially, this allows a plugin with extended parameters
587 * to work with an older framework by updating version as parameters
591 } sasl_server_params_t;
593 /* logging levels (more levels may be added later, if necessary):
595 #define SASL_LOG_NONE 0 /* don't log anything */
596 #define SASL_LOG_ERR 1 /* log unusual errors (default) */
597 #define SASL_LOG_FAIL 2 /* log all authentication failures */
598 #define SASL_LOG_WARN 3 /* log non-fatal warnings */
599 #define SASL_LOG_NOTE 4 /* more verbose than LOG_WARN */
600 #define SASL_LOG_DEBUG 5 /* more verbose than LOG_NOTE */
601 #define SASL_LOG_TRACE 6 /* traces of internal protocols */
602 #define SASL_LOG_PASS 7 /* traces of internal protocols, including
605 /* additional flags for setpass() function below:
607 /* SASL_SET_CREATE create user if pass non-NULL */
608 /* SASL_SET_DISABLE disable user */
609 #define SASL_SET_REMOVE SASL_SET_CREATE /* remove user if pass is NULL */
611 /* features for server plug-in
613 #define SASL_FEAT_SERVICE 0x0200 /* service-specific passwords supported */
614 #define SASL_FEAT_GETSECRET 0x0400 /* sasl_server_{get,put}secret_t callbacks
615 * required by plug-in */
617 /* a C object for a server mechanism
619 typedef struct sasl_server_plug {
621 const char *mech_name;
623 /* best mech additional security layer strength factor */
626 /* best security flags, as defined in sasl_security_properties_t */
627 unsigned security_flags;
629 /* features of plugin */
632 /* global state for mechanism */
635 /* create a new mechanism handler
636 * glob_context -- global context
637 * sparams -- server config params
638 * challenge -- server challenge from previous instance or NULL
639 * challen -- length of challenge from previous instance or 0
641 * conn_context -- connection context
642 * errinfo -- error information
645 * SASL_OK -- successfully created mech instance
646 * SASL_* -- any other server error code
648 int (*mech_new)(void *glob_context,
649 sasl_server_params_t *sparams,
650 const char *challenge,
652 void **conn_context);
654 /* perform one step in exchange
657 * SASL_OK -- success, all done
658 * SASL_CONTINUE -- success, one more round trip
659 * SASL_* -- any other server error code
661 int (*mech_step)(void *conn_context,
662 sasl_server_params_t *sparams,
663 const char *clientin,
664 unsigned clientinlen,
665 const char **serverout,
666 unsigned *serveroutlen,
667 sasl_out_params_t *oparams);
669 /* dispose of a connection state
671 void (*mech_dispose)(void *conn_context, const sasl_utils_t *utils);
673 /* free global state for mechanism
674 * mech_dispose must be called on all mechanisms first
676 void (*mech_free)(void *glob_context, const sasl_utils_t *utils);
678 /* set a password (optional)
679 * glob_context -- global context
680 * sparams -- service, middleware utilities, etc. props ignored
682 * pass -- password/passphrase (NULL = disable/remove/delete)
683 * passlen -- length of password/passphrase
684 * oldpass -- old password/passphrase (NULL = transition)
685 * oldpasslen -- length of password/passphrase
689 * SASL_NOCHANGE -- no change was needed
690 * SASL_NOUSER -- no entry for user
691 * SASL_NOVERIFY -- no mechanism compatible entry for user
692 * SASL_PWLOCK -- password locked
693 * SASL_DIABLED -- account disabled
696 int (*setpass)(void *glob_context,
697 sasl_server_params_t *sparams,
699 const char *pass, unsigned passlen,
700 const char *oldpass, unsigned oldpasslen,
703 /* query which mechanisms are available for user
704 * glob_context -- context
705 * sparams -- service, middleware utilities, etc. props ignored
706 * user -- NUL terminated user name
707 * maxmech -- max number of strings in mechlist (0 = no output)
709 * mechlist -- an array of C string pointers, filled in with
710 * mechanism names available to the user
714 * SASL_NOMEM -- not enough memory
715 * SASL_FAIL -- lower level failure
716 * SASL_DISABLED -- account disabled
717 * SASL_NOUSER -- user not found
718 * SASL_BUFOVER -- maxmech is too small
719 * SASL_NOVERIFY -- user found, but no mechanisms available
721 int (*user_query)(void *glob_context,
722 sasl_server_params_t *sparams,
725 const char **mechlist);
727 /* perform precalculations during a network round-trip
728 * or idle period. conn_context may be NULL (optional)
729 * returns 1 if action taken, 0 if no action taken
731 int (*idle)(void *glob_context,
733 sasl_server_params_t *sparams);
735 /* check if mechanism is available
736 * optional--if NULL, mechanism is available based on ENABLE= in config
738 * If this routine sets conn_context to a non-NULL value, then the call
739 * to mech_new will be skipped. This should not be done unless
740 * there's a significant performance benefit, since it can cause
741 * additional memory allocation in SASL core code to keep track of
742 * contexts potentially for multiple mechanisms.
744 * This is called by the first call to sasl_listmech() for a
745 * given connection context, thus for a given protocol it may
746 * never be called. Note that if mech_avail returns SASL_NOMECH,
747 * then that mechanism is considered disabled for the remainder
748 * of the session. If mech_avail returns SASL_NOTDONE, then a
749 * future call to mech_avail may still return either SASL_OK
752 * returns SASL_OK on success,
753 * SASL_NOTDONE if mech is not available now, but may be later
754 * (e.g. EXTERNAL w/o auth_id)
755 * SASL_NOMECH if mech disabled
757 int (*mech_avail)(void *glob_context,
758 sasl_server_params_t *sparams,
759 void **conn_context);
761 /* for additions which don't require a version upgrade; set to 0 */
762 int (*spare_fptr2)();
763 } sasl_server_plug_t;
765 #define SASL_SERVER_PLUG_VERSION 4
767 /* plug-in entry point:
768 * utils -- utility callback functions
769 * plugname -- name of plug-in (may be NULL)
770 * max_version -- highest server plug version supported
772 * out_version -- server plug-in version of result
773 * pluglist -- list of mechanism plug-ins
774 * plugcount -- number of mechanism plug-ins
777 * SASL_NOMEM -- failure
778 * SASL_BADVERS -- max_version too small
779 * SASL_BADPARAM -- bad config string
782 typedef int sasl_server_plug_init_t(const sasl_utils_t *utils,
785 sasl_server_plug_t **pluglist,
789 * add a server plug-in
791 LIBSASL_API int sasl_server_add_plugin(const char *plugname,
792 sasl_server_plug_init_t *splugfunc);
795 typedef struct server_sasl_mechanism
798 int condition; /* set to SASL_NOUSER if no available users;
799 set to SASL_CONTINUE if delayed plugin loading */
800 char *plugname; /* for AUTHSOURCE tracking */
801 const sasl_server_plug_t *plug;
802 char *f; /* where should i load the mechanism from? */
803 } server_sasl_mechanism_t;
805 typedef void sasl_server_info_callback_t (server_sasl_mechanism_t *m,
806 sasl_info_callback_stage_t stage,
810 /* Dump information about available server plugins (separate functions are
811 used for canon and auxprop plugins) */
812 LIBSASL_API int sasl_server_plugin_info (const char *mech_list,
813 sasl_server_info_callback_t *info_cb,
817 /*********************************************************
818 * user canonicalization plug-in -- added cjn 1999-09-29 *
819 *********************************************************/
821 typedef struct sasl_canonuser {
822 /* optional features of plugin (set to 0) */
825 /* spare integer (set to 0) */
828 /* global state for plugin */
834 /* free global state for plugin */
835 void (*canon_user_free)(void *glob_context, const sasl_utils_t *utils);
837 /* canonicalize a username
838 * glob_context -- global context from this structure
839 * sparams -- server params, note user_realm&propctx elements
840 * user -- user to login as (may not be NUL terminated)
841 * len -- length of user name (0 = strlen(user))
842 * flags -- for SASL_CU_* flags
843 * out -- buffer to copy user name
844 * out_max -- max length of user name
845 * out_len -- set to length of user name
847 * note that the output buffers MAY be the same as the input buffers.
851 * SASL_BADPROT username contains invalid character
853 int (*canon_user_server)(void *glob_context,
854 sasl_server_params_t *sparams,
855 const char *user, unsigned len,
858 unsigned out_umax, unsigned *out_ulen);
860 int (*canon_user_client)(void *glob_context,
861 sasl_client_params_t *cparams,
862 const char *user, unsigned len,
865 unsigned out_max, unsigned *out_len);
867 /* for additions which don't require a version upgrade; set to 0 */
868 int (*spare_fptr1)();
869 int (*spare_fptr2)();
870 int (*spare_fptr3)();
871 } sasl_canonuser_plug_t;
873 #define SASL_CANONUSER_PLUG_VERSION 5
875 /* default name for canonuser plug-in entry point is "sasl_canonuser_init"
876 * similar to sasl_server_plug_init model, except only returns one
877 * sasl_canonuser_plug_t structure;
879 typedef int sasl_canonuser_init_t(const sasl_utils_t *utils,
882 sasl_canonuser_plug_t **plug,
883 const char *plugname);
885 /* add a canonuser plugin
887 LIBSASL_API int sasl_canonuser_add_plugin(const char *plugname,
888 sasl_canonuser_init_t *canonuserfunc);
890 /******************************************************
891 * auxiliary property plug-in -- added cjn 1999-09-29 *
892 ******************************************************/
894 typedef struct sasl_auxprop_plug {
895 /* optional features of plugin (none defined yet, set to 0) */
898 /* spare integer, must be set to 0 */
901 /* global state for plugin */
904 /* free global state for plugin (OPTIONAL) */
905 void (*auxprop_free)(void *glob_context, const sasl_utils_t *utils);
907 /* fill in fields of an auxiliary property context
908 * last element in array has id of SASL_AUX_END
909 * elements with non-0 len should be ignored.
911 void (*auxprop_lookup)(void *glob_context,
912 sasl_server_params_t *sparams,
914 const char *user, unsigned ulen);
916 /* name of the auxprop plugin */
919 /* store the fields/values of an auxiliary property context (OPTIONAL)
921 * if ctx is NULL, just check if storing properties is enabled
925 * SASL_FAIL on failure
927 int (*auxprop_store)(void *glob_context,
928 sasl_server_params_t *sparams,
930 const char *user, unsigned ulen);
931 } sasl_auxprop_plug_t;
933 /* auxprop lookup flags */
934 #define SASL_AUXPROP_OVERRIDE 0x01 /* if clear, ignore auxiliary properties
935 * with non-zero len field. If set,
936 * override value of those properties */
937 #define SASL_AUXPROP_AUTHZID 0x02 /* if clear, we are looking up the
938 * authid flags (prefixed with *), otherwise
939 * we are looking up the authzid flags
942 #define SASL_AUXPROP_PLUG_VERSION 4
944 /* default name for auxprop plug-in entry point is "sasl_auxprop_init"
945 * similar to sasl_server_plug_init model, except only returns one
946 * sasl_auxprop_plug_t structure;
948 typedef int sasl_auxprop_init_t(const sasl_utils_t *utils,
951 sasl_auxprop_plug_t **plug,
952 const char *plugname);
954 /* add an auxiliary property plug-in
956 LIBSASL_API int sasl_auxprop_add_plugin(const char *plugname,
957 sasl_auxprop_init_t *auxpropfunc);
959 typedef void auxprop_info_callback_t (sasl_auxprop_plug_t *m,
960 sasl_info_callback_stage_t stage,
963 /* Dump information about available auxprop plugins (separate functions are
964 used for canon and server authentication plugins) */
965 LIBSASL_API int auxprop_plugin_info (const char *mech_list,
966 auxprop_info_callback_t *info_cb,
973 #endif /* SASLPLUG_H */