先前範例並未針對Project Folder做存取權限控管,所以每位User皆可以透過TortoiseSVN Tools執行Checkout / Commit等作業。
權限設定部分則會使用到下列Configure File:
- Apache Authentication Configure File:/etc/htpasswd.user
- Subversion Apache Configure File Path:/etc/httpd/conf.d/subversion.conf
- SVN Permission Configure File Path:/usr/local/svn/staging/conf/authz
本範例須使用Username:godspeedyen、alice、kevin進行Permission驗證,
故需於 Apache Authentication Configure File 新增Username:alice、kevin,執行方式及結果如下,[方框處]請自行變更密碼:
# Create Authentication User File [root@Subversion ~]# /usr/bin/htdigest /etc/htpasswd.user "Subversion Reository" alice Adding password for alice in realm Subversion Reository. New password: [alice] Re-type new password:[alice] [root@Subversion ~]# /usr/bin/htdigest /etc/htpasswd.user "Subversion Reository" kevin Adding password for kevin in realm Subversion Reository. New password: [kevin] Re-type new password:[kevin] # /etc/htpasswd.user File Format [root@Subversion ~]# /bin/cat /etc/htpasswd.user godspeedyen:Subversion Reository:823400fb0db41989ae173bfca3524015 alice:Subversion Reository:b95dde4e80e1f9603531fdaeec5a431d kevin:Subversion Reository:4a04abc581df12ca1f8a0de373874871
異動Subversion Apache Configure File,讓Apache Server能套用User Permission,設定方式如下:
[root@Subversion ~]# vi /etc/httpd/conf.d/subversion.conf
<Location /svn/>
AuthzSVNAccessFile /usr/local/svn/staging/conf/authz
</Location>
Restart Apache Daemon:
/etc/init.d/httpd restart
SVN Permission Configure File以含有Default Sample,大致說明如下:
[groups] ## user 'harry', 'sally' in group 'harry_and_sally' ## # harry_and_sally = harry,sally ## user 'harry', 'sally' and aliases defined in 'joe' in group 'harry_sally_and_joe' ## # harry_sally_and_joe = harry,sally,&joe # [/foo/bar] ## user 'harry' can read and write access ## # harry = rw ## aliases defined in 'joe' can read access ## # &joe = r ## anyone no access ## # * = ## 'repository' is repository name; '/baz/fuz' is project or file path ## # [repository:/baz/fuz] ## group 'harry_and_sally' can read and write access ## # @harry_and_sally = rw ## anyone can read access ## # * = r
參照Default Sample進行異動,於SVN Permission Configure File新增下列設定值:
Note:SVN Permission Configure File為立即套用設定值,無須重新啟動Daemon。
[root@Subversion ~]# vi /usr/local/svn/staging/conf/authz [groups] godspeedyen_and_alice = godspeedyen,alice [staging:/] * = r [staging:/branches] @godspeedyen_and_alice = r kevin = [staging:/tags] * = [staging:/trunk] @godspeedyen_and_alice = rw kevin = [staging:/trunk/aaa] @godspeedyen_and_alice = r godspeedyen = rw kevin = r [staging:/trunk/aaa/aaa.txt] @godspeedyen_and_alice = rw kevin = rw
Input SVN Server IP Address in Browser URL Path:http://192.168.188.101/svn/staging/
And input account and password of /etc/htpasswd.user file, result:
- Group name is 'godspeedyen_and_alice', member are godspeedyen and alice
- Group name is 'godspeedyen_and_alice' can read http://192.168.188.101/svn/staging/branches
- Group name is 'godspeedyen_and_alice' can read and write http://192.168.188.101/svn/staging/trunk
- Group name is 'godspeedyen_and_alice' can read http://192.168.188.101/svn/staging/trunk/aaa
- Group name is 'godspeedyen_and_alice' can read and write http://192.168.188.101/svn/staging/trunk/aaa/aaa.txt
- Anyone can read http://192.168.188.101/svn/staging
- Anyone no access permission to http://192.168.188.101/svn/staging/tags
- User kevin no access permission to http://192.168.188.101/svn/staging/branches
- User kevin no access permission to http://192.168.188.101/svn/staging/trunk
- User kevin can read http://192.168.188.101/svn/staging/trunk/aaa
- User kevin can read and write http://192.168.188.101/svn/staging/trunk/aaa/aaa.txt
- User godspeedyen can read and write http://192.168.188.101/svn/staging/trunk/aaa
上述結果可於Browser驗證Read Permission,Write Permission可使用TortoiseSVN Tools進行驗證。Example:
When user alice commit /trunk/aaa/alice folder to http://192.168.188.101/svn/staging/aaa, result:
When user godspeedyen commit /trunk/aaa/godspeedyen folder to http://192.168.188.101/svn/staging/aaa, result:
When user kevin edit and commit /trunk/aaa/aaa.txt text file to http://192.168.188.101/svn/staging/aaa/aaa.txt, result:
由上述測試可知SVN Server在權限設定方面,參照下列Policy:
When user alice commit /trunk/aaa/alice folder to http://192.168.188.101/svn/staging/aaa, result:
When user godspeedyen commit /trunk/aaa/godspeedyen folder to http://192.168.188.101/svn/staging/aaa, result:
When user kevin edit and commit /trunk/aaa/aaa.txt text file to http://192.168.188.101/svn/staging/aaa/aaa.txt, result:
Input account and password for kevin in web browser, result:
- 若於父目錄設定權限,則子目錄及檔案預設將會繼承權限
- 若同時設定Read Write 權限及No Access權限 ,則會套用 Read Write權限







沒有留言:
張貼留言