[svn-commits] dlee: branch dlee/ari-type-conf r393827 - in /team/dlee/ari-type-conf: config...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Mon Jul 8 13:23:48 CDT 2013


Author: dlee
Date: Mon Jul  8 13:23:45 2013
New Revision: 393827

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=393827
Log:
Switched user config from being determined by category (user-*) to a type field (type=user)

Modified:
    team/dlee/ari-type-conf/configs/ari.conf.sample
    team/dlee/ari-type-conf/res/res_stasis_http.c
    team/dlee/ari-type-conf/res/stasis_http/config.c

Modified: team/dlee/ari-type-conf/configs/ari.conf.sample
URL: http://svnview.digium.com/svn/asterisk/team/dlee/ari-type-conf/configs/ari.conf.sample?view=diff&rev=393827&r1=393826&r2=393827
==============================================================================
--- team/dlee/ari-type-conf/configs/ari.conf.sample (original)
+++ team/dlee/ari-type-conf/configs/ari.conf.sample Mon Jul  8 13:23:45 2013
@@ -8,7 +8,8 @@
 ;auth_realm =		; Realm to use for authentication. Defaults to Asterisk
 ;			; REST Interface.
 
-;[user-username]
+;[username]
+;type = user		; Specifies user configuration
 ;read_only = no		; When set to yes, user is only authorized for
 ;			; read-only requests.
 ;

Modified: team/dlee/ari-type-conf/res/res_stasis_http.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/ari-type-conf/res/res_stasis_http.c?view=diff&rev=393827&r1=393826&r2=393827
==============================================================================
--- team/dlee/ari-type-conf/res/res_stasis_http.c (original)
+++ team/dlee/ari-type-conf/res/res_stasis_http.c Mon Jul  8 13:23:45 2013
@@ -95,6 +95,14 @@
 
 			<configObject name="user">
 				<synopsis>Per-user configuration settings</synopsis>
+				<configOption name="type">
+					<synopsis>Define this configuration section as a user.</synopsis>
+					<description>
+						<enumlist>
+							<enum name="user"><para>Configure this section as a <replaceable>user</replaceable></para></enum>
+						</enumlist>
+					</description>
+				</configOption>
 				<configOption name="read_only">
 					<synopsis>When set to yes, user is only authorized for read-only requests</synopsis>
 				</configOption>

Modified: team/dlee/ari-type-conf/res/stasis_http/config.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/ari-type-conf/res/stasis_http/config.c?view=diff&rev=393827&r1=393826&r2=393827
==============================================================================
--- team/dlee/ari-type-conf/res/stasis_http/config.c (original)
+++ team/dlee/ari-type-conf/res/stasis_http/config.c Mon Jul  8 13:23:45 2013
@@ -89,16 +89,8 @@
 static void *user_alloc(const char *cat)
 {
 	RAII_VAR(struct ari_conf_user *, user, NULL, ao2_cleanup);
-	const char *username;
 
 	if (!cat) {
-		return NULL;
-	}
-
-	username = strchr(cat, '-') + 1;
-
-	if (!username) {
-		ast_log(LOG_ERROR, "Invalid user category '%s'\n", cat);
 		return NULL;
 	}
 
@@ -110,7 +102,7 @@
 		return NULL;
 	}
 
-	user->username = ast_strdup(username);
+	user->username = ast_strdup(cat);
 	if (!user->username) {
 		return NULL;
 	}
@@ -141,21 +133,20 @@
 /*! \brief \ref aco_type item_find function */
 static void *user_find(struct ao2_container *tmp_container, const char *cat)
 {
-	const char *username;
-
 	if (!cat) {
 		return NULL;
 	}
 
-	username = strchr(cat, '-') + 1;
-	return ao2_find(tmp_container, username, OBJ_KEY);
+	return ao2_find(tmp_container, cat, OBJ_KEY);
 }
 
 static struct aco_type user_option = {
 	.type = ACO_ITEM,
 	.name = "user",
-	.category_match = ACO_WHITELIST,
-	.category = "^user-.+$",
+	.category_match = ACO_BLACKLIST,
+	.category = "^general$",
+	.matchfield = "type",
+	.matchvalue = "user",
 	.item_alloc = user_alloc,
 	.item_find = user_find,
 	.item_offset = offsetof(struct ari_conf, users),
@@ -317,6 +308,8 @@
 		FLDSET(struct ari_conf_general, auth_realm),
 		ARI_AUTH_REALM_LEN);
 
+	aco_option_register(&cfg_info, "type", ACO_EXACT, user, NULL,
+		OPT_NOOP_T, 0, 0);
 	aco_option_register(&cfg_info, "read_only", ACO_EXACT, user,
 		"no", OPT_BOOL_T, 1,
 		FLDSET(struct ari_conf_user, read_only));




More information about the svn-commits mailing list