SVN-based MySQL authentication

Source: Internet
Author: User



Introduction to SVN and how it works

Subversion is the version management software that has risen in recent years and is the successor to CVS, and most open source software uses SVN as the code version management software. Subversion supports Linux and Windows, but common applications are on Linux.

SVN works mainly in two ways: by using a standalone server and relying on the Apache way of working.

SVN's role is reflected in the following areas

1, solve the problem of code management disorder.

2. Solve the problem of code conflict.

3, to solve the code owner of code permissions control.

System Environment: CentOS release 6.5 (Final)

Server ip:192.168.159.130


Vi/etc/sysconfig/network


First, install the relevant software package

[Email protected] ~]# yum-y install MySQL mysql-devel mysql-server httpd mod_auth_mysql Subversion mod_dav_svn

#mod_auth_mysql #实现Apache的MySQL认证

#subversion #SVN软件包

#mod_dav_svn #Subversion与Apache之间的接口, Apache will be able to access the repository and allow the client to access it using the Extended protocol Webdav/deltav of HTTP.

Second, close and start related services


#关闭防火墙和selinux to avoid unnecessary errors in the experiment.

[[email protected] ~]# service iptables Stop

Iptables:setting chains to Policy Accept:filter [OK]

iptables:flushing firewall rules: [OK]

iptables:unloading modules: [OK]

[Email protected] ~]# setenforce 0

[[email protected] ~]# service mysqld start

#SVN是随着httpd服务启动而启动

[[email protected] ~]# service httpd start

Starting Httpd:httpd:apr_sockaddr_info_get () failed for gupt-11

Httpd:could not reliably determine the server ' s fully qualified domain name, using 127.0.0.1 for ServerName

[OK]


Iii. creating repositories and related authorizations


#创建测试目录.

[Email protected] ~]# mkdir-p/data/svn


#在提供的路径上创建一个新的空的版本库, if the supplied directory does not exist, it will be created for you.

[Email protected] ~]# svnadmin create/data/svn/test


#SVN访问认证文件, add a group here that members of this group have read and write permissions to the test project. Here you can grant project-related permissions based on the needs of the developer.

[Email protected] ~]# Cat/data/svn/authz

[Groups]

admin = dailele1,dailele2,php100

[test:/]

@admin = RW


Iv. granting permissions to the project Apache

[Email protected] ~]# chown apache.apache/data/svn/-R

[Email protected] ~]# chmod 755/data/svn/-R

Five, configure the authentication database

[Email protected] ~]# mysql-uroot-p

mysql> CREATE database Svn_auth;

Query OK, 1 row Affected (0.00 sec)

mysql> use Svn_auth;

Database changed

Mysql> Grant all privileges on * * to [e-mail protected] '% ' identified by ' 123456 ' with GRANT option;

Query OK, 0 rows Affected (0.00 sec)

Mysql> CREATE TABLE users

(

- user_name CHAR (+) not NULL,

- user_passwd CHAR (a) not NULL,

PRIMARY KEY (user_name)

);

Query OK, 0 rows affected (0.01 sec)


mysql> INSERT INTO svn_auth.users values (' Dailele1 ', Encrypt (' 123456 '));

Query OK, 1 row Affected (0.00 sec)


mysql> INSERT INTO svn_auth.users values (' Dailele2 ', Encrypt (' 123456 '));

Query OK, 1 row affected (0.01 sec)


mysql> INSERT INTO svn_auth.users values (' php100 ', Encrypt (' 123456 '));

Query OK, 1 row Affected (0.00 sec)


VI, Apache and SVN integration


[Email protected] ~]# vi/etc/httpd/conf/httpd.conf

<Location/svn>

DAV SVN #开启DAV模块支持!

svnparentpath/data/svn/#项目的父目录

Authzsvnaccessfile/data/svn/authz #SVN访问认证文件

AuthName "Eelly SUBVERSION" #认证名称

AuthType Basic #基本认证

Authmysqlenable on #开启Mysql认证

Authmysqluser SVN #数据库访问用户名

Authmysqlpassword 123456 #数据库访问的密码

Authmysqldb Svn_auth #存放认证信息的数据库名称

Authmysqlusertable Users #存放认证信息的表名称

Authmysqlnamefield user_name #存放认证用户名的字段名称

Authmysqlpasswordfield user_passwd #存放认证密码的字段名称

Require Valid-user #表示只有认证的用户才能登陆

</Location>


Seven, restart the service

[Email protected] ~]# service httpd Restart


Viii. Modification of MY.CNF

[Email protected] ~]# vi/etc/my.cnf

[Mysqld]

Datadir=/var/lib/mysql

Socket=/var/lib/mysql/mysql.sock

User=mysql

Skip_grant_tables


#启动mysql时不启动grant-tables Authorization form, otherwise the error will cause the account cannot pass the verification.

[ERROR] [Client 172.18.107.176] MySQL error:access denied for user ' svn ' @ ' localhost ' (using Password:yes)


[Email protected] ~]# service mysqld Restart

Stopping mysqld: [OK]

Starting mysqld: [OK]


Nine, testing


9.1, in the client first in Firefox browser with dailele1 This user login test repository.


650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/4D/B1/wKioL1RXS-7A38uDAAig3EX-OQ0671.jpg "style=" float: none; "title=" 2014-11-03_173028.png "alt=" Wkiol1rxs-7a38udaaig3ex-oq0671.jpg "/>


Dailele users can be certified, because this is a new version of the library, of course, it is empty.

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/4D/B2/wKiom1RXS5DADAJ-AAIll5fxaAI372.jpg "style=" float: none; "title=" 2014-11-03_173034.png "alt=" Wkiom1rxs5dadaj-aaill5fxaai372.jpg "/>


Simple SVN-based MySQL authentication is done, just need to create a user in the MySQL database, and then in the Authz file to give users the appropriate permissions to access the corresponding repository.

This article is from the "Xbc's homepage" blog, so be sure to keep this source http://alipay.blog.51cto.com/7119970/1571369

SVN-based MySQL authentication

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.