Graham Ollis > PlugAuth-Client-Tiny-0.01 > PlugAuth::Client::Tiny

Download:
PlugAuth-Client-Tiny-0.01.tar.gz

Dependencies

Annotate this POD

Website

View/Report Bugs
Module Version: 0.01   Source  

NAME ^

PlugAuth::Client::Tiny - Minimal PlugAuth client

VERSION ^

version 0.01

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 ^

The constructor is (predictably) 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 ^

$client->url

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

METHODS ^

$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.

$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.

CAVEATS ^

This module depends on HTTP::Tiny, which is a non-core dependency, and by some definitions of ::Tiny, therefore no longer tiny.

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.

syntax highlighting: