1Catalyst::Plugin::AuthoUrsiezratCioonnt:r:iRboulteesdC(a3Pt)earllysDto:c:uPmleungtiant:i:oAnuthorization::Roles(3)
2
3
4

NAME

6       Catalyst::Plugin::Authorization::Roles - Role based authorization for
7       Catalyst based on Catalyst::Plugin::Authentication
8

SYNOPSIS

10           use Catalyst qw/
11               Authentication
12               Authorization::Roles
13           /;
14
15           sub delete : Local {
16               my ( $self, $c ) = @_;
17
18               $c->assert_user_roles( qw/admin/ ); # only admins can delete
19
20               $c->model("Foo")->delete_it();
21           }
22

DESCRIPTION

24       Role based access control is very simple: every user has a list of
25       roles, which that user is allowed to assume, and every restricted part
26       of the app makes an assertion about the necessary roles.
27
28       With "assert_user_roles", if the user is a member in all of the
29       required roles access is granted. Otherwise, access is denied. With
30       "assert_any_user_role" it is enough that the user is a member in one
31       role.
32
33       There are alternative approaches to do this on a per action basis, see
34       Catalyst::ActionRole::ACL.
35
36       For example, if you have a CRUD application, for every mutating action
37       you probably want to check that the user is allowed to edit. To do
38       this, create an editor role, and add that role to every user who is
39       allowed to edit.
40
41           sub edit : Local {
42               my ( $self, $c ) = @_;
43               $c->assert_user_roles( qw/editor/ );
44               $c->model("TheModel")->make_changes();
45           }
46
47       When this plugin checks the roles of a user it will first see if the
48       user supports the self check method.
49
50       When this is not supported the list of roles is extracted from the user
51       using the "roles" method.
52
53       When this is supported, the "check_roles" method will be used to
54       delegate the role check to the user class. Classes like the one
55       provided with iCatalyst::Authentication::Store::DBIx::Class optimize
56       the check this way.
57

METHODS

59       assert_user_roles [ $user ], @roles
60           Checks that the user (as supplied by the first argument, or, if
61           omitted, "$c->user") has the specified roles.
62
63           If for any reason ("$c->user" is not defined, the user is missing a
64           role, etc) the check fails, an error is thrown.
65
66           You can either catch these errors with an eval, or clean them up in
67           your "end" action.
68
69       check_user_roles [ $user ], @roles
70           Takes the same args as "assert_user_roles", and performs the same
71           check, but instead of throwing errors returns a boolean value.
72
73       assert_any_user_role [ $user ], @roles
74           Checks that the user (as supplied by the first argument, or, if
75           omitted, "$c->user") has at least one of the specified roles.
76
77           Other than that, works like "assert_user_roles".
78
79       check_any_user_role [ $user ], @roles
80           Takes the same args as "assert_any_user_role", and performs the
81           same check, but instead of throwing errors returns a boolean value.
82

SEE ALSO

84       Catalyst::Plugin::Authentication
85       Catalyst::ActionRole::ACL
86       Catalyst::Manual::Tutorial::06_Authorization
87

AUTHOR

89       Yuval Kogman <nothingmuch@woobling.org>
90
92       Copyright (c) 2005-2011 the Catalyst::Plugin::Authorization::Roles
93       "AUTHOR" as listed above.
94
95       This library is free software; you can redistribute it and/or modify it
96       under the same terms as Perl itself.
97
98
99
100perl v5.32.0                      2020C-a0t7a-l2y8st::Plugin::Authorization::Roles(3)
Impressum