Gbrowse权限管理

评论1,657

或许你的数据没有发布,你只想部分人员访问你的Gbrowse,这就涉及到了权限管理,GBrowse提供了多种机制,你可以限制访问者的主机、IP地址、域名,或者只有通过用户名密码登陆后才可以访问。
Gbrowse权限管理

Gbrowse 2.20以上的版本提供了以下三种权限管理的方式:

  1. 通过Apache提供的权限管理机制
  2. 构建自己的用户账户数据库
  3. 通过插件机制

Gbrowse是以Apache作为默认的服务器,Apache的权限机制自然适用于对其进行管理,Apache的权限管理是基于目录的,提供的多种权限验证机制,包括IP地址、主机名、域名以及用户账户等,通过配置实现,不清楚的读者可以通过Google进一步了解,其缺点就是维护访问账户的经常与服务器配置打交道,另外只能控制到目录层次,对于用户多、权限细化的需求就无法实现。

权限管理最为流行的方式就是用户注册,然后登陆,这里主要介绍,如何通过Gbrowse自身的用户系统实现对权限的访问。

要求

  • perl的DBI模块或者DBD::mysql,DBD::SQLite
  • 允许用户注册,需要安装perl的Net::SMTP模块,以及提供SMTP发邮件的服务器
  • 如果允许用户使用OpenIDs登录,需要安装perl的Net::OpenID::Consumer

配置GBrowse.conf

[GENERAL]
# ...lots of stuff...

# Login Settings
user_accounts               = 1
user_accounts_registration  = 1
user_accounts_openid        = 1
user_account_db             = DBI:SQLite:/var/www/gbrowse2/databases/users.sqlite
smtp_gateway                = localhost
application_name            = GBrowse
application_name_long       = The Generic Genome Browser
email_address               = noreply@gbrowse.com

user_account_db

使用mysql数据库

DBI:mysql:database=gbrowse_login;host=mysql.oicr.on.ca;user=gbrowse;password=gbrowse

使用SQLite数据库

 DBI:SQLite:/var/www/gbrowse2/databases/users.sqlite

smtp_gateway

邮件服务器设置,和客户端发邮件是一个道理。语法如下:

<smtp.server.com>:<port>:<encryption>:<username>:<password>

Gmail邮件设置示例:

smtp_gateway           = smtp.gmail.com:465:ssl:john.doe:open_sesame

数据库的创建

配置好以后,通过允许gbrowse_metadb_config.pl脚本,来创建数据库。包括user、openid_users、sessions、dbinfo四张表。

 USERS

FIELDTYPEDESCRIPTION
useridinteger not null PRIMARY KEY auto_incrementA unique user ID.
emailvarchar(64) not null UNIQUEAn e-mail for confirmation & notification.
passvarchar(32) not nullAn encrypted password (not stored as plain text).
rememberboolean not nullWhether to remember the user at this location or not.
openid_onlyboolean not nullWas registered with an OpenID or no?
confirmedboolean not nullHas been confirmed?
cnfm_codevarchar(32) not nullConfirmation code.
last_logintimestamp not nullDate & time of last login.
createddatetime not nullDate & time created.

OPENID USERS

FIELDTYPEDESCRIPTION
useridinteger not nullA unique user ID.
openid_urlvarchar(128) not null PRIMARY keyThe URL of the openID.

SESSIONS

FIELDTYPEDESCRIPTION
useridinteger not null PRIMARY KEY auto incrementA unique user ID.
usernamevarchar(32)A username, assigned on registration so the user can login. Anonymous users have “an anonymous user” as their username.
sessionidchar(32) not null UNIQUEThe 32-bit hexadecimal ID corresponding to their session.
uploadsidchar(32) not null UNIQUEThe 32-bit hexadecimal ID corresponding to their uploads folder.

DBINFO

FIELDTYPEDESCRIPTION
schema_versionint(10) not null UNIQUEThe version number of the current schema.

通过脚本添加用户

 gbrowse_create_account.pl [-pass <password> -fullname <name> -email <email>] <username>
gbrowse_change_passwd.pl <username> [<password>]

权限的配置

通过restrict标签来进行设置。

限制对于数据源的访问

[GENERAL]
# lots of other stuff...
restrict = require valid-user
...

限制对某个Track的访问

[5_prime_RACE]
glyph    = generic
feature  = RACE:5_prime
restrict = require user fred joseph andrea marta

只有用户名为fred joseph andrea marta的可以访问。

Gbrowse 2.20及以上版本,还另外一种机制就是通过插件实现,调用Linux系统用户对于权限进行管理的,这里不做详述(还没有认真去看)。

参考

本文来源:http://boyun.sh.cn/bio/?p=1870

发表评论

匿名网友