Difference between revisions of "Gbrowse/authentication plugins"

From GMOD
Jump to: navigation, search
(Created page with "=GBrowse Authentication Plugins= To create your own authentication plugin, you need to create a .pm module which inherits from base "Bio::Graphics::Browser2::Plugin::AuthPlug...")
 
(GBrowse Authentication Plugins)
 
(One intermediate revision by the same user not shown)
Line 10: Line 10:
 
Here is a simple example that uses hard-coded values:
 
Here is a simple example that uses hard-coded values:
  
 +
<pre>
 
  package Bio::Graphics::Browser2::Plugin::MyPlugin;
 
  package Bio::Graphics::Browser2::Plugin::MyPlugin;
 
  use base 'Bio::Graphics::Browser2::Plugin::AuthPlugin';
 
  use base 'Bio::Graphics::Browser2::Plugin::AuthPlugin';
Line 25: Line 26:
 
     return $user eq 'george' && $group eq 'potomac';
 
     return $user eq 'george' && $group eq 'potomac';
 
  }
 
  }
 +
</pre>
 +
 +
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.

Latest revision as of 17:18, 4 December 2012

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.