Difference between revisions of "GBrowse Configuration/Authentication"

From GMOD
Jump to: navigation, search
(GBrowse Authentication via Apache's Built-in Authentication Modules)
(GBrowse Authentication via its Built-in User Accounts)
Line 97: Line 97:
  
 
=== GBrowse Authentication via its Built-in User Accounts ===
 
=== GBrowse Authentication via its Built-in User Accounts ===
 +
 +
The GBrowse user account system provides users with a link in the upper right corner of the screen that lets them login, register, and manage their account settings.
 +
 +
[[image:gbrowse_login.png|frame]]
 +
 +
The GBrowse user account system is activated when the following requirements are met:
 +
 +
#The Perl DBI module is installed, and one or both of DBD::mysql and DBD::SQLite.
 +
#The "user accounts" option is set to a "1" (or any other true value) in GBrowse.conf's [GENERAL] section.
 +
#No "authentication plugin" option is defined in GBrowse.conf's [GENERAL] section.
 +
 +
User accounts can be created and managed with the utilities gbrowse_create_account.pl and gbrowse_change_passwd.pl. Users can register themselves and manage their own account settings if:
 +
 +
#The Perl Net::SMTP module is installed (required to validate users via email).
 +
#The "user accounts registration" option is set to a true value in GBrowse.conf.
 +
#The
 +
 +
 +
=== GBrowse Authentication via Authentication Plugins ===
  
 
[[Category:GBrowse]]
 
[[Category:GBrowse]]
 
[[Category:HOWTO]]
 
[[Category:HOWTO]]
 
[[Category:Configuration]]
 
[[Category:Configuration]]

Revision as of 18:55, 17 January 2011

This article describes HTTP authentication and how to configure it to work with GBrowse.

For the main GBrowse2 configuration article, see: GBrowse 2.0 HOWTO.

Authentication & Authorization, Introduction

You can restrict who has access to gbrowse by IP address, host name, domain, username and password, by OpenID, or, via the authentication plugin mechanism, by site-specific restrictions such as possession of a crypto card. Restriction can apply to the database as a whole, or to particular annotation tracks. You can also make a datasource visible only to authorized users.

Authentication Systems

As of version 2.20, GBrowse has three distinct authentication mechanisms:

  1. Authentication via Apache's built-in authentication modules (present in all versions of GBrowse).
  2. Authentication via a built-in user accounts database (GBrowse versions 2.16 and higher).
  3. Authentication via a plugin architecture (GBrowse 2.20 and higher).

The first mechanism uses Apache's standard authentication and authorization modules. This provides you with a large number of authentication backends, but users will not be able to examine and change their credentials unless you install a third-party application for managing Apache authentication.

The second mechanism provides an "accounts database" that is accessible to the server that is running GBrowse. The database is either a local SQLite database, or a local/remote MySQL database. This mechanism provides a way for users to register themselves (if registration is enabled), and allows users to associate OpenIDs with their accounts for one-click login. Users can change their passwords and other information such as their full name and email address.

The third mechanism uses authentication plugins that are similar in spirit to other GBrowse plugins. Plugins can be written to implement a variety of authentication mechanisms, and are intended to be used by organizations to allow users to use the same authentication mechanism for GBrowse as they use for other organizational assets. This mechanism does not allow users to inspect or change their credentials, but one can easily add a link to the login dialogue that directs them to the organization's web site to help them with this. Authentication plugins do, however, provide the ability to restrict access to role-based groups, something that neither of the other two mechanisms allows. Currently there is a single GBrowse authentication plugin defined, the PamAuthenticate plugin, which authenticates users via the Pluggable Authentication Module (PAM) system, and fetches groups from whatever group database is defined in /etc/nsswitch.conf.

GBrowse Authentication via Apache's Built-in Authentication Modules

To use Apache's standard authentication and authorization system, we take advantage of the fact that GBrowse uses a URL of this form to select which data source is active:

     http://your.host/cgi-bin/gb2/gbrowse/your_datasource

where "your_datasource" is the name of the currently selected datasource. For example, the yeast datasource is http://your.host/cgi-bin/gbrowse/yeast.

Apache's access control mechanism is based on URLs. To control access to an entire datasource, create a <Location> section in httpd.conf. The <Location> section should look like this:

  <Location /cgi-bin/gb2/gbrowse/your_datasource>
       Order deny,allow
       deny from all
       allow from localhost .oicr.on.ca .cshl.edu .ebi.ac.uk
  </Location>

This denies access to everybody except for "localhost" and browsers from the domains .oirc.on.ca, .cshl.edu and .ebi.ac.uk. You can also limit by IP address, by username and password or by combinations of these techniques. See Apache Authentication for the full details. Note that the datasource will still be visible in the pop-up menu of datasources in the GBrowse navigation panel, unless you specify "hide=1" in the GBrowse.conf stanza that defines the datasource.

You can limit individual tracks to certain individuals or organizations. Unless the stated requirements are met, the track will not appear on the main screen or any of the configuration screens. To set this up, add a "restrict" option to the track you wish to make off-limits:

       [PROPRIETARY]
       feature = etc
       glyph   = etc
       restrict = Order deny,allow
                  deny from all
                  allow from localhost .oicr.on.ca .cshl.edu .ebi.ac.uk

The value of the restrict option is identical to the Apache authorization directives and can include any of the directives "Order," "Satisfy," "deny from," "allow from," "require valid-user" or "require user." The only difference is that the "require group" directive is not supported, since the location of Apache's group file is not passed to CGI scripts.

As with other gbrowse options, restrict can be a code subroutine. The subroutine will be called with three arguments consisting of the host, ip address and authenticated user. It should return a true value to allow access to the track, or a false value to forbid it. This can be used to implement group-based authorization or more complex schemes.

Here is an example that uses the Text::GenderFromName to allow access if the user's name sounds female and forbids access if the name sounds male. (It might be useful for an X-chromosome annotation site.)

<perl>restrict = sub {

              my ($host,$ip,$user) = @_;
              return unless defined $user;
              use Text::GenderFromName qw(gender);
              return gender($user) eq 'f';
            }</perl>

You should be aware that the username will only be defined if username authentication is turned on and the user has successfully authenticated himself against Apache's user database using the correct password. In addition, the hostname will only be defined if HostnameLookups have been turned on in httpd.conf. In the latter case, you can convert the IP address into a hostname using this piece of code:

<perl> use Socket;

   $host = gethostbyaddr(inet_aton($addr),AF_INET);</perl>

Note that this may slow down the response time of gbrowse noticeably if you have a slow DNS name server.

Another thing to be aware of when restricting access to an entire database is that that even though the database itself will not be accessible to unauthorized users, the name of the database will still be available from the popup "Data Source" menu. There are two ways to suppress this display:

  1. Place "hide=1" in the GBrowse.conf stanza that defines the datasource. This will hide the source from all users, even those who are allowed to access it.
  2. Place a "restrict" option in the GBrowse.conf stanza that defines the datasource. In this way, only users who meet the requirements will be able to see and select the datasource. For example:
[yeast]
description = Yeast Chromosomes 1+2
path        = yeast_simple.conf
restrict    = require valid-user

Finally, you may place a "restrict" option in the [GENERAL] section of an individual datasource conf file, in which case the restrictions are applied on top of those defined by Apache. This might be useful if you prefer to modify the GBrowse conf file rather than Apache's conf file. For example, if Apache's config file contains this section:

   <Location /cgi-bin/gb2/gbrowse/yeast>
       Order deny,allow
       deny from all
       Satisfy all
       allow from .oicr.on.ca
       require valid-user
  </Location>

then any valid user (who can provide a recognized username and password) who accesses the site from a workstation in the .oicr.on.ca domain will be able to get in. You can further restrict access by adding the following to the [GENERAL] section of yeast_simple.conf:

 [GENERAL]
  # .... other stuff ...
  restrict  = require user fred joseph andrew vivian

This will return an unauthorized message for anyone except the four named users.

GBrowse Authentication via its Built-in User Accounts

The GBrowse user account system provides users with a link in the upper right corner of the screen that lets them login, register, and manage their account settings.

Gbrowse login.png

The GBrowse user account system is activated when the following requirements are met:

  1. The Perl DBI module is installed, and one or both of DBD::mysql and DBD::SQLite.
  2. The "user accounts" option is set to a "1" (or any other true value) in GBrowse.conf's [GENERAL] section.
  3. No "authentication plugin" option is defined in GBrowse.conf's [GENERAL] section.

User accounts can be created and managed with the utilities gbrowse_create_account.pl and gbrowse_change_passwd.pl. Users can register themselves and manage their own account settings if:

  1. The Perl Net::SMTP module is installed (required to validate users via email).
  2. The "user accounts registration" option is set to a true value in GBrowse.conf.
  3. The


GBrowse Authentication via Authentication Plugins