Gbrowse权限管理
或许你的数据没有发布,你只想部分人员访问你的Gbrowse,这就涉及到了权限管理,GBrowse提供了多种机制,你可以限制访问者的主机、IP地址、域名,或者只有通过用户名密码登陆后才可以访问。
Gbrowse 2.20以上的版本提供了以下三种权限管理的方式:
- 通过Apache提供的权限管理机制
- 构建自己的用户账户数据库
- 通过插件机制
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
邮件服务器设置,和客户端发邮件是一个道理。语法如下:
:::: Gmail邮件设置示例:
smtp_gateway = smtp.gmail.com:465:ssl:john.doe:open_sesame 数据库的创建
配置好以后,通过允许gbrowse_metadb_config.pl脚本,来创建数据库。包括user、openid_users、sessions、dbinfo四张表。
Users
Field Type Description userid integer not null PRIMARY KEY auto_increment A unique user ID. email varchar(64) not null UNIQUE An e-mail for confirmation & notification. pass varchar(32) not null An encrypted password (not stored as plain text). remember boolean not null Whether to remember the user at this location or not. openid_only boolean not null Was registered with an OpenID or no? confirmed boolean not null Has been confirmed? cnfm_code varchar(32) not null Confirmation code. last_login timestamp not null Date & time of last login. created datetime not null Date & time created. OpenID Users
Field Type Description userid integer not null A unique user ID. openid_url varchar(128) not null PRIMARY key The URL of the openID. Sessions
Field Type Description userid integer not null PRIMARY KEY auto increment A unique user ID. username varchar(32) A username, assigned on registration so the user can login. Anonymous users have “an anonymous user” as their username. sessionid char(32) not null UNIQUE The 32-bit hexadecimal ID corresponding to their session. uploadsid char(32) not null UNIQUE The 32-bit hexadecimal ID corresponding to their uploads folder.
DBInfo
Field Type Description schema_version int(10) not null UNIQUE The version number of the current schema. 通过脚本添加用户
gbrowse_create_account.pl [-pass -fullname -email ] gbrowse_change_passwd.pl [] 权限的配置
通过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://gmod.org/wiki/GBrowse_Configuration/Authentication
- http://gmod.org/wiki/GBrowse_User_Database
> 转载自:博耘生物 > 《Gbrowse权限管理》