Jesse Vincent > Jifty > Jifty::API

Download:
Jifty-0.70824.tar.gz

Dependencies

Annotate this POD

CPAN RT

New  13
Open  4
Stalled  1
View/Report Bugs
Source   Latest Release: Jifty-1.10518

NAME ^

Jifty::API - Manages and allow reflection on the Jifty::Actions that make up a Jifty application's API

SYNOPSIS ^

 # Find the full name of an action
 my $class = Jifty->api->qualify('SomeAction');

 # Logged users with an ID greater than 10 have restrictions
 if (Jifty->web->current_user->id > 10) {
     Jifty->api->deny('Foo');
     Jifty->api->allow('FooBar');
     Jifty->api->deny('FooBarDeleteTheWorld');
 }

 # Fetch the class names of all the allowed actions
 my @actions = Jifty->api->actions;

 # Check to see if an action is allowed
 if (Jifty->api->is_allowed('TrueFooBar')) {
     # do something...
 }

 # Undo all allow/deny/restrict calls
 Jifty->api->reset;

DESCRIPTION ^

You can fetch an instance of this class by calling "api" in Jifty in your application. This object can be used to examine the actions available within your application and manage access to those actions.

METHODS ^

new

Creates a new Jifty::API object.

Don't use this, see "api" in Jifty to access a reference to Jifty::API in your application.

qualify ACTIONNAME

Returns the fully qualified package name for the given provided action. If the ACTIONNAME starts with Jifty:: or ApplicationClass::Action, simply returns the given name; otherwise, it prefixes it with the ApplicationClass::Action.

reset

Resets which actions are allowed to the defaults; that is, all of the application's actions, Jifty::Action::Autocomplete, and Jifty::Action::Redirect are allowed; everything else is denied. See "restrict" for the details of how limits are processed.

allow RESTRICTIONS

Takes a list of strings or regular expressions, and adds them in order to the list of limits for the purposes of "is_allowed". See "restrict" for the details of how limits are processed.

deny RESTRICTIONS

Takes a list of strings or regular expressions, and adds them in order to the list of limits for the purposes of "is_allowed". See "restrict" for the details of how limits are processed.

restrict POLARITY RESTRICTIONS

Method that "allow" and "deny" call internally; POLARITY is either allow or deny. Allow and deny limits are evaluated in the order they're called. The last limit that applies will be the one which takes effect. Regexes are matched against the class; strings are fully /qualify and used as an exact match against the class name. The base set of restrictions (which is reset every request) is set in "reset", and usually modified by the application's Jifty::Dispatcher if need be.

If you call:

    Jifty->api->deny  ( qr'Foo' );
    Jifty->api->allow ( qr'FooBar' );
    Jifty->api->deny  ( qr'FooBarDeleteTheWorld' );

..then:

    calls to MyApp::Action::Baz will succeed.
    calls to MyApp::Action::Foo will fail.
    calls to MyApp::Action::FooBar will pass.
    calls to MyApp::Action::TrueFoo will fail.
    calls to MyApp::Action::TrueFooBar will pass.
    calls to MyApp::Action::TrueFooBarDeleteTheWorld will fail.
    calls to MyApp::Action::FooBarDeleteTheWorld will fail.

is_allowed CLASS

Returns true if the CLASS name (which is fully qualified if it is not already) is allowed to be executed. See "restrict" above for the rules that the class name must pass.

actions

Lists the class names of all of the allowed actions for this Jifty application; this may include actions under the Jifty::Action:: namespace, in addition to your application's actions.

SEE ALSO ^

Jifty, Jifty::Web, Jifty::Action

LICENSE ^

Jifty is Copyright 2005-2006 Best Practical Solutions, LLC. Jifty is distributed under the same terms as Perl itself.

syntax highlighting: