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 */
197 void *gss_local_name;
199 int (*spare_fptr1)();
200 int (*spare_fptr2)();
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;
224 /******************************
225 * Client Mechanism Functions *
226 ******************************/
229 * input parameters to client SASL plugin
231 * created / destroyed by the glue code
234 typedef struct sasl_client_params {
235 const char *service; /* service name */
236 const char *serverFQDN; /* server fully qualified domain name */
237 const char *clientFQDN; /* client's fully qualified domain name */
238 const sasl_utils_t *utils; /* SASL API utility routines --
239 * for a particular sasl_conn_t,
240 * MUST remain valid until mech_free is
242 const sasl_callback_t *prompt_supp; /* client callback list */
243 const char *iplocalport; /* server IP domain literal & port */
244 const char *ipremoteport; /* client IP domain literal & port */
246 unsigned servicelen; /* length of service */
247 unsigned slen; /* length of serverFQDN */
248 unsigned clen; /* length of clientFQDN */
249 unsigned iploclen; /* length of iplocalport */
250 unsigned ipremlen; /* length of ipremoteport */
252 /* application's security requirements & info */
253 sasl_security_properties_t props;
254 sasl_ssf_t external_ssf; /* external SSF active */
256 /* for additions which don't require a version upgrade; set to 0 */
258 void *chanbindingtype;
259 void *chanbindingdata;
262 /* Canonicalize a user name from on-wire to internal format
263 * added rjs3 2001-05-23
264 * Must be called once user name aquired if canon_user is non-NULL.
265 * conn connection context
266 * in user name from wire protocol (need not be NUL terminated)
267 * len length of user name from wire protocol (0 = strlen(user))
268 * flags for SASL_CU_* flags
269 * oparams the user, authid, ulen, alen, fields are
270 * set appropriately after canonicalization/copying and
271 * authorization of arguments
273 * responsible for setting user, ulen, authid, and alen in the oparams
276 * default behavior is to strip leading and trailing whitespace, as
277 * well as allocating space for and copying the parameters.
281 * SASL_NOMEM -- out of memory
282 * SASL_BADPARAM -- invalid conn
283 * SASL_BADPROT -- invalid user/authid
285 int (*canon_user)(sasl_conn_t *conn,
286 const char *in, unsigned len,
288 sasl_out_params_t *oparams);
290 int (*spare_fptr1)();
292 #define SASL_CB_FLAG_NONE 0x00 /* client did not support CB */
293 #define SASL_CB_FLAG_USED 0x01 /* client supports CB, thinks server does not */
294 #define SASL_CB_FLAG_WANT 0x02 /* client supports and used CB */
295 #define SASL_CB_FLAG_CRIT 0x10 /* client requires CB */
296 int chanbindingflags;
297 #define SASL_CB_PRESENT(params) ((params)->chanbindingtype != NULL && (params)->chanbindinglen)
301 /* flags field as passed to sasl_client_new */
304 /* set to 0 initially, this allows a plugin with extended parameters
305 * to work with an older framework by updating version as parameters
309 } sasl_client_params_t;
311 /* features shared between client and server */
312 /* These allow the glue code to handle client-first and server-last issues */
314 /* This indicates that the mechanism prefers to do client-send-first
315 * if the protocol allows it. */
316 #define SASL_FEAT_WANT_CLIENT_FIRST 0x0002
318 /* This feature is deprecated, instead, plugins should set *serverout to
319 * non-NULL and return SASL_OK intelligently to allow flexible use of
320 * server-last semantics */
321 /* #define SASL_FEAT_WANT_SERVER_LAST 0x0004 */
323 /* This feature is deprecated, instead plugins should correctly set
324 * SASL_FEAT_SERVER_FIRST as needed */
325 /* #define SASL_FEAT_INTERNAL_CLIENT_FIRST 0x0008 */
327 /* This indicates that the plugin is server-first only.
328 * Not defining either of SASL_FEAT_SERVER_FIRST or
329 * SASL_FEAT_WANT_CLIENT_FIRST indicates that the mechanism will take care
330 * of the client-first situation internally.
332 #define SASL_FEAT_SERVER_FIRST 0x0010
334 /* This plugin allows proxying */
335 #define SASL_FEAT_ALLOWS_PROXY 0x0020
337 /* Underlying mechanism uses GSS framing */
338 #define SASL_FEAT_GSS_FRAMING 0x0040
340 /* Underlying mechanism supports channel binding */
341 #define SASL_FEAT_CHANNEL_BINDING 0x0080
343 /* client plug-in features */
344 #define SASL_FEAT_NEEDSERVERFQDN 0x0001
346 /* a C object for a client mechanism
348 typedef struct sasl_client_plug {
350 const char *mech_name;
352 /* best mech additional security layer strength factor */
355 /* best security flags, as defined in sasl_security_properties_t */
356 unsigned security_flags;
358 /* features of plugin */
361 /* required prompt ids, NULL = user/pass only */
362 const unsigned long *required_prompts;
364 /* global state for mechanism */
367 /* create context for mechanism, using params supplied
368 * glob_context -- from above
369 * params -- params from sasl_client_new
370 * conn_context -- context for one connection
373 * SASL_NOMEM -- not enough memory
374 * SASL_WRONGMECH -- mech doesn't support security params
376 int (*mech_new)(void *glob_context,
377 sasl_client_params_t *cparams,
378 void **conn_context);
380 /* perform one step of exchange. NULL is passed for serverin on
384 * SASL_INTERACT -- user interaction needed to fill in prompts
385 * SASL_BADPROT -- server protocol incorrect/cancelled
386 * SASL_BADSERV -- server failed mutual auth
388 int (*mech_step)(void *conn_context,
389 sasl_client_params_t *cparams,
390 const char *serverin,
391 unsigned serverinlen,
392 sasl_interact_t **prompt_need,
393 const char **clientout,
394 unsigned *clientoutlen,
395 sasl_out_params_t *oparams);
397 /* dispose of connection context from mech_new
399 void (*mech_dispose)(void *conn_context, const sasl_utils_t *utils);
401 /* free all global space used by mechanism
402 * mech_dispose must be called on all mechanisms first
404 void (*mech_free)(void *glob_context, const sasl_utils_t *utils);
406 /* perform precalculations during a network round-trip
407 * or idle period. conn_context may be NULL
408 * returns 1 if action taken, 0 if no action taken
410 int (*idle)(void *glob_context,
412 sasl_client_params_t *cparams);
414 /* for additions which don't require a version upgrade; set to 0 */
415 int (*spare_fptr1)();
416 int (*spare_fptr2)();
417 } sasl_client_plug_t;
419 #define SASL_CLIENT_PLUG_VERSION 4
421 /* plug-in entry point:
422 * utils -- utility callback functions
423 * max_version -- highest client plug version supported
425 * out_version -- client plug version of result
426 * pluglist -- list of mechanism plug-ins
427 * plugcount -- number of mechanism plug-ins
430 * SASL_NOMEM -- failure
431 * SASL_BADVERS -- max_version too small
432 * SASL_BADPARAM -- bad config string
435 typedef int sasl_client_plug_init_t(const sasl_utils_t *utils,
438 sasl_client_plug_t **pluglist,
442 /* add a client plug-in
444 LIBSASL_API int sasl_client_add_plugin(const char *plugname,
445 sasl_client_plug_init_t *cplugfunc);
447 typedef struct client_sasl_mechanism
452 const sasl_client_plug_t *plug;
453 } client_sasl_mechanism_t;
455 typedef void sasl_client_info_callback_t (client_sasl_mechanism_t *m,
456 sasl_info_callback_stage_t stage,
459 /* Dump information about available client plugins */
460 LIBSASL_API int sasl_client_plugin_info (const char *mech_list,
461 sasl_client_info_callback_t *info_cb,
465 /********************
467 ********************/
469 /* log message formatting routine */
470 typedef void sasl_logmsg_p(sasl_conn_t *conn, const char *fmt, ...);
473 * input parameters to server SASL plugin
475 * created / destroyed by the glue code
478 typedef struct sasl_server_params {
479 const char *service; /* NULL = default service for user_exists
481 const char *appname; /* name of calling application */
482 const char *serverFQDN; /* server default fully qualified domain name
483 * (e.g., gethostname) */
484 const char *user_realm; /* realm for user (NULL = client supplied) */
485 const char *iplocalport; /* server IP domain literal & port */
486 const char *ipremoteport; /* client IP domain literal & port */
488 unsigned servicelen; /* length of service */
489 unsigned applen; /* length of appname */
490 unsigned slen; /* length of serverFQDN */
491 unsigned urlen; /* length of user_realm */
492 unsigned iploclen; /* length of iplocalport */
493 unsigned ipremlen; /* length of ipremoteport */
495 /* This indicates the level of logging desired. See SASL_LOG_*
498 * Plug-ins can ignore this and just pass their desired level to
499 * the log callback. This is primarily used to eliminate logging which
500 * might be a performance problem (e.g., full protocol trace) and
501 * to select between SASL_LOG_TRACE and SASL_LOG_PASS alternatives
505 const sasl_utils_t *utils; /* SASL API utility routines --
506 * for a particular sasl_conn_t,
507 * MUST remain valid until mech_free is
509 const sasl_callback_t *callbacks; /* Callbacks from application */
511 /* application's security requirements */
512 sasl_security_properties_t props;
513 sasl_ssf_t external_ssf; /* external SSF active */
515 /* Pointer to the function which takes the plaintext passphrase and
516 * transitions a user to non-plaintext mechanisms via setpass calls.
517 * (NULL = auto transition not enabled/supported)
519 * If passlen is 0, it defaults to strlen(pass).
520 * returns 0 if no entry added, 1 if entry added
522 int (*transition)(sasl_conn_t *conn, const char *pass, unsigned passlen);
524 /* Canonicalize a user name from on-wire to internal format
525 * added cjn 1999-09-21
526 * Must be called once user name acquired if canon_user is non-NULL.
527 * conn connection context
528 * user user name from wire protocol (need not be NUL terminated)
529 * ulen length of user name from wire protocol (0 = strlen(user))
530 * flags for SASL_CU_* flags
531 * oparams the user, authid, ulen, alen, fields are
532 * set appropriately after canonicalization/copying and
533 * authorization of arguments
535 * responsible for setting user, ulen, authid, and alen in the oparams
538 * default behavior is to strip leading and trailing whitespace, as
539 * well as allocating space for and copying the parameters.
543 * SASL_NOMEM -- out of memory
544 * SASL_BADPARAM -- invalid conn
545 * SASL_BADPROT -- invalid user/authid
547 int (*canon_user)(sasl_conn_t *conn,
548 const char *user, unsigned ulen,
550 sasl_out_params_t *oparams);
552 /* auxiliary property context (see definitions in prop.h)
553 * added cjn 2000-01-30
555 * NOTE: these properties are the ones associated with the
556 * canonicalized "user" (user to login as / authorization id), not
557 * the "authid" (user whose credentials are used / authentication id)
558 * Prefix the property name with a "*" if a property associated with
559 * the "authid" is interesting.
561 struct propctx *propctx;
563 /* for additions which don't require a version upgrade; set to 0 */
565 void *chanbindingtype;
566 void *chanbindingdata;
568 int (*spare_fptr1)();
569 int (*spare_fptr2)();
574 /* flags field as passed to sasl_server_new */
577 /* set to 0 initially, this allows a plugin with extended parameters
578 * to work with an older framework by updating version as parameters
582 } sasl_server_params_t;
584 /* logging levels (more levels may be added later, if necessary):
586 #define SASL_LOG_NONE 0 /* don't log anything */
587 #define SASL_LOG_ERR 1 /* log unusual errors (default) */
588 #define SASL_LOG_FAIL 2 /* log all authentication failures */
589 #define SASL_LOG_WARN 3 /* log non-fatal warnings */
590 #define SASL_LOG_NOTE 4 /* more verbose than LOG_WARN */
591 #define SASL_LOG_DEBUG 5 /* more verbose than LOG_NOTE */
592 #define SASL_LOG_TRACE 6 /* traces of internal protocols */
593 #define SASL_LOG_PASS 7 /* traces of internal protocols, including
596 /* additional flags for setpass() function below:
598 /* SASL_SET_CREATE create user if pass non-NULL */
599 /* SASL_SET_DISABLE disable user */
600 #define SASL_SET_REMOVE SASL_SET_CREATE /* remove user if pass is NULL */
602 /* features for server plug-in
604 #define SASL_FEAT_SERVICE 0x0200 /* service-specific passwords supported */
605 #define SASL_FEAT_GETSECRET 0x0400 /* sasl_server_{get,put}secret_t callbacks
606 * required by plug-in */
608 /* a C object for a server mechanism
610 typedef struct sasl_server_plug {
612 const char *mech_name;
614 /* best mech additional security layer strength factor */
617 /* best security flags, as defined in sasl_security_properties_t */
618 unsigned security_flags;
620 /* features of plugin */
623 /* global state for mechanism */
626 /* create a new mechanism handler
627 * glob_context -- global context
628 * sparams -- server config params
629 * challenge -- server challenge from previous instance or NULL
630 * challen -- length of challenge from previous instance or 0
632 * conn_context -- connection context
633 * errinfo -- error information
636 * SASL_OK -- successfully created mech instance
637 * SASL_* -- any other server error code
639 int (*mech_new)(void *glob_context,
640 sasl_server_params_t *sparams,
641 const char *challenge,
643 void **conn_context);
645 /* perform one step in exchange
648 * SASL_OK -- success, all done
649 * SASL_CONTINUE -- success, one more round trip
650 * SASL_* -- any other server error code
652 int (*mech_step)(void *conn_context,
653 sasl_server_params_t *sparams,
654 const char *clientin,
655 unsigned clientinlen,
656 const char **serverout,
657 unsigned *serveroutlen,
658 sasl_out_params_t *oparams);
660 /* dispose of a connection state
662 void (*mech_dispose)(void *conn_context, const sasl_utils_t *utils);
664 /* free global state for mechanism
665 * mech_dispose must be called on all mechanisms first
667 void (*mech_free)(void *glob_context, const sasl_utils_t *utils);
669 /* set a password (optional)
670 * glob_context -- global context
671 * sparams -- service, middleware utilities, etc. props ignored
673 * pass -- password/passphrase (NULL = disable/remove/delete)
674 * passlen -- length of password/passphrase
675 * oldpass -- old password/passphrase (NULL = transition)
676 * oldpasslen -- length of password/passphrase
680 * SASL_NOCHANGE -- no change was needed
681 * SASL_NOUSER -- no entry for user
682 * SASL_NOVERIFY -- no mechanism compatible entry for user
683 * SASL_PWLOCK -- password locked
684 * SASL_DIABLED -- account disabled
687 int (*setpass)(void *glob_context,
688 sasl_server_params_t *sparams,
690 const char *pass, unsigned passlen,
691 const char *oldpass, unsigned oldpasslen,
694 /* query which mechanisms are available for user
695 * glob_context -- context
696 * sparams -- service, middleware utilities, etc. props ignored
697 * user -- NUL terminated user name
698 * maxmech -- max number of strings in mechlist (0 = no output)
700 * mechlist -- an array of C string pointers, filled in with
701 * mechanism names available to the user
705 * SASL_NOMEM -- not enough memory
706 * SASL_FAIL -- lower level failure
707 * SASL_DISABLED -- account disabled
708 * SASL_NOUSER -- user not found
709 * SASL_BUFOVER -- maxmech is too small
710 * SASL_NOVERIFY -- user found, but no mechanisms available
712 int (*user_query)(void *glob_context,
713 sasl_server_params_t *sparams,
716 const char **mechlist);
718 /* perform precalculations during a network round-trip
719 * or idle period. conn_context may be NULL (optional)
720 * returns 1 if action taken, 0 if no action taken
722 int (*idle)(void *glob_context,
724 sasl_server_params_t *sparams);
726 /* check if mechanism is available
727 * optional--if NULL, mechanism is available based on ENABLE= in config
729 * If this routine sets conn_context to a non-NULL value, then the call
730 * to mech_new will be skipped. This should not be done unless
731 * there's a significant performance benefit, since it can cause
732 * additional memory allocation in SASL core code to keep track of
733 * contexts potentially for multiple mechanisms.
735 * This is called by the first call to sasl_listmech() for a
736 * given connection context, thus for a given protocol it may
737 * never be called. Note that if mech_avail returns SASL_NOMECH,
738 * then that mechanism is considered disabled for the remainder
739 * of the session. If mech_avail returns SASL_NOTDONE, then a
740 * future call to mech_avail may still return either SASL_OK
743 * returns SASL_OK on success,
744 * SASL_NOTDONE if mech is not available now, but may be later
745 * (e.g. EXTERNAL w/o auth_id)
746 * SASL_NOMECH if mech disabled
748 int (*mech_avail)(void *glob_context,
749 sasl_server_params_t *sparams,
750 void **conn_context);
752 /* for additions which don't require a version upgrade; set to 0 */
753 int (*spare_fptr2)();
754 } sasl_server_plug_t;
756 #define SASL_SERVER_PLUG_VERSION 4
758 /* plug-in entry point:
759 * utils -- utility callback functions
760 * plugname -- name of plug-in (may be NULL)
761 * max_version -- highest server plug version supported
763 * out_version -- server plug-in version of result
764 * pluglist -- list of mechanism plug-ins
765 * plugcount -- number of mechanism plug-ins
768 * SASL_NOMEM -- failure
769 * SASL_BADVERS -- max_version too small
770 * SASL_BADPARAM -- bad config string
773 typedef int sasl_server_plug_init_t(const sasl_utils_t *utils,
776 sasl_server_plug_t **pluglist,
780 * add a server plug-in
782 LIBSASL_API int sasl_server_add_plugin(const char *plugname,
783 sasl_server_plug_init_t *splugfunc);
786 typedef struct server_sasl_mechanism
789 int condition; /* set to SASL_NOUSER if no available users;
790 set to SASL_CONTINUE if delayed plugin loading */
791 char *plugname; /* for AUTHSOURCE tracking */
792 const sasl_server_plug_t *plug;
793 char *f; /* where should i load the mechanism from? */
794 } server_sasl_mechanism_t;
796 typedef void sasl_server_info_callback_t (server_sasl_mechanism_t *m,
797 sasl_info_callback_stage_t stage,
801 /* Dump information about available server plugins (separate functions are
802 used for canon and auxprop plugins) */
803 LIBSASL_API int sasl_server_plugin_info (const char *mech_list,
804 sasl_server_info_callback_t *info_cb,
808 /*********************************************************
809 * user canonicalization plug-in -- added cjn 1999-09-29 *
810 *********************************************************/
812 typedef struct sasl_canonuser {
813 /* optional features of plugin (set to 0) */
816 /* spare integer (set to 0) */
819 /* global state for plugin */
825 /* free global state for plugin */
826 void (*canon_user_free)(void *glob_context, const sasl_utils_t *utils);
828 /* canonicalize a username
829 * glob_context -- global context from this structure
830 * sparams -- server params, note user_realm&propctx elements
831 * user -- user to login as (may not be NUL terminated)
832 * len -- length of user name (0 = strlen(user))
833 * flags -- for SASL_CU_* flags
834 * out -- buffer to copy user name
835 * out_max -- max length of user name
836 * out_len -- set to length of user name
838 * note that the output buffers MAY be the same as the input buffers.
842 * SASL_BADPROT username contains invalid character
844 int (*canon_user_server)(void *glob_context,
845 sasl_server_params_t *sparams,
846 const char *user, unsigned len,
849 unsigned out_umax, unsigned *out_ulen);
851 int (*canon_user_client)(void *glob_context,
852 sasl_client_params_t *cparams,
853 const char *user, unsigned len,
856 unsigned out_max, unsigned *out_len);
858 /* for additions which don't require a version upgrade; set to 0 */
859 int (*spare_fptr1)();
860 int (*spare_fptr2)();
861 int (*spare_fptr3)();
862 } sasl_canonuser_plug_t;
864 #define SASL_CANONUSER_PLUG_VERSION 5
866 /* default name for canonuser plug-in entry point is "sasl_canonuser_init"
867 * similar to sasl_server_plug_init model, except only returns one
868 * sasl_canonuser_plug_t structure;
870 typedef int sasl_canonuser_init_t(const sasl_utils_t *utils,
873 sasl_canonuser_plug_t **plug,
874 const char *plugname);
876 /* add a canonuser plugin
878 LIBSASL_API int sasl_canonuser_add_plugin(const char *plugname,
879 sasl_canonuser_init_t *canonuserfunc);
881 /******************************************************
882 * auxiliary property plug-in -- added cjn 1999-09-29 *
883 ******************************************************/
885 typedef struct sasl_auxprop_plug {
886 /* optional features of plugin (none defined yet, set to 0) */
889 /* spare integer, must be set to 0 */
892 /* global state for plugin */
895 /* free global state for plugin (OPTIONAL) */
896 void (*auxprop_free)(void *glob_context, const sasl_utils_t *utils);
898 /* fill in fields of an auxiliary property context
899 * last element in array has id of SASL_AUX_END
900 * elements with non-0 len should be ignored.
902 void (*auxprop_lookup)(void *glob_context,
903 sasl_server_params_t *sparams,
905 const char *user, unsigned ulen);
907 /* name of the auxprop plugin */
910 /* store the fields/values of an auxiliary property context (OPTIONAL)
912 * if ctx is NULL, just check if storing properties is enabled
916 * SASL_FAIL on failure
918 int (*auxprop_store)(void *glob_context,
919 sasl_server_params_t *sparams,
921 const char *user, unsigned ulen);
922 } sasl_auxprop_plug_t;
924 /* auxprop lookup flags */
925 #define SASL_AUXPROP_OVERRIDE 0x01 /* if clear, ignore auxiliary properties
926 * with non-zero len field. If set,
927 * override value of those properties */
928 #define SASL_AUXPROP_AUTHZID 0x02 /* if clear, we are looking up the
929 * authid flags (prefixed with *), otherwise
930 * we are looking up the authzid flags
933 #define SASL_AUXPROP_PLUG_VERSION 4
935 /* default name for auxprop plug-in entry point is "sasl_auxprop_init"
936 * similar to sasl_server_plug_init model, except only returns one
937 * sasl_auxprop_plug_t structure;
939 typedef int sasl_auxprop_init_t(const sasl_utils_t *utils,
942 sasl_auxprop_plug_t **plug,
943 const char *plugname);
945 /* add an auxiliary property plug-in
947 LIBSASL_API int sasl_auxprop_add_plugin(const char *plugname,
948 sasl_auxprop_init_t *auxpropfunc);
950 typedef void auxprop_info_callback_t (sasl_auxprop_plug_t *m,
951 sasl_info_callback_stage_t stage,
954 /* Dump information about available auxprop plugins (separate functions are
955 used for canon and server authentication plugins) */
956 LIBSASL_API int auxprop_plugin_info (const char *mech_list,
957 auxprop_info_callback_t *info_cb,
964 #endif /* SASLPLUG_H */