1:表结构
CREATE TABLE `subscriber` (`id` int(10) unsigned NOT NULL AUTO_INCREMENT,`username` varchar(64) NOT NULL DEFAULT '',`domain` varchar(64) NOT NULL DEFAULT '',`password` varchar(64) NOT NULL DEFAULT '',`ha1` varchar(128) NOT NULL DEFAULT '',`ha1b` varchar(128) NOT NULL DEFAULT '',PRIMARY KEY (`id`),UNIQUE KEY `account_idx` (`username`,`domain`),KEY `username_idx` (`username`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=gb2312;
username
是用户名
domain
是SIP域
password是密码
ha1
和 ha1b
分别是用户的ha1和ha1b值。
ha1=md5('username:domain:password')
ha1b=md5('username@domain:domain:password')
插入实例:
INSERT INTO subscriber (username, domain, password, ha1, ha1b) VALUES '101', 'test.com', 'test123',MD5('101:test.com:test123'), MD5('101@test.com:test.com:test123')
);
kamailio注册认证的配置:
1:开启mysql和auth
#
# *** To enable mysql:
# - define WITH_MYSQL
#!define WITH_MYSQL
#
# *** To enable authentication execute:
# - enable mysql
# - define WITH_AUTH
# - add users using 'kamctl'
#!define WITH_AUTH
2:加载auth模块
#!ifdef WITH_AUTH
loadmodule "auth.so"
loadmodule "auth_db.so"
3:配置auth
#!ifdef WITH_AUTH
modparam("auth_db", "db_url", DBURL)
modparam("auth_db", "calculate_ha1", yes)
modparam("auth_db", "password_column", "password")
modparam("auth_db", "load_credentials", "")
modparam("auth_db", "use_domain", MULTIDOMAIN)
以上配置为 使用 ha1验证合法性