Catalyst-Plugin-Authentication-0.10024/0000755000000000000000000000000014703760554016547 5ustar00rootwheelCatalyst-Plugin-Authentication-0.10024/LICENSE0000644000000000000000000004621714703760554017566 0ustar00rootwheelTerms of the Perl programming language system itself a) the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version, or b) the "Artistic License" --- The GNU General Public License, Version 1, February 1989 --- This software is Copyright (c) 2024 by Yuval Kogman . This is free software, licensed under: The GNU General Public License, Version 1, February 1989 GNU GENERAL PUBLIC LICENSE Version 1, February 1989 Copyright (C) 1989 Free Software Foundation, Inc. 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The license agreements of most software companies try to keep users at the mercy of those companies. By contrast, our General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. The General Public License applies to the Free Software Foundation's software and to any other program whose authors commit to using it. You can use it for your programs, too. When we speak of free software, we are referring to freedom, not price. Specifically, the General Public License is designed to make sure that you have the freedom to give away or sell copies of free software, that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of a such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must tell them their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any work containing the Program or a portion of it, either verbatim or with modifications. Each licensee is addressed as "you". 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this General Public License and to the absence of any warranty; and give any other recipients of the Program a copy of this General Public License along with the Program. You may charge a fee for the physical act of transferring a copy. 2. You may modify your copy or copies of the Program or any portion of it, and copy and distribute such modifications under the terms of Paragraph 1 above, provided that you also do the following: a) cause the modified files to carry prominent notices stating that you changed the files and the date of any change; and b) cause the whole of any work that you distribute or publish, that in whole or in part contains the Program or any part thereof, either with or without modifications, to be licensed at no charge to all third parties under the terms of this General Public License (except that you may choose to grant warranty protection to some or all third parties, at your option). c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the simplest and most usual way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this General Public License. d) You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. Mere aggregation of another independent work with the Program (or its derivative) on a volume of a storage or distribution medium does not bring the other work under the scope of these terms. 3. You may copy and distribute the Program (or a portion or derivative of it, under Paragraph 2) in object code or executable form under the terms of Paragraphs 1 and 2 above provided that you also do one of the following: a) accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Paragraphs 1 and 2 above; or, b) accompany it with a written offer, valid for at least three years, to give any third party free (except for a nominal charge for the cost of distribution) a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Paragraphs 1 and 2 above; or, c) accompany it with the information you received as to where the corresponding source code may be obtained. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form alone.) Source code for a work means the preferred form of the work for making modifications to it. For an executable file, complete source code means all the source code for all modules it contains; but, as a special exception, it need not include source code for modules which are standard libraries that accompany the operating system on which the executable file runs, or for standard header files or definitions files that accompany that operating system. 4. You may not copy, modify, sublicense, distribute or transfer the Program except as expressly provided under this General Public License. Any attempt otherwise to copy, modify, sublicense, distribute or transfer the Program is void, and will automatically terminate your rights to use the Program under this License. However, parties who have received copies, or rights to use copies, from you under this General Public License will not have their licenses terminated so long as such parties remain in full compliance. 5. By copying, distributing or modifying the Program (or any work based on the Program) you indicate your acceptance of this license to do so, and all its terms and conditions. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. 7. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of the license which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the license, you may choose any version ever published by the Free Software Foundation. 8. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 9. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 10. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS Appendix: How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to humanity, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 19yy This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) 19xx name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (a program to direct compilers to make passes at assemblers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice That's all there is to it! --- The Perl Artistic License 1.0 --- This software is Copyright (c) 2024 by Yuval Kogman . This is free software, licensed under: The Perl Artistic License 1.0 The "Artistic License" Preamble The intent of this document is to state the conditions under which a Package may be copied, such that the Copyright Holder maintains some semblance of artistic control over the development of the package, while giving the users of the package the right to use and distribute the Package in a more-or-less customary fashion, plus the right to make reasonable modifications. Definitions: "Package" refers to the collection of files distributed by the Copyright Holder, and derivatives of that collection of files created through textual modification. "Standard Version" refers to such a Package if it has not been modified, or has been modified in accordance with the wishes of the Copyright Holder as specified below. "Copyright Holder" is whoever is named in the copyright or copyrights for the package. "You" is you, if you're thinking about copying or distributing this Package. "Reasonable copying fee" is whatever you can justify on the basis of media cost, duplication charges, time of people involved, and so on. (You will not be required to justify it to the Copyright Holder, but only to the computing community at large as a market that must bear the fee.) "Freely Available" means that no fee is charged for the item itself, though there may be fees involved in handling the item. It also means that recipients of the item may redistribute it under the same conditions they received it. 1. You may make and give away verbatim copies of the source form of the Standard Version of this Package without restriction, provided that you duplicate all of the original copyright notices and associated disclaimers. 2. You may apply bug fixes, portability fixes and other modifications derived from the Public Domain or from the Copyright Holder. A Package modified in such a way shall still be considered the Standard Version. 3. You may otherwise modify your copy of this Package in any way, provided that you insert a prominent notice in each changed file stating how and when you changed that file, and provided that you do at least ONE of the following: a) place your modifications in the Public Domain or otherwise make them Freely Available, such as by posting said modifications to Usenet or an equivalent medium, or placing the modifications on a major archive site such as uunet.uu.net, or by allowing the Copyright Holder to include your modifications in the Standard Version of the Package. b) use the modified Package only within your corporation or organization. c) rename any non-standard executables so the names do not conflict with standard executables, which must also be provided, and provide a separate manual page for each non-standard executable that clearly documents how it differs from the Standard Version. d) make other distribution arrangements with the Copyright Holder. 4. You may distribute the programs of this Package in object code or executable form, provided that you do at least ONE of the following: a) distribute a Standard Version of the executables and library files, together with instructions (in the manual page or equivalent) on where to get the Standard Version. b) accompany the distribution with the machine-readable source of the Package with your modifications. c) give non-standard executables non-standard names, and clearly document the differences in manual pages (or equivalent), together with instructions on where to get the Standard Version. d) make other distribution arrangements with the Copyright Holder. 5. You may charge a reasonable copying fee for any distribution of this Package. You may charge any fee you choose for support of this Package. You may not charge a fee for this Package itself. However, you may distribute this Package in aggregate with other (possibly commercial) programs as part of a larger (possibly commercial) software distribution provided that you do not advertise this Package as a product of your own. You may embed this Package's interpreter within an executable of yours (by linking); this shall be construed as a mere form of aggregation, provided that the complete Standard Version of the interpreter is so embedded. 6. The scripts and library files supplied as input to or produced as output from the programs of this Package do not automatically fall under the copyright of this Package, but belong to whoever generated them, and may be sold commercially, and may be aggregated with this Package. If such scripts or library files are aggregated with this Package via the so-called "undump" or "unexec" methods of producing a binary executable image, then distribution of such an image shall neither be construed as a distribution of this Package nor shall it fall under the restrictions of Paragraphs 3 and 4, provided that you do not represent such an executable image as a Standard Version of this Package. 7. C subroutines (or comparably compiled subroutines in other languages) supplied by you and linked into this Package in order to emulate subroutines and variables of the language defined by this Package shall not be considered part of this Package, but are the equivalent of input as in Paragraph 6, provided these subroutines do not change the language in any way that would cause it to fail the regression tests for the language. 8. Aggregation of this Package with a commercial distribution is always permitted provided that the use of this Package is embedded; that is, when no overt attempt is made to make this Package's interfaces visible to the end user of the commercial distribution. Such use shall not be construed as a distribution of this Package. 9. The name of the Copyright Holder may not be used to endorse or promote products derived from this software without specific prior written permission. 10. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. The End Catalyst-Plugin-Authentication-0.10024/Changes0000644000000000000000000002107414703760473020046 0ustar00rootwheelRevision history for Perl extension Catalyst::Plugin::Authentication 0.10024 - 2024-10-16 - update to prefer modern Catalyst APIs - silence expected warnings in tests - move repository to GitHub - convert tests from Test::WWW::Mechanize::Catalyst to Catalyst::Test - don't load unneeded Tie::RefHash - switch from Digest::SHA1 to Digest::SHA - switch from Test::Exception to Test::Fatal - drop unused dependency Class::Inspector - Don't load password when password_type is 'none', for example when used for authorization 0.10023 11 Jan 2013 - Add Howto on using the auth from the proxy server with ::Credential::Remote (Robert Rothenberg) 0.10022 08 Jan 2013 - Fix NoPasswd store (skaufman) 0.10021 30 June 2012 - Change all classes to Moose and MooseX::Emulate::Class::Accessor::Fast, fixing undeclared dependency on Class::Accessor::Fast. - Change Catalyst::Authentication::Realm to use String::RewritePrefix rather than doing namespace mangling manually. - Fix whitespace and tabs, add Test::EOL and Test::NoTabs - Document optional methods in stores needed for auto_create_user and auto_update_user in realms. - Clarify support channels - Note primary maintainer in docs. - Add x_authority metadata. - Get the NAME right by making it 1 line, due to crappy parsing in EU::MM (RT#77028) 0.10020 05 May 2012 - Allow user_class to be configured for Catalyst::Authentication::Store::Minimal (Jochen Lutz ) 0.10019 14 April 2012 - Upgrade code to use Moose compatibility layer (jnap) - Added some rules to .gitignore for people using macs (jnap) - Updated copyright info - Catalyst::Plugin::Authentication::Credential::NoPassword added (Okko) - Convert repository to git (fREW Schmidt) 0.10018 29 Jul 2011 - Fix failing tests with the new PSGI Catalyst dev release 0.10017 24 Jan 2010 - Fix failing tests with the new PSGI Catalyst dev release 0.10016 22 Jan 2010 - Move root actions out of applcation class in tests to remove warnings in the latest Catalyst. - Add AUTOLOAD method to the default user class so that methods are delegated down onto the underlieing user object retrieved from the store (if present) - Fix typos in documentation (RT#49476) - Fix compatibilty with Catalyst 5.70 (RT#50466) - Various documentation improvements - Fix Realm::Processive's authinfo_munge option (RT#47106) 0.10015 Tue Sep 1 01:40:36 BST 2009 - Remove (undeclared) dependency on Class::Data::Inhertiable (RT#49086) - Remove dependency on Test::MockObject - Fix repository metadata in META.yml / Makefile.PL - Make POD tests author side only. 0.10014 Tue Aug 25 15:42:57 BST 2009 - Don't always supply an "id" column in the authinfo passed to the store class in ::Credential::Remote. This means that it works better with the DBIC store. (t0m) - Make auth_realms method ensure authentication is initialized before calling methods which get created during auth initialization. Fixes back compat cases where auth store is in the plugin list before the authentication plugin. (t0m) 0.10013 Fri Jun 19 16:08:00 BST 2009 - Add a username_field config item to ::Credential::Remote (Nigel Metheringham) - Die with a useful error message if we are about to try to restore a user from a realm which does not exist. (t0m) 0.10012 Sat Jun 6 10:58:43 BST 2009 - Add Catalyst::Authentication::Credential::Remote which authenticates you directly from environment variables passed by your web server. This allows the use of SSL client certificates, NTLM, or just basic/digest auth done at the web server level to be used to authenticate users to your Catalyst application (kmx) - Tests for this - Change ->config invocations to be best practices (t0m) - Note about session auto-vification even when use_session is set to false (robert). - Note about how a realms key used to be needed to unconfuse people running an old version, but browsing the docs on search.cpan (ruoso) 0.10011 Sun Mar 8 23:32:12 GMT 2009 - Update t/live_app_session.t to skip unless you have a newer, more reliable version of TWMC (RT#43817) - Change check for isa Catalyst::Plugin::Session to just check the existance of a session method. (Edmund von der Burg) 0.10010 - Change from NEXT to MRO::Compat - Chop a number off the versions to get back to the correct 0.10000 version scheme. 0.100092_01 - Add hook for failing user restore. - Add test for this. - Fix bug in Credential::Password with password_type: clear. - Add test for this. - Add mock object tests for Credential::Password with password_type: clear. 0.100092 - Release new version, no changes since dev release. 0.10009_01 - Fix POD escaping, from RT#38694 (Luke Ross) - Change authentication backwards compatibility handling to not rely on Class::Data::Inheritable side effects, and so be Catalyst 5.80 safe (t0m) 0.10009 2008-11-27 - Including progressive realm for multiple authentication attempts in a single request. 0.10008 2008-10-23 - Updating config to allow for inclusion of realm ref's in the main config hash rather than in a subref called 'realms' 0.10007 2008-08-17 - Update tests prereqs to include Test::Exception (RT #36339) - Some documentation fixes (including RT #36062) - Compatibility fix where the use of new style config and old style Authentication::Store::Minimal would cause a crash (Reported & fixed by Jos Boumans C) - Documentation update on Password - to indicate proper field naming - Decouple Authentication system from session. The realm class now allows complete control over how a user is persisted across requests. - pod fixes (RT #36062, RT #36063) 0.10006 2008-02-15 - Additional documentation for Realms - Added update_user_in_session routine to allow re-saving of user data into the session. 0.10005 2008-01-24 - Bugfix release - correcting 'Plugin::Authentication' configuration problem. 0.10004 2007-12-04 - Added some code for back-compatibility 0.10003 2007-12-02 - Added a "Null" store for credentials that don't require real stores. - Make realms bonafide objects - Added auto_update_user and auto_create_user options to the Realm object - Doc updates [POSSIBLE INCOMPATIBILITIES] - authenticate() in credentials are now passed a realm object instead of a store object. A realm object still implements find_user() so unless you're doing something special you won't notice the difference. 0.10002 2007-07-22 - $user->store() should NOT be set by C::P::Auth - if it's needed - it should be set by whatever module creates the user. We use realm for saving into the session. 0.10001 2007-07-17 - updated tests 0.10000 2007-07-11 - Minor updates to work better with compatibility mode - Producion release - switch to Module::Install 0.09999_01 2007-02-21 - major changes to the internals of the plugin, to better encapsulate credentials and stores. - introduction of 'realms' concept, allowing multiple different pairs of credential and store in a single application. 0.09 2006-08-01 - be a bit more pedantic about checking values for definedness before invoking methods on them 0.08 2006-07-29 - factor test applications out to files due to changes in Catalyst::Test - don't load session at prepare time unless necessary 0.07 2006-03-17 17:33:12 - allow base64 hashed passwords 0.06 2006-03-14 19:23:50 - pass extra get_user args to store so they can be made use of 0.05 2006-01-01 13:58:00 - Add debugging to Credential::Password - Important doc fixes 0.04 - With User::Hash and Store::Minimal together session will store userid, not actual user object 0.03 2005-12-03 18:00:00 - Added user_exists method. 0.02 2005-11-29 11:39:00 - Fixed a typo (PLugin instead of Plugin) that caused user objects to not be restored from the session properly. Modified test suite to actually test for this case. 0.01 2005-11-27 02:30:00 - Initial release. Catalyst-Plugin-Authentication-0.10024/MANIFEST0000644000000000000000000000370214703760554017702 0ustar00rootwheelChanges lib/Catalyst/Authentication/Credential/NoPassword.pm lib/Catalyst/Authentication/Credential/Password.pm lib/Catalyst/Authentication/Credential/Remote.pm lib/Catalyst/Authentication/Realm.pm lib/Catalyst/Authentication/Realm/Compatibility.pm lib/Catalyst/Authentication/Realm/Progressive.pm lib/Catalyst/Authentication/Store.pod lib/Catalyst/Authentication/Store/Minimal.pm lib/Catalyst/Authentication/Store/Null.pm lib/Catalyst/Authentication/User.pm lib/Catalyst/Authentication/User/Hash.pm lib/Catalyst/Plugin/Authentication.pm lib/Catalyst/Plugin/Authentication/Credential/Password.pm lib/Catalyst/Plugin/Authentication/Internals.pod lib/Catalyst/Plugin/Authentication/Store/Minimal.pm lib/Catalyst/Plugin/Authentication/User.pm lib/Catalyst/Plugin/Authentication/User/Hash.pm maint/Makefile.PL.include Makefile.PL MANIFEST This list of files t/04_authentication.t t/05_password.t t/06_user.t t/lib/AuthRealmTestApp.pm t/lib/AuthRealmTestApp/Controller/Root.pm t/lib/AuthRealmTestAppCompat.pm t/lib/AuthRealmTestAppCompat/Controller/Root.pm t/lib/AuthRealmTestAppProgressive.pm t/lib/AuthRealmTestAppProgressive/Controller/Root.pm t/lib/AuthSessionTestApp.pm t/lib/AuthSessionTestApp/Controller/Root.pm t/lib/AuthTestApp.pm t/lib/AuthTestApp/Controller/Root.pm t/lib/RemoteTestApp1.pm t/lib/RemoteTestApp1/Controller/Root.pm t/lib/RemoteTestApp2.pm t/lib/RemoteTestApp2/Controller/Root.pm t/lib/RemoteTestData.pm t/lib/RemoteTestEngine.pm t/live_app.t t/live_app_realms.t t/live_app_realms_compat.t t/live_app_realms_progressive.t t/live_app_remote1.t t/live_app_remote2.t t/live_app_session.t t/store_nopassord.t xt/eol.t xt/notabs.t xt/pod.t xt/pod_coverage.t META.yml Module YAML meta-data (added by MakeMaker) META.json Module JSON meta-data (added by MakeMaker) README README file (added by Distar) LICENSE LICENSE file (added by Distar) Catalyst-Plugin-Authentication-0.10024/t/0000755000000000000000000000000014703760553017011 5ustar00rootwheelCatalyst-Plugin-Authentication-0.10024/t/live_app_remote1.t0000644000000000000000000000214014703760420022417 0ustar00rootwheeluse strict; use warnings; use Test::More; use lib 't/lib'; use Catalyst::Test qw/RemoteTestApp1/; $RemoteTestEngine::REMOTE_USER = undef; ok( request('/public')->is_success, 'anonymous user (undef) - /public' ); ok( request('/')->is_error, 'anonymous user (undef) - /' ); $RemoteTestEngine::REMOTE_USER = ''; ok( request('/public')->is_success, 'anonymous user (empty) - /public' ); ok( request('/')->is_error, 'anonymous user (empty) - /' ); $RemoteTestEngine::REMOTE_USER = 'john'; ok( request('/')->is_success, 'valid user' ); $RemoteTestEngine::REMOTE_USER = 'nonexisting'; ok( request('/')->is_error, 'non-existing user' ); $RemoteTestEngine::REMOTE_USER = 'denieduser'; ok( request('/')->is_error, 'explicitly denied user' ); $RemoteTestEngine::REMOTE_USER = 'CN=namexyz/OU=Test/C=Company'; ok( request('/')->is_success, 'testing "cutname" option 1' ); is( request('/')->content, 'User:namexyz', 'testing "cutname" option 2' ); $RemoteTestEngine::REMOTE_USER = 'CN=/OU=Test/C=Company'; is( request('/')->content, 'User:CN=/OU=Test/C=Company', 'testing "cutname" option - empty $1 match' ); done_testing; Catalyst-Plugin-Authentication-0.10024/t/04_authentication.t0000644000000000000000000000026114703760420022510 0ustar00rootwheeluse strict; use warnings; use Test::More 'no_plan'; my $m; BEGIN { use_ok($m = "Catalyst::Plugin::Authentication") } can_ok( $m, $_ ) for qw/user logout set_authenticated/; Catalyst-Plugin-Authentication-0.10024/t/live_app_realms_compat.t0000644000000000000000000000025114703760420023672 0ustar00rootwheeluse strict; use warnings; use Test::More; BEGIN { plan "no_plan"; } use lib 't/lib'; use Catalyst::Test qw/AuthRealmTestAppCompat/; ok(get("/moose"), "get ok"); Catalyst-Plugin-Authentication-0.10024/t/store_nopassord.t0000644000000000000000000000026714703760420022420 0ustar00rootwheeluse strict; use warnings; use Test::More tests => 1; use_ok 'Catalyst::Authentication::Credential::NoPassword', "Catalyst::Authentication::Credential::NoPassword at right spot"; Catalyst-Plugin-Authentication-0.10024/t/live_app_remote2.t0000644000000000000000000000127514703760420022430 0ustar00rootwheeluse strict; use warnings; use Test::More; use lib 't/lib'; use Catalyst::Test qw/RemoteTestApp2/; $RemoteTestEngine::REMOTE_USER = undef; # WARNING: this requires $c->engine->env to work properly # $c->engine->env was slightly broken in 5.8004 but this test should pass # as it uses Engine::CGI that works fine even in 5.80004 $RemoteTestEngine::SSL_CLIENT_S_DN = 'CN=anyuser/OU=Test/C=Company'; ok( request('/')->is_success, 'testing "source" option' ); $RemoteTestEngine::SSL_CLIENT_S_DN = 'CN=namexyz/OU=Test/C=Company'; ok( request('/')->is_success, 'testing "source" + "cutname" 1' ); is( request('/')->content, "my_user_name:namexyz", 'testing "source" + "cutname" 2' ); done_testing; Catalyst-Plugin-Authentication-0.10024/t/05_password.t0000644000000000000000000000437514703760420021346 0ustar00rootwheeluse strict; use warnings; use Test::More tests => 11; use Test::Fatal; use Class::MOP; use Class::MOP::Class; use Moose::Object; # 1,2 my $m; BEGIN { use_ok($m = "Catalyst::Authentication::Credential::Password") } can_ok($m, "authenticate"); my $app_meta = Class::MOP::Class->create_anon_class( superclasses => ['Moose::Object'] ); my $realm_meta = Class::MOP::Class->create_anon_class( superclasses => ['Moose::Object'] ); my $user_meta = Class::MOP::Class->create_anon_class( superclasses => ['Moose::Object'] ); our ($user_get_password_field_name, $user_password ); $user_meta->add_method('get' => sub { $user_get_password_field_name = $_[1]; return $user_password }); # 3-6 # Test clear passwords if you mess up the password_field { local $user_password = undef; # The user returns an undef password, local $user_get_password_field_name; # as there is no field named 'mistyped' my $config = { password_type => 'clear', password_field => 'mistyped' }; my $i; is exception { $i = $m->new($config, $app_meta->name->new, $realm_meta->name->new) }, undef, 'Construct instance'; ok($i, 'Have instance'); my $r = $i->check_password($user_meta->name->new, { username => 'someuser', password => 'password' }); is($user_get_password_field_name, 'mistyped', '(Incorrect) field name from config correctly passed to user'); ok(! $r, 'Authentication unsuccessful' ); } # 7-11 # Test clear passwords working, and not working { local $user_password = 'mypassword'; local $user_get_password_field_name; my $config = { password_type => 'clear', password_field => 'the_password_field' }; my $i; is exception { $i = $m->new($config, $app_meta->name->new, $realm_meta->name->new) }, undef, 'Construct instance'; ok($i, 'Have instance'); my $r = $i->check_password($user_meta->name->new, { username => 'someuser', the_password_field => 'mypassword' }); is($user_get_password_field_name, 'the_password_field', 'Correct field name from config correctly passed to user'); ok( $r, 'Authentication successful with correct password' ); $r = $i->check_password($user_meta->name->new, { username => 'someuser', the_password_field => 'adifferentpassword' }); ok( ! $r, 'Authentication ussuccessful with incorrect password' ); } Catalyst-Plugin-Authentication-0.10024/t/06_user.t0000644000000000000000000000212314703760420020450 0ustar00rootwheeluse strict; use warnings; use Test::More; use Test::Fatal; my $m; BEGIN { use_ok($m = "Catalyst::Authentication::User") } { package SomeBaseUser; sub other_method { 'FNAR' }; } { package SomeUser; use base $m; sub new { bless {}, shift }; sub supported_features { { feature => { subfeature => 1, unsupported_subfeature => 0, }, top_level => 1, } } sub get_object { bless {}, 'SomeBaseUser'; } } my $o = SomeUser->new; can_ok( $m, "supports" ); ok( $o->supports("top_level"), "simple top level feature check"); ok( $o->supports(qw/feature subfeature/), "traversal"); ok( !$o->supports(qw/feature unsupported_subfeature/), "traversal terminating in false"); is exception { $o->supports("bad_key"); }, undef, "can check for non existent feature"; #dies_ok { # $o->supports(qw/bad_key subfeature/) #} "but can't traverse into one"; is exception { is $o->other_method, 'FNAR', 'Delegation onto user object works'; }, undef, 'Delegation lives'; done_testing; Catalyst-Plugin-Authentication-0.10024/t/live_app_session.t0000644000000000000000000000203014703760420022524 0ustar00rootwheeluse strict; use warnings; use Test::More; BEGIN { eval { require Catalyst::Plugin::Session; require Catalyst::Plugin::Session::State::Cookie; } or do { plan skip_all => "This test needs Catalyst::Plugin::Session and Catalyst::Plugin::Session::State::Cookie installed"; } } use lib 't/lib'; use Catalyst::Test qw/AuthSessionTestApp/; use HTTP::Cookies; use HTTP::Request::Common qw(GET); my $jar = HTTP::Cookies->new; sub _request { my $url = shift; $url =~ s{^/}{http://localhost/}; my $req = GET $url; $jar->add_cookie_header($req); my $res = request($req); $jar->extract_cookies($res); return $res; } my $res; $res = _request('/moose'); ok +$res->is_success, 'get ok'; $res = _request('/elk'); ok +$res->is_success, 'get ok'; $res = _request('/yak'); ok !$res->is_success, 'Not ok, user unable to be resotred == nasal demons'; foreach my $type (qw/ goat fluffy_bunny possum butterfly /) { $res = _request("/$type"); ok +$res->is_success, "get $type ok"; } done_testing; Catalyst-Plugin-Authentication-0.10024/t/lib/0000755000000000000000000000000014703760553017557 5ustar00rootwheelCatalyst-Plugin-Authentication-0.10024/t/lib/AuthRealmTestAppCompat.pm0000644000000000000000000000166214703760420024442 0ustar00rootwheelpackage AuthRealmTestAppCompat; use warnings; use strict; use base qw/Catalyst/; ### using A::Store::minimal with new style realms ### makes the app blow up, since c::p::a::s::minimal ### isa c:a::s::minimal, and it's compat setup() gets ### run, with an unexpected config has (realms on top, ### not users). This tests makes sure the app no longer ### blows up when this happens. use Catalyst qw/ Authentication Authentication::Store::Minimal /; our $members = { bob => { password => "s00p3r" }, }; __PACKAGE__->config('Plugin::Authentication' => { default_realm => 'members', members => { credential => { class => 'Password', password_field => 'password', password_type => 'clear' }, store => { class => 'Minimal', users => $members, } }, }); __PACKAGE__->setup; 1; Catalyst-Plugin-Authentication-0.10024/t/lib/AuthRealmTestAppCompat/0000755000000000000000000000000014703760553024106 5ustar00rootwheelCatalyst-Plugin-Authentication-0.10024/t/lib/AuthRealmTestAppCompat/Controller/0000755000000000000000000000000014703760553026231 5ustar00rootwheelCatalyst-Plugin-Authentication-0.10024/t/lib/AuthRealmTestAppCompat/Controller/Root.pm0000644000000000000000000000117114703760420027503 0ustar00rootwheelpackage AuthRealmTestAppCompat::Controller::Root; use warnings; use strict; use base qw/Catalyst::Controller/; __PACKAGE__->config( namespace => '' ); use Test::More; sub moose : Local { my ( $self, $c ) = @_; while ( my ($user, $info) = each %$AuthRealmTestAppCompat::members ) { my $ok = eval { $c->authenticate( { username => $user, password => $info->{password} }, 'members' ), }; ok( !$@, "Test did not die: $@" ); ok( $ok, "user $user authentication" ); } $c->res->body( "ok" ); } 1; Catalyst-Plugin-Authentication-0.10024/t/lib/RemoteTestApp1/0000755000000000000000000000000014703760553022374 5ustar00rootwheelCatalyst-Plugin-Authentication-0.10024/t/lib/RemoteTestApp1/Controller/0000755000000000000000000000000014703760553024517 5ustar00rootwheelCatalyst-Plugin-Authentication-0.10024/t/lib/RemoteTestApp1/Controller/Root.pm0000644000000000000000000000067414703760420026000 0ustar00rootwheelpackage RemoteTestApp1::Controller::Root; use strict; use warnings; use base qw/Catalyst::Controller/; __PACKAGE__->config(namespace => ''); sub default : Local { my ( $self, $c ) = @_; if ($c->authenticate()) { $c->res->body('User:' . $c->user->{username}); } else { $c->res->body('FAIL'); $c->res->status(403); } } sub public : Local { my ( $self, $c ) = @_; $c->res->body('OK'); } 1; Catalyst-Plugin-Authentication-0.10024/t/lib/AuthRealmTestAppProgressive.pm0000644000000000000000000000253714703760420025531 0ustar00rootwheelpackage AuthRealmTestAppProgressive; use warnings; use strict; use base qw/Catalyst/; ### using A::Store::minimal with new style realms ### makes the app blow up, since c::p::a::s::minimal ### isa c:a::s::minimal, and it's compat setup() gets ### run, with an unexpected config has (realms on top, ### not users). This tests makes sure the app no longer ### blows up when this happens. use Catalyst qw/ Authentication Authentication::Store::Minimal /; our %members = ( 'members' => { bob => { password => "s00p3r" } }, 'other' => { sally => { password => "s00p3r" } }, ); __PACKAGE__->config('Plugin::Authentication' => { default_realm => 'progressive', progressive => { class => 'Progressive', realms => [ 'other', 'members' ], }, other => { credential => { class => 'Password', password_field => 'password', password_type => 'clear' }, store => { class => 'Minimal', users => $members{other}, } }, members => { credential => { class => 'Password', password_field => 'password', password_type => 'clear' }, store => { class => 'Minimal', users => $members{members}, } }, }); __PACKAGE__->setup; 1; Catalyst-Plugin-Authentication-0.10024/t/lib/AuthSessionTestApp/0000755000000000000000000000000014703760553023325 5ustar00rootwheelCatalyst-Plugin-Authentication-0.10024/t/lib/AuthSessionTestApp/Controller/0000755000000000000000000000000014703760553025450 5ustar00rootwheelCatalyst-Plugin-Authentication-0.10024/t/lib/AuthSessionTestApp/Controller/Root.pm0000644000000000000000000000405714703760420026730 0ustar00rootwheelpackage AuthSessionTestApp::Controller::Root; use strict; use warnings; use base qw/Catalyst::Controller/; __PACKAGE__->config(namespace => ''); use Test::More; use Digest::MD5 qw/md5/; sub moose : Local { my ( $self, $c ) = @_; ok(!$c->sessionid, "no session id yet"); ok(!$c->user_exists, "no user exists"); ok(!$c->user, "no user yet"); ok($c->login( "foo", "s3cr3t" ), "can login with clear"); is( $c->user, $AuthSessionTestApp::users->{foo}, "user object is in proper place"); } sub elk : Local { my ( $self, $c ) = @_; ok( $c->sessionid, "session ID was restored" ); ok( $c->user_exists, "user exists" ); ok( $c->user, "a user was also restored"); is_deeply( $c->user, $AuthSessionTestApp::users->{foo}, "restored user is the right one (deep test - store might change identity)" ); # Rename the user! $AuthSessionTestApp::users->{bar} = delete $AuthSessionTestApp::users->{foo}; } sub yak : Local { my ( $self, $c ) = @_; ok( $c->sessionid, "session ID was restored after user renamed" ); ok( $c->user_exists, "user appears to exist" ); ok( !$c->user, "user was not restored"); ok(scalar(@{ $c->error }), 'Error recorded'); ok( !$c->user_exists, "user no longer appears to exist" ); } sub goat : Local { my ( $self, $c ) = @_; ok($c->login( "bar", "s3cr3t" ), "can login with clear (new username)"); is( $c->user, $AuthSessionTestApp::users->{bar}, "user object is in proper place"); $c->logout; } sub fluffy_bunny : Local { my ( $self, $c ) = @_; ok( $c->session_is_valid, "session ID is restored after logout"); ok( !$c->user, "no user was restored after logout"); $c->delete_session("bah"); } sub possum : Local { my ( $self, $c ) = @_; ok( !$c->session_is_valid, "no session ID was restored"); $c->session->{definitely_not_a_user} = "moose"; } sub butterfly : Local { my ( $self, $c ) = @_; ok( $c->session_is_valid, "valid session" ); ok( !$c->user_exists, "but no user exists" ); ok( !$c->user, "no user object either" ); } 1; Catalyst-Plugin-Authentication-0.10024/t/lib/RemoteTestData.pm0000644000000000000000000000074014703760420022774 0ustar00rootwheelpackage RemoteTestData; use strict; use warnings; use Moose::Role; if ($Catalyst::VERSION < 5.89000) { require RemoteTestEngine; around engine_class => sub { 'RemoteTestEngine' }; } around psgi_app => sub { my ($orig, $self, @arg) = @_; my $app = $self->$orig(@arg); sub { my ($e) = @_; $e->{REMOTE_USER} = $RemoteTestEngine::REMOTE_USER; $e->{SSL_CLIENT_S_DN} = $RemoteTestEngine::SSL_CLIENT_S_DN; $app->($e); }; }; 1; Catalyst-Plugin-Authentication-0.10024/t/lib/AuthRealmTestAppProgressive/0000755000000000000000000000000014703760553025173 5ustar00rootwheelCatalyst-Plugin-Authentication-0.10024/t/lib/AuthRealmTestAppProgressive/Controller/0000755000000000000000000000000014703760553027316 5ustar00rootwheelCatalyst-Plugin-Authentication-0.10024/t/lib/AuthRealmTestAppProgressive/Controller/Root.pm0000644000000000000000000000141214703760420030566 0ustar00rootwheelpackage AuthRealmTestAppProgressive::Controller::Root; use warnings; use strict; use base qw/Catalyst::Controller/; __PACKAGE__->config(namespace => ''); use Test::More; sub progressive : Local { my ( $self, $c ) = @_; foreach my $realm ( keys %AuthRealmTestAppProgressive::members ) { while ( my ( $user, $info ) = each %{$AuthRealmTestAppProgressive::members{$realm}} ) { my $ok = eval { $c->authenticate( { username => $user, password => $info->{password} }, ); }; ok( !$@, "authentication passed." ); ok( $ok, "user authenticated" ); ok( $c->user_in_realm($realm), "user in proper realm" ); } } $c->res->body( "ok" ); } 1; Catalyst-Plugin-Authentication-0.10024/t/lib/AuthRealmTestApp/0000755000000000000000000000000014703760553022742 5ustar00rootwheelCatalyst-Plugin-Authentication-0.10024/t/lib/AuthRealmTestApp/Controller/0000755000000000000000000000000014703760553025065 5ustar00rootwheelCatalyst-Plugin-Authentication-0.10024/t/lib/AuthRealmTestApp/Controller/Root.pm0000644000000000000000000000341114703760420026336 0ustar00rootwheelpackage AuthRealmTestApp::Controller::Root; use warnings; use strict; use base qw/Catalyst::Controller/; __PACKAGE__->config(namespace => ''); use Test::More; sub moose : Local { my ( $self, $c ) = @_; ok(!$c->user, "no user"); while ( my ($user, $info) = each %$AuthRealmTestApp::members ) { ok( $c->authenticate( { username => $user, password => $info->{password} }, 'members' ), "user $user authentication" ); # check existing realms ok( $c->user_in_realm('members'), "user in members realm"); ok(!$c->user_in_realm('admins'), "user not in admins realm"); # check an invalid realm ok(!$c->user_in_realm('foobar'), "user not in foobar realm"); # check if we've got the right user is( $c->user, $info, "user object is in proper place"); $c->logout; # sanity check ok(!$c->user, "no more user after logout"); } while ( my ($user, $info) = each %$AuthRealmTestApp::admins ) { ok( $c->authenticate( { username => $user, password => $info->{password} }, 'admins' ), "user $user authentication" ); # check existing realms ok(!$c->user_in_realm('members'), "user not in members realm"); ok( $c->user_in_realm('admins'), "user in admins realm"); # check an invalid realm ok(!$c->user_in_realm('foobar'), "user not in foobar realm"); # check if we've got the right user is( $c->user, $info, "user object is in proper place"); $c->logout; # sanity check ok(!$c->user, "no more user after logout"); } $c->res->body( "ok" ); } 1; Catalyst-Plugin-Authentication-0.10024/t/lib/AuthTestApp.pm0000644000000000000000000000145014703760420022310 0ustar00rootwheelpackage AuthTestApp; use strict; use warnings; use base qw/Catalyst/; use Catalyst qw/ Authentication Authentication::Store::Minimal Authentication::Credential::Password /; use Digest::MD5 qw/md5/; use Digest::SHA qw/sha1_base64/; our $users = { foo => { password => "s3cr3t", }, bar => { crypted_password => crypt("s3cr3t", "x8"), }, gorch => { hashed_password => md5("s3cr3t"), hash_algorithm => "MD5", }, shabaz => { hashed_password => sha1_base64("s3cr3t"), hash_algorithm => "SHA-1" }, sadeek => { hashed_password => sha1_base64("s3cr3t").'=', hash_algorithm => "SHA-1" }, baz => {}, }; __PACKAGE__->config('Plugin::Authentication' =>{users => $users}); __PACKAGE__->setup; 1; Catalyst-Plugin-Authentication-0.10024/t/lib/RemoteTestApp1.pm0000644000000000000000000000123514703760420022724 0ustar00rootwheelpackage RemoteTestApp1; use strict; use warnings; use Catalyst qw/ Authentication /; use Moose; extends 'Catalyst'; with 'RemoteTestData'; __PACKAGE__->config( 'Plugin::Authentication' => { default_realm => 'remote', realms => { remote => { credential => { class => 'Remote', allow_regexp => '^(bob|john|CN=.*)$', deny_regexp=> 'denied', cutname_regexp=> 'CN=(.*)/OU=Test', }, store => { class => 'Null', }, }, }, }, ); __PACKAGE__->setup; 1; Catalyst-Plugin-Authentication-0.10024/t/lib/RemoteTestEngine.pm0000644000000000000000000000105114703760420023324 0ustar00rootwheelpackage RemoteTestEngine; BEGIN { require Catalyst; if ($Catalyst::VERSION >= 5.89000) { require Catalyst::Engine; @ISA = qw(Catalyst::Engine); } else { require Catalyst::Engine::CGI; @ISA = qw(Catalyst::Engine::CGI); } } our $REMOTE_USER; our $SSL_CLIENT_S_DN; sub env { my $self = shift; my %e; if ($Catalyst::VERSION >= 5.89000) { %e = %{ $self->SUPER::env() }; } else { %e = %ENV; } $e{REMOTE_USER} = $REMOTE_USER; $e{SSL_CLIENT_S_DN} = $SSL_CLIENT_S_DN; return \%e; }; 1; Catalyst-Plugin-Authentication-0.10024/t/lib/RemoteTestApp2.pm0000644000000000000000000000140414703760420022723 0ustar00rootwheelpackage RemoteTestApp2; use strict; use warnings; use Catalyst qw/ Authentication /; use Moose; extends 'Catalyst'; with 'RemoteTestData'; __PACKAGE__->config( 'Plugin::Authentication' => { default_realm => 'remote', realms => { remote => { credential => { class => 'Remote', allow_regexp => '^(bob|john|CN=.*)$', deny_regexp=> 'denied', cutname_regexp=> 'CN=(.*)/OU=Test', source => 'SSL_CLIENT_S_DN', username_field => 'my_user_name', }, store => { class => 'Null', }, }, }, }, ); __PACKAGE__->setup; 1; Catalyst-Plugin-Authentication-0.10024/t/lib/AuthTestApp/0000755000000000000000000000000014703760553021761 5ustar00rootwheelCatalyst-Plugin-Authentication-0.10024/t/lib/AuthTestApp/Controller/0000755000000000000000000000000014703760553024104 5ustar00rootwheelCatalyst-Plugin-Authentication-0.10024/t/lib/AuthTestApp/Controller/Root.pm0000644000000000000000000000336714703760420025367 0ustar00rootwheelpackage AuthTestApp::Controller::Root; use strict; use warnings; use base qw/ Catalyst::Controller /; __PACKAGE__->config( namespace => '' ); use Test::More; use Test::Fatal; use Digest::MD5 qw/md5/; use Digest::SHA qw/sha1_base64/; sub number_of_elements { return scalar @_ } sub moose : Local { my ( $self, $c ) = @_; is(number_of_elements($c->user), 1, "Array undef"); is($c->user, undef, "no user, returns undef"); ok(!$c->user, "no user"); ok($c->login( "foo", "s3cr3t" ), "can login with clear"); is( $c->user, $AuthTestApp::users->{foo}, "user object is in proper place"); ok( !$c->user->roles, "no roles for foo" ); my @new = qw/foo bar gorch/; $c->user->roles( @new ); is_deeply( [ $c->user->roles ], \@new, "roles set as array"); $c->logout; ok(!$c->user, "no more user, after logout"); ok($c->login( "bar", "s3cr3t" ), "can login with crypted"); is( $c->user, $AuthTestApp::users->{bar}, "user object is in proper place"); $c->logout; ok($c->login("gorch", "s3cr3t"), "can login with hashed"); is( $c->user, $AuthTestApp::users->{gorch}, "user object is in proper place"); $c->logout; ok($c->login("shabaz", "s3cr3t"), "can login with base64 hashed"); is( $c->user, $AuthTestApp::users->{shabaz}, "user object is in proper place"); $c->logout; ok($c->login("sadeek", "s3cr3t"), "can login with padded base64 hashed"); is( $c->user, $AuthTestApp::users->{sadeek}, "user object is in proper place"); $c->logout; ok(!$c->login( "bar", "bad pass" ), "can't login with bad password"); ok(!$c->user, "no user"); like exception { $c->login( "baz", "foo" ) }, qr/support.*mechanism/, "can't login without any supported mech"; $c->res->body( "ok" ); } Catalyst-Plugin-Authentication-0.10024/t/lib/RemoteTestApp2/0000755000000000000000000000000014703760553022375 5ustar00rootwheelCatalyst-Plugin-Authentication-0.10024/t/lib/RemoteTestApp2/Controller/0000755000000000000000000000000014703760553024520 5ustar00rootwheelCatalyst-Plugin-Authentication-0.10024/t/lib/RemoteTestApp2/Controller/Root.pm0000644000000000000000000000075414703760420026000 0ustar00rootwheelpackage RemoteTestApp2::Controller::Root; use strict; use warnings; use base 'Catalyst::Controller'; __PACKAGE__->config(namespace => ''); sub default : Local { my ( $self, $c ) = @_; if ($c->authenticate()) { $c->res->body( 'my_user_name:' . $c->user->{my_user_name} ); } else { $c->res->body('FAIL'); $c->res->status(403); } } sub public : Local { my ( $self, $c ) = @_; $c->res->body('OK'); } 1; Catalyst-Plugin-Authentication-0.10024/t/lib/AuthRealmTestApp.pm0000644000000000000000000000206514703760420023274 0ustar00rootwheelpackage AuthRealmTestApp; use warnings; use strict; use Catalyst qw/ Authentication Authentication::Store::Minimal /; use Test::More; our $members = { bob => { password => "s00p3r" }, william => { password => "s3cr3t" } }; our $admins = { joe => { password => "31337" } }; __PACKAGE__->config('Plugin::Authentication' => { default_realm => 'members', realms => { members => { credential => { class => 'Password', password_field => 'password', password_type => 'clear' }, store => { class => 'Minimal', users => $members } }, admins => { credential => { class => 'Password', password_field => 'password', password_type => 'clear' }, store => { class => 'Minimal', users => $admins } } } }); __PACKAGE__->setup; 1; Catalyst-Plugin-Authentication-0.10024/t/lib/AuthSessionTestApp.pm0000644000000000000000000000126214703760420023655 0ustar00rootwheelpackage User::SessionRestoring; use base qw/Catalyst::Authentication::User::Hash/; sub for_session { $_[0]->id } sub store { $_[0]->{store} } package AuthSessionTestApp; use strict; use warnings; use base qw/Catalyst/; use Catalyst qw/ Session Session::Store::Dummy Session::State::Cookie Authentication Authentication::Store::Minimal Authentication::Credential::Password /; our $users = { foo => User::SessionRestoring->new( id => 'foo', password => "s3cr3t", ), }; __PACKAGE__->config(authentication => {users => $users}); __PACKAGE__->setup; __PACKAGE__->log->levels(); $users->{foo}{store} = __PACKAGE__->default_auth_store; 1; Catalyst-Plugin-Authentication-0.10024/t/live_app.t0000644000000000000000000000040014703760420020760 0ustar00rootwheeluse strict; use warnings; use Test::More; BEGIN { plan skip_all => "Digest::SHA is required for this test" unless eval { require Digest::SHA }; plan "no_plan"; } use lib 't/lib'; use Catalyst::Test qw/AuthTestApp/; ok(get("/moose"), "get ok"); Catalyst-Plugin-Authentication-0.10024/t/live_app_realms.t0000644000000000000000000000024414703760420022331 0ustar00rootwheeluse strict; use warnings; use Test::More; BEGIN { plan "no_plan"; } use lib 't/lib'; use Catalyst::Test qw/AuthRealmTestApp/; ok(get("/moose"), "get ok"); Catalyst-Plugin-Authentication-0.10024/t/live_app_realms_progressive.t0000644000000000000000000000024514703760420024762 0ustar00rootwheeluse strict; use warnings; use Test::More; use lib 't/lib'; use Catalyst::Test qw/AuthRealmTestAppProgressive/; ok(get("/progressive"), "get ok"); done_testing; Catalyst-Plugin-Authentication-0.10024/xt/0000755000000000000000000000000014703760553017201 5ustar00rootwheelCatalyst-Plugin-Authentication-0.10024/xt/pod.t0000644000000000000000000000007214703760420020140 0ustar00rootwheeluse Test::More; use Test::Pod 1.14; all_pod_files_ok(); Catalyst-Plugin-Authentication-0.10024/xt/eol.t0000644000000000000000000000006414703760420020136 0ustar00rootwheeluse Test::More; use Test::EOL; all_perl_files_ok(); Catalyst-Plugin-Authentication-0.10024/xt/notabs.t0000644000000000000000000000017214703760420020645 0ustar00rootwheeluse strict; use warnings; use File::Spec; use FindBin (); use Test::More; use Test::NoTabs; all_perl_files_ok(qw/lib/); Catalyst-Plugin-Authentication-0.10024/xt/pod_coverage.t0000644000000000000000000000010714703760420022012 0ustar00rootwheeluse Test::More; use Test::Pod::Coverage 1.04; all_pod_coverage_ok(); Catalyst-Plugin-Authentication-0.10024/README0000644000000000000000000006022014703760554017427 0ustar00rootwheelNAME Catalyst::Plugin::Authentication - Infrastructure plugin for the Catalyst authentication framework. SYNOPSIS use Catalyst qw/ Authentication /; # later on ... $c->authenticate({ username => 'myusername', password => 'mypassword' }); my $age = $c->user->get('age'); $c->logout; DESCRIPTION The authentication plugin provides generic user support for Catalyst apps. It is the basis for both authentication (checking the user is who they claim to be), and authorization (allowing the user to do what the system authorises them to do). Using authentication is split into two parts. A Store is used to actually store the user information, and can store any amount of data related to the user. Credentials are used to verify users, using information from the store, given data from the frontend. A Credential and a Store are paired to form a 'Realm'. A Catalyst application using the authentication framework must have at least one realm, and may have several. To implement authentication in a Catalyst application you need to add this module, and specify at least one realm in the configuration. Authentication data can also be stored in a session, if the application is using the Catalyst::Plugin::Session module. NOTE in version 0.10 of this module, the interface to this module changed. Please see "COMPATIBILITY ROUTINES" for more information. INTRODUCTION The Authentication/Authorization Process Web applications typically need to identify a user - to tell the user apart from other users. This is usually done in order to display private information that is only that user's business, or to limit access to the application so that only certain entities can access certain parts. This process is split up into several steps. First you ask the user to identify themselves. At this point you can't be sure that the user is really who they claim to be. Then the user tells you who they are, and backs this claim with some piece of information that only the real user could give you. For example, a password is a secret that is known to both the user and you. When the user tells you this password you can assume they're in on the secret and can be trusted (ignore identity theft for now). Checking the password, or any other proof is called credential verification. By this time you know exactly who the user is - the user's identity is authenticated. This is where this module's job stops, and your application or other plugins step in. The next logical step is authorization, the process of deciding what a user is (or isn't) allowed to do. For example, say your users are split into two main groups - regular users and administrators. You want to verify that the currently logged in user is indeed an administrator before performing the actions in an administrative part of your application. These decisions may be made within your application code using just the information available after authentication, or it may be facilitated by a number of plugins. The Components In This Framework Realms Configuration of the Catalyst::Plugin::Authentication framework is done in terms of realms. In simplest terms, a realm is a pairing of a Credential verifier and a User storage (Store) backend. As of version 0.10003, realms are now objects that you can create and customize. An application can have any number of Realms, each of which operates independent of the others. Each realm has a name, which is used to identify it as the target of an authentication request. This name can be anything, such as 'users' or 'members'. One realm must be defined as the default_realm, which is used when no realm name is specified. More information about configuring realms is available in the configuration section. Credential Verifiers When user input is transferred to the Catalyst application (typically via form inputs) the application may pass this information into the authentication system through the "$c->authenticate()" method. From there, it is passed to the appropriate Credential verifier. These plugins check the data, and ensure that it really proves the user is who they claim to be. Credential verifiers compatible with versions of this module 0.10x and upwards should be in the namespace "Catalyst::Authentication::Credential". Storage Backends The authentication data also identifies a user, and the Storage backend modules use this data to locate and return a standardized object-oriented representation of a user. When a user is retrieved from a store it is not necessarily authenticated. Credential verifiers accept a set of authentication data and use this information to retrieve the user from the store they are paired with. Storage backends compatible with versions of this module 0.10x and upwards should be in the namespace "Catalyst::Authentication::Store". The Core Plugin This plugin on its own is the glue, providing realm configuration, session integration, and other goodness for the other plugins. Other Plugins More layers of plugins can be stacked on top of the authentication code. For example, Catalyst::Plugin::Session::PerUser provides an abstraction of browser sessions that is more persistent per user. Catalyst::Plugin::Authorization::Roles provides an accepted way to separate and group users into categories, and then check which categories the current user belongs to. EXAMPLE Let's say we were storing users in a simple Perl hash. Users are verified by supplying a password which is matched within the hash. This means that our application will begin like this: package MyApp; use Catalyst qw/ Authentication /; __PACKAGE__->config( 'Plugin::Authentication' => { default => { credential => { class => 'Password', password_field => 'password', password_type => 'clear' }, store => { class => 'Minimal', users => { bob => { password => "s00p3r", editor => 'yes', roles => [qw/edit delete/], }, william => { password => "s3cr3t", roles => [qw/comment/], } } } } } ); This tells the authentication plugin what realms are available, which credential and store modules are used, and the configuration of each. With this code loaded, we can now attempt to authenticate users. To show an example of this, let's create an authentication controller: package MyApp::Controller::Auth; sub login : Local { my ( $self, $c ) = @_; if ( my $user = $c->req->params->{user} and my $password = $c->req->params->{password} ) { if ( $c->authenticate( { username => $user, password => $password } ) ) { $c->res->body( "hello " . $c->user->get("name") ); } else { # login incorrect } } else { # invalid form input } } This code should be self-explanatory. If all the necessary fields are supplied, call the "authenticate" method on the context object. If it succeeds the user is logged in. The credential verifier will attempt to retrieve the user whose details match the authentication information provided to "$c->authenticate()". Once it fetches the user the password is checked and if it matches the user will be authenticated and "$c->user" will contain the user object retrieved from the store. In the above case, the default realm is checked, but we could just as easily check an alternate realm. If this were an admin login, for example, we could authenticate on the admin realm by simply changing the "$c->authenticate()" call: if ( $c->authenticate( { username => $user, password => $password }, 'admin' ) ) { $c->res->body( "hello " . $c->user->get("name") ); } ... Now suppose we want to restrict the ability to edit to a user with an 'editor' value of yes. The restricted action might look like this: sub edit : Local { my ( $self, $c ) = @_; $c->detach("unauthorized") unless $c->user_exists and $c->user->get('editor') eq 'yes'; # do something restricted here } (Note that if you have multiple realms, you can use "$c->user_in_realm('realmname')" in place of "$c->user_exists();" This will essentially perform the same verification as user_exists, with the added requirement that if there is a user, it must have come from the realm specified.) The above example is somewhat similar to role based access control. Catalyst::Authentication::Store::Minimal treats the roles field as an array of role names. Let's leverage this. Add the role authorization plugin: use Catalyst qw/ ... Authorization::Roles /; sub edit : Local { my ( $self, $c ) = @_; $c->detach("unauthorized") unless $c->check_user_roles("edit"); # do something restricted here } This is somewhat simpler and will work if you change your store, too, since the role interface is consistent. Let's say your app grows, and you now have 10,000 users. It's no longer efficient to maintain a hash of users, so you move this data to a database. You can accomplish this simply by installing the DBIx::Class Store and changing your config: __PACKAGE__->config( 'Plugin::Authentication' => { default_realm => 'members', members => { credential => { class => 'Password', password_field => 'password', password_type => 'clear' }, store => { class => 'DBIx::Class', user_model => 'MyApp::Users', role_column => 'roles', } } } ); The authentication system works behind the scenes to load your data from the new source. The rest of your application is completely unchanged. CONFIGURATION # example __PACKAGE__->config( 'Plugin::Authentication' => { default_realm => 'members', members => { credential => { class => 'Password', password_field => 'password', password_type => 'clear' }, store => { class => 'DBIx::Class', user_model => 'MyApp::Users', role_column => 'roles', } }, admins => { credential => { class => 'Password', password_field => 'password', password_type => 'clear' }, store => { class => '+MyApp::Authentication::Store::NetAuth', authserver => '192.168.10.17' } } } ); NOTE: Until version 0.10008 of this module, you would need to put all the realms inside a "realms" key in the configuration. Please see "COMPATIBILITY CONFIGURATION" for more information use_session Whether or not to store the user's logged in state in the session, if the application is also using Catalyst::Plugin::Session. This value is set to true per default. However, even if use_session is disabled, if any code touches $c->session, a session object will be auto-vivified and session Cookies will be sent in the headers. To prevent accidental session creation, check if a session already exists with if ($c->sessionid) { ... }. If the session doesn't exist, then don't place anything in the session to prevent an unecessary session from being created. default_realm This defines which realm should be used as when no realm is provided to methods that require a realm such as authenticate or find_user. realm refs The Plugin::Authentication config hash contains the series of realm configurations you want to use for your app. The only rule here is that there must be at least one. A realm consists of a name, which is used to reference the realm, a credential and a store. You may also put your realm configurations within a subelement called 'realms' if you desire to separate them from the remainder of your configuration. Note that if you use a 'realms' subelement, you must put ALL of your realms within it. You can also specify a realm class to instantiate instead of the default Catalyst::Authentication::Realm class using the 'class' element within the realm config. Each realm config contains two hashes, one called 'credential' and one called 'store', each of which provide configuration details to the respective modules. The contents of these hashes is specific to the module being used, with the exception of the 'class' element, which tells the core Authentication module the classname to instantiate. The 'class' element follows the standard Catalyst mechanism of class specification. If a class is prefixed with a +, it is assumed to be a complete class name. Otherwise it is considered to be a portion of the class name. For credentials, the classname 'Password', for example, is expanded to Catalyst::Authentication::Credential::Password. For stores, the classname 'storename' is expanded to: Catalyst::Authentication::Store::storename. METHODS $c->authenticate( $userinfo [, $realm ]) Attempts to authenticate the user using the information in the $userinfo hash reference using the realm $realm. $realm may be omitted, in which case the default realm is checked. $c->user( ) Returns the currently logged in user, or undef if there is none. Normally the user is re-retrieved from the store. For Catalyst::Authentication::Store::DBIx::Class the user is re-restored using the primary key of the user table. Thus user can throw an error even though user_exists returned true. $c->user_exists( ) Returns true if a user is logged in right now. The difference between user_exists and user is that user_exists will return true if a user is logged in, even if it has not been yet retrieved from the storage backend. If you only need to know if the user is logged in, depending on the storage mechanism this can be much more efficient. user_exists only looks into the session while user is trying to restore the user. $c->user_in_realm( $realm ) Works like user_exists, except that it only returns true if a user is both logged in right now and was retrieved from the realm provided. $c->logout( ) Logs the user out. Deletes the currently logged in user from "$c->user" and the session. It does not delete the session. $c->find_user( $userinfo, $realm ) Fetch a particular users details, matching the provided user info, from the realm specified in $realm. $user = $c->find_user({ id => $id }); $c->set_authenticated($user); # logs the user in and calls persist_user persist_user() Under normal circumstances the user data is only saved to the session during initial authentication. This call causes the auth system to save the currently authenticated user's data across requests. Useful if you have changed the user data and want to ensure that future requests reflect the most current data. Assumes that at the time of this call, $c->user contains the most current data. find_realm_for_persisted_user() Private method, do not call from user code! INTERNAL METHODS These methods are for Catalyst::Plugin::Authentication INTERNAL USE only. Please do not use them in your own code, whether application or credential / store modules. If you do, you will very likely get the nasty shock of having to fix / rewrite your code when things change. They are documented here only for reference. $c->set_authenticated( $user, $realmname ) Marks a user as authenticated. This is called from within the authenticate routine when a credential returns a user. $realmname defaults to 'default'. You can use find_user to get $user $c->auth_restore_user( $user, $realmname ) Used to restore a user from the session. In most cases this is called without arguments to restore the user via the session. Can be called with arguments when restoring a user from some other method. Currently not used in this way. $c->auth_realms( ) Returns a hashref containing realmname -> realm instance pairs. Realm instances contain an instantiated store and credential object as the 'store' and 'credential' elements, respectively $c->get_auth_realm( $realmname ) Retrieves the realm instance for the realmname provided. $c->update_user_in_session This was a short-lived method to update user information - you should use persist_user instead. $c->setup_auth_realm( ) OVERRIDDEN METHODS $c->setup( ) SEE ALSO This list might not be up to date. Below are modules known to work with the updated API of 0.10 and are therefore compatible with realms. Realms Catalyst::Authentication::Realm User Storage Backends Catalyst::Authentication::Store::Minimal Catalyst::Authentication::Store::DBIx::Class Catalyst::Authentication::Store::LDAP Catalyst::Authentication::Store::RDBO Catalyst::Authentication::Store::Model::KiokuDB Catalyst::Authentication::Store::Jifty::DBI Catalyst::Authentication::Store::Htpasswd Credential verification Catalyst::Authentication::Credential::Password Catalyst::Authentication::Credential::HTTP Catalyst::Authentication::Credential::OpenID Catalyst::Authentication::Credential::Authen::Simple Catalyst::Authentication::Credential::Flickr Catalyst::Authentication::Credential::Testing Catalyst::Authentication::Credential::AuthTkt Catalyst::Authentication::Credential::Kerberos Authorization Catalyst::Plugin::Authorization::ACL, Catalyst::Plugin::Authorization::Roles Internals Documentation Catalyst::Plugin::Authentication::Internals Misc Catalyst::Plugin::Session, Catalyst::Plugin::Session::PerUser DON'T SEE ALSO This module along with its sub plugins deprecate a great number of other modules. These include Catalyst::Plugin::Authentication::Simple, Catalyst::Plugin::Authentication::CDBI. INCOMPATABILITIES The realms-based configuration and functionality of the 0.10 update of Catalyst::Plugin::Authentication required a change in the API used by credentials and stores. It has a compatibility mode which allows use of modules that have not yet been updated. This, however, completely mimics the older api and disables the new realm-based features. In other words you cannot mix the older credential and store modules with realms, or realm-based configs. The changes required to update modules are relatively minor and are covered in Catalyst::Plugin::Authentication::Internals. We hope that most modules will move to the compatible list above very quickly. COMPATIBILITY CONFIGURATION Until version 0.10008 of this module, you needed to put all the realms inside a "realms" key in the configuration. # example __PACKAGE__->config( 'Plugin::Authentication' => { default_realm => 'members', realms => { members => { ... }, }, } ); If you use the old, deprecated "__PACKAGE__->config( 'authentication' )" configuration key, then the realms key is still required. COMPATIBILITY ROUTINES In version 0.10 of Catalyst::Plugin::Authentication, the API changed. For app developers, this change is fairly minor, but for Credential and Store authors, the changes are significant. Please see the documentation in version 0.09 of Catalyst::Plugin::Authentication for a better understanding of how the old API functioned. The items below are still present in the plugin, though using them is deprecated. They remain only as a transition tool, for those sites which can not yet be upgraded to use the new system due to local customizations or use of Credential / Store modules that have not yet been updated to work with the new API. These routines should not be used in any application using realms functionality or any of the methods described above. These are for reference purposes only. $c->login( ) This method is used to initiate authentication and user retrieval. Technically this is part of the old Password credential module and it still resides in the Password class. It is included here for reference only. $c->default_auth_store( ) Return the store whose name is 'default'. This is set to "$c->config( 'Plugin::Authentication' => { store => # Store} )" if that value exists, or by using a Store plugin: # load the Minimal authentication store. use Catalyst qw/Authentication Authentication::Store::Minimal/; Sets the default store to Catalyst::Plugin::Authentication::Store::Minimal. $c->get_auth_store( $name ) Return the store whose name is $name. $c->get_auth_store_name( $store ) Return the name of the store $store. $c->auth_stores( ) A hash keyed by name, with the stores registered in the app. $c->register_auth_stores( %stores_by_name ) Register stores into the application. $c->auth_store_names( ) $c->get_user( ) SUPPORT Please use the rt.cpan.org bug tracker, and git patches are wecome. Questions on usage should be directed to the Catalyst mailing list or the #catalyst irc channel. AUTHORS Yuval Kogman, "nothingmuch@woobling.org" - original author Jay Kuri, "jayk@cpan.org" - Large rewrite PRIMARY MAINTAINER Tomas Doran (t0m), "bobtfish@bobtfish.net" ADDITIONAL CONTRIBUTORS Jess Robinson David Kamholz kmx Nigel Metheringham Florian Ragwitz "rafl@debian.org" Stephan Jauernick "stephanj@cpan.org" Oskari Ojala (Okko), "perl@okko.net" John Napiorkowski (jnap) "jjnapiork@cpan.org" COPYRIGHT & LICENSE Copyright (c) 2005 - 2012 the Catalyst::Plugin::Authentication "AUTHORS", "PRIMARY MAINTAINER" and "ADDITIONAL CONTRIBUTORS" as listed above. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. Catalyst-Plugin-Authentication-0.10024/META.yml0000644000000000000000000000202714703760553020020 0ustar00rootwheel--- abstract: 'Infrastructure plugin for the Catalyst authentication framework.' author: - 'Yuval Kogman ' build_requires: Test::Fatal: '0' Test::More: '0.88' configure_requires: ExtUtils::MakeMaker: '0' dynamic_config: 1 generated_by: 'ExtUtils::MakeMaker version 7.70, CPAN::Meta::Converter version 2.150010' license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: '1.4' name: Catalyst-Plugin-Authentication no_index: directory: - t - xt requires: Catalyst::Runtime: '0' MRO::Compat: '0' Moose: '0' MooseX::Emulate::Class::Accessor::Fast: '0' String::RewritePrefix: '0' Try::Tiny: '0' namespace::autoclean: '0' resources: bugtracker: https://rt.cpan.org/Public/Dist/Display.html?Name=Catalyst-Plugin-Authentication license: http://dev.perl.org/licenses/ repository: https://github.com/perl-catalyst/Catalyst-Plugin-Authentication.git version: '0.10024' x_authority: cpan:BOBTFISH x_serialization_backend: 'CPAN::Meta::YAML version 0.018' Catalyst-Plugin-Authentication-0.10024/lib/0000755000000000000000000000000014703760553017314 5ustar00rootwheelCatalyst-Plugin-Authentication-0.10024/lib/Catalyst/0000755000000000000000000000000014703760553021100 5ustar00rootwheelCatalyst-Plugin-Authentication-0.10024/lib/Catalyst/Plugin/0000755000000000000000000000000014703760553022336 5ustar00rootwheelCatalyst-Plugin-Authentication-0.10024/lib/Catalyst/Plugin/Authentication.pm0000644000000000000000000011412414703760457025661 0ustar00rootwheelpackage Catalyst::Plugin::Authentication; use Moose; use namespace::clean -except => 'meta'; use MRO::Compat; use Catalyst::Authentication::Realm; with 'MooseX::Emulate::Class::Accessor::Fast'; __PACKAGE__->mk_accessors(qw/_user/); our $VERSION = '0.10024'; sub set_authenticated { my ( $c, $user, $realmname ) = @_; $c->user($user); $c->request->{user} = $user; # compatibility kludge if (!$realmname) { $realmname = 'default'; } my $realm = $c->get_auth_realm($realmname); if (!$realm) { Catalyst::Exception->throw( "set_authenticated called with nonexistant realm: '$realmname'."); } $user->auth_realm($realm->name); $c->persist_user(); $c->maybe::next::method($user, $realmname); } sub user { my $c = shift; if (@_) { return $c->_user(@_); } if ( defined($c->_user) ) { return $c->_user; } else { return $c->auth_restore_user; } } # change this to allow specification of a realm - to verify the user is part of that realm # in addition to verifying that they exist. sub user_exists { my $c = shift; return defined($c->_user) || defined($c->find_realm_for_persisted_user); } # works like user_exists - except only returns true if user # exists AND is in the realm requested. sub user_in_realm { my ($c, $realmname) = @_; if (defined($c->_user)) { return ($c->_user->auth_realm eq $realmname); } else { my $realm = $c->find_realm_for_persisted_user; if ($realm) { return ($realm->name eq $realmname); } else { return undef; } } } sub __old_save_user_in_session { my ( $c, $user, $realmname ) = @_; $c->session->{__user_realm} = $realmname; # we want to ask the store for a user prepared for the session. # but older modules split this functionality between the user and the # store. We try the store first. If not, we use the old method. my $realm = $c->get_auth_realm($realmname); if ($realm->{'store'}->can('for_session')) { $c->session->{__user} = $realm->{'store'}->for_session($c, $user); } else { $c->session->{__user} = $user->for_session; } } sub persist_user { my $c = shift; if ($c->user_exists) { ## if we have a valid session handler - we store the ## realm in the session. If not - we have to hope that ## the realm can recognize its frozen user somehow. if ($c->can('session') && $c->config->{'Plugin::Authentication'}{'use_session'} && $c->session_is_valid) { $c->session->{'__user_realm'} = $c->_user->auth_realm; } my $realm = $c->get_auth_realm($c->_user->auth_realm); # used to call $realm->save_user_in_session $realm->persist_user($c, $c->user); } } ## this was a short lived method to update user information - ## you should use persist_user instead. sub update_user_in_session { my $c = shift; return $c->persist_user; } sub logout { my $c = shift; $c->user(undef); my $realm = $c->find_realm_for_persisted_user; if ($realm) { $realm->remove_persisted_user($c); } $c->maybe::next::method(@_); } sub find_user { my ( $c, $userinfo, $realmname ) = @_; $realmname ||= 'default'; my $realm = $c->get_auth_realm($realmname); if (!$realm) { Catalyst::Exception->throw( "find_user called with nonexistant realm: '$realmname'."); } return $realm->find_user($userinfo, $c); } ## Consider making this a public method. - would make certain things easier when ## dealing with things pre-auth restore. sub find_realm_for_persisted_user { my $c = shift; my $realm; if ($c->can('session') and $c->config->{'Plugin::Authentication'}{'use_session'} and $c->session_is_valid and exists($c->session->{'__user_realm'})) { $realm = $c->auth_realms->{$c->session->{'__user_realm'}}; if ($realm->user_is_restorable($c)) { return $realm; } } else { ## we have no choice but to ask each realm whether it has a persisted user. foreach my $realmname (@{$c->_auth_realm_restore_order}) { my $realm = $c->auth_realms->{$realmname} || Catalyst::Exception->throw("Could not find authentication realm '$realmname'"); return $realm if $realm->user_is_restorable($c); } } return undef; } sub auth_restore_user { my ( $c, $frozen_user, $realmname ) = @_; my $realm; if (defined($realmname)) { $realm = $c->get_auth_realm($realmname); } else { $realm = $c->find_realm_for_persisted_user; } return undef unless $realm; # FIXME die unless? This is an internal inconsistency $c->_user( my $user = $realm->restore_user( $c, $frozen_user ) ); # this sets the realm the user originated in. $user->auth_realm($realm->name) if $user; return $user; } # we can't actually do our setup in setup because the model has not yet been loaded. # So we have to trigger off of setup_finished. :-( sub setup { my $app = shift; $app->_authentication_initialize(); $app->next::method(@_); } ## the actual initialization routine. whee. sub _authentication_initialize { my $app = shift; ## let's avoid recreating / configuring everything if we have already done it, eh? if ($app->can('_auth_realms')) { return }; ## make classdata where it is used. $app->mk_classdata( '_auth_realms' => {}); ## the order to attempt restore in - If we don't have session - we have ## no way to be sure where a frozen user came from - so we have to ## ask each realm if it can restore the user. Unfortunately it is possible ## that multiple realms could restore the user from the data we have - ## So we have to determine at setup time what order to ask the realms in. ## The default is to use the user_restore_priority values defined in the realm ## config. if they are not defined - we go by alphabetical order. Note that ## the 'default' realm always gets first chance at it unless it is explicitly ## placed elsewhere by user_restore_priority. Remember this only comes ## into play if session is disabled. $app->mk_classdata( '_auth_realm_restore_order' => []); my $cfg = $app->config->{'Plugin::Authentication'}; my $realmshash; if (!defined($cfg)) { if (exists($app->config->{'authentication'})) { $cfg = $app->config->{'authentication'}; $app->config->{'Plugin::Authentication'} = $app->config->{'authentication'}; } else { $cfg = {}; } } else { # the realmshash contains the various configured realms. By default this is # the main $app->config->{'Plugin::Authentication'} hash - but if that is # not defined, or there is a subkey {'realms'} then we use that. $realmshash = $cfg; } ## If we have a sub-key of {'realms'} then we use that for realm configuration if (exists($cfg->{'realms'})) { $realmshash = $cfg->{'realms'}; } # old default was to force use_session on. This must remain for that # reason - but if use_session is already in the config, we respect its setting. if (!exists($cfg->{'use_session'})) { $cfg->{'use_session'} = 1; } ## if we have a realms hash if (ref($realmshash) eq 'HASH') { my %auth_restore_order; my $authcount = 2; my $defaultrealm = 'default'; foreach my $realm (sort keys %{$realmshash}) { if (ref($realmshash->{$realm}) eq 'HASH' && (exists($realmshash->{$realm}{credential}) || exists($realmshash->{$realm}{class}))) { $app->setup_auth_realm($realm, $realmshash->{$realm}); if (exists($realmshash->{$realm}{'user_restore_priority'})) { $auth_restore_order{$realm} = $realmshash->{$realm}{'user_restore_priority'}; } else { $auth_restore_order{$realm} = $authcount++; } } } # if we have a 'default_realm' in the config hash and we don't already # have a realm called 'default', we point default at the realm specified if (exists($cfg->{'default_realm'}) && !$app->get_auth_realm('default')) { if ($app->_set_default_auth_realm($cfg->{'default_realm'})) { $defaultrealm = $cfg->{'default_realm'}; $auth_restore_order{'default'} = $auth_restore_order{$cfg->{'default_realm'}}; delete($auth_restore_order{$cfg->{'default_realm'}}); } } ## if the default realm did not have a defined priority in its config - we put it at the front. if (!exists($realmshash->{$defaultrealm}{'user_restore_priority'})) { $auth_restore_order{'default'} = 1; } @{$app->_auth_realm_restore_order} = sort { $auth_restore_order{$a} <=> $auth_restore_order{$b} } keys %auth_restore_order; } else { ## BACKWARDS COMPATIBILITY - if realms is not defined - then we are probably dealing ## with an old-school config. The only caveat here is that we must add a classname ## also - we have to treat {store} as {stores}{default} - because ## while it is not a clear as a valid config in the docs, it ## is functional with the old api. Whee! if (exists($cfg->{'store'}) && !exists($cfg->{'stores'}{'default'})) { $cfg->{'stores'}{'default'} = $cfg->{'store'}; } push @{$app->_auth_realm_restore_order}, 'default'; foreach my $storename (keys %{$cfg->{'stores'}}) { my $realmcfg = { store => { class => $cfg->{'stores'}{$storename} }, }; $app->setup_auth_realm($storename, $realmcfg); } } } # set up realmname. sub setup_auth_realm { my ($app, $realmname, $config) = @_; my $realmclass = $config->{class}; if( !$realmclass ) { $realmclass = 'Catalyst::Authentication::Realm'; } elsif ($realmclass !~ /^\+(.*)$/ ) { $realmclass = "Catalyst::Authentication::Realm::${realmclass}"; } else { $realmclass = $1; } Catalyst::Utils::ensure_class_loaded( $realmclass ); my $realm = $realmclass->new($realmname, $config, $app); if ($realm) { $app->auth_realms->{$realmname} = $realm; } else { $app->log->debug("realm initialization for '$realmname' failed."); } return $realm; } sub auth_realms { my $self = shift; $self->_authentication_initialize(); # Ensure _auth_realms created! return($self->_auth_realms); } sub get_auth_realm { my ($app, $realmname) = @_; return $app->auth_realms->{$realmname}; } # Very internal method. Vital Valuable Urgent, Do not touch on pain of death. # Using this method just assigns the default realm to be the value associated # with the realmname provided. It WILL overwrite any real realm called 'default' # so can be very confusing if used improperly. It's used properly already. # Translation: don't use it. sub _set_default_auth_realm { my ($app, $realmname) = @_; if (exists($app->auth_realms->{$realmname})) { $app->auth_realms->{'default'} = $app->auth_realms->{$realmname}; } return $app->get_auth_realm('default'); } sub authenticate { my ($app, $userinfo, $realmname) = @_; if (!$realmname) { $realmname = 'default'; } my $realm = $app->get_auth_realm($realmname); ## note to self - make authenticate throw an exception if realm is invalid. if ($realm) { return $realm->authenticate($app, $userinfo); } else { Catalyst::Exception->throw( "authenticate called with nonexistant realm: '$realmname'."); } return undef; } ## BACKWARDS COMPATIBILITY -- Warning: Here be monsters! # # What follows are backwards compatibility routines - for use with Stores and Credentials # that have not been updated to work with C::P::Authentication v0.10. # These are here so as to not break people's existing installations, but will go away # in a future version. # # The old style of configuration only supports a single store, as each store module # sets itself as the default store upon being loaded. This is the only supported # 'compatibility' mode. # sub get_user { my ( $c, $uid, @rest ) = @_; return $c->find_user( {'id' => $uid, 'rest'=>\@rest }, 'default' ); } ## this should only be called when using old-style authentication plugins. IF this gets ## called in a new-style config - it will OVERWRITE the store of your default realm. Don't do it. ## also - this is a partial setup - because no credential is instantiated... in other words it ONLY ## works with old-style auth plugins and C::P::Authentication in compatibility mode. Trying to combine ## this with a realm-type config will probably crash your app. sub default_auth_store { my $self = shift; my $realm = $self->get_auth_realm('default'); if (!$realm) { $realm = $self->setup_auth_realm('default', { class => 'Compatibility' }); } if ( my $new = shift ) { $realm->store($new); my $storeclass; if (ref($new)) { $storeclass = ref($new); } else { $storeclass = $new; } # BACKWARDS COMPATIBILITY - if the store class does not define find_user, we define it in terms # of get_user and add it to the class. this is because the auth routines use find_user, # and rely on it being present. (this avoids per-call checks) if (!$storeclass->can('find_user')) { no strict 'refs'; *{"${storeclass}::find_user"} = sub { my ($self, $info) = @_; my @rest = @{$info->{rest}} if exists($info->{rest}); $self->get_user($info->{id}, @rest); }; } } return $self->get_auth_realm('default')->store; } ## BACKWARDS COMPATIBILITY ## this only ever returns a hash containing 'default' - as that is the only ## supported mode of calling this. sub auth_store_names { my $self = shift; my %hash = ( $self->get_auth_realm('default')->store => 'default' ); } sub get_auth_store { my ( $self, $name ) = @_; if ($name ne 'default') { Carp::croak "get_auth_store called on non-default realm '$name'. Only default supported in compatibility mode"; } else { $self->default_auth_store(); } } sub get_auth_store_name { my ( $self, $store ) = @_; return 'default'; } # sub auth_stores is only used internally - here for completeness sub auth_stores { my $self = shift; my %hash = ( 'default' => $self->get_auth_realm('default')->store); } __PACKAGE__->meta->make_immutable; __PACKAGE__; __END__ =pod =head1 NAME Catalyst::Plugin::Authentication - Infrastructure plugin for the Catalyst authentication framework. =head1 SYNOPSIS use Catalyst qw/ Authentication /; # later on ... $c->authenticate({ username => 'myusername', password => 'mypassword' }); my $age = $c->user->get('age'); $c->logout; =head1 DESCRIPTION The authentication plugin provides generic user support for Catalyst apps. It is the basis for both authentication (checking the user is who they claim to be), and authorization (allowing the user to do what the system authorises them to do). Using authentication is split into two parts. A Store is used to actually store the user information, and can store any amount of data related to the user. Credentials are used to verify users, using information from the store, given data from the frontend. A Credential and a Store are paired to form a 'Realm'. A Catalyst application using the authentication framework must have at least one realm, and may have several. To implement authentication in a Catalyst application you need to add this module, and specify at least one realm in the configuration. Authentication data can also be stored in a session, if the application is using the L module. B in version 0.10 of this module, the interface to this module changed. Please see L for more information. =head1 INTRODUCTION =head2 The Authentication/Authorization Process Web applications typically need to identify a user - to tell the user apart from other users. This is usually done in order to display private information that is only that user's business, or to limit access to the application so that only certain entities can access certain parts. This process is split up into several steps. First you ask the user to identify themselves. At this point you can't be sure that the user is really who they claim to be. Then the user tells you who they are, and backs this claim with some piece of information that only the real user could give you. For example, a password is a secret that is known to both the user and you. When the user tells you this password you can assume they're in on the secret and can be trusted (ignore identity theft for now). Checking the password, or any other proof is called B. By this time you know exactly who the user is - the user's identity is B. This is where this module's job stops, and your application or other plugins step in. The next logical step is B, the process of deciding what a user is (or isn't) allowed to do. For example, say your users are split into two main groups - regular users and administrators. You want to verify that the currently logged in user is indeed an administrator before performing the actions in an administrative part of your application. These decisions may be made within your application code using just the information available after authentication, or it may be facilitated by a number of plugins. =head2 The Components In This Framework =head3 Realms Configuration of the Catalyst::Plugin::Authentication framework is done in terms of realms. In simplest terms, a realm is a pairing of a Credential verifier and a User storage (Store) backend. As of version 0.10003, realms are now objects that you can create and customize. An application can have any number of Realms, each of which operates independent of the others. Each realm has a name, which is used to identify it as the target of an authentication request. This name can be anything, such as 'users' or 'members'. One realm must be defined as the default_realm, which is used when no realm name is specified. More information about configuring realms is available in the configuration section. =head3 Credential Verifiers When user input is transferred to the L application (typically via form inputs) the application may pass this information into the authentication system through the C<< $c->authenticate() >> method. From there, it is passed to the appropriate Credential verifier. These plugins check the data, and ensure that it really proves the user is who they claim to be. Credential verifiers compatible with versions of this module 0.10x and upwards should be in the namespace C. =head3 Storage Backends The authentication data also identifies a user, and the Storage backend modules use this data to locate and return a standardized object-oriented representation of a user. When a user is retrieved from a store it is not necessarily authenticated. Credential verifiers accept a set of authentication data and use this information to retrieve the user from the store they are paired with. Storage backends compatible with versions of this module 0.10x and upwards should be in the namespace C. =head3 The Core Plugin This plugin on its own is the glue, providing realm configuration, session integration, and other goodness for the other plugins. =head3 Other Plugins More layers of plugins can be stacked on top of the authentication code. For example, L provides an abstraction of browser sessions that is more persistent per user. L provides an accepted way to separate and group users into categories, and then check which categories the current user belongs to. =head1 EXAMPLE Let's say we were storing users in a simple Perl hash. Users are verified by supplying a password which is matched within the hash. This means that our application will begin like this: package MyApp; use Catalyst qw/ Authentication /; __PACKAGE__->config( 'Plugin::Authentication' => { default => { credential => { class => 'Password', password_field => 'password', password_type => 'clear' }, store => { class => 'Minimal', users => { bob => { password => "s00p3r", editor => 'yes', roles => [qw/edit delete/], }, william => { password => "s3cr3t", roles => [qw/comment/], } } } } } ); This tells the authentication plugin what realms are available, which credential and store modules are used, and the configuration of each. With this code loaded, we can now attempt to authenticate users. To show an example of this, let's create an authentication controller: package MyApp::Controller::Auth; sub login : Local { my ( $self, $c ) = @_; if ( my $user = $c->req->params->{user} and my $password = $c->req->params->{password} ) { if ( $c->authenticate( { username => $user, password => $password } ) ) { $c->res->body( "hello " . $c->user->get("name") ); } else { # login incorrect } } else { # invalid form input } } This code should be self-explanatory. If all the necessary fields are supplied, call the C method on the context object. If it succeeds the user is logged in. The credential verifier will attempt to retrieve the user whose details match the authentication information provided to C<< $c->authenticate() >>. Once it fetches the user the password is checked and if it matches the user will be B and C<< $c->user >> will contain the user object retrieved from the store. In the above case, the default realm is checked, but we could just as easily check an alternate realm. If this were an admin login, for example, we could authenticate on the admin realm by simply changing the C<< $c->authenticate() >> call: if ( $c->authenticate( { username => $user, password => $password }, 'admin' ) ) { $c->res->body( "hello " . $c->user->get("name") ); } ... Now suppose we want to restrict the ability to edit to a user with an 'editor' value of yes. The restricted action might look like this: sub edit : Local { my ( $self, $c ) = @_; $c->detach("unauthorized") unless $c->user_exists and $c->user->get('editor') eq 'yes'; # do something restricted here } (Note that if you have multiple realms, you can use C<< $c->user_in_realm('realmname') >> in place of C<< $c->user_exists(); >> This will essentially perform the same verification as user_exists, with the added requirement that if there is a user, it must have come from the realm specified.) The above example is somewhat similar to role based access control. L treats the roles field as an array of role names. Let's leverage this. Add the role authorization plugin: use Catalyst qw/ ... Authorization::Roles /; sub edit : Local { my ( $self, $c ) = @_; $c->detach("unauthorized") unless $c->check_user_roles("edit"); # do something restricted here } This is somewhat simpler and will work if you change your store, too, since the role interface is consistent. Let's say your app grows, and you now have 10,000 users. It's no longer efficient to maintain a hash of users, so you move this data to a database. You can accomplish this simply by installing the L Store and changing your config: __PACKAGE__->config( 'Plugin::Authentication' => { default_realm => 'members', members => { credential => { class => 'Password', password_field => 'password', password_type => 'clear' }, store => { class => 'DBIx::Class', user_model => 'MyApp::Users', role_column => 'roles', } } } ); The authentication system works behind the scenes to load your data from the new source. The rest of your application is completely unchanged. =head1 CONFIGURATION # example __PACKAGE__->config( 'Plugin::Authentication' => { default_realm => 'members', members => { credential => { class => 'Password', password_field => 'password', password_type => 'clear' }, store => { class => 'DBIx::Class', user_model => 'MyApp::Users', role_column => 'roles', } }, admins => { credential => { class => 'Password', password_field => 'password', password_type => 'clear' }, store => { class => '+MyApp::Authentication::Store::NetAuth', authserver => '192.168.10.17' } } } ); NOTE: Until version 0.10008 of this module, you would need to put all the realms inside a "realms" key in the configuration. Please see L for more information =over 4 =item use_session Whether or not to store the user's logged in state in the session, if the application is also using L. This value is set to true per default. However, even if use_session is disabled, if any code touches $c->session, a session object will be auto-vivified and session Cookies will be sent in the headers. To prevent accidental session creation, check if a session already exists with if ($c->sessionid) { ... }. If the session doesn't exist, then don't place anything in the session to prevent an unecessary session from being created. =item default_realm This defines which realm should be used as when no realm is provided to methods that require a realm such as authenticate or find_user. =item realm refs The Plugin::Authentication config hash contains the series of realm configurations you want to use for your app. The only rule here is that there must be at least one. A realm consists of a name, which is used to reference the realm, a credential and a store. You may also put your realm configurations within a subelement called 'realms' if you desire to separate them from the remainder of your configuration. Note that if you use a 'realms' subelement, you must put ALL of your realms within it. You can also specify a realm class to instantiate instead of the default L class using the 'class' element within the realm config. Each realm config contains two hashes, one called 'credential' and one called 'store', each of which provide configuration details to the respective modules. The contents of these hashes is specific to the module being used, with the exception of the 'class' element, which tells the core Authentication module the classname to instantiate. The 'class' element follows the standard Catalyst mechanism of class specification. If a class is prefixed with a +, it is assumed to be a complete class name. Otherwise it is considered to be a portion of the class name. For credentials, the classname 'B', for example, is expanded to Catalyst::Authentication::Credential::B. For stores, the classname 'B' is expanded to: Catalyst::Authentication::Store::B. =back =head1 METHODS =head2 $c->authenticate( $userinfo [, $realm ]) Attempts to authenticate the user using the information in the $userinfo hash reference using the realm $realm. $realm may be omitted, in which case the default realm is checked. =head2 $c->user( ) Returns the currently logged in user, or undef if there is none. Normally the user is re-retrieved from the store. For L the user is re-restored using the primary key of the user table. Thus B can throw an error even though B returned true. =head2 $c->user_exists( ) Returns true if a user is logged in right now. The difference between B and B is that user_exists will return true if a user is logged in, even if it has not been yet retrieved from the storage backend. If you only need to know if the user is logged in, depending on the storage mechanism this can be much more efficient. B only looks into the session while B is trying to restore the user. =head2 $c->user_in_realm( $realm ) Works like user_exists, except that it only returns true if a user is both logged in right now and was retrieved from the realm provided. =head2 $c->logout( ) Logs the user out. Deletes the currently logged in user from C<< $c->user >> and the session. It does not delete the session. =head2 $c->find_user( $userinfo, $realm ) Fetch a particular users details, matching the provided user info, from the realm specified in $realm. $user = $c->find_user({ id => $id }); $c->set_authenticated($user); # logs the user in and calls persist_user =head2 persist_user() Under normal circumstances the user data is only saved to the session during initial authentication. This call causes the auth system to save the currently authenticated user's data across requests. Useful if you have changed the user data and want to ensure that future requests reflect the most current data. Assumes that at the time of this call, $c->user contains the most current data. =head2 find_realm_for_persisted_user() Private method, do not call from user code! =head1 INTERNAL METHODS These methods are for Catalyst::Plugin::Authentication B only. Please do not use them in your own code, whether application or credential / store modules. If you do, you will very likely get the nasty shock of having to fix / rewrite your code when things change. They are documented here only for reference. =head2 $c->set_authenticated( $user, $realmname ) Marks a user as authenticated. This is called from within the authenticate routine when a credential returns a user. $realmname defaults to 'default'. You can use find_user to get $user =head2 $c->auth_restore_user( $user, $realmname ) Used to restore a user from the session. In most cases this is called without arguments to restore the user via the session. Can be called with arguments when restoring a user from some other method. Currently not used in this way. =head2 $c->auth_realms( ) Returns a hashref containing realmname -> realm instance pairs. Realm instances contain an instantiated store and credential object as the 'store' and 'credential' elements, respectively =head2 $c->get_auth_realm( $realmname ) Retrieves the realm instance for the realmname provided. =head2 $c->update_user_in_session This was a short-lived method to update user information - you should use persist_user instead. =head2 $c->setup_auth_realm( ) =head1 OVERRIDDEN METHODS =head2 $c->setup( ) =head1 SEE ALSO This list might not be up to date. Below are modules known to work with the updated API of 0.10 and are therefore compatible with realms. =head2 Realms L =head2 User Storage Backends =over =item L =item L =item L =item L =item L =item L =item L =back =head2 Credential verification =over =item L =item L =item L =item L =item L =item L =item L =item L =back =head2 Authorization L, L =head2 Internals Documentation L =head2 Misc L, L =head1 DON'T SEE ALSO This module along with its sub plugins deprecate a great number of other modules. These include L, L. =head1 INCOMPATABILITIES The realms-based configuration and functionality of the 0.10 update of L required a change in the API used by credentials and stores. It has a compatibility mode which allows use of modules that have not yet been updated. This, however, completely mimics the older api and disables the new realm-based features. In other words you cannot mix the older credential and store modules with realms, or realm-based configs. The changes required to update modules are relatively minor and are covered in L. We hope that most modules will move to the compatible list above very quickly. =head1 COMPATIBILITY CONFIGURATION Until version 0.10008 of this module, you needed to put all the realms inside a "realms" key in the configuration. # example __PACKAGE__->config( 'Plugin::Authentication' => { default_realm => 'members', realms => { members => { ... }, }, } ); If you use the old, deprecated C<< __PACKAGE__->config( 'authentication' ) >> configuration key, then the realms key is still required. =head1 COMPATIBILITY ROUTINES In version 0.10 of L, the API changed. For app developers, this change is fairly minor, but for Credential and Store authors, the changes are significant. Please see the documentation in version 0.09 of Catalyst::Plugin::Authentication for a better understanding of how the old API functioned. The items below are still present in the plugin, though using them is deprecated. They remain only as a transition tool, for those sites which can not yet be upgraded to use the new system due to local customizations or use of Credential / Store modules that have not yet been updated to work with the new API. These routines should not be used in any application using realms functionality or any of the methods described above. These are for reference purposes only. =head2 $c->login( ) This method is used to initiate authentication and user retrieval. Technically this is part of the old Password credential module and it still resides in the L class. It is included here for reference only. =head2 $c->default_auth_store( ) Return the store whose name is 'default'. This is set to C<< $c->config( 'Plugin::Authentication' => { store => # Store} ) >> if that value exists, or by using a Store plugin: # load the Minimal authentication store. use Catalyst qw/Authentication Authentication::Store::Minimal/; Sets the default store to L. =head2 $c->get_auth_store( $name ) Return the store whose name is $name. =head2 $c->get_auth_store_name( $store ) Return the name of the store $store. =head2 $c->auth_stores( ) A hash keyed by name, with the stores registered in the app. =head2 $c->register_auth_stores( %stores_by_name ) Register stores into the application. =head2 $c->auth_store_names( ) =head2 $c->get_user( ) =head1 SUPPORT Please use the rt.cpan.org bug tracker, and git patches are wecome. Questions on usage should be directed to the Catalyst mailing list or the #catalyst irc channel. =head1 AUTHORS Yuval Kogman, C - original author Jay Kuri, C - Large rewrite =head1 PRIMARY MAINTAINER Tomas Doran (t0m), C =head1 ADDITIONAL CONTRIBUTORS =over =item Jess Robinson =item David Kamholz =item kmx =item Nigel Metheringham =item Florian Ragwitz C =item Stephan Jauernick C =item Oskari Ojala (Okko), C =item John Napiorkowski (jnap) C =back =head1 COPYRIGHT & LICENSE Copyright (c) 2005 - 2012 the Catalyst::Plugin::Authentication L, L and L as listed above. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =cut Catalyst-Plugin-Authentication-0.10024/lib/Catalyst/Plugin/Authentication/0000755000000000000000000000000014703760553025315 5ustar00rootwheelCatalyst-Plugin-Authentication-0.10024/lib/Catalyst/Plugin/Authentication/User.pm0000644000000000000000000000072314703760420026564 0ustar00rootwheelpackage Catalyst::Plugin::Authentication::User; use strict; use warnings; use base qw/Catalyst::Authentication::User/; __PACKAGE__; __END__ =pod =head1 NAME Catalyst::Plugin::Authentication::User - Compatibility shim =head1 DESCRIPTION THIS IS A COMPATIBILITY SHIM. It allows old configurations of Catalyst Authentication to work without code changes. B Please see L for more information. Catalyst-Plugin-Authentication-0.10024/lib/Catalyst/Plugin/Authentication/Credential/0000755000000000000000000000000014703760553027367 5ustar00rootwheelCatalyst-Plugin-Authentication-0.10024/lib/Catalyst/Plugin/Authentication/Credential/Password.pm0000644000000000000000000001013414703760420031517 0ustar00rootwheelpackage Catalyst::Plugin::Authentication::Credential::Password; use strict; use warnings; use Catalyst::Authentication::Credential::Password (); ## BACKWARDS COMPATIBILITY - all subs below here are deprecated ## They are here for compatibility with older modules that use / inherit from C::P::A::Password ## login()'s existance relies rather heavily on the fact that only Credential::Password ## is being used as a credential. This may not be the case. This is only here ## for backward compatibility. It will go away in a future version ## login should not be used in new applications. sub login { my ( $c, $user, $password, @rest ) = @_; unless ( defined($user) or $user = $c->request->param("login") || $c->request->param("user") || $c->request->param("username") ) { $c->log->debug( "Can't login a user without a user object or user ID param") if $c->debug; return; } unless ( defined($password) or $password = $c->request->param("password") || $c->request->param("passwd") || $c->request->param("pass") ) { $c->log->debug("Can't login a user without a password") if $c->debug; return; } unless ( Scalar::Util::blessed($user) and $user->isa("Catalyst::Authentication::User") ) { if ( my $user_obj = $c->get_user( $user, $password, @rest ) ) { $user = $user_obj; } else { $c->log->debug("User '$user' doesn't exist in the default store") if $c->debug; return; } } if ( $c->_check_password( $user, $password ) ) { $c->set_authenticated($user); $c->log->debug("Successfully authenticated user '$user'.") if $c->debug; return 1; } else { $c->log->debug( "Failed to authenticate user '$user'. Reason: 'Incorrect password'") if $c->debug; return; } } ## also deprecated. Here for compatibility with older credentials which do not inherit from C::P::A::Password sub _check_password { my ( $c, $user, $password ) = @_; if ( $user->supports(qw/password clear/) ) { return $user->password eq $password; } elsif ( $user->supports(qw/password crypted/) ) { my $crypted = $user->crypted_password; return $crypted eq crypt( $password, $crypted ); } elsif ( $user->supports(qw/password hashed/) ) { my $d = Digest->new( $user->hash_algorithm ); $d->add( $user->password_pre_salt || '' ); $d->add($password); $d->add( $user->password_post_salt || '' ); my $stored = $user->hashed_password; my $computed = $d->clone()->digest; my $b64computed = $d->clone()->b64digest; return ( ( $computed eq $stored ) || ( unpack( "H*", $computed ) eq $stored ) || ( $b64computed eq $stored) || ( $b64computed.'=' eq $stored) ); } elsif ( $user->supports(qw/password salted_hash/) ) { require Crypt::SaltedHash; my $salt_len = $user->can("password_salt_len") ? $user->password_salt_len : 0; return Crypt::SaltedHash->validate( $user->hashed_password, $password, $salt_len ); } elsif ( $user->supports(qw/password self_check/) ) { # while somewhat silly, this is to prevent code duplication return $user->check_password($password); } else { Catalyst::Exception->throw( "The user object $user does not support any " . "known password authentication mechanism." ); } } __PACKAGE__; __END__ =pod =head1 NAME Catalyst::Plugin::Authentication::Credential::Password - Compatibility shim =head1 DESCRIPTION THIS IS A COMPATIBILITY SHIM. It allows old configurations of Catalyst Authentication to work without code changes. B Please see L for more information. =head1 METHODS =head2 login( ) =cut Catalyst-Plugin-Authentication-0.10024/lib/Catalyst/Plugin/Authentication/User/0000755000000000000000000000000014703760553026233 5ustar00rootwheelCatalyst-Plugin-Authentication-0.10024/lib/Catalyst/Plugin/Authentication/User/Hash.pm0000644000000000000000000000075314703760420027452 0ustar00rootwheelpackage Catalyst::Plugin::Authentication::User::Hash; use strict; use warnings; use base qw/Catalyst::Authentication::User::Hash/; __PACKAGE__; __END__ =pod =head1 NAME Catalyst::Plugin::Authentication::User::Hash - Compatibility shim =head1 DESCRIPTION THIS IS A COMPATIBILITY SHIM. It allows old configurations of Catalyst Authentication to work without code changes. B Please see L for more information. Catalyst-Plugin-Authentication-0.10024/lib/Catalyst/Plugin/Authentication/Internals.pod0000644000000000000000000004610514703760420027757 0ustar00rootwheel =head1 NAME Catalyst::Plugin::Authentication::Internals - All about authentication Stores and Credentials =head1 INTRODUCTION L provides a standard authentication interface to application developers using the Catalyst framework. It is designed to allow application developers to use various methods of user storage and credential verification. It is also designed to provide for minimal change to the application when switching between different storage and credential verification methods. While L provides the interface to the application developer, the actual work of verifying the credentials and retrieving users is delegated to separate modules. These modules are called B and storage backends, or B, respectively. For authentication to function there must be at least one credential and one store. A pairing of a store and a credential is referred to as a B. There may be any number of realms defined for an application, though most applications will not require more than one or two. The details of using this module can be found in the L documentation. What follows is an explanation of how the module functions internally and what is required to implement a credential or a store. =head1 OVERVIEW There are two main entry points you need to be aware of when writing a store or credential module. The first is initialization and the second is during the actual call to the Catalyst application's authenticate method. A simplified description of the authentication process follows: B =over 4 B - for each realm: =over 4 1) The Realm is instantiated using new() method 2) The Store is instantiated using new() method 3) The Credential Instantiated using new() method 4) Credential and Store objects tied to realm for use during requests =back =back B =over 4 C<< $c->authenticate( $userinfo, $realm ) >> called =over 4 1) Credential object retrieved for realm provided 2) Credential's authenticate() method called with authinfo and realm object for current realm =over 4 The realm object and the authinfo hash are provided to the credential object's authenticate call. In most cases the credential object will attempt to retrieve a user using the realm's find_user() method, which by default relays the call directly to the Store's find_user() method. It will then usually compare the retrieved user's information with the information provided in the $authinfo hash. This is how the default 'Password' credential functions. If the credentials match, the authenticate() method should return a user object. =back 3) User object stored in session =over 4 If the user object supports session storage, the successfully authenticated user will be placed in session storage. This is done by calling the realm object's persist_user() method. The persist_user() routine by default calls the Store's for_session() method, which should return serialized data (IE a scalar). This serialized data is passed back to the store via the from_session() method, so the data should contain enough information for the store to recreate / reload the user. =back =back =back B - Per-Request operations =over 4 When any user-related activity occurs, and $c->authenticate has not yet been called, the Catalyst::Plugin::Authentication module will attempt to restore the persisted user (normally from the session if one is available). There is only one step in this process: =over 4 1) Store object's from_session() is called =back The serialized data previously returned by the store's for_session() method is provided to the from_session() method. The from_session() method should return a valid user object. Note that the for_session() is only called during the original $c->authenticate() call, so if changes are made to the user that need to be reflected in your session data, you will want to call the $c->persist_user() method - which will perform the session storage process again (complete with call to for_session()). =back More detailed information about these processes is below. =head2 INITIALIZATION When the authentication module is loaded, it reads it's configuration to determine the realms to set up for the application and which realm is to be the default. For each realm defined in the application's config, L instantiates both a new credential object and a new store object. See below for the details of how credentials and stores are instantiated. B: The instances created will remain active throughout the entire lifetime of the application, and so should be relatively lightweight. Care should be taken to ensure that they do not grow, or retain information per request, because they will be involved in each authentication request and could therefore substantially hurt memory consumption over time. =head2 AUTHENTICATION When C<$c-Eauthenticate()> is called from within an application, the objects created in the initialization process come into play. C<$c-Eauthenticate()> takes two arguments. The first is a hash reference containing all the information available about the user. This will be used to locate the user in the store and verify the user's credentials. The second argument is the realm to authenticate against. If the second argument is omitted, the default realm is assumed. The main authentication module then locates the credential and store objects for the realm specified and calls the credential object's C method. It provides three arguments, first the application object, or C<$c>, then a reference to the store object, and finally the hashref provided in the C<$c-Eauthenticate> call. The main authentication module expects the return value to be a reference to a user object upon successful authentication. If it receives anything aside from a reference, it is considered to be an authentication failure. Upon success, the returned user is marked as authenticated and the application can act accordingly, using C<$c-Euser> to access the authenticated user, etc. Astute readers will note that the main L module does not interact with the store in any way, save for passing a reference to it to the credential. This is correct. The credential object is responsible for obtaining the user from the provided store using information from the userinfo hashref and/or data obtained during the credential verification process. =head1 WRITING A STORE There are two parts to an authentication store, the store object and the user object. =head2 STORAGE BACKEND Writing a store is actually quite simple. There are only five methods that must be implemented. They are: new() - instantiates the store object find_user() - locates a user using data contained in the hashref for_session() - prepares a user to be stored in the session from_session() - does any restoration required when obtaining a user from the session user_supports() - provides information about what the user object supports =head3 STORE METHODS =over 4 =item new( $config, $app, $realm ) The C method is called only once, during the setup process of L. The first argument, C<$config>, is a hash reference containing the configuration information for the store module. The second argument is a reference to the Catalyst application. Note that when new() is called, Catalyst has not yet loaded the various controller and model classes, nor is it definite that other plugins have been loaded, so your new() method must not rely on any of those being present. If any of this is required for your store to function, you should defer that part of initialization until the first method call. The C method should return a blessed reference to your store object. =item find_user( $authinfo, $c ) This is the workhorse of any authentication store. It's job is to take the information provided to it via the C<$authinfo> hashref and locate the user that matches it. It should return a reference to a user object. A return value of anything else is considered to mean no user was found that matched the information provided. How C accomplishes it's job is entirely up to you, the author, as is what $authinfo is required to contain. Many stores will simply use a username element in $authinfo to locate the user, but more advanced functionality is possible and you may bend the $authinfo to your needs. Be aware, however, that both Credentials and Stores usually work with the same $authinfo hash, so take care to avoid overlapping element names. Please note that this routine may be called numerous times in various circumstances, and that a successful match for a user here does B necessarily constitute successful authentication. Your store class should never assume this and in most cases C<$c> B by your store object. =item for_session( $c, $user ) This method is responsible for preparing a user object for storage in the session. It should return information that can be placed in the session and later used to restore a user object (using the C method). It should therefore ensure that whatever information provided can be used by the C method to locate the unique user being saved. Note that there is no guarantee that the same Catalyst instance will receive both the C and C calls. You should take care to provide information that can be used to restore a user, regardless of the current state of the application. A good rule of thumb is that if C can revive the user with the given information even if the Catalyst application has just started up, you are in good shape. =item from_session( $c, $frozenuser ) This method is called whenever a user is being restored from the session. C<$frozenuser> contains the information that was stored in the session for the user. This will under normal circumstances be the exact data your store returned from the previous call to C. C should return a valid user object. =item user_supports( $feature, ... ) This method allows credentials and other objects to inquire as to what the underlying user object is capable of. This is pretty-well free-form and the main purpose is to allow graceful integration with credentials and applications that may provide advanced functionality based on whether the underlying user object can do certain things. In most cases you will want to pass this directly to the underlying user class' C method. Note that this is used as a B method against the user class and therefore must be able to function without an instantiated user object. =back =head3 OPTIONAL STORE METHODS If you want your store to be able to auto- create users, then you can implement these methods: =head4 auto_update_user( $authinfo, $c, $res ) This method is called if the realm's auto_update_user setting is true. =head4 auto_create_user( $authinfo, $c ) This method is called if the realm's auto_create_user setting is true. =head2 USER OBJECT The user object is an important piece of your store module. It will be the part of the system that the application developer will interact with most. As such, the API for the user object is very rigid. All user objects B inherit from L. =head3 USER METHODS The routines required by the L plugin are below. Note that of these, only get_object is strictly required, as the L base class contains reasonable implementations of the rest. If you do choose to implement only the C routine, please read the base class code and documentation so that you fully understand how the other routines will be implemented for you. Also, your user object can implement whatever additional methods you require to provide the functionality you need. So long as the below are implemented, and you don't overlap the base class' methods with incompatible routines, you should experience no problems. =over 4 =item id( ) The C method should return a unique id (scalar) that can be used to retreive this user from the store. Often this will be provided to the store's C routine as C $user-Eid> so you should ensure that your store's C can cope with that. =item supports( $feature, $subfeature ... ) This method checks to see if the user class supports a particular feature. It is implemented such that each argument provides a subfeature of the previous argument. In other words, passing 'foo', 'bar' would return true if the user supported the 'foo' feature, and the 'bar' feature of 'foo'. This is implemented in Catalyst::Authentication::User, so if your class inherits from that, you do not need to implement this and can instead implement supported_features(). B If you want the authentication module to be able to save your user in the session you must return true when presented with the feature 'session'. =item supported_features( ) This method should return a hashref of features supported by the user class. This is for more flexible integration with some Credentials / applications. It is not required that you support anything, and returning C is perfectly acceptable and in most cases what you will do. =item get( $fieldname ) This method should return the value of the field matching fieldname provided, or undef if there is no field matching that fieldname. In most cases this will access the underlying storage mechanism for the user data and return the information. This is used as a standard method of accessing an authenticated user's data, and MUST be implemented by all user objects. B: There is no equivalent 'set' method. Each user class is likely to vary greatly in how data must be saved and it is therefore impractical to try to provide a standard way of accomplishing it. When an application developer needs to save data, they should obtain the underlying object / data by calling get_object, and work with it directly. =item get_object( ) This method returns the underlying user object. If your user object is backed by another object class, this method should return that underlying object. This allows the application developer to obtain an editable object. Generally speaking this will only be done by developers who know what they are doing and require advanced functionality which is either unforeseen or inconsistent across user classes. If your object is not backed by another class, or you need to provide additional intermediate functionality, it is perfectly reasonable to return C<$self>. =back =head1 WRITING A CREDENTIAL Compared to writing a store, writing a credential is very simple. There is only one class to implement, and it consists of only two required routines. They are: new() - instantiates the credential object authenticate() - performs the authentication and returns a user object =head2 CREDENTIAL METHODS =over 4 =item new( $config, $app, $realm ) Like the Store method of the same name, the C method is called only once, during the setup process of L. The first argument, C<$config>, is a hash reference containing the configuration information for the credential module. The second argument is a reference to the Catalyst application. $realm is the instantiated Realm object, which you may use to access realm routines - such as find_user. Again, when the credential's new() method is called, Catalyst has not yet loaded the various controller and model classes. The new method should perform any necessary setup required and instantiate your credential object. It should return your instantiated credential. =item authenticate( $c, $realm, $authinfo ) This is the workhorse of your credential. When $c->authenticate() is called the L module retrieves the realm object and passes it, along with the $authinfo hash to your credential's authenticate method. Your module should use the $authinfo hash to obtain the user from the realm passed, and then perform any credential verification steps necessary to authenticate the user. This method should return the user object returned by the authentication store if credential verification succeeded. It should return undef on failure. How your credential module performs the credential verification is entirely up to you. In most cases, the credential will retrieve a user from the store first (using the stores find_user() method), and then validate the user's information. However, this does not have to be the case. It is perfectly acceptable for your credential to perform other tasks prior to attempting to retrieve the user from the store. It may also make sense for your credential to perform activities which help to locate the user in question, for example, finding a user id based on an encrypted token. In these scenarios, the $authinfo hash passed to find_user() can be different than that which is passed in to $c->authenticate(). Once again this is perfectly acceptable if it makes sense for your credential, though you are strongly advised to note this behavior clearly in your credential's documentation - as application authors are almost certainly expecting the user to be found using the information provided to $c->authenticate(). Look at the L module source to see this in action. In order to avoid possible mismatches between the encrypted and unencrypted passwords, the password credential actually removes the provided password from the authinfo array. It does this because, in many cases, the store's password field will be encrypted in some way, and the password passed to $c->authenticate is almost certainly in plaintext. NOTE: You should always assume that a store is going to use all the information passed to it to locate the user in question. If there are fields in the $authinfo hash that you are sure are specific to your credential, you may want to consider removing them before user retrieval. A better solution is to place those arguments that are specific to your credential within their own subhash named after your module. The L module does this in order to encapsulate arguments intended specifically for that module. See the L source for details. =back =head1 AUTHORS Jay Kuri, C =head1 COPYRIGHT & LICENSE Copyright (c) 2005 the aforementioned authors. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =cut Catalyst-Plugin-Authentication-0.10024/lib/Catalyst/Plugin/Authentication/Store/0000755000000000000000000000000014703760553026411 5ustar00rootwheelCatalyst-Plugin-Authentication-0.10024/lib/Catalyst/Plugin/Authentication/Store/Minimal.pm0000644000000000000000000000404414703760420030330 0ustar00rootwheelpackage Catalyst::Plugin::Authentication::Store::Minimal; use strict; use warnings; use MRO::Compat; use Catalyst::Authentication::Store::Minimal (); ## backwards compatibility sub setup { my $c = shift; ### If a user does 'use Catalyst qw/Authentication::Store::Minimal/' ### he will be proxied on to this setup routine (and only then -- ### non plugins should NOT have their setup routine invoked!) ### Beware what we pass to the 'new' routine; it wants ### a config has with a top level key 'users'. New style ### configs do not have this, and split by realms. If we ### blindly pass this to new, we will 1) overwrite what we ### already passed and 2) make ->userhash undefined, which ### leads to: ### Can't use an undefined value as a HASH reference at ### lib/Catalyst/Authentication/Store/Minimal.pm line 38. ### ### So only do this compatibility call if: ### 1) we have a {users} config directive ### ### Ideally we could also check for: ### 2) we don't already have a ->userhash ### however, that's an attribute of an object we can't ### access =/ --kane my $cfg = $c->config->{'Plugin::Authentication'}->{users} ? $c->config->{'Plugin::Authentication'} : undef; $c->default_auth_store( Catalyst::Authentication::Store::Minimal->new( $cfg, $c ) ) if $cfg; $c->next::method(@_); } foreach my $method (qw/ get_user user_supports find_user from_session /) { no strict 'refs'; *{$method} = sub { __PACKAGE__->default_auth_store->$method( @_ ) }; } __PACKAGE__; __END__ =pod =head1 NAME Catalyst::Plugin::Authentication::Store::Minimal - Compatibility shim =head1 DESCRIPTION THIS IS A COMPATIBILITY SHIM. It allows old configurations of Catalyst Authentication to work without code changes. B Please see L for more information. =head1 METHODS =over =item find_user =item from_session =item get_user =item setup =item user_supports =back =cut Catalyst-Plugin-Authentication-0.10024/lib/Catalyst/Authentication/0000755000000000000000000000000014703760553024057 5ustar00rootwheelCatalyst-Plugin-Authentication-0.10024/lib/Catalyst/Authentication/User.pm0000644000000000000000000000777714703760420025346 0ustar00rootwheelpackage Catalyst::Authentication::User; use Moose; use namespace::autoclean; with 'MooseX::Emulate::Class::Accessor::Fast'; use Scalar::Util qw/refaddr/; ## auth_realm is the realm this user came from. __PACKAGE__->mk_accessors(qw/auth_realm store/); ## THIS IS NOT A COMPLETE CLASS! it is intended to provide base functionality only. ## translation - it won't work if you try to use it directly. ## chances are you want to override this. sub id { shift->get('id'); } ## this relies on 'supported_features' being implemented by the subclass.. ## but it is not an error if it is not. it just means you support nothing. ## nihilist user objects are welcome here. sub supports { my ( $self, @spec ) = @_; my $cursor = undef; if ($self->can('supported_features')) { $cursor = $self->supported_features; # traverse the feature list, for (@spec) { #die "bad feature spec: @spec" if ref($cursor) ne "HASH"; return if ref($cursor) ne "HASH"; $cursor = $cursor->{$_}; } } return $cursor; } ## REQUIRED. ## get should return the value of the field specified as it's single argument from the underlying ## user object. This is here to provide a simple, standard way of accessing individual elements of a user ## object - ensuring no overlap between C::P::A::User methods and actual fieldnames. ## this is not the most effecient method, since it uses introspection. If you have an underlying object ## you most likely want to write this yourself. sub get { my ($self, $field) = @_; my $object; if ($object = $self->get_object and $object->can($field)) { return $object->$field(); } else { return undef; } } ## REQUIRED. ## get_object should return the underlying user object. This is for when more advanced uses of the ## user is required. Modifications to the existing user, etc. Changes in the object returned ## by this routine may not be reflected in the C::P::A::User object - if this is required, re-authenticating ## the user is probably the best route to take. ## note that it is perfectly acceptable to return $self in cases where there is no underlying object. sub get_object { return shift; } ## obj is shorthand for get_object. This is originally from the DBIx::Class store, but ## as it has become common usage, this makes things more compatible. Plus, it's shorter. sub obj { my $self = shift; return $self->get_object(@_); } sub AUTOLOAD { my $self = shift; (my $method) = (our $AUTOLOAD =~ /([^:]+)$/); return if $method eq "DESTROY"; my $obj = $self->obj; # Don't bother unless we have a backing object return if refaddr($obj) eq refaddr($self); $obj->$method(@_); } __PACKAGE__; __END__ =pod =head1 NAME Catalyst::Authentication::User - Base class for user objects. =head1 SYNOPSIS package MyStore::User; use base qw/Catalyst::Authentication::User/; =head1 DESCRIPTION This is the base class for authentication user objects. THIS IS NOT A COMPLETE CLASS! it is intended to provide base functionality only. It provides the base methods listed below, and any additional methods are proxied onto the user object fetched from the underlieing store. =head1 NOTES TO STORE IMPLEMENTORS Please read the comments in the source code of this class to work out which methods you should override. =head1 METHODS =head2 id( ) A unique ID by which a user can be retrieved from the store. =head2 store( ) Should return a class name that can be used to refetch the user using it's ID. =head2 supports( ) An introspection method used to determine what features a user object has, to support credential and authorization plugins. =head2 get( $field ) Returns the value for the $field provided. =head2 get_object( ) Returns the underlying object storing the user data. The return value of this method will vary depending on the storage module used. =head2 obj( ) Shorthand for get_object( ) =head2 AUTOLOAD Delegates any unknown methods onto the user object returned by ->obj =cut Catalyst-Plugin-Authentication-0.10024/lib/Catalyst/Authentication/Credential/0000755000000000000000000000000014703760553026131 5ustar00rootwheelCatalyst-Plugin-Authentication-0.10024/lib/Catalyst/Authentication/Credential/NoPassword.pm0000644000000000000000000000335014703760420030560 0ustar00rootwheelpackage Catalyst::Authentication::Credential::NoPassword; use Moose; use utf8; has 'realm' => (is => 'ro', required => 1); around BUILDARGS => sub { my $orig = shift; my $class = shift; if ( @_ == 3 ) { my ($config, $app, $realm) = @_; return $class->$orig( realm => $realm ); } else { return $class->$orig(@_); } }; sub authenticate { my ($self, $c, $realm, $authinfo) = @_; $self->realm->find_user($authinfo, $c); } 1; __END__ =head1 NAME Catalyst::Authentication::Credential::NoPassword - Authenticate a user without a password. =head1 SYNOPSIS use Catalyst qw/ Authentication /; package MyApp::Controller::Auth; sub login_as_another_user : Local { my ($self, $c) = @_; if ($c->user_exists() and $c->user->username() eq 'root') { $c->authenticate( {id => c->req->params->{user_id}}, 'nopassword' ); } } =head1 DESCRIPTION This authentication credential checker takes authentication information (most often a username) and retrieves the user from the store. No validation of any credentials is done. This is intended for administrative backdoors, SAML logins and so on when you have identified the new user by other means. =head1 CONFIGURATION # example class = NoPassword class = DBIx::Class user_model = DB::User role_relation = roles role_field = name =head1 METHODS =head2 authenticate ( $c, $realm, $authinfo ) Try to log a user in. =cut Catalyst-Plugin-Authentication-0.10024/lib/Catalyst/Authentication/Credential/Remote.pm0000644000000000000000000003072614703760420027723 0ustar00rootwheelpackage Catalyst::Authentication::Credential::Remote; use Moose; use namespace::autoclean; with 'MooseX::Emulate::Class::Accessor::Fast'; use Try::Tiny qw/ try catch /; __PACKAGE__->mk_accessors( qw/allow_re deny_re cutname_re source realm username_field/); sub new { my ( $class, $config, $app, $realm ) = @_; my $self = { }; bless $self, $class; # we are gonna compile regular expresions defined in config parameters # and explicitly throw an exception saying what parameter was invalid if (defined($config->{allow_regexp}) && ($config->{allow_regexp} ne "")) { try { $self->allow_re( qr/$config->{allow_regexp}/ ) } catch { Catalyst::Exception->throw( "Invalid regular expression in ". "'allow_regexp' configuration parameter"); }; } if (defined($config->{deny_regexp}) && ($config->{deny_regexp} ne "")) { try { $self->deny_re( qr/$config->{deny_regexp}/ ) } catch { Catalyst::Exception->throw( "Invalid regular expression in ". "'deny_regexp' configuration parameter"); }; } if (defined($config->{cutname_regexp}) && ($config->{cutname_regexp} ne "")) { try { $self->cutname_re( qr/$config->{cutname_regexp}/ ) } catch { Catalyst::Exception->throw( "Invalid regular expression in ". "'cutname_regexp' configuration parameter"); }; } $self->source($config->{source} || 'REMOTE_USER'); $self->realm($realm); $self->username_field($config->{username_field} || 'username'); return $self; } sub authenticate { my ( $self, $c, $realm, $authinfo ) = @_; my $remuser; if ($self->source eq "REMOTE_USER") { if ($c->req->can('remote_user')) { # $c->req->remote_users was introduced in 5.80005; if not evailable we are # gonna use $c->req->user that is deprecated but more or less works as well $remuser = $c->req->remote_user; } # compatibility hack: elsif ($c->engine->can('env') && defined($c->engine->env)) { # BEWARE: $c->engine->env was broken prior 5.80005 $remuser = $c->engine->env->{REMOTE_USER}; } elsif ($c->req->can('user')) { # maybe show warning that we are gonna use DEPRECATED $req->user if (ref($c->req->user)) { # I do not know exactly when this happens but it happens Catalyst::Exception->throw( "Cannot get remote user from ". "\$c->req->user as it seems to be a reference not a string" ); } else { $remuser = $c->req->user; } } } elsif ($self->source =~ /^(SSL_CLIENT_.*|CERT_*|AUTH_USER)$/) { # if you are using 'exotic' webserver or if the user is # authenticated e.g via SSL certificate his name could be avaliable # in different variables # BEWARE: $c->engine->env was broken prior 5.80005 my $nam=$self->source; if ($c->request->can('env')) { $remuser = $c->request->env->{$nam}; } elsif ($c->engine->can('env')) { $remuser = $c->engine->env->{$nam}; } else { # this happens on Catalyst 5.80004 and before (when using FastCGI) Catalyst::Exception->throw( "Cannot handle parameter 'source=$nam'". " as running Catalyst engine has broken \$c->engine->env" ); } } else { Catalyst::Exception->throw( "Invalid value of 'source' parameter"); } return unless defined($remuser); return if ($remuser eq ""); # $authinfo hash can contain item username (it is optional) - if it is so # this username has to be equal to remote_user my $authuser = $authinfo->{username}; return if (defined($authuser) && ($authuser ne $remuser)); # handle deny / allow checks return if (defined($self->deny_re) && ($remuser =~ $self->deny_re)); return if (defined($self->allow_re) && ($remuser !~ $self->allow_re)); # if param cutname_regexp is specified we try to cut the final usename as a # substring from remote_user my $usr = $remuser; if (defined($self->cutname_re)) { if (($remuser =~ $self->cutname_re) && ($1 ne "")) { $usr = $1; } } $authinfo->{ $self->username_field } = $usr; my $user_obj = $realm->find_user( $authinfo, $c ); return ref($user_obj) ? $user_obj : undef; } 1; __END__ =pod =head1 NAME Catalyst::Authentication::Credential::Remote - Let the webserver (e.g. Apache) authenticate Catalyst application users =head1 SYNOPSIS # in your MyApp.pm __PACKAGE__->config( 'Plugin::Authentication' => { default_realm => 'remoterealm', realms => { remoterealm => { credential => { class => 'Remote', allow_regexp => '^(user.*|admin|guest)$', deny_regexp => 'test', }, store => { class => 'Null', # if you want to have some additional user attributes # like user roles, user full name etc. you can specify # here the store where you keep this data } }, }, }, ); # in your Controller/Root.pm you can implement "auto-login" in this way sub begin : Private { my ( $self, $c ) = @_; unless ($c->user_exists) { # authenticate() for this module does not need any user info # as the username is taken from $c->req->remote_user and # password is not needed unless ($c->authenticate( {} )) { # return 403 forbidden or kick out the user in other way }; } } # or you can implement in any controller an ordinary login action like this sub login : Global { my ( $self, $c ) = @_; $c->authenticate( {} ); } =head1 DESCRIPTION This module allows you to authenticate the users of your Catalyst application on underlaying webserver. The complete list of authentication method available via this module depends just on what your webserver (e.g. Apache, IIS, Lighttpd) is able to handle. Besides the common methods like HTTP Basic and Digest authentication you can also use sophisticated ones like so called "integrated authentication" via NTLM or Kerberos (popular in corporate intranet applications running in Windows Active Directory environment) or even the SSL authentication when users authenticate themself using their client SSL certificates. The main idea of this module is based on a fact that webserver passes the name of authenticated user into Catalyst application as REMOTE_USER variable (or in case of SSL client authentication in other variables like SSL_CLIENT_S_DN on Apache + mod_ssl) - from this point referenced as WEBUSER. This module simply takes this value - perfoms some optional checks (see below) - and if everything is OK the WEBUSER is declared as authenticated on Catalyst level. In fact this module does not perform any check for password or other credential; it simply believes the webserver that user was properly authenticated. =head1 CONFIG =head2 class This config item is B. B is part of the core L module, it contains the class name of the store to be used. The classname used for Credential. This is part of L and is the method by which Catalyst::Authentication::Credential::Remote is loaded as the credential validator. For this module to be used, this must be set to 'Remote'. =head2 source This config item is B - default is REMOTE_USER. B contains a name of a variable passed from webserver that contains the user identification. Supported values: REMOTE_USER, SSL_CLIENT_*, CERT_*, AUTH_USER B Support for using different variables than REMOTE_USER does not work properly with Catalyst 5.8004 and before (if you want details see source code). Note1: Apache + mod_ssl uses SSL_CLIENT_S_DN, SSL_CLIENT_S_DN_* etc. (has to be enabled by 'SSLOption +StdEnvVars') or you can also let Apache make a copy of this value into REMOTE_USER (Apache option 'SSLUserName SSL_CLIENT_S_DN'). Note2: Microsoft IIS uses CERT_SUBJECT, CERT_SERIALNUMBER etc. for storing info about client authenticated via SSL certificate. AUTH_USER on IIS seems to have the same value as REMOTE_USER (but there might be some differences I am not aware of). =head2 deny_regexp This config item is B - no default value. B contains a regular expression used for check against WEBUSER (see details below) =head2 allow_regexp This config item is B - no default value. B contains a regular expression used for check against WEBUSER. Allow/deny checking of WEBUSER values goes in this way: 1) If B is defined and WEBUSER matches deny_regexp then authentication FAILS otherwise continues with next step. If deny_regexp is not defined or is an empty string we skip this step. 2) If B is defined and WEBUSER matches allow_regexp then authentication PASSES otherwise FAILS. If allow_regexp is not defined or is an empty string we skip this step. The order deny-allow is fixed. =head2 cutname_regexp This config item is B - no default value. If param B is specified we try to cut the final usename passed to Catalyst application as a substring from WEBUSER. This is useful for example in case of SSL authentication when WEBUSER looks like this 'CN=john, OU=Unit Name, O=Company, C=CZ' - from this format we can simply cut pure usename by cutname_regexp set to 'CN=(.*), OU=Unit Name, O=Company, C=CZ'. Substring is always taken as '$1' regexp substring. If WEBUSER does not match cutname_regexp at all or if '$1' regexp substring is empty we pass the original WEBUSER value (without cutting) to Catalyst application. =head2 username_field This config item is B - default is I The key name in the authinfo hash that the user's username is mapped into. This is useful for using a store which requires a specific unusual field name for the username. The username is additionally mapped onto the I key. =head1 METHODS =head2 new ( $config, $app, $realm ) Instantiate a new Catalyst::Authentication::Credential::Remote object using the configuration hash provided in $config. In case of invalid value of any configuration parameter (e.g. invalid regular expression) throws an exception. =cut =head2 authenticate ( $realm, $authinfo ) Takes the username form WEBUSER set by webserver, performs additional checks using optional allow_regexp/deny_regexp configuration params, optionaly takes substring from WEBUSER and the sets the resulting value as a Catalyst username. =cut =head1 COMPATIBILITY It is B to use this module with Catalyst 5.80005 and above as previous versions have some bugs related to $c->engine->env and do not support $c->req->remote_user. This module tries some workarounds when it detects an older version and should work as well. =head1 USING WITH A REVERSE PROXY If you are using a reverse proxy, then the WEBUSER will not be directly accessible by the Catalyst server. To use remote authentication, you will have to modify the web server to set a header containing the WEBUSER. You would then need to modify the PSGI configuration to map the header back to the WEBUSER variable. For example, in Apache you would add the configuration RequestHeader unset X-Forwarded-User RewriteEngine On RewriteCond %{LA-U:REMOTE_USER} (.+) RewriteRule . - [E=RU:%1] RequestHeader set X-Forwarded-User %{RU}e You then need to create a Plack::Middleware module to map the header back to the WEBUSER: package Plack::Middleware::MyRemote; use parent qw( Plack::Middleware ); use Plack::Util; sub call { my ($self, $env) = @_; my $user = $env->{HTTP_X_FORWARDED_USER} // ""; $env->{REMOTE_USER} = $user if ($user && ($user ne '(null)')); my $res = $self->app->($env); return $res; } 1; Finally, you need to modify F to use the custom middleware: use strict; use warnings; use MyApp; use Plack::Builder; my $app = Drain->apply_default_middlewares(Drain->psgi_app); builder { enable "Plack::Middleware::MyRemote"; $app; }; =cut Catalyst-Plugin-Authentication-0.10024/lib/Catalyst/Authentication/Credential/Password.pm0000644000000000000000000002214414703760420030265 0ustar00rootwheelpackage Catalyst::Authentication::Credential::Password; use Moose; use namespace::autoclean; with 'MooseX::Emulate::Class::Accessor::Fast'; use Scalar::Util (); use Catalyst::Exception (); use Digest (); __PACKAGE__->mk_accessors(qw/_config realm/); sub new { my ($class, $config, $app, $realm) = @_; # Note _config is horrible back compat hackery! my $self = { _config => $config }; bless $self, $class; $self->realm($realm); $self->_config->{'password_field'} ||= 'password'; $self->_config->{'password_type'} ||= 'clear'; $self->_config->{'password_hash_type'} ||= 'SHA-1'; my $passwordtype = $self->_config->{'password_type'}; if (!grep /$passwordtype/, ('none', 'clear', 'hashed', 'salted_hash', 'crypted', 'self_check')) { Catalyst::Exception->throw(__PACKAGE__ . " used with unsupported password type: " . $self->_config->{'password_type'}); } return $self; } sub authenticate { my ( $self, $c, $realm, $authinfo ) = @_; ## because passwords may be in a hashed format, we have to make sure that we remove the ## password_field before we pass it to the user routine, as some auth modules use ## all data passed to them to find a matching user... my $userfindauthinfo = {%{$authinfo}}; delete($userfindauthinfo->{$self->_config->{'password_field'}}); my $user_obj = $realm->find_user($userfindauthinfo, $c); if (ref($user_obj)) { if ($self->check_password($user_obj, $authinfo)) { return $user_obj; } } else { $c->log->debug( 'Unable to locate user matching user info provided in realm: ' . $realm->name ) if $c->debug; return; } } sub check_password { my ( $self, $user, $authinfo ) = @_; if ($self->_config->{'password_type'} eq 'self_check') { return $user->check_password($authinfo->{$self->_config->{'password_field'}}); } else { return 1 if $self->_config->{'password_type'} eq 'none'; my $password = $authinfo->{$self->_config->{'password_field'}}; my $storedpassword = $user->get($self->_config->{'password_field'}); if ($self->_config->{'password_type'} eq 'clear') { # FIXME - Should we warn in the $storedpassword undef case, # as the user probably fluffed the config? return unless defined $storedpassword; return $password eq $storedpassword; } elsif ($self->_config->{'password_type'} eq 'crypted') { return $storedpassword eq crypt( $password, $storedpassword ); } elsif ($self->_config->{'password_type'} eq 'salted_hash') { require Crypt::SaltedHash; my $salt_len = $self->_config->{'password_salt_len'} ? $self->_config->{'password_salt_len'} : 0; return Crypt::SaltedHash->validate( $storedpassword, $password, $salt_len ); } elsif ($self->_config->{'password_type'} eq 'hashed') { my $d = Digest->new( $self->_config->{'password_hash_type'} ); $d->add( $self->_config->{'password_pre_salt'} || '' ); $d->add($password); $d->add( $self->_config->{'password_post_salt'} || '' ); my $computed = $d->clone()->digest; my $b64computed = $d->clone()->b64digest; return ( ( $computed eq $storedpassword ) || ( unpack( "H*", $computed ) eq $storedpassword ) || ( $b64computed eq $storedpassword) || ( $b64computed.'=' eq $storedpassword) ); } } } __PACKAGE__; __END__ =pod =head1 NAME Catalyst::Authentication::Credential::Password - Authenticate a user with a password. =head1 SYNOPSIS use Catalyst qw/ Authentication /; package MyApp::Controller::Auth; sub login : Local { my ( $self, $c ) = @_; $c->authenticate( { username => $c->req->param('username'), password => $c->req->param('password') }); } =head1 DESCRIPTION This authentication credential checker takes authentication information (most often a username) and a password, and attempts to validate the password provided against the user retrieved from the store. =head1 CONFIGURATION # example __PACKAGE__->config('Plugin::Authentication' => { default_realm => 'members', realms => { members => { credential => { class => 'Password', password_field => 'password', password_type => 'hashed', password_hash_type => 'SHA-1' }, ... The password module is capable of working with several different password encryption/hashing algorithms. The one the module uses is determined by the credential configuration. Those who have used L prior to the 0.10 release should note that the password field and type information is no longer part of the store configuration and is now part of the Password credential configuration. =over 4 =item class The classname used for Credential. This is part of L and is the method by which Catalyst::Authentication::Credential::Password is loaded as the credential validator. For this module to be used, this must be set to 'Password'. =item password_field The field in the user object that contains the password. This will vary depending on the storage class used, but is most likely something like 'password'. In fact, this is so common that if this is left out of the config, it defaults to 'password'. This field is obtained from the user object using the get() method. Essentially: $user->get('passwordfieldname'); B If the password_field is something other than 'password', you must be sure to use that same field name when calling $c->authenticate(). =item password_type This sets the password type. Often passwords are stored in crypted or hashed formats. In order for the password module to verify the plaintext password passed in, it must be told what format the password will be in when it is retreived from the user object. The supported options are: =over 8 =item none No password check is done. An attempt is made to retrieve the user based on the information provided in the $c->authenticate() call. If a user is found, authentication is considered to be successful. =item clear The password in user is in clear text and will be compared directly. =item self_check This option indicates that the password should be passed to the check_password() routine on the user object returned from the store. =item crypted The password in user is in UNIX crypt hashed format. =item salted_hash The password in user is in salted hash format, and will be validated using L. If this password type is selected, you should also provide the B config element to define the salt length. =item hashed If the user object supports hashed passwords, they will be used in conjunction with L. The following config elements affect the hashed configuration: =over 8 =item password_hash_type The hash type used, passed directly to L. =item password_pre_salt Any pre-salt data to be passed to L before processing the password. =item password_post_salt Any post-salt data to be passed to L after processing the password. =back =back =back =head1 USAGE The Password credential module is very simple to use. Once configured as indicated above, authenticating using this module is simply a matter of calling $c->authenticate() with an authinfo hashref that includes the B element. The password element should contain the password supplied by the user to be authenticated, in clear text. The other information supplied in the auth hash is ignored by the Password module, and simply passed to the auth store to be used to retrieve the user. An example call follows: if ($c->authenticate({ username => $username, password => $password} )) { # authentication successful } else { # authentication failed } =head1 METHODS There are no publicly exported routines in the Password module (or indeed in most credential modules.) However, below is a description of the routines required by L for all credential modules. =head2 new( $config, $app, $realm ) Instantiate a new Password object using the configuration hash provided in $config. A reference to the application is provided as the second argument. Note to credential module authors: new() is called during the application's plugin setup phase, which is before the application specific controllers are loaded. The practical upshot of this is that things like $c->model(...) will not function as expected. =head2 authenticate( $authinfo, $c ) Try to log a user in, receives a hashref containing authentication information as the first argument, and the current context as the second. =head2 check_password( ) =cut Catalyst-Plugin-Authentication-0.10024/lib/Catalyst/Authentication/Store.pod0000644000000000000000000001001214703760420025642 0ustar00rootwheel =head1 NAME Catalyst::Authentication::Store - All about authentication stores =head1 MULTIPLE BACKENDS B This is documentation for the old store system used in versions of L prior to 0.10. This is NOT how the new realm-based stores work. This is here for reference only. See L instead. =head1 OLD STORE DOCUMENTATION BELOW A key issue to understand about authentication stores is that there are potentially many of them. Each one is registered into the application, and has a name. For most applications, there is only one, and in this framework it is called 'default'. When you use a plugin, like use Catalyst qw/ Authentication Authentication::Store::Foo /; the Store plugins typically only act at setup time. They rarely do more than check out the configuration, and register e.g. Store::Foo, and set it as the default store. __PACKAGE__->default_auth_store( $store ); # the same as __PACKAGE__->register_auth_stores( default => $store ); =head1 WORKING WITH USERS All credential verifiers should accept either a user object, or a user ID. If a user ID is provided, then they will fetch the user object from the default store, and check against it. This should be pretty much DWIM all the time. When you need multiple authentication backends per application then you must fetch things yourself. For example: my $user = $c->get_auth_store("other_store")->get_user($id); $c->login( $user, $supplied_password ); Instead of just: $c->login( $id, $supplied_password ); which will go to the default store. =head1 WRITING A BACKEND Writing an authentication storage backend is a very simple matter. The only method you really need to support is C. This method should accept an arbitrary list of parameters (determined by you or the credential verifyer), and return an object inheriting L. For introspection purposes you can also define the C method. See below for optional features. This is not necessary, but might be in the future. =head2 Integrating with Catalyst::Plugin::Session If your users support sessions, your store should also define the C method. When the user object is saved in the session the C method is called, and that is used as the value in the session (typically a user id). The store is also saved in the hash. If C<< $user->store >> returns something registered, that store's name is used. If not, the user's class is used as if it were a store (and must also support C). =head2 Optional Features Each user has the C method. For example: $user->supports(qw/password clear/); should return a true value if this specific user has a clear text password. This is on a per user (not necessarily a per store) basis. To make assumptions about the store as a whole, $store->user_supports(qw/password clear/); is supposed to be the lowest common denominator. The standardization of these values is to be goverened by the community, typically defined by the credential verification plugins. =head2 Stores implying certain credentials Sometimes a store is agnostic to the credentials (DB storage, for example), but sometimes it isn't (like an Htpasswd file). If you are writing a backend that wraps around a module, like L wraps around L, it makes sense to delegate the credential checks. This particular example caused the following "feature" to be added: $user->supports(qw/password self_check/); =head2 Writing a plugin to go with the backend Typically the backend will do the heavy lifting, by registering a store. These plugins should look something like this: sub setup { my $c = shift; $c->default_auth_store( # a store can be an object or a class Catalyst::Authentication::Store::Foo::Backend->new( ... ) ); $c->NEXT::setup(@_); } Catalyst-Plugin-Authentication-0.10024/lib/Catalyst/Authentication/User/0000755000000000000000000000000014703760553024775 5ustar00rootwheelCatalyst-Plugin-Authentication-0.10024/lib/Catalyst/Authentication/User/Hash.pm0000644000000000000000000000601514703760420026211 0ustar00rootwheelpackage Catalyst::Authentication::User::Hash; use strict; use warnings; use base qw/Catalyst::Authentication::User/; sub new { my $class = shift; bless { ( @_ > 1 ) ? @_ : %{ $_[0] } }, $class; } sub AUTOLOAD { my $self = shift; ( my $key ) = ( our $AUTOLOAD =~ m/([^:]*)$/ ); $self->_accessor( $key, @_ ); } # this class effectively handles any method calls sub can { 1 } sub id { my $self = shift; $self->_accessor( "id", @_ ); } ## deprecated. Let the base class handle this. # sub store { # my $self = shift; # $self->_accessor( "store", @_ ) || ref $self; # } sub _accessor { my $self = shift; my $key = shift; if (@_) { my $arr = $self->{__hash_obj_key_is_array}{$key} = @_ > 1; $self->{$key} = $arr ? [@_] : shift; } my $data = $self->{$key}; ( $self->{__hash_obj_key_is_array}{$key} || $key =~ /roles/ ) ? @{ $data || [] } : $data; } ## password portion of this is no longer necessary, but here for backwards compatibility. my %features = ( password => { clear => ["password"], crypted => ["crypted_password"], hashed => [qw/hashed_password hash_algorithm/], self_check => undef, }, roles => ["roles"], session => 1, ); sub supports { my ( $self, @spec ) = @_; my $cursor = \%features; return 1 if @spec == 1 and exists $self->{ $spec[0] }; # traverse the feature list, for (@spec) { return if ref($cursor) ne "HASH"; $cursor = $cursor->{$_}; } if ( ref $cursor ) { die "bad feature spec: @spec" unless ref $cursor eq "ARRAY"; # check that all the keys required for a feature are in here foreach my $key (@$cursor) { return undef unless exists $self->{$key}; } return 1; } else { return $cursor; } } sub for_session { my $self = shift; return $self; # we serialize the whole user } sub from_session { my ( $self, $c, $user ) = @_; $user; } __PACKAGE__; __END__ =pod =head1 NAME Catalyst::Authentication::User::Hash - An easy authentication user object based on hashes. =head1 SYNOPSIS use Catalyst::Authentication::User::Hash; Catalyst::Authentication::User::Hash->new( password => "s3cr3t", ); =head1 DESCRIPTION This implementation of authentication user handles is supposed to go hand in hand with L. =head1 METHODS =head2 new( @pairs ) Create a new object with the key-value-pairs listed in the arg list. =head2 supports( ) Checks for existence of keys that correspond with features. =head2 for_session( ) Just returns $self, expecting it to be serializable. =head2 from_session( ) Just passes returns the unserialized object, hoping it's intact. =head2 AUTOLOAD( ) Accessor for the key whose name is the method. =head2 store( ) Accessors that override superclass's dying virtual methods. =head2 id( ) =head2 can( ) =head1 SEE ALSO L =cut Catalyst-Plugin-Authentication-0.10024/lib/Catalyst/Authentication/Realm.pm0000644000000000000000000003076414703760420025460 0ustar00rootwheelpackage Catalyst::Authentication::Realm; use Moose; use namespace::autoclean; with 'MooseX::Emulate::Class::Accessor::Fast'; use String::RewritePrefix; use Try::Tiny qw/ try catch /; __PACKAGE__->mk_accessors(qw/store credential name config/); ## Add use_session config item to realm. sub new { my ($class, $realmname, $config, $app) = @_; my $self = { config => $config }; bless $self, $class; $self->name($realmname); if (!exists($self->config->{'use_session'})) { if (exists($app->config->{'Plugin::Authentication'}{'use_session'})) { $self->config->{'use_session'} = $app->config->{'Plugin::Authentication'}{'use_session'}; } else { $self->config->{'use_session'} = 1; } } $app->log->debug("Setting up auth realm $realmname") if $app->debug; # use the Null store as a default - Don't complain if the realm class is being overridden, # as the new realm may behave differently. if( ! exists($config->{store}{class}) ) { $config->{store}{class} = '+Catalyst::Authentication::Store::Null'; if (! exists($config->{class})) { $app->log->debug( qq(No Store specified for realm "$realmname", using the Null store.) ); } } my $storeclass = $config->{'store'}{'class'}; ## follow catalyst class naming - a + prefix means a fully qualified class, otherwise it's ## taken to mean C::P::A::Store::(specifiedclass) $storeclass = String::RewritePrefix->rewrite({ '' => 'Catalyst::Authentication::Store::', '+' => '', }, $storeclass); # a little niceness - since most systems seem to use the password credential class, # if no credential class is specified we use password. $config->{credential}{class} ||= '+Catalyst::Authentication::Credential::Password'; my $credentialclass = $config->{'credential'}{'class'}; ## follow catalyst class naming - a + prefix means a fully qualified class, otherwise it's ## taken to mean C::A::Credential::(specifiedclass) $credentialclass = String::RewritePrefix->rewrite({ '' => 'Catalyst::Authentication::Credential::', '+' => '', }, $credentialclass); # if we made it here - we have what we need to load the classes ### BACKWARDS COMPATIBILITY - DEPRECATION WARNING: ### we must eval the ensure_class_loaded - because we might need to try the old-style ### ::Plugin:: module naming if the standard method fails. ## Note to self - catch second exception and bitch in detail? try { Catalyst::Utils::ensure_class_loaded( $credentialclass ); } catch { # If the file is missing, then try the old-style fallback, # but re-throw anything else for the user to deal with. die $_ unless /^Can't locate/; $app->log->warn( qq(Credential class "$credentialclass" not found, trying deprecated ::Plugin:: style naming. ) ); my $origcredentialclass = $credentialclass; $credentialclass =~ s/Catalyst::Authentication/Catalyst::Plugin::Authentication/; try { Catalyst::Utils::ensure_class_loaded( $credentialclass ); } catch { # Likewise this croak is useful if the second exception is also "not found", # but would be confusing if it's anything else. die $_ unless /^Can't locate/; Carp::croak "Unable to load credential class, " . $origcredentialclass . " OR " . $credentialclass . " in realm " . $self->name; }; }; try { Catalyst::Utils::ensure_class_loaded( $storeclass ); } catch { # If the file is missing, then try the old-style fallback, # but re-throw anything else for the user to deal with. die $_ unless /^Can't locate/; $app->log->warn( qq(Store class "$storeclass" not found, trying deprecated ::Plugin:: style naming. ) ); my $origstoreclass = $storeclass; $storeclass =~ s/Catalyst::Authentication/Catalyst::Plugin::Authentication/; try { Catalyst::Utils::ensure_class_loaded( $storeclass ); } catch { # Likewise this croak is useful if the second exception is also "not found", # but would be confusing if it's anything else. die $_ unless /^Can't locate/; Carp::croak "Unable to load store class, " . $origstoreclass . " OR " . $storeclass . " in realm " . $self->name; }; }; # BACKWARDS COMPATIBILITY - if the store class does not define find_user, we define it in terms # of get_user and add it to the class. this is because the auth routines use find_user, # and rely on it being present. (this avoids per-call checks) if (!$storeclass->can('find_user')) { no strict 'refs'; *{"${storeclass}::find_user"} = sub { my ($self, $info) = @_; my @rest = @{$info->{rest}} if exists($info->{rest}); $self->get_user($info->{id}, @rest); }; } ## a little cruft to stay compatible with some poorly written stores / credentials ## we'll remove this soon. if ($storeclass->can('new')) { $self->store($storeclass->new($config->{'store'}, $app, $self)); } else { $app->log->error("THIS IS DEPRECATED: $storeclass has no new() method - Attempting to use uninstantiated"); $self->store($storeclass); } if ($credentialclass->can('new')) { $self->credential($credentialclass->new($config->{'credential'}, $app, $self)); } else { $app->log->error("THIS IS DEPRECATED: $credentialclass has no new() method - Attempting to use uninstantiated"); $self->credential($credentialclass); } return $self; } sub find_user { my ( $self, $authinfo, $c ) = @_; my $res = $self->store->find_user($authinfo, $c); if (!$res) { if ($self->config->{'auto_create_user'} && $self->store->can('auto_create_user') ) { $res = $self->store->auto_create_user($authinfo, $c); } } elsif ($self->config->{'auto_update_user'} && $self->store->can('auto_update_user')) { $res = $self->store->auto_update_user($authinfo, $c, $res); } return $res; } sub authenticate { my ($self, $c, $authinfo) = @_; my $user = $self->credential->authenticate($c, $self, $authinfo); if (ref($user)) { $c->set_authenticated($user, $self->name); return $user; } else { return undef; } } sub user_is_restorable { my ($self, $c) = @_; return unless $c->can('session') and $self->config->{'use_session'} and $c->session_is_valid; return $c->session->{__user}; } sub restore_user { my ($self, $c, $frozen_user) = @_; $frozen_user ||= $self->user_is_restorable($c); return unless defined($frozen_user); my $user = $self->from_session( $c, $frozen_user ); if ($user) { $c->_user( $user ); # this sets the realm the user originated in. $user->auth_realm($self->name); } else { $self->failed_user_restore($c) || $c->error("Store claimed to have a restorable user, but restoration failed. Did you change the user's id_field?"); } return $user; } ## this occurs if there is a session but the thing the session refers to ## can not be found. Do what you must do here. ## Return true if you can fix the situation and find a user, false otherwise sub failed_user_restore { my ($self, $c) = @_; $self->remove_persisted_user($c); return; } sub persist_user { my ($self, $c, $user) = @_; if ( $c->can('session') and $self->config->{'use_session'} and $user->supports("session") ) { $c->session->{__user_realm} = $self->name; # we want to ask the store for a user prepared for the session. # but older modules split this functionality between the user and the # store. We try the store first. If not, we use the old method. if ($self->store->can('for_session')) { $c->session->{__user} = $self->store->for_session($c, $user); } else { $c->session->{__user} = $user->for_session; } } return $user; } sub remove_persisted_user { my ($self, $c) = @_; if ( $c->can('session') and $self->config->{'use_session'} and $c->session_is_valid ) { delete @{ $c->session }{qw/__user __user_realm/}; } } ## backwards compatibility - I don't think many people wrote realms since they ## have only existed for a short time - but just in case. sub save_user_in_session { my ( $self, $c, $user ) = @_; return $self->persist_user($c, $user); } sub from_session { my ($self, $c, $frozen_user) = @_; return $self->store->from_session($c, $frozen_user); } __PACKAGE__; __END__ =pod =head1 NAME Catalyst::Authentication::Realm - Base class for realm objects. =head1 DESCRIPTION =head1 CONFIGURATION =over 4 =item class By default this class is used by L for all realms. The class parameter allows you to choose a different class to use for this realm. Creating a new Realm class can allow for authentication methods that fall outside the normal credential/store methodology. =item auto_create_user Set this to true if you wish this realm to auto-create user accounts when the user doesn't exist (most useful for remote authentication schemes). =item auto_update_user Set this to true if you wish this realm to auto-update user accounts after authentication (most useful for remote authentication schemes). =item use_session Sets session usage for this particular realm - overriding the global use_sesion setting. =back =head1 METHODS =head2 new( $realmname, $config, $app ) Instantiantes this realm, plus the specified store and credential classes. =head2 store( ) Returns an instance of the store object for this realm. =head2 credential( ) Returns an instance of the credential object for this realm. =head2 find_user( $authinfo, $c ) Retrieves the user given the authentication information provided. This is most often called from the credential. The default realm class simply delegates this call the store object. If enabled, auto-creation and auto-updating of users is also handled here. =head2 authenticate( $c, $authinfo) Performs the authentication process for the current realm. The default realm class simply delegates this to the credential and sets the authenticated user on success. Returns the authenticated user object; =head1 USER PERSISTENCE The Realm class allows complete control over the persistance of users between requests. By default the realm attempts to use the Catalyst session system to accomplish this. By overriding the methods below in a custom Realm class, however, you can handle user persistance in any way you see fit. =head2 persist_user($c, $user) persist_user is the entry point for saving user information between requests in most cases this will utilize the session. By default this uses the catalyst session system to store the user by calling for_session on the active store. The user object must be a subclass of Catalyst::Authentication::User. If you have updated the user object, you must call persist_user again to ensure that the persisted user object reflects your updates. =head2 remove_persisted_user($c) Removes any persisted user data. By default, removes the user from the session. =head2 user_is_restorable( $c ) Returns whether there is a persisted user that may be restored. Returns a token used to restore the user. With the default session persistance it returns the raw frozen user information. =head2 restore_user($c, [$frozen_user]) Restores the user from the given frozen_user parameter, or if not provided, using the response from $self->user_is_restorable(); Uses $self->from_session() to decode the frozen user. =head2 failed_user_restore($c) If there is a session to restore, but the restore fails for any reason then this method is called. This method supplied just removes the persisted user, but can be overridden if required to have more complex logic (e.g. finding a the user by their 'old' username). =head2 from_session($c, $frozenuser ) Decodes the frozenuser information provided and returns an instantiated user object. By default, this call is delegated to $store->from_session(). =head2 save_user_in_session($c, $user) DEPRECATED. Use persist_user instead. (this simply calls persist_user) =cut Catalyst-Plugin-Authentication-0.10024/lib/Catalyst/Authentication/Realm/0000755000000000000000000000000014703760553025117 5ustar00rootwheelCatalyst-Plugin-Authentication-0.10024/lib/Catalyst/Authentication/Realm/Compatibility.pm0000644000000000000000000000153214703760420030260 0ustar00rootwheelpackage Catalyst::Authentication::Realm::Compatibility; use strict; use warnings; use base qw/Catalyst::Authentication::Realm/; ## very funky - the problem here is that we can't do real realm initialization ## but we need a real realm object to function. So - we kinda fake it - we ## create an empty object - sub new { my ($class, $realmname, $config, $app) = @_; my $self = { config => $config }; bless $self, $class; $self->config->{'use_session'} = $app->config->{'Plugin::Authentication'}{'use_session'} || '1'; $self->name($realmname); return $self; } __PACKAGE__; __END__ =pod =head1 NAME Catalyst::Authentication::Realm::Compatibility - Compatibility realm object =head1 DESCRIPTION An empty realm object for compatibility reasons. =head1 METHODS =head2 new( ) Returns a, basically empty, realm object. =cut Catalyst-Plugin-Authentication-0.10024/lib/Catalyst/Authentication/Realm/Progressive.pm0000644000000000000000000001261214703760420027760 0ustar00rootwheelpackage Catalyst::Authentication::Realm::Progressive; use Carp; use warnings; use strict; use base 'Catalyst::Authentication::Realm'; =head1 NAME Catalyst::Authentication::Realm::Progressive - Authenticate against multiple realms =head1 SYNOPSIS This Realm allows an application to use a single authenticate() call during which multiple realms are used and tried incrementally until one performs a successful authentication is accomplished. A simple use case is a Temporary Password that looks and acts exactly as a regular password. Without changing the authentication code, you can authenticate against multiple realms. Another use might be to support a legacy website authentication system, trying the current auth system first, and upon failure, attempting authentication against the legacy system. =head2 EXAMPLE If your application has multiple realms to authenticate, such as a temporary password realm and a normal realm, you can configure the progressive realm as the default, and configure it to iteratively call the temporary realm and then the normal realm. __PACKAGE__->config( 'Plugin::Authentication' => { default_realm => 'progressive', realms => { progressive => { class => 'Progressive', realms => [ 'temp', 'normal' ], # Modify the authinfo passed into authenticate by merging # these hashes into the realm's authenticate call: authinfo_munge => { normal => { 'type' => 'normal' }, temp => { 'type' => 'temporary' }, } }, normal => { credential => { class => 'Password', password_field => 'secret', password_type => 'hashed', password_hash_type => 'SHA-1', }, store => { class => 'DBIx::Class', user_model => 'Schema::Person::Identity', id_field => 'id', } }, temp => { credential => { class => 'Password', password_field => 'secret', password_type => 'hashed', password_hash_type => 'SHA-1', }, store => { class => 'DBIx::Class', user_model => 'Schema::Person::Identity', id_field => 'id', } }, } } ); Then, in your controller code, to attempt authentication against both realms you just have to do a simple authenticate call: if ( $c->authenticate({ id => $username, password => $password }) ) { if ( $c->user->type eq 'temporary' ) { # Force user to change password } } =head1 CONFIGURATION =over =item realms An array reference consisting of each realm to attempt authentication against, in the order listed. If the realm does not exist, calling authenticate will die. =item authinfo_munge A hash reference keyed by realm names, with values being hash references to merge into the authinfo call that is subsequently passed into the realm's authenticate method. This is useful if your store uses the same class for each realm, separated by some other token (in the L authinfo_mungesection, the 'realm' is a column on C that will be either 'temp' or 'local', to ensure the query to fetch the user finds the right Identity record for that realm. =back =head1 METHODS =head2 new ($realmname, $config, $app) Constructs an instance of this realm. =head2 authenticate This method iteratively calls each realm listed in the C configuration key. It returns after the first successful authentication call is done. =cut sub authenticate { my ( $self, $c, $authinfo ) = @_; my $realms = $self->config->{realms}; carp "No realms to authenticate against, check configuration" unless $realms; carp "Realms configuration must be an array reference" unless ref $realms eq 'ARRAY'; foreach my $realm_name ( @$realms ) { my $realm = $c->get_auth_realm( $realm_name ); carp "Unable to find realm: $realm_name, check configuration" unless $realm; my $auth = { %$authinfo }; $auth->{realm} ||= $realm->name; if ( my $info = $self->config->{authinfo_munge}->{$realm->name} ) { $auth = Catalyst::Utils::merge_hashes($auth, $info); } if ( my $obj = $realm->authenticate( $c, $auth ) ) { $c->set_authenticated( $obj, $realm->name ); return $obj; } } return; } ## we can not rely on inheriting new() because in this case we do not ## load a credential or store, which is what new() sets up in the ## standard realm. So we have to create our realm object, set our name ## and return $self in order to avoid nasty warnings. sub new { my ($class, $realmname, $config, $app) = @_; my $self = { config => $config }; bless $self, $class; $self->name($realmname); return $self; } =head1 AUTHORS J. Shirley C<< >> Jay Kuri C<< >> =head1 COPYRIGHT & LICENSE Copyright (c) 2008 the aforementioned authors. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =cut 1; Catalyst-Plugin-Authentication-0.10024/lib/Catalyst/Authentication/Store/0000755000000000000000000000000014703760553025153 5ustar00rootwheelCatalyst-Plugin-Authentication-0.10024/lib/Catalyst/Authentication/Store/Null.pm0000644000000000000000000000375614703760420026427 0ustar00rootwheelpackage Catalyst::Authentication::Store::Null; use Moose; use namespace::autoclean; with 'MooseX::Emulate::Class::Accessor::Fast'; use Catalyst::Authentication::User::Hash; __PACKAGE__->mk_accessors( qw( _config ) ); sub new { my ( $class, $config, $app, $realm ) = @_; bless { _config => $config }, $class; } sub for_session { my ( $self, $c, $user ) = @_; return $user; } sub from_session { my ( $self, $c, $user ) = @_; return $user; } sub find_user { my ( $self, $userinfo, $c ) = @_; return bless $userinfo, 'Catalyst::Authentication::User::Hash'; } sub user_supports { my $self = shift; Catalyst::Authentication::User::Hash->supports(@_); } 1; __END__ =pod =head1 NAME Catalyst::Authentication::Store::Null - Null authentication store =head1 SYNOPSIS use Catalyst qw( Authentication ); __PACKAGE__->config( 'Plugin::Authentication' => { default_realm => 'remote', realms => { remote => { credential => { class => 'TypeKey', key_url => 'http://example.com/regkeys.txt', }, store => { class => 'Null', } } } }); =head1 DESCRIPTION The Null store is a transparent store where any supplied user data is accepted. This is mainly useful for remotely authenticating credentials (e.g. TypeKey, OpenID) which may not be tied to any local storage. It also helps facilitate integration with the Session plugin. =head1 METHODS =head2 new( ) Creates a new instance of the store. =head2 for_session( ) Returns the user object passed to the method. =head2 from_session( ) Returns the user object passed to the method. =head2 find_user( ) Since this store isn't tied to any real set of users, this method just returns the user info bless as a L object. =head2 user_supports( ) Delegates to L. =cut Catalyst-Plugin-Authentication-0.10024/lib/Catalyst/Authentication/Store/Minimal.pm0000644000000000000000000001347614703760420027103 0ustar00rootwheelpackage Catalyst::Authentication::Store::Minimal; use Moose; use namespace::autoclean; with 'MooseX::Emulate::Class::Accessor::Fast'; use Scalar::Util qw( blessed ); __PACKAGE__->mk_accessors(qw/userhash userclass/); sub new { my ( $class, $config, $app, $realm) = @_; my $self = bless { userhash => $config->{'users'}, userclass => $config->{'user_class'} || "Catalyst::Authentication::User::Hash", }, $class; Catalyst::Utils::ensure_class_loaded( $self->userclass ); return $self; } sub from_session { my ( $self, $c, $id ) = @_; return $id if ref $id; $self->find_user( { id => $id } ); } ## this is not necessarily a good example of what find_user can do, since all we do is ## look up with the id anyway. find_user can be used to locate a user based on other ## combinations of data. See C::P::Authentication::Store::DBIx::Class for a better example sub find_user { my ( $self, $userinfo, $c ) = @_; my $id = $userinfo->{'id'}; $id ||= $userinfo->{'username'}; return unless exists $self->userhash->{$id}; my $user = $self->userhash->{$id}; if ( ref($user) eq "HASH") { $user->{id} ||= $id; return bless $user, $self->userclass; } elsif ( ref($user) && blessed($user) && $user->isa('Catalyst::Authentication::User::Hash')) { return $user; } else { Catalyst::Exception->throw( "The user '$id' must be a hash reference or an " . "object of class Catalyst::Authentication::User::Hash"); } return $user; } sub user_supports { my $self = shift; # choose a random user scalar keys %{ $self->userhash }; ( undef, my $user ) = each %{ $self->userhash }; $user->supports(@_); } ## Backwards compatibility # # This is a backwards compatible routine. get_user is specifically for loading a user by it's unique id # find_user is capable of doing the same by simply passing { id => $id } # no new code should be written using get_user as it is deprecated. sub get_user { my ( $self, $id ) = @_; $self->find_user({id => $id}); } __PACKAGE__; __END__ =pod =head1 NAME Catalyst::Authentication::Store::Minimal - Minimal authentication store =head1 SYNOPSIS # you probably just want Store::Minimal under most cases, # but if you insist you can instantiate your own store: use Catalyst::Authentication::Store::Minimal; use Catalyst qw/ Authentication /; __PACKAGE__->config( 'Plugin::Authentication' => { default_realm => 'members', realms => { members => { credential => { class => 'Password', password_field => 'password', password_type => 'clear' }, store => { class => 'Minimal', users => { bob => { password => "s00p3r", editor => 'yes', roles => [qw/edit delete/], }, william => { password => "s3cr3t", roles => [qw/comment/], } } } } } } ); =head1 DESCRIPTION This authentication store lets you create a very quick and dirty user database in your application's config hash. You will need to include the Authentication plugin, and at least one Credential plugin to use this Store. Credential::Password is reccommended. It's purpose is mainly for testing, and it should probably be replaced by a more "serious" store for production. The hash in the config, as well as the user objects/hashes are freely mutable at runtime. =head1 CONFIGURATION =over 4 =item class The classname used for the store. This is part of L and is the method by which Catalyst::Authentication::Store::Minimal is loaded as the user store. For this module to be used, this must be set to 'Minimal'. =item user_class The class used for the user object. If you don't specify a class name, the default L will be used. If you define your own class, it must inherit from L. =item users This is a simple hash of users, the keys are the usenames, and the values are hashrefs containing a password key/value pair, and optionally, a roles/list of role-names pair. If using roles, you will also need to add the Authorization::Roles plugin. See the SYNOPSIS for an example. =back =head1 METHODS There are no publicly exported routines in the Minimal store (or indeed in most authentication stores) However, below is a description of the routines required by L for all authentication stores. =head2 new( $config, $app, $realm ) Constructs a new store object, which uses the user element of the supplied config hash ref as it's backing structure. =head2 find_user( $authinfo, $c ) Keys the hash by the 'id' or 'username' element in the authinfo hash and returns the user. ... documentation fairy stopped here. ... If the return value is unblessed it will be blessed as L. =head2 from_session( $id ) Delegates to C. =head2 user_supports( ) Chooses a random user from the hash and delegates to it. =head2 get_user( ) Deprecated =head2 setup( ) =cut Catalyst-Plugin-Authentication-0.10024/Makefile.PL0000644000000000000000000000626314703760420020520 0ustar00rootwheeluse strict; use warnings; use 5.008001; my %META = ( name => 'Catalyst-Plugin-Authentication', license => 'perl_5', prereqs => { configure => { requires => { 'ExtUtils::MakeMaker' => 0, } }, test => { requires => { 'Test::More' => '0.88', 'Test::Fatal' => 0, }, }, runtime => { requires => { 'Catalyst::Runtime' => 0, 'MRO::Compat' => 0, 'Moose' => 0, 'MooseX::Emulate::Class::Accessor::Fast' => 0, 'namespace::autoclean' => 0, 'String::RewritePrefix' => 0, 'Try::Tiny' => 0, }, }, develop => { requires => { 'Test::Pod' => '1.14', 'Test::Pod::Coverage' => '1.04', 'Test::NoTabs' => 0, 'Test::EOL' => 0, 'Catalyst::Plugin::Session' => '0.10', 'Catalyst::Plugin::Session::State::Cookie' => 0, 'Digest::SHA' => 0, }, }, }, resources => { repository => { url => 'https://github.com/perl-catalyst/Catalyst-Plugin-Authentication.git', web => 'https://github.com/perl-catalyst/Catalyst-Plugin-Authentication', type => 'git', }, bugtracker => { web => 'https://rt.cpan.org/Public/Dist/Display.html?Name=Catalyst-Plugin-Authentication', mailto => 'bug-Catalyst-Plugin-Authentication@rt.cpan.org', }, license => [ 'http://dev.perl.org/licenses/' ], }, no_index => { directory => [ 't', 'xt' ] }, x_authority => 'cpan:BOBTFISH', ); my %MM_ARGS = (); ## BOILERPLATE ############################################################### require ExtUtils::MakeMaker; (do './maint/Makefile.PL.include' or die $@) unless -f 'META.yml'; # have to do this since old EUMM dev releases miss the eval $VERSION line my $eumm_version = eval $ExtUtils::MakeMaker::VERSION; my $mymeta = $eumm_version >= 6.57_02; my $mymeta_broken = $mymeta && $eumm_version < 6.57_07; ($MM_ARGS{NAME} = $META{name}) =~ s/-/::/g; ($MM_ARGS{VERSION_FROM} = "lib/$MM_ARGS{NAME}.pm") =~ s{::}{/}g; $META{license} = [ $META{license} ] if $META{license} && !ref $META{license}; $MM_ARGS{LICENSE} = $META{license}[0] if $META{license} && $eumm_version >= 6.30; $MM_ARGS{NO_MYMETA} = 1 if $mymeta_broken; $MM_ARGS{META_ADD} = { 'meta-spec' => { version => 2 }, %META } unless -f 'META.yml'; $MM_ARGS{PL_FILES} ||= {}; $MM_ARGS{NORECURS} = 1 if not exists $MM_ARGS{NORECURS}; for (qw(configure build test runtime)) { my $key = $_ eq 'runtime' ? 'PREREQ_PM' : uc $_.'_REQUIRES'; my $r = $MM_ARGS{$key} = { %{$META{prereqs}{$_}{requires} || {}}, %{delete $MM_ARGS{$key} || {}}, }; defined $r->{$_} or delete $r->{$_} for keys %$r; } $MM_ARGS{MIN_PERL_VERSION} = delete $MM_ARGS{PREREQ_PM}{perl} || 0; delete $MM_ARGS{MIN_PERL_VERSION} if $eumm_version < 6.47_01; $MM_ARGS{BUILD_REQUIRES} = {%{$MM_ARGS{BUILD_REQUIRES}}, %{delete $MM_ARGS{TEST_REQUIRES}}} if $eumm_version < 6.63_03; $MM_ARGS{PREREQ_PM} = {%{$MM_ARGS{PREREQ_PM}}, %{delete $MM_ARGS{BUILD_REQUIRES}}} if $eumm_version < 6.55_01; delete $MM_ARGS{CONFIGURE_REQUIRES} if $eumm_version < 6.51_03; ExtUtils::MakeMaker::WriteMakefile(%MM_ARGS); ## END BOILERPLATE ########################################################### Catalyst-Plugin-Authentication-0.10024/maint/0000755000000000000000000000000014703760553017656 5ustar00rootwheelCatalyst-Plugin-Authentication-0.10024/maint/Makefile.PL.include0000644000000000000000000000026314703760420023244 0ustar00rootwheelBEGIN { -e 'Distar' or system qw(git clone https://github.com/p5sagit/Distar.git) } use lib 'Distar/lib'; use Distar 0.001; author 'Yuval Kogman '; 1; Catalyst-Plugin-Authentication-0.10024/META.json0000644000000000000000000000422114703760554020167 0ustar00rootwheel{ "abstract" : "Infrastructure plugin for the Catalyst authentication framework.", "author" : [ "Yuval Kogman " ], "dynamic_config" : 1, "generated_by" : "ExtUtils::MakeMaker version 7.70, CPAN::Meta::Converter version 2.150010", "license" : [ "perl_5" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : 2 }, "name" : "Catalyst-Plugin-Authentication", "no_index" : { "directory" : [ "t", "xt" ] }, "prereqs" : { "build" : {}, "configure" : { "requires" : { "ExtUtils::MakeMaker" : "0" } }, "develop" : { "requires" : { "Catalyst::Plugin::Session" : "0.10", "Catalyst::Plugin::Session::State::Cookie" : "0", "Digest::SHA" : "0", "Test::EOL" : "0", "Test::NoTabs" : "0", "Test::Pod" : "1.14", "Test::Pod::Coverage" : "1.04" } }, "runtime" : { "requires" : { "Catalyst::Runtime" : "0", "MRO::Compat" : "0", "Moose" : "0", "MooseX::Emulate::Class::Accessor::Fast" : "0", "String::RewritePrefix" : "0", "Try::Tiny" : "0", "namespace::autoclean" : "0" } }, "test" : { "requires" : { "Test::Fatal" : "0", "Test::More" : "0.88" } } }, "release_status" : "stable", "resources" : { "bugtracker" : { "mailto" : "bug-Catalyst-Plugin-Authentication@rt.cpan.org", "web" : "https://rt.cpan.org/Public/Dist/Display.html?Name=Catalyst-Plugin-Authentication" }, "license" : [ "http://dev.perl.org/licenses/" ], "repository" : { "type" : "git", "url" : "https://github.com/perl-catalyst/Catalyst-Plugin-Authentication.git", "web" : "https://github.com/perl-catalyst/Catalyst-Plugin-Authentication" } }, "version" : "0.10024", "x_authority" : "cpan:BOBTFISH", "x_serialization_backend" : "JSON::PP version 4.16" }