Add auth_policy option to jabber.conf for auto user registration.

The option is global and currently the acceptable values as noted in the sample
config are accept or deny.

(closes issue #15228)
Reported by: lp0


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@235342 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Jeff Peeler
2009-12-16 20:25:27 +00:00
parent fb931dac4f
commit 6b34563778
4 changed files with 38 additions and 18 deletions

View File

@@ -367,6 +367,7 @@ Miscellaneous
code set to 2. code set to 2.
* An 'X' option has been added to the asterisk application which enables #exec support. * An 'X' option has been added to the asterisk application which enables #exec support.
This allows #exec to be used in asterisk.conf. This allows #exec to be used in asterisk.conf.
* jabber.conf supports a new option auth_policy that toggles auto user registration.
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
--- Functionality changes from Asterisk 1.6.1 to Asterisk 1.6.2 ------------- --- Functionality changes from Asterisk 1.6.1 to Asterisk 1.6.2 -------------

View File

@@ -4,6 +4,9 @@
;;setup (ie, using your personal Gtalk account for a test) ;;setup (ie, using your personal Gtalk account for a test)
;;you might lose your contacts list. Default is 'no'. ;;you might lose your contacts list. Default is 'no'.
;autoregister=yes ;;Auto register users from buddy list. ;autoregister=yes ;;Auto register users from buddy list.
;auth_policy=accept ;;Auto accept users' subscription requests (default).
;;Set to deny for auto denial.
;[asterisk] ;;label ;[asterisk] ;;label
;type=client ;;Client or Component connection ;type=client ;;Client or Component connection

View File

@@ -84,7 +84,8 @@ enum aji_state {
enum { enum {
AJI_AUTOPRUNE = (1 << 0), AJI_AUTOPRUNE = (1 << 0),
AJI_AUTOREGISTER = (1 << 1) AJI_AUTOREGISTER = (1 << 1),
AJI_AUTOACCEPT = (1 << 2)
}; };
enum aji_btype { enum aji_btype {

View File

@@ -353,7 +353,7 @@ static ast_cond_t message_received_condition;
static ast_mutex_t messagelock; static ast_mutex_t messagelock;
/*! \brief Global flags, initialized to default values */ /*! \brief Global flags, initialized to default values */
static struct ast_flags globalflags = { AJI_AUTOREGISTER }; static struct ast_flags globalflags = { AJI_AUTOREGISTER | AJI_AUTOACCEPT };
/*! /*!
* \internal * \internal
@@ -2410,6 +2410,7 @@ static void aji_handle_subscribe(struct aji_client *client, ikspak *pak)
switch (pak->subtype) { switch (pak->subtype) {
case IKS_TYPE_SUBSCRIBE: case IKS_TYPE_SUBSCRIBE:
if (ast_test_flag(&client->flags, AJI_AUTOACCEPT)) {
presence = iks_new("presence"); presence = iks_new("presence");
status = iks_new("status"); status = iks_new("status");
if (presence && status) { if (presence && status) {
@@ -2426,6 +2427,7 @@ static void aji_handle_subscribe(struct aji_client *client, ikspak *pak)
iks_delete(presence); iks_delete(presence);
iks_delete(status); iks_delete(status);
}
if (client->component) if (client->component)
aji_set_presence(client, pak->from->full, iks_find_attrib(pak->x, "to"), client->status, client->statusmessage); aji_set_presence(client, pak->from->full, iks_find_attrib(pak->x, "to"), client->status, client->statusmessage);
@@ -3410,6 +3412,13 @@ static int aji_create_client(char *label, struct ast_variable *var, int debug)
ast_set2_flag(&client->flags, ast_true(var->value), AJI_AUTOPRUNE); ast_set2_flag(&client->flags, ast_true(var->value), AJI_AUTOPRUNE);
else if (!strcasecmp(var->name, "autoregister")) else if (!strcasecmp(var->name, "autoregister"))
ast_set2_flag(&client->flags, ast_true(var->value), AJI_AUTOREGISTER); ast_set2_flag(&client->flags, ast_true(var->value), AJI_AUTOREGISTER);
else if (!strcasecmp(var->name, "auth_policy")) {
if (!strcasecmp(var->value, "accept")) {
ast_set_flag(&client->flags, AJI_AUTOACCEPT);
} else {
ast_clear_flag(&client->flags, AJI_AUTOACCEPT);
}
}
else if (!strcasecmp(var->name, "buddy")) else if (!strcasecmp(var->name, "buddy"))
aji_create_buddy((char *)var->value, client); aji_create_buddy((char *)var->value, client);
else if (!strcasecmp(var->name, "priority")) else if (!strcasecmp(var->name, "priority"))
@@ -3595,7 +3604,7 @@ static int aji_load_config(int reload)
return -1; return -1;
/* Reset flags to default value */ /* Reset flags to default value */
ast_set_flag(&globalflags, AJI_AUTOREGISTER); ast_set_flag(&globalflags, AJI_AUTOREGISTER | AJI_AUTOACCEPT);
if (cfg == CONFIG_STATUS_FILEMISSING || cfg == CONFIG_STATUS_FILEINVALID) { if (cfg == CONFIG_STATUS_FILEMISSING || cfg == CONFIG_STATUS_FILEINVALID) {
ast_log(LOG_WARNING, "No such configuration file %s\n", JABBER_CONFIG); ast_log(LOG_WARNING, "No such configuration file %s\n", JABBER_CONFIG);
@@ -3610,6 +3619,12 @@ static int aji_load_config(int reload)
ast_set2_flag(&globalflags, ast_true(var->value), AJI_AUTOPRUNE); ast_set2_flag(&globalflags, ast_true(var->value), AJI_AUTOPRUNE);
} else if (!strcasecmp(var->name, "autoregister")) { } else if (!strcasecmp(var->name, "autoregister")) {
ast_set2_flag(&globalflags, ast_true(var->value), AJI_AUTOREGISTER); ast_set2_flag(&globalflags, ast_true(var->value), AJI_AUTOREGISTER);
} else if (!strcasecmp(var->name, "auth_policy")) {
if (!strcasecmp(var->value, "accept")) {
ast_set_flag(&globalflags, AJI_AUTOACCEPT);
} else {
ast_clear_flag(&globalflags, AJI_AUTOACCEPT);
}
} }
} }