加入收藏 | 设为首页 | Life家族 | SCMLife | RMLife | PMLife | SQALife | TESTLife | 企业VIP专区 | 中文化荣誉殿堂

查看完整版本: Apache和subversion认证mysql数据库方式

oases2008 2006-9-12 16:57

Apache和subversion认证mysql数据库方式

[align=center][align=center][size=3][color=#000000][font=Times New Roman]Apache[/font][font=宋体]和[/font][font=Times New Roman]subversion[/font][font=宋体]认证[/font][font=Times New Roman]mysql[/font][font=宋体]数据库方式[/font][/font][/font][/align][/align][align=center][align=center][size=3][color=#000000][font=Times New Roman] [/font][/font][/font][/align][/align][align=center][align=center][size=3][color=#000000][font=宋体]李树仁[/font][font=Times New Roman]2005-10-28[/font][/font][/font][/align][/align][size=3][color=#000000][font=Times New Roman] [/font][/font][/font]
[size=3][color=#000000][font=Times New Roman]       [/font][font=宋体]在安装[/font][font=Times New Roman]apache[/font][font=宋体]时要选择[/font][font=Times New Roman]apache[/font][font=宋体]的模块[/font][font=Times New Roman]mysql_auth_module[/font][font=宋体],否则要自己安装该模块,该模块下载网址是:[/font][/font][/font]
[font=Times New Roman][size=3][color=#000000]       [/color][/size][/font][url=http://prdownloads.sourceforge.net/modauthmysql/mod_auth_mysql-3.0.0.tar.gz?download][font=Times New Roman][size=3][color=#0000ff]http://prdownloads.sourceforge.net/modauthmysql/mod_auth_mysql-3.0.0.tar.gz?download[/color][/size][/font][/url]
[size=3][color=#000000][font=Times New Roman]       [/font][font=宋体]在安装[/font][font=Times New Roman]linux[/font][font=宋体]时可以选择安装[/font][font=Times New Roman]apache[/font][font=宋体]和模块[/font][font=Times New Roman]mysql_auth_module[/font][font=宋体]。[/font][/font][/font]
[size=3][color=#000000][font=Times New Roman]       [/font][font=宋体]安装完模块后在[/font][font=Times New Roman]/etc/httpd/conf.d[/font][font=宋体]目录下有[/font][font=Times New Roman]auth_mysql.conf[/font][font=宋体]配置文件,根据配置内容进行数据库创建、表和[/font][font=Times New Roman]user[/font][font=宋体]的创建。根据需要来创建用户表和组表。例如:[/font][/font][/font]
[size=3][color=#000000][font=Times New Roman] [/font][/font][/font]
[size=3][color=#000000][font=Times New Roman]       #    CREATE DATABASE http_auth;[/font][/font][/font]
[font=Times New Roman][size=3][color=#000000]#    USE auth;[/color][/size][/font]
[size=3][color=#000000][font=Times New Roman]#[/font][font=宋体]创建表[/font][font=Times New Roman]users[/font][font=宋体]和[/font][font=Times New Roman]groups[/font][/font][/font]
[font=Times New Roman][size=3][color=#000000]#    CREATE TABLE users ([/color][/size][/font]
[font=Times New Roman][size=3][color=#000000]#      user_name CHAR(30) NOT NULL,[/color][/size][/font]
[font=Times New Roman][size=3][color=#000000]#      user_passwd CHAR(20) NOT NULL,[/color][/size][/font]
[font=Times New Roman][size=3][color=#000000]#      PRIMARY KEY (user_name)[/color][/size][/font]
[font=Times New Roman][size=3][color=#000000]#    );[/color][/size][/font]
[font=Times New Roman][size=3][color=#000000]#    CREATE TABLE groups ([/color][/size][/font]
[font=Times New Roman][size=3][color=#000000]#      user_name CHAR(30) NOT NULL,[/color][/size][/font]
[font=Times New Roman][size=3][color=#000000]#      user_group CHAR(20) NOT NULL,[/color][/size][/font]
[font=Times New Roman][size=3][color=#000000]#      PRIMARY KEY (user_name, user_group)[/color][/size][/font]
[font=Times New Roman][size=3][color=#000000]#    );[/color][/size][/font]
[size=3][color=#000000][font=Times New Roman]#[/font][font=宋体]授权给用户[/font][font=Times New Roman]authuser[/font][font=宋体]来查询[/font][font=Times New Roman],[/font][font=宋体]任何一台计算机都可以查询数据库[/font][/font][/font]
[font=Times New Roman][size=3][color=#000000]#    GRANT SELECT[/color][/size][/font]
[font=Times New Roman][size=3][color=#000000]#      ON auth.users[/color][/size][/font]
[font=Times New Roman][size=3][color=#000000]#      TO authuser@localhost[/color][/size][/font]
[font=Times New Roman][size=3][color=#000000]#      IDENTIFIED BY 'PaSsW0Rd';[/color][/size][/font]
[font=Times New Roman][size=3][color=#000000]#    GRANT SELECT[/color][/size][/font]
[font=Times New Roman][size=3][color=#000000]#      ON auth.users[/color][/size][/font]
[font=Times New Roman][size=3][color=#000000]#      TO authuser@'%'[/color][/size][/font]
[font=Times New Roman][size=3][color=#000000]#      IDENTIFIED BY 'PaSsW0Rd';[/color][/size][/font]
[size=3][color=#000000][font=Times New Roman] [/font][/font][/font]
[size=3][color=#000000][font=Times New Roman] [/font][/font][/font]
[font=Times New Roman][size=3][color=#000000]#    GRANT SELECT[/color][/size][/font]
[font=Times New Roman][size=3][color=#000000]#      ON auth.groups[/color][/size][/font]
[font=Times New Roman][size=3][color=#000000]#      TO authuser@localhost[/color][/size][/font]
[font=Times New Roman][size=3][color=#000000]#      IDENTIFIED BY 'PaSsW0Rd';[/color][/size][/font]
[size=3][color=#000000][font=Times New Roman] [/font][/font][/font]
[font=Times New Roman][size=3][color=#000000]#    GRANT SELECT[/color][/size][/font]
[font=Times New Roman][size=3][color=#000000]#      ON auth.groups[/color][/size][/font]
[font=Times New Roman][size=3][color=#000000]#      TO authuser@'%'[/color][/size][/font]
[font=Times New Roman][size=3][color=#000000]#      IDENTIFIED BY 'PaSsW0Rd';[/color][/size][/font]
[size=3][color=#000000][font=Times New Roman] [/font][/font][/font]
[size=3][color=#000000][font=Times New Roman] [/font][/font][/font]
[size=3][color=#000000][font=Times New Roman]#[/font][font=宋体]插入用户和组数据[/font][/font][/font]
[font=Times New Roman][size=3][color=#000000]#    INSERT INTO users VALUES ('test user',  ENCRYPT('testpass'));[/color][/size][/font]
[font=Times New Roman][size=3][color=#000000]#    INSERT INTO groups VALUES ('testuser', 'user');[/color][/size][/font]
[font=Times New Roman][size=3][color=#000000]#    INSERT INTO users VALUES ('testadmin', ENCRYPT('testpass'));[/color][/size][/font]
[font=Times New Roman][size=3][color=#000000]#    INSERT INTO groups VALUES ('testadmin', 'admin');[/color][/size][/font]
[font=Times New Roman][size=3][color=#000000]#    INSERT INTO groups VALUES ('testadmin', 'user');[/color][/size][/font]
[size=3][color=#000000][font=Times New Roman] [/font][/font][/font]
[size=3][color=#000000][font=宋体]这样在数据库建成后就可以对相应的[/font][font=Times New Roman]web[/font][font=宋体]应用进行设置权限。例如:[/font][/font][/font]
[size=3][color=#000000][font=Times New Roman] [/font][/font][/font]
[font=Times New Roman][size=3][color=#000000]#<Directory /var/www>[/color][/size][/font]
[font=Times New Roman][size=3][color=#000000]#    AuthName "MySQL group authenticated zone"[/color][/size][/font]
[font=Times New Roman][size=3][color=#000000]#    AuthType Basic[/color][/size][/font]
[font=Times New Roman][size=3][color=#000000]#[/color][/size][/font]
[font=Times New Roman][size=3][color=#000000]#    AuthMySQLUser authuser[/color][/size][/font]
[font=Times New Roman][size=3][color=#000000]#    AuthMySQLPassword PaSsW0Rd[/color][/size][/font]
[font=Times New Roman][size=3][color=#000000]#    AuthMySQLDB auth[/color][/size][/font]
[font=Times New Roman][size=3][color=#000000]#    AuthMySQLUserTable users[/color][/size][/font]
[font=Times New Roman][size=3][color=#000000]#    AuthMySQLNameField user_name[/color][/size][/font]
[font=Times New Roman][size=3][color=#000000]#    AuthMySQLPasswordField user_passwd[/color][/size][/font]
[font=Times New Roman][size=3][color=#000000]#    AuthMySQLGroupTable groups[/color][/size][/font]
[font=Times New Roman][size=3][color=#000000]#    AuthMySQLGroupField user_group[/color][/size][/font]
[font=Times New Roman][size=3][color=#000000]#[/color][/size][/font]
[font=Times New Roman][size=3][color=#000000]#    require group user[/color][/size][/font]
[font=Times New Roman][size=3][color=#000000]#</Directory>[/color][/size][/font]
[size=3][color=#000000][font=Times New Roman] [/font][/font][/font]
[size=3][color=#000000][font=宋体]如果是对[/font][font=Times New Roman]subversion[/font][font=宋体]资源库进行认证的话,需要把配置信息放入到[/font][font=Times New Roman]subvesion.conf[/font][font=宋体]配置文件中去。[/font][/font][/font]
[size=3][color=#000000][font=宋体]最后需要特别说明的是:[/font][font=Times New Roman]users [/font][font=宋体]表中的[/font][font=Times New Roman] user_passwd [/font][font=宋体]字段是采用[/font][font=Times New Roman] mysql [/font][font=宋体]的[/font][font=Times New Roman] encrypt() [/font][font=宋体]加密的,而不是[/font][font=Times New Roman] password() [/font][font=宋体],更不是明码。[/font][/font][/font][size=3][color=#000000][font=Times New Roman] [/font][/font][/font]
[size=3][color=#000000][font=Times New Roman] [/font][/font][/font]
[font=Times New Roman][size=3][color=#000000] INSERT INTO users VALUES ('lsr',  ENCRYPT('lsr'));[/color][/size][/font]
[size=3][color=#000000][font=Times New Roman] INSERT INTO groups VALUES ('lsr', 'admin');[/font][/font][/font]
[font=Times New Roman][size=3][color=#000000][/color][/size][/font]
[size=3][color=#000000][font=Times New Roman] INSERT INTO users VALUES ('csdn',  ENCRYPT(csdn));[/font][/font][/font]
[size=3][color=#000000][font=Times New Roman] INSERT INTO groups VALUES (csdn, 'admin');[/font][/font][/font]
[font=Times New Roman][size=3][color=#000000][/color][/size][/font]
[size=3][color=#000000][font=Times New Roman] [/font][/font][/font]

CMStruggling 2008-4-24 19:18

“Apache和subversion认证mysql数据库方式”
这都行,
厉害!不佩服不行。
mysql数据库最近发现用的挺多。
有机会得研究一下,先学习了。
::em71::
页: [1]
查看完整版本: Apache和subversion认证mysql数据库方式