The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

PlugAuth::Client::Tiny - Minimal PlugAuth client

VERSION

version 0.02

SYNOPSIS

 use PlugAuth::Client::Tiny;
 my $client = PlugAuth::Client::Tiny->new( url => "http://localhost:3000/" );
 if($client->auth('primus', 'spark'))
 {
   # authentication succeeded
 }
 else
 {
   # authentication failed
 }

DESCRIPTION

PlugAuth::Client::Tiny is a minimal PlugAuth client. It uses HTTP::Tiny instead of LWP or Mojo::UserAgent. It provides only a mechanism for authenticating and authorizing against a PlugAuth server. If you need to modify the users/groups/authorization on the server through the RESTful API then you will need the heavier PlugAuth::Client which relies on Clustericious::Client and Mojo::UserAgent.

PlugAuth::Client::Tiny should work perfectly with PlugAuth::Lite as well, because it only uses the subset of the PlugAuth API which is implemented by PlugAuth::Lite.

CONSTRUCTOR

new

 use PlugAuth::Client::Tiny->new;
 my $client = PlugAuth::Client::Tiny->new;

PlugAuth::Client::Tiny's constructor accepts one optional option:

url

The URL of the PlugAuth server. If not specified, http://localhost:3000 is used.

All other options passed to new will be passed on to the constructor of HTTP::Tiny, which allows you to set agent, default_headers, etc. See the documentation of HTTP::Tiny for details.

ATTRIBUTES

url

 my $url = $client->url;

Returns the URL for the PlugAuth server. This attribute is read-only.

METHODS

auth

 my $bool = $client->auth( $user, $password );

Attempt to authenticate against the PlugAuth server using the given username and password. Returns 1 on success, 0 on failure and dies on a connection failure.

authz

 my $bool = $client->authz( $user, $action, $resource );

Determine if the given user is authorized to perform the given action on the given resource. Returns 1 on success, 0 on failure and dies on connection failure.

version

 my $version = $client->version;

Returns the version of the PlugAuth server.

AUTHOR

Graham Ollis <plicease@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2012 by Graham Ollis.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.