Difference between revisions of "Gbrowse/authentication plugins/testauthenticator"
(New page: The TestAuthenticator plugin is used for testing the GBrowse authentication system. The entire module's code looks like this: package Bio::Graphics::Browser2::Plugin::TestAuthenticator; ...) |
|||
Line 1: | Line 1: | ||
The TestAuthenticator plugin is used for testing the GBrowse authentication system. The entire module's code looks like this: | The TestAuthenticator plugin is used for testing the GBrowse authentication system. The entire module's code looks like this: | ||
− | package Bio::Graphics::Browser2::Plugin::TestAuthenticator; | + | package Bio::Graphics::Browser2::Plugin::TestAuthenticator; |
− | use strict; | + | use strict; |
− | use base 'Bio::Graphics::Browser2::Plugin::AuthPlugin'; | + | use base 'Bio::Graphics::Browser2::Plugin::AuthPlugin'; |
− | + | ||
− | sub authenticate { | + | sub authenticate { |
− | my $self = shift; | + | my $self = shift; |
− | my ($name,$password) = $self->credentials; | + | my ($name,$password) = $self->credentials; |
− | return unless $name eq 'lincoln' && $password eq 'foobar'; | + | return unless $name eq 'lincoln' && $password eq 'foobar'; |
− | return ($name,'Lincoln Stein'); # username, fullname | + | return ($name,'Lincoln Stein'); # username, fullname |
− | } | + | } |
− | + | ||
1; | 1; | ||
The idea is very simple. The module inherits from Bio::Graphics::Browser2::Plugin::AuthPlugin, a "template" module that does the hard work. It then overrides the authenticate() method, which does the actual matching of username and password. The call to $self->credentials() returns a username and password previously entered into the login dialog box. We return false unless the username is "lincoln" and the password is "foobar". Otherwise, we return a two-element list consisting of the username and the user's full name. | The idea is very simple. The module inherits from Bio::Graphics::Browser2::Plugin::AuthPlugin, a "template" module that does the hard work. It then overrides the authenticate() method, which does the actual matching of username and password. The call to $self->credentials() returns a username and password previously entered into the login dialog box. We return false unless the username is "lincoln" and the password is "foobar". Otherwise, we return a two-element list consisting of the username and the user's full name. | ||
− | Run | + | Run '''perldoc Bio::Graphics::Browser2::Plugin::AuthPlugin''' for information on how to write more sophisticated authentication plugins. |
Revision as of 20:58, 18 January 2011
The TestAuthenticator plugin is used for testing the GBrowse authentication system. The entire module's code looks like this:
package Bio::Graphics::Browser2::Plugin::TestAuthenticator; use strict; use base 'Bio::Graphics::Browser2::Plugin::AuthPlugin';
sub authenticate { my $self = shift; my ($name,$password) = $self->credentials; return unless $name eq 'lincoln' && $password eq 'foobar'; return ($name,'Lincoln Stein'); # username, fullname }
1;
The idea is very simple. The module inherits from Bio::Graphics::Browser2::Plugin::AuthPlugin, a "template" module that does the hard work. It then overrides the authenticate() method, which does the actual matching of username and password. The call to $self->credentials() returns a username and password previously entered into the login dialog box. We return false unless the username is "lincoln" and the password is "foobar". Otherwise, we return a two-element list consisting of the username and the user's full name.
Run perldoc Bio::Graphics::Browser2::Plugin::AuthPlugin for information on how to write more sophisticated authentication plugins.