This is the new server for GMOD.org. Please let us know if you notice anything weird while it's getting broken in.

Gbrowse/authentication plugins

From GMOD
Jump to: navigation, search

GBrowse Authentication Plugins

To create your own authentication plugin, you need to create a .pm module which inherits from base "Bio::Graphics::Browser2::Plugin::AuthPlugin" and defines a minimum of two methods:

authenticate()
Given a username and credentials (e.g. a password), return true if the user has provided a valid combination. The username and password are ordinarily returned by calling the internal method credentials().
user_in_group()
Given a user and a groupname, return true if the user belongs to the group.

Here is a simple example that uses hard-coded values:

 package Bio::Graphics::Browser2::Plugin::MyPlugin;
 use base 'Bio::Graphics::Browser2::Plugin::AuthPlugin';

 sub authenticate {
     my $self = shift;
     my ($user,$password) = $self->credentials;
     return unless  $user eq 'george' && $password eq 'washington';
     return ($user,'George Washington','george@whitehouse.gov');
 }

 sub user_in_group {
     my $self = shift;
     my ($user,$group) = @_;
     return $user eq 'george' && $group eq 'potomac';
 }

This .pm module should be installed in GBrowse's configuration directory, under plugins. It can be activated by adding the following line to GBrowse.conf or an individual data source configuration line:

authentication plugin = NameOfMyAuthenticationModule

There are a variety of other methods that can be overridden in order to pass configuration information into the plugin, customize the credentials dialog box to collect more information (e.g. the current value from an authentication token), and provide the user with help text. Run perldoc Bio::Graphics::Browser2::Plugin::AuthPlugin for the full details. Good examples can be found by looking at the source code for PamAuthenticate.pm, LDAPAuthenticate.pm, and TestAuthenticator.pm.