Mojolicious-Plugin-Authentication-1.37000755001750001750 014060477376 20422 5ustar00jjatriajjatria000000000000Changes100644001750001750 1166114060477376 22023 0ustar00jjatriajjatria000000000000Mojolicious-Plugin-Authentication-1.37Revision history for Mojolicious-Plugin-Authentication 1.37 2021-06-10 22:07:08+01:00 Europe/London * Fixed: * Updated documentation to avoid references to 'over', which has been deprecated in Mojolicious 9.0. The documentation uses 'requires' instead (seeken) * Minor changes to the release process 1.36 2021-04-21 21:25:29 BST No changes from previous release 1.35 2021-03-03 21:33:37 GMT (TRIAL RELEASE) * Changes: * Moved dependency specification to cpanfile. * Distribution should now be installable from the repository as-is 1.34 2020-08-03 22:02:52+01:00 Europe/London (TRIAL RELEASE) * New: * Support async callbacks with "_p" appended 1.33 2018-04-22 00:05:05+01:00 Europe/London * Fixed: * Fixed some minor typos in the documentation (kberov) * Fixed a broken link in the project's metadata (fschlich) 1.32 2017-05-09 18:18:49+01:00 Europe/London * New: * The fail_render option now also accepts a code reference * Add contributor metadata for proper attribution. Names are matched with the ASCII names and emails on CPAN when available. If you spot a mistake or prefer something different, let me know! * POD is now tested as part of release cycle * Fixed: * Fixed an encoding error in POD 1.31 2017-05-09 00:46:25+01:00 Europe/London * Fixed: * Retroactively updated the change log... 1.30 2017-05-09 00:36:25+01:00 Europe/London * New: * The current user can be manually set by passing an argument to current_user (preaction) * Added a note in the documentation on possible namespace conflicts * Fixed: * Fixed an error that made the auto_validate key not behave as documented (jjatria) * Fixed the tests for Travis CI (preaction) * Fixed some typos in sample code (moltar) * Changes: * Simplified some of the conditional code in the distribution 1.29 2015-10-28 09:35:22+01:00 Europe/Berlin Implements new parameter to control response from routing via condition 1.28 2015-09-30 09:51:30+02:00 Europe/Paris Fix for bug that'd consider a defined-but-false return value from load_user/validate_user as a failed login/load attempt. (via carragom/github) 1.27 2015-06-16 21:28:06+07:00 Asia/Jakarta Merged pull requests fixing the documentation (bridge -> under) 1.26 2013-08-27 10:02:37 Asia/Jakarta Merged a pull request from kthakore that fixed the broken tests - thanks! Added 'auto_validate' option to extra data in authentication sub 1.24 2012-08-02 01:36:17 Asia/Jakarta Removed the example app until next release to resolve some RPM build issues, it will return in the next release 1.23 2012-07-03 13:56:38 Asia/Jakarta Issue #5 closed; the signed and authenticated conditions only worked if you indicated 'required' to be true, this got fixed. (Reported by SailingYYC) 1.22 2012-03-30 08:43:13 Asia/Jakarta Ed W contributed some more functionality and renamed some options and methods to make things a bit more sane. *NOTE*: The following options and methods have been deprecated: - The 'lazy' config option is now called 'autoload_user' - The 'user' helper is now called 'current_user' - The 'user_exists' helper is now called 'is_user_authenticated' Using these options and helpers will now generate deprecation warnings; they will be removed in the next release. 1.21 2012-01-11 08:33:07 Asia/Jakarta Ivo Welch was kind enough to send me his first ever Mojolicious application that demonstrates the usage of this module, and I've included it in the distribution. Changed the date on copyright notices to 2012 - how time flies! 1.20 2011-12-15 15:00:24 Asia/Jakarta Added "lazy_mode" and "signature_exists" along with some doc patches (meettya) 1.19 2011-09-25 21:26:38 Asia/Jakarta Added an 'extra_data' hashref to the authenticate method that will be passed to your registered callback, and merged in some documentation fixes courtesy of metaperl. 1.18 2011-07-27 01:15:43 Asia/Jakarta Fixed a bug for newer versions of Mojolicious that no longer send the same set of parameters to a hook Added the ability to pass extra data to the validate_user callback, it came up as a need in a project so ported it over 1.16 2011-06-04 18:29:01 Asia/Jakarta POD fixes and cleanup 1.15 2011-05-02 02:32:12 Asia/Jakarta Added a README.pod file for Github to display, since the "real" README is generated by Dist::Zilla 1.14 2011-04-30 00:39:11 Asia/Jakarta Code cleanup (memowe) 1.13 2011-04-25 17:49:13 Asia/Jakarta Added extra check on load_user and validate_user configuration options to make sure they're not only there, but they are actually code refs 1.12 2011-04-25 16:00:21 Asia/Jakarta A little bit of code cleanup, no major changes LICENSE100644001750001750 4367114060477376 21543 0ustar00jjatriajjatria000000000000Mojolicious-Plugin-Authentication-1.37This software is copyright (c) 2021 by Ben van Staveren. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. Terms 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) 2021 by Ben van Staveren. 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 Artistic License 1.0 --- This software is Copyright (c) 2021 by Ben van Staveren. This is free software, licensed under: The 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. - "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 ftp.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) accompany any non-standard executables with their corresponding Standard Version executables, giving the non-standard executables non-standard names, and clearly documenting 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. 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 whomever generated them, and may be sold commercially, and may be aggregated with this Package. 7. C or perl subroutines supplied by you and linked into this Package shall not be considered part of this Package. 8. The name of the Copyright Holder may not be used to endorse or promote products derived from this software without specific prior written permission. 9. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. The End META.yml100644001750001750 2702714060477376 22004 0ustar00jjatriajjatria000000000000Mojolicious-Plugin-Authentication-1.37--- abstract: 'A plugin to make authentication a bit easier' author: - 'Ben van Staveren ' build_requires: ExtUtils::MakeMaker: '0' File::Spec: '0' Test::More: '0.96' perl: '5.016' configure_requires: ExtUtils::MakeMaker: '0' perl: '5.016' dynamic_config: 0 generated_by: 'Dist::Zilla version 6.017, 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: Mojolicious-Plugin-Authentication no_index: directory: - eg - examples - inc - share - t - xt provides: Mojolicious::Plugin::Authentication: file: lib/Mojolicious/Plugin/Authentication.pm version: '1.37' requires: Exporter: '0' Mojolicious: '8.0' perl: '5.016' resources: bugtracker: https://github.com/benvanstaveren/Mojolicious-Plugin-Authentication/issues homepage: https://github.com/benvanstaveren/Mojolicious-Plugin-Authentication repository: https://github.com/benvanstaveren/Mojolicious-Plugin-Authentication.git version: '1.37' x_Dist_Zilla: perl: version: '5.034000' plugins: - class: Dist::Zilla::Plugin::NextRelease name: NextRelease version: '6.017' - class: Dist::Zilla::Plugin::ReadmeAnyFromPod config: Dist::Zilla::Role::FileWatcher: version: '0.006' name: MarkdownInBuild version: '0.163250' - class: Dist::Zilla::Plugin::Git::GatherDir config: Dist::Zilla::Plugin::GatherDir: exclude_filename: - LICENSE - META.json - Makefile.PL - README.md - cpanfile - dist.ini exclude_match: [] follow_symlinks: 0 include_dotfiles: 0 prefix: '' prune_directory: [] root: . Dist::Zilla::Plugin::Git::GatherDir: include_untracked: 0 name: '@Starter::Git/Git::GatherDir' version: '2.047' - class: Dist::Zilla::Plugin::MetaYAML name: '@Starter::Git/MetaYAML' version: '6.017' - class: Dist::Zilla::Plugin::MetaJSON name: '@Starter::Git/MetaJSON' version: '6.017' - class: Dist::Zilla::Plugin::License name: '@Starter::Git/License' version: '6.017' - class: Dist::Zilla::Plugin::PodSyntaxTests name: '@Starter::Git/PodSyntaxTests' version: '6.017' - class: Dist::Zilla::Plugin::Test::ReportPrereqs name: '@Starter::Git/Test::ReportPrereqs' version: '0.028' - class: Dist::Zilla::Plugin::Test::Compile config: Dist::Zilla::Plugin::Test::Compile: bail_out_on_fail: '0' fail_on_warning: author fake_home: 0 filename: xt/author/00-compile.t module_finder: - ':InstallModules' needs_display: 0 phase: develop script_finder: - ':PerlExecFiles' skips: [] switch: [] name: '@Starter::Git/Test::Compile' version: '2.058' - class: Dist::Zilla::Plugin::MakeMaker config: Dist::Zilla::Role::TestRunner: default_jobs: 1 name: '@Starter::Git/MakeMaker' version: '6.017' - class: Dist::Zilla::Plugin::Manifest name: '@Starter::Git/Manifest' version: '6.017' - class: Dist::Zilla::Plugin::PruneCruft name: '@Starter::Git/PruneCruft' version: '6.017' - class: Dist::Zilla::Plugin::ManifestSkip name: '@Starter::Git/ManifestSkip' version: '6.017' - class: Dist::Zilla::Plugin::RunExtraTests config: Dist::Zilla::Role::TestRunner: default_jobs: 1 name: '@Starter::Git/RunExtraTests' version: '0.029' - class: Dist::Zilla::Plugin::Git::Check config: Dist::Zilla::Plugin::Git::Check: untracked_files: die Dist::Zilla::Role::Git::DirtyFiles: allow_dirty: - Changes - dist.ini allow_dirty_match: [] changelog: Changes Dist::Zilla::Role::Git::Repo: git_version: 2.31.1 repo_root: . name: '@Starter::Git/Git::Check' version: '2.047' - class: Dist::Zilla::Plugin::RewriteVersion config: Dist::Zilla::Plugin::RewriteVersion: add_tarball_name: 0 finders: - ':ExecFiles' - ':InstallModules' global: 0 skip_version_provider: 0 name: '@Starter::Git/RewriteVersion' version: '0.018' - class: Dist::Zilla::Plugin::NextRelease name: '@Starter::Git/NextRelease' version: '6.017' - class: Dist::Zilla::Plugin::CopyFilesFromRelease config: Dist::Zilla::Plugin::CopyFilesFromRelease: filename: - LICENSE - META.json - Makefile.PL - README.md match: [] name: '@Starter::Git/CopyFilesFromRelease' version: '0.007' - class: Dist::Zilla::Plugin::Regenerate::AfterReleasers config: Dist::Zilla::Plugin::Regenerate::AfterReleasers: plugins: - '@Starter::Git/CopyFilesFromRelease' Dist::Zilla::Role::Regenerator: $Dist::Zilla::Role::Regenerator::VERSION: '0.001002' name: '@Starter::Git/Regenerate::AfterReleasers' version: '0.001002' - class: Dist::Zilla::Plugin::Git::Commit config: Dist::Zilla::Plugin::Git::Commit: add_files_in: - / commit_msg: 'Release v%V%t' signoff: '0' Dist::Zilla::Role::Git::DirtyFiles: allow_dirty: - Changes - LICENSE - META.json - Makefile.PL - README.md - dist.ini allow_dirty_match: [] changelog: Changes Dist::Zilla::Role::Git::Repo: git_version: 2.31.1 repo_root: . Dist::Zilla::Role::Git::StringFormatter: time_zone: local name: '@Starter::Git/Release_Commit' version: '2.047' - class: Dist::Zilla::Plugin::Git::Tag config: Dist::Zilla::Plugin::Git::Tag: branch: ~ changelog: Changes signed: 0 tag: '1.37' tag_format: '%v' tag_message: '' Dist::Zilla::Role::Git::Repo: git_version: 2.31.1 repo_root: . Dist::Zilla::Role::Git::StringFormatter: time_zone: local name: '@Starter::Git/Git::Tag' version: '2.047' - class: Dist::Zilla::Plugin::BumpVersionAfterRelease config: Dist::Zilla::Plugin::BumpVersionAfterRelease: finders: - ':ExecFiles' - ':InstallModules' global: 0 munge_makefile_pl: 1 name: '@Starter::Git/BumpVersionAfterRelease' version: '0.018' - class: Dist::Zilla::Plugin::Git::Commit config: Dist::Zilla::Plugin::Git::Commit: add_files_in: [] commit_msg: 'Release v%V%t' signoff: '0' Dist::Zilla::Role::Git::DirtyFiles: allow_dirty: - Changes - dist.ini allow_dirty_match: - (?^:^) changelog: Changes Dist::Zilla::Role::Git::Repo: git_version: 2.31.1 repo_root: . Dist::Zilla::Role::Git::StringFormatter: time_zone: local name: '@Starter::Git/Version_Bump_Commit' version: '2.047' - class: Dist::Zilla::Plugin::TestRelease name: '@Starter::Git/TestRelease' version: '6.017' - class: Dist::Zilla::Plugin::ConfirmRelease name: '@Starter::Git/ConfirmRelease' version: '6.017' - class: Dist::Zilla::Plugin::UploadToCPAN name: '@Starter::Git/UploadToCPAN' version: '6.017' - class: Dist::Zilla::Plugin::MetaConfig name: '@Starter::Git/MetaConfig' version: '6.017' - class: Dist::Zilla::Plugin::MetaNoIndex name: '@Starter::Git/MetaNoIndex' version: '6.017' - class: Dist::Zilla::Plugin::MetaProvides::Package config: Dist::Zilla::Plugin::MetaProvides::Package: finder_objects: - class: Dist::Zilla::Plugin::FinderCode name: '@Starter::Git/MetaProvides::Package/AUTOVIV/:InstallModulesPM' version: '6.017' include_underscores: 0 Dist::Zilla::Role::MetaProvider::Provider: $Dist::Zilla::Role::MetaProvider::Provider::VERSION: '2.002004' inherit_missing: '1' inherit_version: '1' meta_noindex: '1' Dist::Zilla::Role::ModuleMetadata: Module::Metadata: '1.000037' version: '0.006' name: '@Starter::Git/MetaProvides::Package' version: '2.004003' - class: Dist::Zilla::Plugin::ShareDir name: '@Starter::Git/ShareDir' version: '6.017' - class: Dist::Zilla::Plugin::ExecDir name: '@Starter::Git/ExecDir' version: '6.017' - class: Dist::Zilla::Plugin::MinimumPerl name: MinimumPerl version: '1.006' - class: Dist::Zilla::Plugin::Prereqs::FromCPANfile name: Prereqs::FromCPANfile version: '0.08' - class: Dist::Zilla::Plugin::GithubMeta name: GithubMeta version: '0.58' - class: Dist::Zilla::Plugin::Git::Contributors config: Dist::Zilla::Plugin::Git::Contributors: git_version: 2.31.1 include_authors: 0 include_releaser: 1 order_by: name paths: [] name: Git::Contributors version: '0.036' - class: Dist::Zilla::Plugin::FinderCode name: ':InstallModules' version: '6.017' - class: Dist::Zilla::Plugin::FinderCode name: ':IncModules' version: '6.017' - class: Dist::Zilla::Plugin::FinderCode name: ':TestFiles' version: '6.017' - class: Dist::Zilla::Plugin::FinderCode name: ':ExtraTestFiles' version: '6.017' - class: Dist::Zilla::Plugin::FinderCode name: ':ExecFiles' version: '6.017' - class: Dist::Zilla::Plugin::FinderCode name: ':PerlExecFiles' version: '6.017' - class: Dist::Zilla::Plugin::FinderCode name: ':ShareFiles' version: '6.017' - class: Dist::Zilla::Plugin::FinderCode name: ':MainModule' version: '6.017' - class: Dist::Zilla::Plugin::FinderCode name: ':AllFiles' version: '6.017' - class: Dist::Zilla::Plugin::FinderCode name: ':NoFiles' version: '6.017' - class: Dist::Zilla::Plugin::FinderCode name: '@Starter::Git/MetaProvides::Package/AUTOVIV/:InstallModulesPM' version: '6.017' zilla: class: Dist::Zilla::Dist::Builder config: is_trial: '0' version: '6.017' x_contributors: - 'Carlos Ramos ' - 'Chris Rohlfs ' - 'David Steinbrunner ' - 'Doug Bell ' - 'Ed J ' - 'Edward Wildgoose ' - 'Florian Schlichting ' - 'Hernan Lopes ' - 'Jose Joaquin Atria ' - 'Karpich Dmitry ' - 'Kartik Thakore ' - 'Krasimir Berov ' - 'Mirko Westermeier ' - 'Roman F. ' - 'Terrence Brannon ' x_generated_by_perl: v5.34.0 x_serialization_backend: 'YAML::Tiny version 1.73' x_spdx_expression: 'Artistic-1.0-Perl OR GPL-1.0-or-later' MANIFEST100644001750001750 56314060477376 21620 0ustar00jjatriajjatria000000000000Mojolicious-Plugin-Authentication-1.37# This file was automatically generated by Dist::Zilla::Plugin::Manifest v6.017. Changes LICENSE MANIFEST META.json META.yml Makefile.PL README.md lib/Mojolicious/Plugin/Authentication.pm t/00-load.t t/00-report-prereqs.dd t/00-report-prereqs.t t/01-functional.t t/02-functional_lazy.t t/03-current_user.t t/lib/TestUtils.pm xt/author/00-compile.t xt/author/pod-syntax.t README.md100644001750001750 2651514060477376 22013 0ustar00jjatriajjatria000000000000Mojolicious-Plugin-Authentication-1.37# NAME Mojolicious::Plugin::Authentication - A plugin to make authentication a bit easier # SYNOPSIS use Mojolicious::Plugin::Authentication; $self->plugin('Authentication' => { autoload_user => 1, session_key => 'wickedapp', load_user_p => sub { ... }, validate_user_p => sub { ... }, }); # ... $self->authenticate_p( 'username', 'password', { optional => 'extra data stuff' }, )->then(sub { my ($authenticated) = @_; if ($authenticated) { # ... } }); # or, synchronous style $self->plugin('Authentication' => { autoload_user => 1, session_key => 'wickedapp', load_user => sub { ... }, validate_user => sub { ... }, current_user_fn => 'user', # compatibility with old code }); my $authenticated = $self->authenticate( 'username', 'password', { optional => 'extra data stuff' }, ); if ($authenticated) { ... } # METHODS Like other Mojolicious plugins, loading this plugin will import some function helpers into the namespace of your application. This will not normally cause any trouble, but be aware that if you define methods with the same names as those below, you'll likely run into unexpected results. ## authenticate($username, $password, $extra\_data\_hashref) Authenticate will use the supplied `load_user` and `validate_user` subroutine refs to see whether a user exists with the given username and password, and will set up the session accordingly. Returns true when the user has been successfully authenticated, false otherwise. You can pass additional data along in the `extra_data` hashref, it will be passed to your `validate_user` subroutine as-is. If the extra data hash contains a key `auto_validate`, the value of that key will be used as the UID, and authenticate will not call your `validate_user` callback; this can be used when working with OAuth tokens or other authentication mechanisms that do not use a local username and password form. ## authenticate\_p($username, $password, $extra\_data\_hashref) As above, but instead of returning a value, returns a promise of same. Available even if only synchronous callbacks are provided as these will be "promisified". ## is\_user\_authenticated Returns true if current\_user() returns some valid object, false otherwise. ## is\_user\_authenticated\_p As above, but instead of returning a value, returns a promise of same. ## current\_user Returns the user object as it was returned from the supplied `load_user` subroutine ref. You can change the current user by passing it in, but be careful: This bypasses the authentication. This is useful if you have multiple ways to authenticate users and want to re-use authorization checks that use `current_user`. Note that the name of this helper can be changed with the `current_user_fn` field during initialisation (see [below](#configuration)). ## current\_user\_p As above, but instead of returning a value, returns a promise of same. ## reload\_user Flushes the current user object and then returns current\_user(). ## reload\_user\_p As above, but instead of returning a value, returns a promise of same. ## signature\_exists Returns true if uid signature exist on the client side (in cookies), false otherwise. Warning: non-secure check! Use this method only for a "fast & dirty" lookup to see if the client has the proper cookies. May be helpful in some cases (for example - in counting `guest`/`logged users` or for additional non-confidential information for `logged users` but not for `guest`). ## logout Removes the session data for authentication, and effectively logs a user out. Returns a true value, to allow for chaining. # CONFIGURATION The following options can be set for the plugin, (but the "REQUIRED" ones can be replaced with a promise-returning equivalent with `_p` appended to the key): - load\_user (REQUIRED) A coderef for user loading (see ["USER LOADING"](#user-loading)) - validate\_user (REQUIRED) A coderef for user validation (see ["USER VALIDATION"](#user-validation)) - session\_key (optional) The name of the session key - autoload\_user (optional) Turn on/off automatic loading of user data - user data can be loaded only if it be used. May reduce site latency in some cases. - current\_user\_fn (optional) Set the name for the `current_user()` helper function. `_p` will be appended for the asynchronous version. - fail\_render (optional) Specify what is to be rendered when the authenticated condition is not met. Set to a coderef which will be called with the following signature: sub { my ($routes, $controller, $captures, $required) = @_; ... return $hashref; } The return value of the subroutine will be ignored if it evaluates to false. If it returns a hash reference, it will be dereferenced and passed as-is to the controller's `render` function. If you return anything else, you are going to have a bad time. If set directly to a hash reference, that will be passed to `render` instead. In order to set the session expiry time, use the following in your startup routine: $app->plugin('authentication', { ... }); $app->sessions->default_expiration(86400); # set expiry to 1 day $app->sessions->default_expiration(3600); # set expiry to 1 hour # USER LOADING The coderef you pass to the load\_user configuration key has the following signature: sub { my ($app, $uid) = @_; ... return $user; } The uid is the value that was originally returned from the `validate_user` coderef. You must return either a user object (it can be a hashref, arrayref, or a blessed object) or undef. # USER VALIDATION User validation is what happens when we need to authenticate someone. The coderef you pass to the `validate_user` configuration key has the following signature: sub { my ($c, $username, $password, $extradata) = @_; ... return $uid; } You must return either a user id or undef. The user id can be numerical or a string. Do not return hashrefs, arrayrefs or objects, since the behaviour of this plugin could get a little bit on the odd side of weird if you do that. # EXAMPLES For a code example using this, see the `t/01-functional.t` and `t/02-functional_lazy.t` tests, it uses [Mojolicious::Lite](https://metacpan.org/pod/Mojolicious%3A%3ALite) and this plugin. # ROUTING VIA CONDITION This plugin also exports a routing condition you can use in order to limit access to certain documents to only authenticated users. $r->route('/foo')->requires(authenticated => 1)->to('mycontroller#foo'); my $authenticated_only = $r->route('/members') ->requires(authenticated => 1) ->to('members#index'); $authenticated_only->route('online')->to('members#online'); If someone is not authenticated, these routes will not be considered by the dispatcher and unless you have set up a catch-all route, a 404 Not Found will be generated instead. And another condition for fast and unsecured checking for users, having a signature (without validating it). This method just checks client cookies for uid data existing. $r->route('/foo')->requires(signed => 1)->to('mycontroller#foo'); This behavior is similar to the "authenticated" condition. Prior to Mojolicious 9, use "over" instead of "requires." # ROUTING VIA CALLBACK If you want to be able to send people to a login page, you will have to use the following: my $members_only = $r->route('/members')->to(cb => sub { my $self = shift; $self->redirect_to('/login') and return 0 unless($self->is_user_authenticated); return 1; }); $members_only->route('online')->to('members#online'); Lazy and unsecured methods: my $members_only = $r->route('/unimportant')->to(cb => sub { my $self = shift; $self->redirect_to('/login') and return 0 unless($self->signature_exists); return 1; }); $members_only->route('pages')->to('unimportant#pages'); # ROUTING VIA BRIDGE If you want to be able to send people to a login page, you will have to use the following: my $auth_bridge = $r->under('/members')->to('auth#check'); # only visible to logged in users $auth_bridge->route('/list')->to('members#list'); And in your Auth controller you would put: sub check { my $self = shift; $self->redirect_to('/login') and return 0 unless($self->is_user_authenticated); return 1; }; Lazy and unsecured methods: sub check { my $self = shift; $self->redirect_to('/login') and return 0 unless($self->signature_exists); return 1; }; # SEE ALSO - [Mojolicious::Sessions](https://metacpan.org/pod/Mojolicious%3A%3ASessions) - [Mojocast 3: Authentication](http://mojocasts.com/e3#) # AUTHOR - Ben van Staveren, `` - José Joaquín Atria, `` # BUGS / CONTRIBUTING Please report any bugs or feature requests through the web interface at [https://github.com/benvanstaveren/mojolicious-plugin-authentication/issues](https://github.com/benvanstaveren/mojolicious-plugin-authentication/issues). # SUPPORT You can find documentation for this module with the perldoc command. perldoc Mojolicious::Plugin::Authentication You can also look for information at: - AnnoCPAN: Annotated CPAN documentation [http://annocpan.org/dist/Mojolicious-Plugin-Authentication](http://annocpan.org/dist/Mojolicious-Plugin-Authentication) - CPAN Ratings [http://cpanratings.perl.org/d/Mojolicious-Plugin-Authentication](http://cpanratings.perl.org/d/Mojolicious-Plugin-Authentication) - Search CPAN [http://search.cpan.org/dist/Mojolicious-Plugin-Authentication/](http://search.cpan.org/dist/Mojolicious-Plugin-Authentication/) # ACKNOWLEDGEMENTS Andrew Parker - For pointing out some bugs that crept in; a silent reminder not to code while sleepy Mirko Westermeier (memowe) - For doing some (much needed) code cleanup Terrence Brannon (metaperl) - Documentation patches Karpich Dmitry (meettya) - `lazy_mode` and `signature_exists` functionality, including a test and documentation Ivo Welch - For donating his first ever Mojolicious application that shows an example of how to use this module Ed Wildgoose (ewildgoose) - Adding the `current_user()` functionality, as well as some method renaming to make things a bit more sane. Colin Cyr (SailingYYC) - For reporting an issue with routing conditions; I really should not code while sleepy, brainfarts imminent! Carlos Ramos (carragom) - For fixing the bug that'd consider an uid of 0 or "0" to be a problem Doug Bell (preaction) - For improving the Travis CI integration and enabling arguments for current\_user Roman F (moltar) - For fixing some pesky typos in sample code Hernan Lopes (hernan604) - For updating some deprecated method names in the documentation # LICENSE AND COPYRIGHT Copyright 2011-2021 Ben van Staveren. This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License. See http://dev.perl.org/licenses/ for more information. META.json100644001750001750 4344614060477376 22157 0ustar00jjatriajjatria000000000000Mojolicious-Plugin-Authentication-1.37{ "abstract" : "A plugin to make authentication a bit easier", "author" : [ "Ben van Staveren " ], "dynamic_config" : 0, "generated_by" : "Dist::Zilla version 6.017, CPAN::Meta::Converter version 2.150010", "license" : [ "perl_5" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : 2 }, "name" : "Mojolicious-Plugin-Authentication", "no_index" : { "directory" : [ "eg", "examples", "inc", "share", "t", "xt" ] }, "prereqs" : { "configure" : { "requires" : { "ExtUtils::MakeMaker" : "0", "perl" : "5.016" } }, "develop" : { "recommends" : { "Test::CheckManifest" : "1.31" }, "requires" : { "File::Spec" : "0", "IO::Handle" : "0", "IPC::Open3" : "0", "Test::CPAN::Changes" : "0.400002", "Test::More" : "0", "Test::Pod" : "1.41" } }, "runtime" : { "requires" : { "Exporter" : "0", "Mojolicious" : "8.0", "perl" : "5.016" } }, "test" : { "recommends" : { "CPAN::Meta" : "2.120900" }, "requires" : { "ExtUtils::MakeMaker" : "0", "File::Spec" : "0", "Test::More" : "0.96", "perl" : "5.016" } } }, "provides" : { "Mojolicious::Plugin::Authentication" : { "file" : "lib/Mojolicious/Plugin/Authentication.pm", "version" : "1.37" } }, "release_status" : "stable", "resources" : { "bugtracker" : { "web" : "https://github.com/benvanstaveren/Mojolicious-Plugin-Authentication/issues" }, "homepage" : "https://github.com/benvanstaveren/Mojolicious-Plugin-Authentication", "repository" : { "type" : "git", "url" : "https://github.com/benvanstaveren/Mojolicious-Plugin-Authentication.git", "web" : "https://github.com/benvanstaveren/Mojolicious-Plugin-Authentication" } }, "version" : "1.37", "x_Dist_Zilla" : { "perl" : { "version" : "5.034000" }, "plugins" : [ { "class" : "Dist::Zilla::Plugin::NextRelease", "name" : "NextRelease", "version" : "6.017" }, { "class" : "Dist::Zilla::Plugin::ReadmeAnyFromPod", "config" : { "Dist::Zilla::Role::FileWatcher" : { "version" : "0.006" } }, "name" : "MarkdownInBuild", "version" : "0.163250" }, { "class" : "Dist::Zilla::Plugin::Git::GatherDir", "config" : { "Dist::Zilla::Plugin::GatherDir" : { "exclude_filename" : [ "LICENSE", "META.json", "Makefile.PL", "README.md", "cpanfile", "dist.ini" ], "exclude_match" : [], "follow_symlinks" : 0, "include_dotfiles" : 0, "prefix" : "", "prune_directory" : [], "root" : "." }, "Dist::Zilla::Plugin::Git::GatherDir" : { "include_untracked" : 0 } }, "name" : "@Starter::Git/Git::GatherDir", "version" : "2.047" }, { "class" : "Dist::Zilla::Plugin::MetaYAML", "name" : "@Starter::Git/MetaYAML", "version" : "6.017" }, { "class" : "Dist::Zilla::Plugin::MetaJSON", "name" : "@Starter::Git/MetaJSON", "version" : "6.017" }, { "class" : "Dist::Zilla::Plugin::License", "name" : "@Starter::Git/License", "version" : "6.017" }, { "class" : "Dist::Zilla::Plugin::PodSyntaxTests", "name" : "@Starter::Git/PodSyntaxTests", "version" : "6.017" }, { "class" : "Dist::Zilla::Plugin::Test::ReportPrereqs", "name" : "@Starter::Git/Test::ReportPrereqs", "version" : "0.028" }, { "class" : "Dist::Zilla::Plugin::Test::Compile", "config" : { "Dist::Zilla::Plugin::Test::Compile" : { "bail_out_on_fail" : 0, "fail_on_warning" : "author", "fake_home" : 0, "filename" : "xt/author/00-compile.t", "module_finder" : [ ":InstallModules" ], "needs_display" : 0, "phase" : "develop", "script_finder" : [ ":PerlExecFiles" ], "skips" : [], "switch" : [] } }, "name" : "@Starter::Git/Test::Compile", "version" : "2.058" }, { "class" : "Dist::Zilla::Plugin::MakeMaker", "config" : { "Dist::Zilla::Role::TestRunner" : { "default_jobs" : 1 } }, "name" : "@Starter::Git/MakeMaker", "version" : "6.017" }, { "class" : "Dist::Zilla::Plugin::Manifest", "name" : "@Starter::Git/Manifest", "version" : "6.017" }, { "class" : "Dist::Zilla::Plugin::PruneCruft", "name" : "@Starter::Git/PruneCruft", "version" : "6.017" }, { "class" : "Dist::Zilla::Plugin::ManifestSkip", "name" : "@Starter::Git/ManifestSkip", "version" : "6.017" }, { "class" : "Dist::Zilla::Plugin::RunExtraTests", "config" : { "Dist::Zilla::Role::TestRunner" : { "default_jobs" : 1 } }, "name" : "@Starter::Git/RunExtraTests", "version" : "0.029" }, { "class" : "Dist::Zilla::Plugin::Git::Check", "config" : { "Dist::Zilla::Plugin::Git::Check" : { "untracked_files" : "die" }, "Dist::Zilla::Role::Git::DirtyFiles" : { "allow_dirty" : [ "Changes", "dist.ini" ], "allow_dirty_match" : [], "changelog" : "Changes" }, "Dist::Zilla::Role::Git::Repo" : { "git_version" : "2.31.1", "repo_root" : "." } }, "name" : "@Starter::Git/Git::Check", "version" : "2.047" }, { "class" : "Dist::Zilla::Plugin::RewriteVersion", "config" : { "Dist::Zilla::Plugin::RewriteVersion" : { "add_tarball_name" : 0, "finders" : [ ":ExecFiles", ":InstallModules" ], "global" : 0, "skip_version_provider" : 0 } }, "name" : "@Starter::Git/RewriteVersion", "version" : "0.018" }, { "class" : "Dist::Zilla::Plugin::NextRelease", "name" : "@Starter::Git/NextRelease", "version" : "6.017" }, { "class" : "Dist::Zilla::Plugin::CopyFilesFromRelease", "config" : { "Dist::Zilla::Plugin::CopyFilesFromRelease" : { "filename" : [ "LICENSE", "META.json", "Makefile.PL", "README.md" ], "match" : [] } }, "name" : "@Starter::Git/CopyFilesFromRelease", "version" : "0.007" }, { "class" : "Dist::Zilla::Plugin::Regenerate::AfterReleasers", "config" : { "Dist::Zilla::Plugin::Regenerate::AfterReleasers" : { "plugins" : [ "@Starter::Git/CopyFilesFromRelease" ] }, "Dist::Zilla::Role::Regenerator" : { "$Dist::Zilla::Role::Regenerator::VERSION" : "0.001002" } }, "name" : "@Starter::Git/Regenerate::AfterReleasers", "version" : "0.001002" }, { "class" : "Dist::Zilla::Plugin::Git::Commit", "config" : { "Dist::Zilla::Plugin::Git::Commit" : { "add_files_in" : [ "/" ], "commit_msg" : "Release v%V%t", "signoff" : 0 }, "Dist::Zilla::Role::Git::DirtyFiles" : { "allow_dirty" : [ "Changes", "LICENSE", "META.json", "Makefile.PL", "README.md", "dist.ini" ], "allow_dirty_match" : [], "changelog" : "Changes" }, "Dist::Zilla::Role::Git::Repo" : { "git_version" : "2.31.1", "repo_root" : "." }, "Dist::Zilla::Role::Git::StringFormatter" : { "time_zone" : "local" } }, "name" : "@Starter::Git/Release_Commit", "version" : "2.047" }, { "class" : "Dist::Zilla::Plugin::Git::Tag", "config" : { "Dist::Zilla::Plugin::Git::Tag" : { "branch" : null, "changelog" : "Changes", "signed" : 0, "tag" : "1.37", "tag_format" : "%v", "tag_message" : "" }, "Dist::Zilla::Role::Git::Repo" : { "git_version" : "2.31.1", "repo_root" : "." }, "Dist::Zilla::Role::Git::StringFormatter" : { "time_zone" : "local" } }, "name" : "@Starter::Git/Git::Tag", "version" : "2.047" }, { "class" : "Dist::Zilla::Plugin::BumpVersionAfterRelease", "config" : { "Dist::Zilla::Plugin::BumpVersionAfterRelease" : { "finders" : [ ":ExecFiles", ":InstallModules" ], "global" : 0, "munge_makefile_pl" : 1 } }, "name" : "@Starter::Git/BumpVersionAfterRelease", "version" : "0.018" }, { "class" : "Dist::Zilla::Plugin::Git::Commit", "config" : { "Dist::Zilla::Plugin::Git::Commit" : { "add_files_in" : [], "commit_msg" : "Release v%V%t", "signoff" : 0 }, "Dist::Zilla::Role::Git::DirtyFiles" : { "allow_dirty" : [ "Changes", "dist.ini" ], "allow_dirty_match" : [ "(?^:^)" ], "changelog" : "Changes" }, "Dist::Zilla::Role::Git::Repo" : { "git_version" : "2.31.1", "repo_root" : "." }, "Dist::Zilla::Role::Git::StringFormatter" : { "time_zone" : "local" } }, "name" : "@Starter::Git/Version_Bump_Commit", "version" : "2.047" }, { "class" : "Dist::Zilla::Plugin::TestRelease", "name" : "@Starter::Git/TestRelease", "version" : "6.017" }, { "class" : "Dist::Zilla::Plugin::ConfirmRelease", "name" : "@Starter::Git/ConfirmRelease", "version" : "6.017" }, { "class" : "Dist::Zilla::Plugin::UploadToCPAN", "name" : "@Starter::Git/UploadToCPAN", "version" : "6.017" }, { "class" : "Dist::Zilla::Plugin::MetaConfig", "name" : "@Starter::Git/MetaConfig", "version" : "6.017" }, { "class" : "Dist::Zilla::Plugin::MetaNoIndex", "name" : "@Starter::Git/MetaNoIndex", "version" : "6.017" }, { "class" : "Dist::Zilla::Plugin::MetaProvides::Package", "config" : { "Dist::Zilla::Plugin::MetaProvides::Package" : { "finder_objects" : [ { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : "@Starter::Git/MetaProvides::Package/AUTOVIV/:InstallModulesPM", "version" : "6.017" } ], "include_underscores" : 0 }, "Dist::Zilla::Role::MetaProvider::Provider" : { "$Dist::Zilla::Role::MetaProvider::Provider::VERSION" : "2.002004", "inherit_missing" : 1, "inherit_version" : 1, "meta_noindex" : 1 }, "Dist::Zilla::Role::ModuleMetadata" : { "Module::Metadata" : "1.000037", "version" : "0.006" } }, "name" : "@Starter::Git/MetaProvides::Package", "version" : "2.004003" }, { "class" : "Dist::Zilla::Plugin::ShareDir", "name" : "@Starter::Git/ShareDir", "version" : "6.017" }, { "class" : "Dist::Zilla::Plugin::ExecDir", "name" : "@Starter::Git/ExecDir", "version" : "6.017" }, { "class" : "Dist::Zilla::Plugin::MinimumPerl", "name" : "MinimumPerl", "version" : "1.006" }, { "class" : "Dist::Zilla::Plugin::Prereqs::FromCPANfile", "name" : "Prereqs::FromCPANfile", "version" : "0.08" }, { "class" : "Dist::Zilla::Plugin::GithubMeta", "name" : "GithubMeta", "version" : "0.58" }, { "class" : "Dist::Zilla::Plugin::Git::Contributors", "config" : { "Dist::Zilla::Plugin::Git::Contributors" : { "git_version" : "2.31.1", "include_authors" : 0, "include_releaser" : 1, "order_by" : "name", "paths" : [] } }, "name" : "Git::Contributors", "version" : "0.036" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":InstallModules", "version" : "6.017" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":IncModules", "version" : "6.017" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":TestFiles", "version" : "6.017" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":ExtraTestFiles", "version" : "6.017" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":ExecFiles", "version" : "6.017" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":PerlExecFiles", "version" : "6.017" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":ShareFiles", "version" : "6.017" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":MainModule", "version" : "6.017" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":AllFiles", "version" : "6.017" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":NoFiles", "version" : "6.017" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : "@Starter::Git/MetaProvides::Package/AUTOVIV/:InstallModulesPM", "version" : "6.017" } ], "zilla" : { "class" : "Dist::Zilla::Dist::Builder", "config" : { "is_trial" : 0 }, "version" : "6.017" } }, "x_contributors" : [ "Carlos Ramos ", "Chris Rohlfs ", "David Steinbrunner ", "Doug Bell ", "Ed J ", "Edward Wildgoose ", "Florian Schlichting ", "Hernan Lopes ", "Jose Joaquin Atria ", "Karpich Dmitry ", "Kartik Thakore ", "Krasimir Berov ", "Mirko Westermeier ", "Roman F. ", "Terrence Brannon " ], "x_generated_by_perl" : "v5.34.0", "x_serialization_backend" : "Cpanel::JSON::XS version 4.26", "x_spdx_expression" : "Artistic-1.0-Perl OR GPL-1.0-or-later" } t000755001750001750 014060477376 20606 5ustar00jjatriajjatria000000000000Mojolicious-Plugin-Authentication-1.3700-load.t100644001750001750 12414060477376 22244 0ustar00jjatriajjatria000000000000Mojolicious-Plugin-Authentication-1.37/t#!perl -T use Test::More tests => 1; use_ok('Mojolicious::Plugin::Authentication'); Makefile.PL100644001750001750 235014060477376 22455 0ustar00jjatriajjatria000000000000Mojolicious-Plugin-Authentication-1.37# This file was automatically generated by Dist::Zilla::Plugin::MakeMaker v6.017. use strict; use warnings; use 5.016; use ExtUtils::MakeMaker; my %WriteMakefileArgs = ( "ABSTRACT" => "A plugin to make authentication a bit easier", "AUTHOR" => "Ben van Staveren ", "CONFIGURE_REQUIRES" => { "ExtUtils::MakeMaker" => 0 }, "DISTNAME" => "Mojolicious-Plugin-Authentication", "LICENSE" => "perl", "MIN_PERL_VERSION" => "5.016", "NAME" => "Mojolicious::Plugin::Authentication", "PREREQ_PM" => { "Exporter" => 0, "Mojolicious" => "8.0" }, "TEST_REQUIRES" => { "ExtUtils::MakeMaker" => 0, "File::Spec" => 0, "Test::More" => "0.96" }, "VERSION" => "1.37", "test" => { "TESTS" => "t/*.t" } ); my %FallbackPrereqs = ( "Exporter" => 0, "ExtUtils::MakeMaker" => 0, "File::Spec" => 0, "Mojolicious" => "8.0", "Test::More" => "0.96" ); unless ( eval { ExtUtils::MakeMaker->VERSION(6.63_03) } ) { delete $WriteMakefileArgs{TEST_REQUIRES}; delete $WriteMakefileArgs{BUILD_REQUIRES}; $WriteMakefileArgs{PREREQ_PM} = \%FallbackPrereqs; } delete $WriteMakefileArgs{CONFIGURE_REQUIRES} unless eval { ExtUtils::MakeMaker->VERSION(6.52) }; WriteMakefile(%WriteMakefileArgs); 01-functional.t100644001750001750 647214060477376 23524 0ustar00jjatriajjatria000000000000Mojolicious-Plugin-Authentication-1.37/t#!/usr/bin/env perl use strict; use warnings; # Disable IPv6, epoll and kqueue BEGIN { $ENV{MOJO_NO_IPV6} = $ENV{MOJO_POLL} = 1 } use Test::More; use Mojo::File qw(path); use lib path(qw(t lib)).""; use TestUtils qw(load_user_t validate_user_t load_user_t_p validate_user_t_p); # testing code starts here use Mojolicious::Lite; use Test::Mojo; plugin 'Authentication', { autoload_user => 1, load_user => \&load_user_t, validate_user => \&validate_user_t,, }; get '/' => sub { my $self = shift; $self->render(text => 'index page'); }; post '/login' => sub { my $self = shift; my $u = $self->req->param('u'); my $p = $self->req->param('p'); $self->render(text => ($self->authenticate($u, $p)) ? 'ok' : 'failed'); }; post '/login2' => sub { my $self = shift; my $u = $self->req->param('u'); my $p = $self->req->param('p'); $self->render(text => ($self->authenticate($u, $p, { 'ohnoes' => 'itsameme' })) ? 'ok' : 'failed'); }; get '/authonly' => sub { my $self = shift; $self->render(text => ($self->is_user_authenticated) ? 'authenticated' : 'not authenticated'); }; get '/condition/authonly' => (authenticated => 1) => sub { my $self = shift; $self->render(text => 'authenticated condition'); }; get '/logout' => sub { my $self = shift; $self->logout(); $self->render(text => 'logout'); }; my $t = Test::Mojo->new; $t->get_ok('/')->status_is(200)->content_is('index page'); $t->get_ok('/authonly')->status_is(200)->content_is('not authenticated'); $t->get_ok('/condition/authonly')->status_is(404); # let's try this $t->post_ok('/login' => form => { u => 'fnark', p => 'fnork' })->status_is(200)->content_is('failed'); $t->get_ok('/authonly')->status_is(200)->content_is('not authenticated'); $t->post_ok('/login' => form => { u => 'foo', p => 'bar' })->status_is(200)->content_is('ok'); $t->get_ok('/authonly')->status_is(200)->content_is('authenticated'); $t->get_ok('/condition/authonly')->status_is(200)->content_is('authenticated condition'); $t->get_ok('/logout')->status_is(200)->content_is('logout'); $t->get_ok('/authonly')->status_is(200)->content_is('not authenticated'); $t->post_ok('/login2' => form => { u => 'foo', p => 'bar' })->status_is(200)->content_is('ok'); $t->get_ok('/authonly')->status_is(200)->content_is('authenticated'); $t->get_ok('/condition/authonly')->status_is(200)->content_is('authenticated condition'); plugin 'Authentication', { autoload_user => 1, fail_render => { status => 401, json => { message => 'Unauthorized' } }, load_user => \&load_user_t, validate_user => \&validate_user_t, }; get '/condition/authonly' => (authenticated => 1) => sub { my $self = shift; $self->render(text => 'authenticated condition'); }; $t = Test::Mojo->new; $t->get_ok('/condition/authonly') ->status_is(401) ->json_is('/message' => 'Unauthorized'); plugin 'Authentication', { autoload_user => 1, fail_render => { status => 401, json => { message => 'Unauthorized' } }, load_user_p => \&load_user_t_p, validate_user_p => \&validate_user_t_p, }; get '/condition/authonly_p' => (authenticated => 1) => sub { my $self = shift; $self->render(text => 'authenticated condition'); }; $t->get_ok('/condition/authonly_p') ->status_is(401) ->json_is('/message' => 'Unauthorized'); done_testing; lib000755001750001750 014060477376 21354 5ustar00jjatriajjatria000000000000Mojolicious-Plugin-Authentication-1.37/tTestUtils.pm100644001750001750 161314060477376 24013 0ustar00jjatriajjatria000000000000Mojolicious-Plugin-Authentication-1.37/t/libuse strict; use warnings; use Exporter 'import'; use Mojo::Promise; our @EXPORT_OK = qw( load_user_t validate_user_t load_user_t_p validate_user_t_p ); sub load_user_t { my $self = shift; my $uid = shift; return { 'username' => 'foo', 'password' => 'bar', 'name' => 'Foo' } if ( $uid eq 'userid' ) || $uid eq 'useridwithextradata'; return undef; } sub validate_user_t { my $self = shift; my $username = shift || ''; my $password = shift || ''; my $extradata = shift || {}; return 'useridwithextradata' if($username eq 'foo' && $password eq 'bar' && ( $extradata->{'ohnoes'} || '' ) eq 'itsameme'); return 'userid' if($username eq 'foo' && $password eq 'bar'); return undef; } sub load_user_t_p { Mojo::Promise->resolve(load_user_t(@_)) } sub validate_user_t_p { Mojo::Promise->resolve(validate_user_t(@_)) } 03-current_user.t100644001750001750 350714060477376 24100 0ustar00jjatriajjatria000000000000Mojolicious-Plugin-Authentication-1.37/t#!/usr/bin/env perl use strict; use warnings; # Disable IPv6, epoll and kqueue BEGIN { $ENV{MOJO_NO_IPV6} = $ENV{MOJO_POLL} = 1 } use Test::More; use Mojo::File qw(path); use lib path(qw(t lib)).""; use TestUtils qw(load_user_t validate_user_t load_user_t_p validate_user_t_p); # testing code starts here use Mojolicious::Lite; use Test::Mojo; plugin 'Authentication', { autoload_user => 1, load_user => \&load_user_t, validate_user => \&validate_user_t, }; get '/other/endpoint' => sub { my $self = shift; $self->authenticate( 'foo', 'bar' ); $self->render( text => $self->current_user->{username} ); }; under '/api' => sub { my $self = shift; $self->current_user( { username => 'custom' } ); return 1; }; get '/endpoint' => sub { my $self = shift; $self->render( text => $self->current_user->{username} ); }; under '/'; # reset my $t = Test::Mojo->new; $t->get_ok( '/other/endpoint' )->status_is( 200 )->content_is( 'foo' ); $t->get_ok( '/api/endpoint' )->status_is( 200 )->content_is( 'custom' ); plugin 'Authentication', { autoload_user => 1, load_user_p => \&load_user_t_p, validate_user_p => \&validate_user_t_p, }; get '/other/endpoint_p' => sub { my $c = shift; $c->authenticate_p( 'foo', 'bar' ) ->then(sub { $c->current_user_p }) ->then(sub { $c->render( text => $_[0]->{username} ) }); }; under '/api_p' => sub { my $c = shift; $c->current_user_p( { username => 'custom' } )->then(sub { $c->continue }); return undef; }; get '/endpoint_p' => sub { my $c = shift; $c->current_user_p->then(sub { $c->render( text => $_[0]->{username} ); }); }; $t = Test::Mojo->new; $t->get_ok( '/other/endpoint_p' )->status_is( 200 )->content_is( 'foo' ); $t->get_ok( '/api_p/endpoint_p' )->status_is( 200 )->content_is( 'custom' ); done_testing; 00-report-prereqs.t100644001750001750 1345214060477376 24367 0ustar00jjatriajjatria000000000000Mojolicious-Plugin-Authentication-1.37/t#!perl use strict; use warnings; # This test was generated by Dist::Zilla::Plugin::Test::ReportPrereqs 0.028 use Test::More tests => 1; use ExtUtils::MakeMaker; use File::Spec; # from $version::LAX my $lax_version_re = qr/(?: undef | (?: (?:[0-9]+) (?: \. | (?:\.[0-9]+) (?:_[0-9]+)? )? | (?:\.[0-9]+) (?:_[0-9]+)? ) | (?: v (?:[0-9]+) (?: (?:\.[0-9]+)+ (?:_[0-9]+)? )? | (?:[0-9]+)? (?:\.[0-9]+){2,} (?:_[0-9]+)? ) )/x; # hide optional CPAN::Meta modules from prereq scanner # and check if they are available my $cpan_meta = "CPAN::Meta"; my $cpan_meta_pre = "CPAN::Meta::Prereqs"; my $HAS_CPAN_META = eval "require $cpan_meta; $cpan_meta->VERSION('2.120900')" && eval "require $cpan_meta_pre"; ## no critic # Verify requirements? my $DO_VERIFY_PREREQS = 1; sub _max { my $max = shift; $max = ( $_ > $max ) ? $_ : $max for @_; return $max; } sub _merge_prereqs { my ($collector, $prereqs) = @_; # CPAN::Meta::Prereqs object if (ref $collector eq $cpan_meta_pre) { return $collector->with_merged_prereqs( CPAN::Meta::Prereqs->new( $prereqs ) ); } # Raw hashrefs for my $phase ( keys %$prereqs ) { for my $type ( keys %{ $prereqs->{$phase} } ) { for my $module ( keys %{ $prereqs->{$phase}{$type} } ) { $collector->{$phase}{$type}{$module} = $prereqs->{$phase}{$type}{$module}; } } } return $collector; } my @include = qw( ); my @exclude = qw( ); # Add static prereqs to the included modules list my $static_prereqs = do './t/00-report-prereqs.dd'; # Merge all prereqs (either with ::Prereqs or a hashref) my $full_prereqs = _merge_prereqs( ( $HAS_CPAN_META ? $cpan_meta_pre->new : {} ), $static_prereqs ); # Add dynamic prereqs to the included modules list (if we can) my ($source) = grep { -f } 'MYMETA.json', 'MYMETA.yml'; my $cpan_meta_error; if ( $source && $HAS_CPAN_META && (my $meta = eval { CPAN::Meta->load_file($source) } ) ) { $full_prereqs = _merge_prereqs($full_prereqs, $meta->prereqs); } else { $cpan_meta_error = $@; # capture error from CPAN::Meta->load_file($source) $source = 'static metadata'; } my @full_reports; my @dep_errors; my $req_hash = $HAS_CPAN_META ? $full_prereqs->as_string_hash : $full_prereqs; # Add static includes into a fake section for my $mod (@include) { $req_hash->{other}{modules}{$mod} = 0; } for my $phase ( qw(configure build test runtime develop other) ) { next unless $req_hash->{$phase}; next if ($phase eq 'develop' and not $ENV{AUTHOR_TESTING}); for my $type ( qw(requires recommends suggests conflicts modules) ) { next unless $req_hash->{$phase}{$type}; my $title = ucfirst($phase).' '.ucfirst($type); my @reports = [qw/Module Want Have/]; for my $mod ( sort keys %{ $req_hash->{$phase}{$type} } ) { next if $mod eq 'perl'; next if grep { $_ eq $mod } @exclude; my $file = $mod; $file =~ s{::}{/}g; $file .= ".pm"; my ($prefix) = grep { -e File::Spec->catfile($_, $file) } @INC; my $want = $req_hash->{$phase}{$type}{$mod}; $want = "undef" unless defined $want; $want = "any" if !$want && $want == 0; my $req_string = $want eq 'any' ? 'any version required' : "version '$want' required"; if ($prefix) { my $have = MM->parse_version( File::Spec->catfile($prefix, $file) ); $have = "undef" unless defined $have; push @reports, [$mod, $want, $have]; if ( $DO_VERIFY_PREREQS && $HAS_CPAN_META && $type eq 'requires' ) { if ( $have !~ /\A$lax_version_re\z/ ) { push @dep_errors, "$mod version '$have' cannot be parsed ($req_string)"; } elsif ( ! $full_prereqs->requirements_for( $phase, $type )->accepts_module( $mod => $have ) ) { push @dep_errors, "$mod version '$have' is not in required range '$want'"; } } } else { push @reports, [$mod, $want, "missing"]; if ( $DO_VERIFY_PREREQS && $type eq 'requires' ) { push @dep_errors, "$mod is not installed ($req_string)"; } } } if ( @reports ) { push @full_reports, "=== $title ===\n\n"; my $ml = _max( map { length $_->[0] } @reports ); my $wl = _max( map { length $_->[1] } @reports ); my $hl = _max( map { length $_->[2] } @reports ); if ($type eq 'modules') { splice @reports, 1, 0, ["-" x $ml, "", "-" x $hl]; push @full_reports, map { sprintf(" %*s %*s\n", -$ml, $_->[0], $hl, $_->[2]) } @reports; } else { splice @reports, 1, 0, ["-" x $ml, "-" x $wl, "-" x $hl]; push @full_reports, map { sprintf(" %*s %*s %*s\n", -$ml, $_->[0], $wl, $_->[1], $hl, $_->[2]) } @reports; } push @full_reports, "\n"; } } } if ( @full_reports ) { diag "\nVersions for all modules listed in $source (including optional ones):\n\n", @full_reports; } if ( $cpan_meta_error || @dep_errors ) { diag "\n*** WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING ***\n"; } if ( $cpan_meta_error ) { my ($orig_source) = grep { -f } 'MYMETA.json', 'MYMETA.yml'; diag "\nCPAN::Meta->load_file('$orig_source') failed with: $cpan_meta_error\n"; } if ( @dep_errors ) { diag join("\n", "\nThe following REQUIRED prerequisites were not satisfied:\n", @dep_errors, "\n" ); } pass('Reported prereqs'); # vim: ts=4 sts=4 sw=4 et: 02-functional_lazy.t100644001750001750 747314060477376 24566 0ustar00jjatriajjatria000000000000Mojolicious-Plugin-Authentication-1.37/t#!/usr/bin/env perl use strict; use warnings; # Disable IPv6, epoll and kqueue BEGIN { $ENV{MOJO_NO_IPV6} = $ENV{MOJO_POLL} = 1 } use Mojo::File qw(path); use lib path(qw(t lib)).""; use TestUtils qw(load_user_t validate_user_t load_user_t_p validate_user_t_p); use Test::More; # testing code starts here use Mojolicious::Lite; use Test::Mojo; plugin 'Authentication', { autoload_user => 0, load_user => \&load_user_t, validate_user => \&validate_user_t, }; get '/' => sub { my $self = shift; $self->render( text => 'index page' ); }; post '/login' => sub { my $self = shift; my $u = $self->req->param('u'); my $p = $self->req->param('p'); $self->render( text => ( $self->authenticate( $u, $p ) ) ? 'ok' : 'failed' ); }; get '/authonly' => sub { my $self = shift; $self->render( text => ( $self->is_user_authenticated ) ? 'authenticated' : 'not authenticated' ); }; get '/condition/authonly' => ( authenticated => 1 ) => sub { my $self = shift; $self->render( text => 'authenticated condition' ); }; get '/authonly/lazy' => sub { my $self = shift; $self->render( text => ( $self->signature_exists ) ? 'sign authenticated' : 'sign not authenticated' ); }; get '/condition/authonly/lazy' => ( signed => 1 ) => sub { my $self = shift; $self->render( text => 'signed authenticated condition' ); }; get '/logout' => sub { my $self = shift; $self->logout(); $self->render( text => 'logout' ); }; get '/auto_validate' => sub { my $self = shift; eval { $self->authenticate( undef, undef, { auto_validate => 'userid' } ) }; if ($@) { $self->reply->exception( 'failed' ); } else { $self->render( text => 'ok' ); } }; my $t = Test::Mojo->new; $t->get_ok('/')->status_is(200)->content_is('index page'); $t->get_ok('/authonly/lazy')->status_is(200) ->content_is('sign not authenticated'); $t->get_ok('/condition/authonly/lazy')->status_is(404); # let's try this $t->post_ok( '/login' => form => { u => 'fnark', p => 'fnork' } )->status_is(200) ->content_is('failed'); $t->get_ok('/authonly')->status_is(200)->content_is('not authenticated'); $t->post_ok( '/login' => form => { u => 'foo', p => 'bar' } )->status_is(200) ->content_is('ok'); # try original auth in lazy mode $t->get_ok('/authonly')->status_is(200)->content_is('authenticated'); $t->get_ok('/condition/authonly')->status_is(200) ->content_is('authenticated condition'); # try lazy auth - is user just signed $t->get_ok('/authonly/lazy')->status_is(200)->content_is('sign authenticated'); $t->get_ok('/condition/authonly/lazy')->status_is(200) ->content_is('signed authenticated condition'); $t->get_ok('/logout')->status_is(200)->content_is('logout'); $t->get_ok('/authonly')->status_is(200)->content_is('not authenticated'); $t->get_ok('/authonly/lazy')->status_is(200) ->content_is('sign not authenticated'); $t->get_ok('/auto_validate')->status_is(200); plugin 'Authentication', { autoload_user => 0, load_user_p => \&load_user_t_p, validate_user_p => \&validate_user_t_p, }; post '/login_p' => sub { my $self = shift; my $u = $self->req->param('u'); my $p = $self->req->param('p'); $self->authenticate_p( $u, $p )->then(sub { $self->render( text => $_[0] ? 'ok' : 'failed' ); }); }; get '/authonly_p' => sub { my $self = shift; $self->is_user_authenticated_p->then(sub { $self->render( text => $_[0] ? 'authenticated' : 'not authenticated' ); }); }; $t = Test::Mojo->new; $t->post_ok( '/login_p' => form => { u => 'fnark', p => 'fnork' } )->status_is(200) ->content_is('failed'); $t->get_ok('/authonly_p')->status_is(200)->content_is('not authenticated'); $t->post_ok( '/login_p' => form => { u => 'foo', p => 'bar' } )->status_is(200) ->content_is('ok'); done_testing; author000755001750001750 014060477376 22300 5ustar00jjatriajjatria000000000000Mojolicious-Plugin-Authentication-1.37/xtpod-syntax.t100644001750001750 25214060477376 24712 0ustar00jjatriajjatria000000000000Mojolicious-Plugin-Authentication-1.37/xt/author#!perl # This file was automatically generated by Dist::Zilla::Plugin::PodSyntaxTests. use strict; use warnings; use Test::More; use Test::Pod 1.41; all_pod_files_ok(); 00-report-prereqs.dd100644001750001750 325514060477376 24473 0ustar00jjatriajjatria000000000000Mojolicious-Plugin-Authentication-1.37/tdo { my $x = { 'configure' => { 'requires' => { 'ExtUtils::MakeMaker' => '0', 'perl' => '5.016' } }, 'develop' => { 'recommends' => { 'Test::CheckManifest' => '1.31' }, 'requires' => { 'File::Spec' => '0', 'IO::Handle' => '0', 'IPC::Open3' => '0', 'Test::CPAN::Changes' => '0.400002', 'Test::More' => '0', 'Test::Pod' => '1.41' } }, 'runtime' => { 'requires' => { 'Exporter' => '0', 'Mojolicious' => '8.0', 'perl' => '5.016' } }, 'test' => { 'recommends' => { 'CPAN::Meta' => '2.120900' }, 'requires' => { 'ExtUtils::MakeMaker' => '0', 'File::Spec' => '0', 'Test::More' => '0.96', 'perl' => '5.016' } } }; $x; }00-compile.t100644001750001750 257114060477376 24477 0ustar00jjatriajjatria000000000000Mojolicious-Plugin-Authentication-1.37/xt/authoruse 5.006; use strict; use warnings; # this test was generated with Dist::Zilla::Plugin::Test::Compile 2.058 use Test::More; plan tests => 2; my @module_files = ( 'Mojolicious/Plugin/Authentication.pm' ); # no fake home requested my @switches = ( -d 'blib' ? '-Mblib' : '-Ilib', ); use File::Spec; use IPC::Open3; use IO::Handle; open my $stdin, '<', File::Spec->devnull or die "can't open devnull: $!"; my @warnings; for my $lib (@module_files) { # see L my $stderr = IO::Handle->new; diag('Running: ', join(', ', map { my $str = $_; $str =~ s/'/\\'/g; q{'} . $str . q{'} } $^X, @switches, '-e', "require q[$lib]")) if $ENV{PERL_COMPILE_TEST_DEBUG}; my $pid = open3($stdin, '>&STDERR', $stderr, $^X, @switches, '-e', "require q[$lib]"); binmode $stderr, ':crlf' if $^O eq 'MSWin32'; my @_warnings = <$stderr>; waitpid($pid, 0); is($?, 0, "$lib loaded ok"); shift @_warnings if @_warnings and $_warnings[0] =~ /^Using .*\bblib/ and not eval { +require blib; blib->VERSION('1.01') }; if (@_warnings) { warn @_warnings; push @warnings, @_warnings; } } is(scalar(@warnings), 0, 'no warnings found') or diag 'got warnings: ', ( Test::More->can('explain') ? Test::More::explain(\@warnings) : join("\n", '', @warnings) ); Plugin000755001750001750 014060477376 24643 5ustar00jjatriajjatria000000000000Mojolicious-Plugin-Authentication-1.37/lib/MojoliciousAuthentication.pm100644001750001750 4647614060477376 30361 0ustar00jjatriajjatria000000000000Mojolicious-Plugin-Authentication-1.37/lib/Mojolicious/Pluginuse warnings; use strict; package Mojolicious::Plugin::Authentication; our $VERSION = '1.37'; use Mojo::Base 'Mojolicious::Plugin'; use Mojo::Promise; sub register { my ($self, $app, $args) = @_; $args = { %{ $args || {} } }; # copy as mutating for my $cb_name (qw(load_user validate_user)) { my $p_name = $cb_name."_p"; die __PACKAGE__, ": missing '$cb_name' subroutine ref in parameters\n" unless grep ref eq 'CODE', @$args{$cb_name, $p_name}; $args->{$p_name} = sub { my @r = eval { $args->{$cb_name}->(@_) }; $@ ? Mojo::Promise->reject($@) : Mojo::Promise->resolve(@r); } if !$args->{$p_name}; } if (defined $args->{lazy}) { warn __PACKAGE__, ": the 'lazy' option is deprecated, ", "use 'autoload_user' instead\n"; $args->{autoload_user} = delete $args->{lazy}; } my $autoload_user = $args->{autoload_user} // 0; my $session_key = $args->{session_key} || 'auth_data'; my $our_stash_key = $args->{stash_key} || '__authentication__'; my $current_user_fn = $args->{current_user_fn} || 'current_user'; my $load_user_cb = $args->{load_user}; my $validate_user_cb = $args->{validate_user}; my $load_user_cb_p = $args->{load_user_p}; my $validate_user_cb_p= $args->{validate_user_p}; my $fail_render = ref $args->{fail_render} eq 'CODE' ? $args->{fail_render} : sub { $args->{fail_render} }; my $user_loader_sub = user_loader_closure( $our_stash_key, $session_key, $load_user_cb, ); my $user_loader_sub_p = user_loader_closure_p( $our_stash_key, $session_key, $load_user_cb_p, ); my $current_user = user_stash_extractor_closure( $our_stash_key, $user_loader_sub, ); my $current_user_p = user_stash_extractor_closure_p( $our_stash_key, $user_loader_sub_p, ); $app->helper(authenticate => authenticate_closure( $our_stash_key, $session_key, $validate_user_cb, $current_user, )); $app->helper(authenticate_p => authenticate_closure_p( $our_stash_key, $session_key, $validate_user_cb_p, $current_user_p, )); $app->hook(before_dispatch => $user_loader_sub_p) if $autoload_user; $app->routes->add_condition(authenticated => sub { my ($r, $c, $captures, $required) = @_; my $res = (!$required or $c->is_user_authenticated); unless ($res) { my $fail = $fail_render->(@_); $c->render(%{$fail}) if $fail; } return $res; }); $app->routes->add_condition(signed => sub { my ($r, $c, $captures, $required) = @_; return (!$required or $c->signature_exists); }); # deprecation handling $app->helper(user_exists => sub { warn __PACKAGE__, ": the 'user_exists' helper is deprecated, ", "use 'is_user_authenticated' instead\n"; return shift->is_user_authenticated(@_); }); $app->helper(user => sub { warn __PACKAGE__, ": the 'user' helper is deprecated, ", "use '$current_user_fn' instead\n"; return shift->$current_user_fn(@_); }); $app->helper(reload_user => sub { my $c = shift; # Clear stash to force a reload of the user object delete $c->stash->{$our_stash_key}; return $current_user->($c); }); $app->helper(reload_user_p => sub { my $c = shift; # Clear stash to force a reload of the user object delete $c->stash->{$our_stash_key}; return $current_user_p->($c); }); $app->helper(signature_exists => sub { my $c = shift; return !!$c->session($session_key); }); $app->helper(is_user_authenticated => sub { my $c = shift; return defined $current_user->($c); }); $app->helper(is_user_authenticated_p => sub { my $c = shift; $current_user_p->($c)->then(sub { return defined $_[0]; }); }); $app->helper($current_user_fn => $current_user); $app->helper($current_user_fn."_p" => $current_user_p); $app->helper(logout => sub { my $c = shift; delete $c->stash->{$our_stash_key}; delete $c->session->{$session_key}; return 1; }); } # Unconditionally load the user based on uid in session sub user_loader_closure { my ($our_stash_key, $session_key, $load_user_cb) = @_; sub { my $c = shift; my $uid = $c->session($session_key); return if !defined $uid; my $user = $load_user_cb->($c, $uid); if ($user) { $c->stash($our_stash_key => { user => $user }); } else { # cache result that user does not exist $c->stash($our_stash_key => { no_user => 1 }); } }; } sub user_loader_closure_p { my ($our_stash_key, $session_key, $load_user_cb_p) = @_; sub { my $c = shift; my $uid = $c->session($session_key); return Mojo::Promise->resolve if !defined $uid; $load_user_cb_p->($c, $uid)->then(sub { my $user = $_[0]; if ($user) { $c->stash($our_stash_key => { user => $user }); } else { # cache result that user does not exist $c->stash($our_stash_key => { no_user => 1 }); } }); }; } # Fetch the current user object from the stash - loading it if # not already loaded sub user_stash_extractor_closure { my ($our_stash_key, $user_loader_sub) = @_; sub { my ($c, $user) = @_; # Allow setting the current_user if ( defined $user ) { $c->stash($our_stash_key => { user => $user }); return; } my $stash = $c->stash($our_stash_key); $user_loader_sub->($c) unless $stash->{no_user} or defined $stash->{user}; $stash = $c->stash($our_stash_key); return $stash->{user}; }; } sub user_stash_extractor_closure_p { my ($our_stash_key, $user_loader_sub_p) = @_; sub { my ($c, $user) = @_; # Allow setting the current_user if ( defined $user ) { return Mojo::Promise->resolve->then(sub { $c->stash($our_stash_key => { user => $user }); }); } my $stash = $c->stash($our_stash_key); my $promise = ($stash->{no_user} or defined $stash->{user}) ? Mojo::Promise->resolve : $user_loader_sub_p->($c); $promise->then(sub { $stash = $c->stash($our_stash_key); return $stash->{user}; }); }; } sub authenticate_closure { my ($our_stash_key, $session_key, $validate_user_cb, $current_user) = @_; sub { my ($c, $user, $pass, $extradata) = @_; # if extradata contains "auto_validate", assume the passed username # is in fact valid, and auto_validate contains the uid; used for # OAuth and other stuff that does not work with usernames and # passwords; use this with extreme care if you must $extradata ||= {}; my $uid = $extradata->{auto_validate} // $validate_user_cb->($c, $user, $pass, $extradata); return undef if !defined $uid; $c->session($session_key => $uid); # Clear stash to force reload of any already loaded user object delete $c->stash->{$our_stash_key}; return 1 if defined $current_user->($c); return undef; }; } sub authenticate_closure_p { my ($our_stash_key, $session_key, $validate_user_cb_p, $current_user_p) = @_; sub { my ($c, $user, $pass, $extradata) = @_; $extradata ||= {}; my $promise = defined($extradata->{auto_validate}) ? Mojo::Promise->resolve($extradata->{auto_validate}) : $validate_user_cb_p->($c, $user, $pass, $extradata); $promise->then(sub { my ($uid) = @_; return undef if !defined $uid; $c->session($session_key => $uid); # Clear stash to force reload of any already loaded user object delete $c->stash->{$our_stash_key}; $current_user_p->($c); })->then(sub { defined $_[0] ? 1 : undef; }); }; } 1; __END__ =encoding UTF-8 =head1 NAME Mojolicious::Plugin::Authentication - A plugin to make authentication a bit easier =head1 SYNOPSIS use Mojolicious::Plugin::Authentication; $self->plugin('Authentication' => { autoload_user => 1, session_key => 'wickedapp', load_user_p => sub { ... }, validate_user_p => sub { ... }, }); # ... $self->authenticate_p( 'username', 'password', { optional => 'extra data stuff' }, )->then(sub { my ($authenticated) = @_; if ($authenticated) { # ... } }); # or, synchronous style $self->plugin('Authentication' => { autoload_user => 1, session_key => 'wickedapp', load_user => sub { ... }, validate_user => sub { ... }, current_user_fn => 'user', # compatibility with old code }); my $authenticated = $self->authenticate( 'username', 'password', { optional => 'extra data stuff' }, ); if ($authenticated) { ... } =head1 METHODS Like other Mojolicious plugins, loading this plugin will import some function helpers into the namespace of your application. This will not normally cause any trouble, but be aware that if you define methods with the same names as those below, you'll likely run into unexpected results. =head2 authenticate($username, $password, $extra_data_hashref) Authenticate will use the supplied C and C subroutine refs to see whether a user exists with the given username and password, and will set up the session accordingly. Returns true when the user has been successfully authenticated, false otherwise. You can pass additional data along in the C hashref, it will be passed to your C subroutine as-is. If the extra data hash contains a key C, the value of that key will be used as the UID, and authenticate will not call your C callback; this can be used when working with OAuth tokens or other authentication mechanisms that do not use a local username and password form. =head2 authenticate_p($username, $password, $extra_data_hashref) As above, but instead of returning a value, returns a promise of same. Available even if only synchronous callbacks are provided as these will be "promisified". =head2 is_user_authenticated Returns true if current_user() returns some valid object, false otherwise. =head2 is_user_authenticated_p As above, but instead of returning a value, returns a promise of same. =head2 current_user Returns the user object as it was returned from the supplied C subroutine ref. You can change the current user by passing it in, but be careful: This bypasses the authentication. This is useful if you have multiple ways to authenticate users and want to re-use authorization checks that use C. Note that the name of this helper can be changed with the C field during initialisation (see L). =head2 current_user_p As above, but instead of returning a value, returns a promise of same. =head2 reload_user Flushes the current user object and then returns current_user(). =head2 reload_user_p As above, but instead of returning a value, returns a promise of same. =head2 signature_exists Returns true if uid signature exist on the client side (in cookies), false otherwise. Warning: non-secure check! Use this method only for a "fast & dirty" lookup to see if the client has the proper cookies. May be helpful in some cases (for example - in counting C/C or for additional non-confidential information for C but not for C). =head2 logout Removes the session data for authentication, and effectively logs a user out. Returns a true value, to allow for chaining. =head1 CONFIGURATION The following options can be set for the plugin, (but the "REQUIRED" ones can be replaced with a promise-returning equivalent with C<_p> appended to the key): =over 4 =item load_user (REQUIRED) A coderef for user loading (see L) =item validate_user (REQUIRED) A coderef for user validation (see L) =item session_key (optional) The name of the session key =item autoload_user (optional) Turn on/off automatic loading of user data - user data can be loaded only if it be used. May reduce site latency in some cases. =item current_user_fn (optional) Set the name for the C helper function. C<_p> will be appended for the asynchronous version. =item fail_render (optional) Specify what is to be rendered when the authenticated condition is not met. Set to a coderef which will be called with the following signature: sub { my ($routes, $controller, $captures, $required) = @_; ... return $hashref; } The return value of the subroutine will be ignored if it evaluates to false. If it returns a hash reference, it will be dereferenced and passed as-is to the controller's C function. If you return anything else, you are going to have a bad time. If set directly to a hash reference, that will be passed to C instead. =back In order to set the session expiry time, use the following in your startup routine: $app->plugin('authentication', { ... }); $app->sessions->default_expiration(86400); # set expiry to 1 day $app->sessions->default_expiration(3600); # set expiry to 1 hour =head1 USER LOADING The coderef you pass to the load_user configuration key has the following signature: sub { my ($app, $uid) = @_; ... return $user; } The uid is the value that was originally returned from the C coderef. You must return either a user object (it can be a hashref, arrayref, or a blessed object) or undef. =head1 USER VALIDATION User validation is what happens when we need to authenticate someone. The coderef you pass to the C configuration key has the following signature: sub { my ($c, $username, $password, $extradata) = @_; ... return $uid; } You must return either a user id or undef. The user id can be numerical or a string. Do not return hashrefs, arrayrefs or objects, since the behaviour of this plugin could get a little bit on the odd side of weird if you do that. =head1 EXAMPLES For a code example using this, see the F and F tests, it uses L and this plugin. =head1 ROUTING VIA CONDITION This plugin also exports a routing condition you can use in order to limit access to certain documents to only authenticated users. $r->route('/foo')->requires(authenticated => 1)->to('mycontroller#foo'); my $authenticated_only = $r->route('/members') ->requires(authenticated => 1) ->to('members#index'); $authenticated_only->route('online')->to('members#online'); If someone is not authenticated, these routes will not be considered by the dispatcher and unless you have set up a catch-all route, a 404 Not Found will be generated instead. And another condition for fast and unsecured checking for users, having a signature (without validating it). This method just checks client cookies for uid data existing. $r->route('/foo')->requires(signed => 1)->to('mycontroller#foo'); This behavior is similar to the "authenticated" condition. Prior to Mojolicious 9, use "over" instead of "requires." =head1 ROUTING VIA CALLBACK If you want to be able to send people to a login page, you will have to use the following: my $members_only = $r->route('/members')->to(cb => sub { my $self = shift; $self->redirect_to('/login') and return 0 unless($self->is_user_authenticated); return 1; }); $members_only->route('online')->to('members#online'); Lazy and unsecured methods: my $members_only = $r->route('/unimportant')->to(cb => sub { my $self = shift; $self->redirect_to('/login') and return 0 unless($self->signature_exists); return 1; }); $members_only->route('pages')->to('unimportant#pages'); =head1 ROUTING VIA BRIDGE If you want to be able to send people to a login page, you will have to use the following: my $auth_bridge = $r->under('/members')->to('auth#check'); # only visible to logged in users $auth_bridge->route('/list')->to('members#list'); And in your Auth controller you would put: sub check { my $self = shift; $self->redirect_to('/login') and return 0 unless($self->is_user_authenticated); return 1; }; Lazy and unsecured methods: sub check { my $self = shift; $self->redirect_to('/login') and return 0 unless($self->signature_exists); return 1; }; =head1 SEE ALSO =over 4 =item L =item L =back =head1 AUTHOR =over 4 =item Ben van Staveren, C<< >> =item José Joaquín Atria, C<< >> =back =head1 BUGS / CONTRIBUTING Please report any bugs or feature requests through the web interface at L. =head1 SUPPORT You can find documentation for this module with the perldoc command. perldoc Mojolicious::Plugin::Authentication You can also look for information at: =over 4 =item * AnnoCPAN: Annotated CPAN documentation L =item * CPAN Ratings L =item * Search CPAN L =back =head1 ACKNOWLEDGEMENTS Andrew Parker - For pointing out some bugs that crept in; a silent reminder not to code while sleepy Mirko Westermeier (memowe) - For doing some (much needed) code cleanup Terrence Brannon (metaperl) - Documentation patches Karpich Dmitry (meettya) - C and C functionality, including a test and documentation Ivo Welch - For donating his first ever Mojolicious application that shows an example of how to use this module Ed Wildgoose (ewildgoose) - Adding the C functionality, as well as some method renaming to make things a bit more sane. Colin Cyr (SailingYYC) - For reporting an issue with routing conditions; I really should not code while sleepy, brainfarts imminent! Carlos Ramos (carragom) - For fixing the bug that'd consider an uid of 0 or "0" to be a problem Doug Bell (preaction) - For improving the Travis CI integration and enabling arguments for current_user Roman F (moltar) - For fixing some pesky typos in sample code Hernan Lopes (hernan604) - For updating some deprecated method names in the documentation =head1 LICENSE AND COPYRIGHT Copyright 2011-2021 Ben van Staveren. This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License. See http://dev.perl.org/licenses/ for more information. =cut