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)
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>

Revision as of 17:13, 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';
 }