Apache-Session-Browseable-1.3.13000755001750001750 014451523531 15514 5ustar00yaddyadd000000000000Apache-Session-Browseable-1.3.13/Build.PL000444001750001750 144714451523531 17153 0ustar00yaddyadd000000000000use Module::Build; # See perldoc Module::Build for details of how this works Module::Build->new( module_name => 'Apache::Session::Browseable', license => 'perl', requires => { 'Apache::Session' => 0, 'JSON' => 0, }, recommends => { 'DBI' => 0, 'Net::LDAP' => 0.38, 'DBD::Cassandra' => 0, 'Redis' => 0, }, test_requires => { DBI => 0, 'DBD::SQLite' => 0, }, dist_version => '1.3.13', autosplit => [qw(lib/Apache/Session/Browseable/_common.pm)], configure_requires => { 'Module::Build' => 0, }, meta_merge => { resources => { repository => 'https://github.com/LemonLDAPNG/Apache-Session-Browseable' } }, )->create_build_script; Apache-Session-Browseable-1.3.13/COPYRIGHT000444001750001750 23714451523531 17126 0ustar00yaddyadd000000000000Copyright (C) 2009-2020 by Xavier Guimard Copyright (C) 2013-2020 by Clement Oudot Copyright (C) 2019-2020 by Maxime Besson Copyright (C) 2018-2020 by Worteks Apache-Session-Browseable-1.3.13/Changes000444001750001750 635014451523531 17150 0ustar00yaddyadd000000000000Revision history for Perl extension Apache::Session::Browseable. 1.3.13 - Fix versions - Update Cassandra doc 1.3.12 - Add Cassandra support via DBD::Cassandra 1.3.11 - Revert 1.3.10 changes 1.3.10 - Add quote for fields in INSERT query 1.3.9 - Return number of deleted rows when called in array context. See [LemonLDAP issue #2428](https://gitlab.ow2.org/lemonldap-ng/lemonldap-ng/-/issues/2428) 1.3.8 - Add specific error handling for old versions (#28) 1.3.7 - Fix ldap+tls:// regression in 1.3.6 (#27) 1.3.6 - Improve logs (#26) - Add ldapVerify option for SSL cert validation (#25) 1.3.5 - Update cast syntax for vanilla MySQL (#21) - Redis: doc and tests improvements (#23) 1.3.4 - Don't stop parsing sessions when one is bad 1.3.3 - LDAP: Add ldapRaw parameter (#20) 1.3.2 - Allow sentinel list to be passed as a comma-delimited string (#19) 1.3.1 - Fix typo on Oracle.pm (#15) - Postgres: ensure that returned @fields keep their original case (Closes: #17) 1.3.0 - Fix also PgHstore error when searchOn is used without fields 1.2.9 - Use either Redis::Fast or Redis - Fix error when searchOn is used without fields (PgJSON) 1.2.8 - Missing UTF-8 hook 1.2.7 - Force UTF-8 1.2.6 - Force allow_nonref option (#14) 1.2.5 Thu Apr 4 07:09:23 2017 - PostgreSQL "hstore" and "json" support - Add "deleteIfLowerThan" method 1.2.4 Sun Feb 19 08:25:10 2016 - Incorrect logic for old database formats (fixes: #11) 1.2.3 Tue Jun 7 15:55:56 2016 - Replace "/" for Windows 1.2.2 Fri Apr 1 13:22:22 2016 - Manage old session format for databases 1.2.1 Thu Mar 10 07:27:45 2016 - Add an empty Browseable.pm due to new Pause restrictions 1.2 Tue Mar 08 22:08:09 2016 - replace MD5 by SHA256 - replace serialization by JSON 1.0.1 Fri Aug 30 06:40:02 2013 - Add Apache::Session in required dependencies (was ommited in 1.0) 1.0.2 Thu Oct 17 20:27:24 2013 - _common::_tabInTab() must return 0 if no fields are required Closes http://jira.ow2.org/browse/LEMONLDAP-627 1.0 Sat Jul 06 19:57:46 2013 - Add SQLite support - Corrects POD ($args was forgotten) - Add searchOnExpr() sub: - default implementation in _common - optimized implementation in LDAP and DBI - Optimize SQL queries when only indexed files are required - Create _common.pm lib for unoptimized functions - Add basic tests for all libs - Add advanced tests using SQLite backend 0.9 Thu Feb 28 06:51:51 2013 - Fix Undefined value warning with Redis backend (https://github.com/coudot/apache-session-browseable/issues/1) - Update copyright 0.7 Sun Jun 24 09:07:21 2012 - Add "eval" to avoid errors in unserialize (LDAP) 0.6 Mon Dec 8 16:43:23 2010 - Add LDAP (Closes LEMONLDAP-243) - Redis parsing returned nothing 0.5 Mon Dec 6 21:54:23 2010 - Add Redis (Closes LEMONLDAP-244) 0.4 Mon Aug 16 17:16:12 2010 - Missing "use" 0.3 Sun Nov 1 17:12:34 2009 - Add Sybase, Oracle, Informix, File and Postgres 0.2 Sun Nov 1 10:06:51 2009 - Remove 5.10 dependency 0.1 Sat Oct 31 08:10:54 2009 - Initial release 0.8 Fri Oct 12 06:20:54 2012 - storable must not be always used in DBI Apache-Session-Browseable-1.3.13/LICENSE000444001750001750 5007414451523531 16704 0ustar00yaddyadd000000000000Terms of Perl 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 General Public License (GPL) Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 675 Mass Ave, Cambridge, MA 02139, USA. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU 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. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), 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 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 show them these terms so they know 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. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. 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 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 derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 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 License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. 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. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary 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 License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 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 Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing 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 for copying, distributing or modifying the Program or works based on it. 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. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. 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 this 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 this License, you may choose any version ever published by the Free Software Foundation. 10. 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 11. 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. 12. 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 --------------------------------------------------------------------------- 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. 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 MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. The End Apache-Session-Browseable-1.3.13/MANIFEST000444001750001750 343714451523531 17011 0ustar00yaddyadd000000000000Build.PL Changes COPYRIGHT lib/Apache/Session/Browseable.pm lib/Apache/Session/Browseable/_common.pm lib/Apache/Session/Browseable/Cassandra.pm lib/Apache/Session/Browseable/DBI.pm lib/Apache/Session/Browseable/File.pm lib/Apache/Session/Browseable/Informix.pm lib/Apache/Session/Browseable/LDAP.pm lib/Apache/Session/Browseable/MySQL.pm lib/Apache/Session/Browseable/MySQLJSON.pm lib/Apache/Session/Browseable/Oracle.pm lib/Apache/Session/Browseable/PgHstore.pm lib/Apache/Session/Browseable/PgJSON.pm lib/Apache/Session/Browseable/Postgres.pm lib/Apache/Session/Browseable/Redis.pm lib/Apache/Session/Browseable/SQLite.pm lib/Apache/Session/Browseable/Store/Cassandra.pm lib/Apache/Session/Browseable/Store/DBI.pm lib/Apache/Session/Browseable/Store/File.pm lib/Apache/Session/Browseable/Store/Informix.pm lib/Apache/Session/Browseable/Store/LDAP.pm lib/Apache/Session/Browseable/Store/MySQL.pm lib/Apache/Session/Browseable/Store/Oracle.pm lib/Apache/Session/Browseable/Store/Postgres.pm lib/Apache/Session/Browseable/Store/Redis.pm lib/Apache/Session/Browseable/Store/SQLite.pm lib/Apache/Session/Browseable/Store/Sybase.pm lib/Apache/Session/Browseable/Sybase.pm lib/Apache/Session/Generate/SHA256.pm lib/Apache/Session/Serialize/Hstore.pm lib/Apache/Session/Serialize/JSON.pm LICENSE MANIFEST META.json META.yml Module meta-data (added by MakeMaker) README.md rpm/Apache-Session-Browseable.spec t/Apache-Session-Browseable-Cassandra.t t/Apache-Session-Browseable-common.t t/Apache-Session-Browseable-DBI.t t/Apache-Session-Browseable-File.t t/Apache-Session-Browseable-LDAP.t t/Apache-Session-Browseable-Redis.t t/Apache-Session-Browseable-SQLite.t t/Apache-Session-Browseable-Store-DBI.t t/Apache-Session-Browseable-Store-MySQL.t t/test-browseable-functions-using-File.t t/test-browseable-functions-using-SQLite.t Apache-Session-Browseable-1.3.13/META.json000444001750001750 1307014451523531 17313 0ustar00yaddyadd000000000000{ "abstract" : "Add index and search methods to Apache::Session", "author" : [ "Xavier Guimard, Ex.guimard@free.frE" ], "dynamic_config" : 1, "generated_by" : "Module::Build version 0.4234", "license" : [ "perl_5" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : 2 }, "name" : "Apache-Session-Browseable", "prereqs" : { "configure" : { "requires" : { "Module::Build" : "0" } }, "runtime" : { "recommends" : { "DBD::Cassandra" : "0", "DBI" : "0", "Net::LDAP" : "0.38", "Redis" : "0" }, "requires" : { "Apache::Session" : "0", "JSON" : "0" } }, "test" : { "requires" : { "DBD::SQLite" : "0", "DBI" : "0" } } }, "provides" : { "Apache::Session::Browseable" : { "file" : "lib/Apache/Session/Browseable.pm", "version" : "v1.3.13" }, "Apache::Session::Browseable::Cassandra" : { "file" : "lib/Apache/Session/Browseable/Cassandra.pm", "version" : "v1.3.13" }, "Apache::Session::Browseable::DBI" : { "file" : "lib/Apache/Session/Browseable/DBI.pm", "version" : "v1.3.9" }, "Apache::Session::Browseable::File" : { "file" : "lib/Apache/Session/Browseable/File.pm", "version" : "v1.3.5" }, "Apache::Session::Browseable::Informix" : { "file" : "lib/Apache/Session/Browseable/Informix.pm", "version" : "v1.2.2" }, "Apache::Session::Browseable::LDAP" : { "file" : "lib/Apache/Session/Browseable/LDAP.pm", "version" : "v1.3.6" }, "Apache::Session::Browseable::MySQL" : { "file" : "lib/Apache/Session/Browseable/MySQL.pm", "version" : "v1.2.5" }, "Apache::Session::Browseable::MySQLJSON" : { "file" : "lib/Apache/Session/Browseable/MySQLJSON.pm", "version" : "v1.3.9" }, "Apache::Session::Browseable::Oracle" : { "file" : "lib/Apache/Session/Browseable/Oracle.pm", "version" : "v1.2.2" }, "Apache::Session::Browseable::PgHstore" : { "file" : "lib/Apache/Session/Browseable/PgHstore.pm", "version" : "v1.3.9" }, "Apache::Session::Browseable::PgJSON" : { "file" : "lib/Apache/Session/Browseable/PgJSON.pm", "version" : "v1.3.9" }, "Apache::Session::Browseable::Postgres" : { "file" : "lib/Apache/Session/Browseable/Postgres.pm", "version" : "v1.3.1" }, "Apache::Session::Browseable::Redis" : { "file" : "lib/Apache/Session/Browseable/Redis.pm", "version" : "v1.3.9" }, "Apache::Session::Browseable::SQLite" : { "file" : "lib/Apache/Session/Browseable/SQLite.pm", "version" : "v1.2.2" }, "Apache::Session::Browseable::Store::Cassandra" : { "file" : "lib/Apache/Session/Browseable/Store/Cassandra.pm", "version" : "v1.3.13" }, "Apache::Session::Browseable::Store::DBI" : { "file" : "lib/Apache/Session/Browseable/Store/DBI.pm", "version" : "v1.3.11" }, "Apache::Session::Browseable::Store::File" : { "file" : "lib/Apache/Session/Browseable/Store/File.pm", "version" : "v1.2.2" }, "Apache::Session::Browseable::Store::Informix" : { "file" : "lib/Apache/Session/Browseable/Store/Informix.pm", "version" : "v1.2.2" }, "Apache::Session::Browseable::Store::LDAP" : { "file" : "lib/Apache/Session/Browseable/Store/LDAP.pm", "version" : "v1.3.8" }, "Apache::Session::Browseable::Store::MySQL" : { "file" : "lib/Apache/Session/Browseable/Store/MySQL.pm", "version" : "v1.2.2" }, "Apache::Session::Browseable::Store::Oracle" : { "file" : "lib/Apache/Session/Browseable/Store/Oracle.pm", "version" : "v1.2.2" }, "Apache::Session::Browseable::Store::Postgres" : { "file" : "lib/Apache/Session/Browseable/Store/Postgres.pm", "version" : "v1.2.2" }, "Apache::Session::Browseable::Store::Redis" : { "file" : "lib/Apache/Session/Browseable/Store/Redis.pm", "version" : "v1.3.2" }, "Apache::Session::Browseable::Store::SQLite" : { "file" : "lib/Apache/Session/Browseable/Store/SQLite.pm", "version" : "v1.2.7" }, "Apache::Session::Browseable::Store::Sybase" : { "file" : "lib/Apache/Session/Browseable/Store/Sybase.pm", "version" : "v1.2.2" }, "Apache::Session::Browseable::Sybase" : { "file" : "lib/Apache/Session/Browseable/Sybase.pm", "version" : "v1.2.2" }, "Apache::Session::Generate::SHA256" : { "file" : "lib/Apache/Session/Generate/SHA256.pm", "version" : "v1.2.2" }, "Apache::Session::Serialize::Hstore" : { "file" : "lib/Apache/Session/Serialize/Hstore.pm", "version" : "v1.2.5" }, "Apache::Session::Serialize::JSON" : { "file" : "lib/Apache/Session/Serialize/JSON.pm", "version" : "v1.2.6" } }, "release_status" : "stable", "resources" : { "license" : [ "http://dev.perl.org/licenses/" ], "repository" : { "url" : "https://github.com/LemonLDAPNG/Apache-Session-Browseable" } }, "version" : "v1.3.13", "x_serialization_backend" : "JSON::PP version 4.07" } Apache-Session-Browseable-1.3.13/META.yml000444001750001750 773714451523531 17140 0ustar00yaddyadd000000000000--- abstract: 'Add index and search methods to Apache::Session' author: - 'Xavier Guimard, Ex.guimard@free.frE' build_requires: DBD::SQLite: '0' DBI: '0' configure_requires: Module::Build: '0' dynamic_config: 1 generated_by: 'Module::Build version 0.4234, 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: Apache-Session-Browseable provides: Apache::Session::Browseable: file: lib/Apache/Session/Browseable.pm version: v1.3.13 Apache::Session::Browseable::Cassandra: file: lib/Apache/Session/Browseable/Cassandra.pm version: v1.3.13 Apache::Session::Browseable::DBI: file: lib/Apache/Session/Browseable/DBI.pm version: v1.3.9 Apache::Session::Browseable::File: file: lib/Apache/Session/Browseable/File.pm version: v1.3.5 Apache::Session::Browseable::Informix: file: lib/Apache/Session/Browseable/Informix.pm version: v1.2.2 Apache::Session::Browseable::LDAP: file: lib/Apache/Session/Browseable/LDAP.pm version: v1.3.6 Apache::Session::Browseable::MySQL: file: lib/Apache/Session/Browseable/MySQL.pm version: v1.2.5 Apache::Session::Browseable::MySQLJSON: file: lib/Apache/Session/Browseable/MySQLJSON.pm version: v1.3.9 Apache::Session::Browseable::Oracle: file: lib/Apache/Session/Browseable/Oracle.pm version: v1.2.2 Apache::Session::Browseable::PgHstore: file: lib/Apache/Session/Browseable/PgHstore.pm version: v1.3.9 Apache::Session::Browseable::PgJSON: file: lib/Apache/Session/Browseable/PgJSON.pm version: v1.3.9 Apache::Session::Browseable::Postgres: file: lib/Apache/Session/Browseable/Postgres.pm version: v1.3.1 Apache::Session::Browseable::Redis: file: lib/Apache/Session/Browseable/Redis.pm version: v1.3.9 Apache::Session::Browseable::SQLite: file: lib/Apache/Session/Browseable/SQLite.pm version: v1.2.2 Apache::Session::Browseable::Store::Cassandra: file: lib/Apache/Session/Browseable/Store/Cassandra.pm version: v1.3.13 Apache::Session::Browseable::Store::DBI: file: lib/Apache/Session/Browseable/Store/DBI.pm version: v1.3.11 Apache::Session::Browseable::Store::File: file: lib/Apache/Session/Browseable/Store/File.pm version: v1.2.2 Apache::Session::Browseable::Store::Informix: file: lib/Apache/Session/Browseable/Store/Informix.pm version: v1.2.2 Apache::Session::Browseable::Store::LDAP: file: lib/Apache/Session/Browseable/Store/LDAP.pm version: v1.3.8 Apache::Session::Browseable::Store::MySQL: file: lib/Apache/Session/Browseable/Store/MySQL.pm version: v1.2.2 Apache::Session::Browseable::Store::Oracle: file: lib/Apache/Session/Browseable/Store/Oracle.pm version: v1.2.2 Apache::Session::Browseable::Store::Postgres: file: lib/Apache/Session/Browseable/Store/Postgres.pm version: v1.2.2 Apache::Session::Browseable::Store::Redis: file: lib/Apache/Session/Browseable/Store/Redis.pm version: v1.3.2 Apache::Session::Browseable::Store::SQLite: file: lib/Apache/Session/Browseable/Store/SQLite.pm version: v1.2.7 Apache::Session::Browseable::Store::Sybase: file: lib/Apache/Session/Browseable/Store/Sybase.pm version: v1.2.2 Apache::Session::Browseable::Sybase: file: lib/Apache/Session/Browseable/Sybase.pm version: v1.2.2 Apache::Session::Generate::SHA256: file: lib/Apache/Session/Generate/SHA256.pm version: v1.2.2 Apache::Session::Serialize::Hstore: file: lib/Apache/Session/Serialize/Hstore.pm version: v1.2.5 Apache::Session::Serialize::JSON: file: lib/Apache/Session/Serialize/JSON.pm version: v1.2.6 recommends: DBD::Cassandra: '0' DBI: '0' Net::LDAP: '0.38' Redis: '0' requires: Apache::Session: '0' JSON: '0' resources: license: http://dev.perl.org/licenses/ repository: https://github.com/LemonLDAPNG/Apache-Session-Browseable version: v1.3.13 x_serialization_backend: 'CPAN::Meta::YAML version 0.018' Apache-Session-Browseable-1.3.13/README.md000444001750001750 73514451523531 17115 0ustar00yaddyadd000000000000# Apache::Session::Browseable [![Build Status](https://travis-ci.org/LemonLDAPNG/Apache-Session-Browseable.svg?branch=master)](https://travis-ci.org/LemonLDAPNG/Apache-Session-Browseable) This module is an Apache::Session implementation allowing to define index to speed up searches. ## Installation To install this module type the following: ```` perl Build.PL ./Build ./Build test ./Build install ```` ## CPAN See http://search.cpan.org/dist/Apache-Session-Browseable/ Apache-Session-Browseable-1.3.13/lib000755001750001750 014451523531 16262 5ustar00yaddyadd000000000000Apache-Session-Browseable-1.3.13/lib/Apache000755001750001750 014451523531 17443 5ustar00yaddyadd000000000000Apache-Session-Browseable-1.3.13/lib/Apache/Session000755001750001750 014451523531 21066 5ustar00yaddyadd000000000000Apache-Session-Browseable-1.3.13/lib/Apache/Session/Browseable.pm000444001750001750 354314451523531 23653 0ustar00yaddyadd000000000000package Apache::Session::Browseable; our $VERSION = '1.3.13'; print STDERR "Use a sub module of Apache::Session::Browseable such as Apache::Session::Browseable::File"; 1; __END__ =head1 NAME Apache::Session::Browseable - Add index and search methods to Apache::Session =head1 DESCRIPTION Apache::Session::browseable provides some class methods to manipulate all sessions and add the capability to index some fields to make research faster. It has been written to increase performances of LemonLDAP::NG. Read the chosen module documentation carefully to set the indexes. =head1 AVAILABLE MODULES =head2 SQL databases =head3 PostgreSQL =over =item L =item L: uses "hstore" field =item L: uses "json/jsonb" field =back =head3 MySQL or MariaDB =over =item L: for MySQL and MariaDB =item L: for MySQL only, uses "json" field =back =head3 Other =over =item L =item L =item L =back =head2 NoSQL =over =item L =item L =back =head1 SEE ALSO L, L, L =head1 AUTHOR Xavier Guimard, Ex.guimard@free.frE =head1 COPYRIGHT AND LICENSE =encoding utf8 Copyright (C): =over =item 2009-2017 by Xavier Guimard =item 2013-2017 by Clément Oudot =back This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.10.1 or, at your option, any later version of Perl 5 you may have available. =cut Apache-Session-Browseable-1.3.13/lib/Apache/Session/Browseable000755001750001750 014451523531 23153 5ustar00yaddyadd000000000000Apache-Session-Browseable-1.3.13/lib/Apache/Session/Browseable/Cassandra.pm000444001750001750 530714451523531 25552 0ustar00yaddyadd000000000000package Apache::Session::Browseable::Cassandra; use strict; use Apache::Session; use Apache::Session::Lock::Null; use Apache::Session::Browseable::Store::Cassandra; use Apache::Session::Generate::SHA256; use Apache::Session::Serialize::JSON; use Apache::Session::Browseable::DBI; our $VERSION = '1.3.13'; our @ISA = qw(Apache::Session::Browseable::DBI Apache::Session); sub populate { my $self = shift; $self->{object_store} = new Apache::Session::Browseable::Store::Cassandra $self; $self->{lock_manager} = new Apache::Session::Lock::Null $self; $self->{generate} = \&Apache::Session::Generate::SHA256::generate; $self->{validate} = \&Apache::Session::Generate::SHA256::validate; $self->{serialize} = \&Apache::Session::Serialize::JSON::serialize; $self->{unserialize} = \&Apache::Session::Serialize::JSON::unserialize; return $self; } 1; =pod =head1 NAME Apache::Session::Browseable::Cassandra - Apache::Session backend to store sessions in a Cassadra database. =head1 SYNOPSIS use Apache::Session::Browseable::Cassandra; my $args = { DataSource => 'dbi:Cassandra:host=localhost;keyspace=llng', UserName => $db_user, Password => $db_pass, # Choose your browseable fileds Index => '_whatToTrace _session_kind _utime iAddr', }; # Use it like Apache::Session my %session; tie %session, 'Apache::Session::Browseable::Cassandra', $id, $args; $session{uid} = 'me'; $session{mail} = 'me@me.com'; $session{unindexedField} = 'zz'; untie %session; =head1 DESCRIPTION Apache::Session::Browseable::Cassandra is an implementation of Apache::Session for Cassandra database. =head1 SCHEMA To use this module, you will need at least these columns in a table called 'sessions': id text a_session text To create this schema, you can execute this command using cqlsh: CREATE TABLE sessions ( id text PRIMARY KEY, a_session text ); =head1 CONFIGURATION The module must know what datasource, username, and password to use when connecting to the database. These values can be set using the options hash (see Apache::Session documentation). The options are DataSource, UserName, and Password. Example: tie %hash, 'Apache::Session::Cassandra', $id, { DataSource => 'dbi:Cassandra:host=localhost;keyspace=llng', UserName => 'database_user', Password => 'K00l' }; Instead, you may pass in an already-opened DBI handle to your database. tie %hash, 'Apache::Session::Cassandra', $id, { Handle => $dbh }; =head1 AUTHOR This module was written by Mike Langen , based on the original for Oracle. =head1 SEE ALSO L, L 1; Apache-Session-Browseable-1.3.13/lib/Apache/Session/Browseable/DBI.pm000444001750001750 1572414451523531 24275 0ustar00yaddyadd000000000000package Apache::Session::Browseable::DBI; use strict; use DBI; use Apache::Session; use Apache::Session::Browseable::_common; our $VERSION = '1.3.9'; our @ISA = qw(Apache::Session Apache::Session::Browseable::_common); sub searchOn { my $class = shift; my ( $args, $selectField, $value, @fields ) = @_; # Escape quotes $selectField =~ s/'/''/g; if ( $class->_fieldIsIndexed( $args, $selectField ) ) { return $class->_query( $args, $selectField, $value, { query => "$selectField=?", values => [$value] }, @fields ); } else { return $class->SUPER::searchOn(@_); } } sub searchOnExpr { my $class = shift; my ( $args, $selectField, $value, @fields ) = @_; # Escape quotes $value =~ s/'/''/g; $selectField =~ s/'/''/g; if ( $class->_fieldIsIndexed( $args, $selectField ) ) { $value =~ s/\*/%/g; return $class->_query( $args, $selectField, $value, { query => "$selectField like ?", values => [$value] }, @fields ); } else { return $class->SUPER::searchOnExpr(@_); } } sub _query { my ( $class, $args, $selectField, $value, $query, @fields ) = @_; my %res = (); my $index = ref( $args->{Index} ) ? $args->{Index} : [ split /\s+/, $args->{Index} ]; my $dbh = $class->_classDbh($args); my $table_name = $args->{TableName} || $Apache::Session::Store::DBI::TableName; # Case 1: all requested fields are also indexed my $indexed = $class->_tabInTab( \@fields, $index ); my $sth; if ($indexed) { my $fields = join( ',', 'id', map { s/'//g; $_ } @fields ); $sth = $dbh->prepare( "SELECT $fields from $table_name where $query->{query}"); $sth->execute( @{ $query->{values} } ); return $sth->fetchall_hashref('id'); } # Case 1: at least one field isn't indexed, decoding is needed else { $sth = $dbh->prepare( "SELECT id,a_session from $table_name where $query->{query}"); $sth->execute( @{ $query->{values} } ); while ( my @row = $sth->fetchrow_array ) { no strict 'refs'; my $self = eval "&${class}::populate();"; my $sub = $self->{unserialize}; eval { my $tmp = &$sub( { serialized => $row[1] } ); if (@fields) { $res{ $row[0] }->{$_} = $tmp->{$_} foreach (@fields); } else { $res{ $row[0] } = $tmp; } }; if ($@) { print STDERR "Error in session $row[0]: $@\n"; delete $res{ $row[0] }; } } } return \%res; } sub deleteIfLowerThan { my ( $class, $args, $rule ) = @_; my ( $query, %fields ); my $index = ref( $args->{Index} ) ? $args->{Index} : [ split /\s+/, $args->{Index} ]; if ( $rule->{or} ) { $query = join ' OR ', map { $fields{$_}++; $class->_buildLowerThanExpression( $_, $rule->{or}->{$_} ) } keys %{ $rule->{or} }; } elsif ( $rule->{and} ) { $query = join ' AND ', map { $fields{$_}++; $class->_buildLowerThanExpression( $_, $rule->{or}->{$_} ) } keys %{ $rule->{or} }; } if ( $rule->{not} ) { $query = "($query) AND " . join( ' AND ', map { $fields{$_}++; "$_ <> '$rule->{not}->{$_}'" } keys %{ $rule->{not} } ); } return 0 unless ( $query and $class->_tabInTab( [ keys %fields ], $index ) ); my $dbh = $class->_classDbh($args); my $table_name = $args->{TableName} || $Apache::Session::Store::DBI::TableName; my $rows = $dbh->do("DELETE FROM $table_name WHERE $query"); return 0 unless defined $rows; if (wantarray) { $rows = 0 if $rows == -1; return ( 1, $rows ); } else { return 1; } } # Let specialized modules override this syntax if they need to sub _buildLowerThanExpression { my ( $class, $field, $value ) = @_; return "cast($field as integer) < $value"; } sub get_key_from_all_sessions { my $class = shift; my $args = shift; my $data = shift; my $table_name = $args->{TableName} || $Apache::Session::Store::DBI::TableName; my $dbh = $class->_classDbh($args); # Special case if all wanted fields are indexed if ( $data and ref($data) ne 'CODE' ) { $data = [$data] unless ( ref($data) ); my $index = ref( $args->{Index} ) ? $args->{Index} : [ split /\s+/, $args->{Index} ]; # Test if one field isn't indexed my $indexed = $class->_tabInTab( $data, $index ); # OK, all fields are indexed if ($indexed) { my $sth = $dbh->prepare_cached( 'SELECT id,' . join( ',', map { s/'/''/g; $_ } @$data ) . " from $table_name" ); $sth->execute; return $sth->fetchall_hashref('id'); } } my $sth = $dbh->prepare_cached("SELECT id,a_session from $table_name"); $sth->execute; my %res; my $next = ( $args->{DataSource} =~ /^sybase/i ? sub { require Storable; return Storable::thaw( pack( 'H*', $_[0] ) ); } : $args->{DataSource} =~ /^mysql/i ? sub { require MIME::Base64; require Storable; return Storable::thaw( MIME::Base64::decode_base64( $_[0] ) ); } : undef ); while ( my @row = $sth->fetchrow_array ) { no strict 'refs'; my $self = eval "&${class}::populate();"; eval { my $sub = $self->{unserialize}; my $tmp = &$sub( { serialized => $row[1] }, $next ); if ( ref($data) eq 'CODE' ) { $tmp = &$data( $tmp, $row[0] ); $res{ $row[0] } = $tmp if ( defined($tmp) ); } elsif ($data) { $data = [$data] unless ( ref($data) ); $res{ $row[0] }->{$_} = $tmp->{$_} foreach (@$data); } else { $res{ $row[0] } = $tmp; } }; if ($@) { print STDERR "Error in session $row[0]: $@\n"; delete $res{ $row[0] }; } } return \%res; } sub _classDbh { my $class = shift; my $args = shift; my $datasource = $args->{DataSource} or die "No datasource given !"; my $username = $args->{UserName}; my $password = $args->{Password}; my $dbh = DBI->connect_cached( $datasource, $username, $password, { RaiseError => 1, AutoCommit => 1 } ) || die $DBI::errstr; if ( $datasource =~ /^dbi:sqlite/i ) { $dbh->{sqlite_unicode} = 1; } elsif ( $datasource =~ /^dbi:mysql/i ) { $dbh->{mysql_enable_utf8} = 1; } elsif ( $datasource =~ /^dbi:pg/i ) { $dbh->{pg_enable_utf8} = 1; } return $dbh; } 1; Apache-Session-Browseable-1.3.13/lib/Apache/Session/Browseable/File.pm000444001750001750 442214451523531 24527 0ustar00yaddyadd000000000000package Apache::Session::Browseable::File; use strict; use Apache::Session; use Apache::Session::Lock::File; use Apache::Session::Browseable::Store::File; use Apache::Session::Generate::SHA256; use Apache::Session::Serialize::JSON; use Apache::Session::Browseable::_common; use constant SL => ( $^O and $^O =~ /(?:MSWin|Windows)/i ? '\\' : '/' ); our $VERSION = '1.3.5'; our @ISA = qw(Apache::Session Apache::Session::Browseable::_common); sub populate { my $self = shift; $self->{object_store} = new Apache::Session::Browseable::Store::File $self; $self->{lock_manager} = new Apache::Session::Lock::File $self; $self->{generate} = \&Apache::Session::Generate::SHA256::generate; $self->{validate} = \&Apache::Session::Generate::SHA256::validate; $self->{serialize} = \&Apache::Session::Serialize::JSON::serialize; $self->{unserialize} = \&Apache::Session::Serialize::JSON::unserialize; return $self; } sub DESTROY { my $self = shift; $self->save; $self->{object_store}->close; $self->release_all_locks; } sub get_key_from_all_sessions { my ( $class, $args, $data ) = @_; $args->{Directory} ||= $Apache::Session::Store::File::Directory; unless ( opendir DIR, $args->{Directory} ) { die "Cannot open directory $args->{Directory}\n"; } my @t = grep { -f $args->{Directory} . SL . $_ and /^[A-Za-z0-9@\-]+$/ } readdir(DIR); closedir DIR; my %res; for my $f (@t) { eval { open F, $args->{Directory} . SL . $f or die $!; my $row = join '', ; if ( ref($data) eq 'CODE' ) { $res{$f} = &$data( &Apache::Session::Serialize::JSON::_unserialize($row), $f ); } elsif ($data) { $data = [$data] unless ( ref($data) ); my $tmp = &Apache::Session::Serialize::JSON::_unserialize($row); $res{$f}->{$_} = $tmp->{$_} foreach (@$data); } else { $res{$f} = &Apache::Session::Serialize::JSON::_unserialize($row); } }; if ($@) { print STDERR "Error in session $f: $@\n"; delete $res{$f}; } } return \%res; } 1; __END__ Apache-Session-Browseable-1.3.13/lib/Apache/Session/Browseable/Informix.pm000444001750001750 160214451523531 25440 0ustar00yaddyadd000000000000package Apache::Session::Browseable::Informix; use strict; use Apache::Session; use Apache::Session::Lock::Null; use Apache::Session::Browseable::Store::Informix; use Apache::Session::Generate::SHA256; use Apache::Session::Serialize::JSON; use Apache::Session::Browseable::DBI; our $VERSION = '1.2.2'; our @ISA = qw(Apache::Session::Browseable::DBI Apache::Session); sub populate { my $self = shift; $self->{object_store} = new Apache::Session::Browseable::Store::Informix $self; $self->{lock_manager} = new Apache::Session::Lock::Null $self; $self->{generate} = \&Apache::Session::Generate::SHA256::generate; $self->{validate} = \&Apache::Session::Generate::SHA256::validate; $self->{serialize} = \&Apache::Session::Serialize::JSON::serialize; $self->{unserialize} = \&Apache::Session::Serialize::JSON::unserialize; return $self; } 1; Apache-Session-Browseable-1.3.13/lib/Apache/Session/Browseable/LDAP.pm000444001750001750 1442214451523531 24411 0ustar00yaddyadd000000000000package Apache::Session::Browseable::LDAP; use strict; use Apache::Session; use Apache::Session::Lock::Null; use Apache::Session::Browseable::Store::LDAP; use Apache::Session::Generate::SHA256; use Apache::Session::Serialize::JSON; use Apache::Session::Browseable::_common; use Net::LDAP::Util qw(escape_filter_value); our $VERSION = '1.3.6'; our @ISA = qw(Apache::Session Apache::Session::Browseable::_common); sub populate { my $self = shift; $self->{object_store} = new Apache::Session::Browseable::Store::LDAP $self; $self->{lock_manager} = new Apache::Session::Lock::Null $self; $self->{generate} = \&Apache::Session::Generate::SHA256::generate; $self->{validate} = \&Apache::Session::Generate::SHA256::validate; $self->{serialize} = \&Apache::Session::Serialize::JSON::serialize; $self->{unserialize} = \&Apache::Session::Serialize::JSON::unserialize; return $self; } sub unserialize { my $session = shift; my $tmp = { serialized => $session }; Apache::Session::Serialize::JSON::unserialize($tmp); return $tmp->{data}; } sub searchOn { my ( $class, $args, $selectField, $value, @fields ) = @_; my $index = ref( $args->{Index} ) ? $args->{Index} : [ split /\s+/, $args->{Index} ]; if ( grep { $_ eq $selectField } @$index ) { ( $selectField, $value ) = escape_filter_value( $selectField, $value ); return $class->_query( $args, $selectField, $value, @fields ); } else { return $class->SUPER::searchOn( $args, $selectField, $value, @fields ); } } sub searchOnExpr { my ( $class, $args, $selectField, $value, @fields ) = @_; my $index = ref( $args->{Index} ) ? $args->{Index} : [ split /\s+/, $args->{Index} ]; if ( grep { $_ eq $selectField } @$index ) { ( $selectField, $value ) = escape_filter_value( $selectField, $value ); $value =~ s/\\2a/\*/gi; return $class->_query( $args, $selectField, $value, @fields ); } else { return $class->SUPER::searchOn( $args, $selectField, $value, @fields ); } } sub _query { my ( $class, $args, $selectField, $value, @fields ) = @_; $args->{ldapObjectClass} ||= 'applicationProcess'; $args->{ldapAttributeId} ||= 'cn'; $args->{ldapAttributeContent} ||= 'description'; $args->{ldapAttributeIndex} ||= 'ou'; my %res = (); my $ldap = Apache::Session::Browseable::Store::LDAP::ldap( { args => $args } ); my $msg = $ldap->search( base => $args->{ldapConfBase}, filter => "(&(objectClass=" . $args->{ldapObjectClass} . ")(" . $args->{ldapAttributeIndex} . "=${selectField}_$value))", #scope => 'base', attrs => [ $args->{ldapAttributeContent}, $args->{ldapAttributeId} ], ); $ldap->unbind(); $ldap->disconnect(); if ( $msg->code ) { Apache::Session::Browseable::Store::LDAP->logError($msg); } else { foreach my $entry ( $msg->entries ) { my $id = $entry->get_value( $args->{ldapAttributeId} ) or die; my $tmp = $entry->get_value( $args->{ldapAttributeContent} ); next unless ($tmp); eval { $tmp = unserialize($tmp); }; next if ($@); if (@fields) { $res{$id}->{$_} = $tmp->{$_} foreach (@fields); } else { $res{$id} = $tmp; } } } return \%res; } sub get_key_from_all_sessions { my $class = shift; my $args = shift; my $data = shift; $args->{ldapObjectClass} ||= 'applicationProcess'; $args->{ldapAttributeId} ||= 'cn'; $args->{ldapAttributeContent} ||= 'description'; $args->{ldapAttributeIndex} ||= 'ou'; my %res; my $ldap = Apache::Session::Browseable::Store::LDAP::ldap( { args => $args } ); my $msg = $ldap->search( base => $args->{ldapConfBase}, # VERY STRANGE BUG ! With this filter, description isn't base64 encoded !!! #filter => '(objectClass=applicationProcess)', filter => '(&(objectClass=' . $args->{ldapObjectClass} . ')(' . $args->{ldapAttributeIndex} . '=*))', attrs => [ $args->{ldapAttributeId}, $args->{ldapAttributeContent} ], ); $ldap->unbind(); if ( $msg->code ) { Apache::Session::Browseable::Store::LDAP->logError($msg); } else { foreach my $entry ( $msg->entries ) { my $id = $entry->get_value( $args->{ldapAttributeId} ) or die; my $tmp = $entry->get_value( $args->{ldapAttributeContent} ); next unless ($tmp); eval { $tmp = unserialize($tmp); }; next if ($@); if ( ref($data) eq 'CODE' ) { $res{$id} = &$data( $tmp, $id ); } elsif ($data) { $data = [$data] unless ( ref($data) ); $res{$id}->{$_} = $tmp->{$_} foreach (@$data); } else { $res{$id} = $tmp; } } } return \%res; } 1; =pod =head1 NAME Apache::Session::Browseable::LDAP - An implementation of Apache::Session::LDAP =head1 SYNOPSIS use Apache::Session::Browseable::LDAP; tie %hash, 'Apache::Session::Browseable::LDAP', $id, { ldapServer => 'ldap://localhost:389', ldapConfBase => 'dmdName=applications,dc=example,dc=com', ldapBindDN => 'cn=admin,dc=example,dc=com', ldapBindPassword => 'pass', Index => 'uid ipAddr', ldapObjectClass => 'applicationProcess', ldapAttributeId => 'cn', ldapAttributeContent => 'description', ldapAttributeIndex => 'ou', ldapVerify => 'require', ldapCAFile => '/etc/ssl/certs/ca-certificates.crt', }; =head1 DESCRIPTION This module is an implementation of Apache::Session. It uses an LDAP directory to store datas. =head1 AUTHOR Xavier Guimard, Ex.guimard@free.frE =head1 COPYRIGHT AND LICENSE =encoding utf8 Copyright (C) 2009-2017 by Xavier Guimard Copyright (C) 2013-2017 by Clement Oudot This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.10.0 or, at your option, any later version of Perl 5 you may have available. =head1 SEE ALSO L =cut Apache-Session-Browseable-1.3.13/lib/Apache/Session/Browseable/MySQL.pm000444001750001750 757514451523531 24631 0ustar00yaddyadd000000000000package Apache::Session::Browseable::MySQL; use strict; use Apache::Session; use Apache::Session::Lock::Null; use Apache::Session::Browseable::Store::MySQL; use Apache::Session::Generate::SHA256; use Apache::Session::Serialize::JSON; use Apache::Session::Browseable::DBI; our $VERSION = '1.2.5'; our @ISA = qw(Apache::Session::Browseable::DBI Apache::Session); sub populate { my $self = shift; $self->{object_store} = new Apache::Session::Browseable::Store::MySQL $self; $self->{lock_manager} = new Apache::Session::Lock::Null $self; $self->{generate} = \&Apache::Session::Generate::SHA256::generate; $self->{validate} = \&Apache::Session::Generate::SHA256::validate; $self->{serialize} = \&Apache::Session::Serialize::JSON::serialize; $self->{unserialize} = \&Apache::Session::Serialize::JSON::unserialize; return $self; } # Override default CAST syntax from DBI.pm sub _buildLowerThanExpression { my ( $class, $field, $value ) = @_; return "CAST($field AS SIGNED INTEGER) < $value"; } 1; __END__ =head1 NAME Apache::Session::Browseable::MySQL - Add index and search methods to Apache::Session::MySQL =head1 SYNOPSIS Create table with columns for indexed fields. Example for Lemonldap::NG: CREATE TABLE sessions ( id varchar(64) not null primary key, a_session text, _whatToTrace text, _session_kind text, _utime bigint, ipAddr text ); Add indexes: CREATE INDEX uid1 ON sessions (_whatToTrace) USING BTREE; CREATE INDEX s1 ON sessions (_session_kind); CREATE INDEX u1 ON sessions (_utime); CREATE INDEX ip1 ON sessions (ipAddr) USING BTREE; Use it with Perl: use Apache::Session::Browseable::MySQL; my $args = { DataSource => 'dbi:mysql:sessions', UserName => $db_user, Password => $db_pass, LockDataSource => 'dbi:mysql:sessions', LockUserName => $db_user, LockPassword => $db_pass, # Choose your browseable fileds Index => 'uid mail', }; # Use it like Apache::Session my %session; tie %session, 'Apache::Session::Browseable::MySQL', $id, $args; $session{uid} = 'me'; $session{mail} = 'me@me.com'; $session{unindexedField} = 'zz'; untie %session; # Apache::Session::Browseable add some global class methods # # 1) search on a field (indexed or not) my $hash = Apache::Session::Browseable::MySQL->searchOn( $args, 'uid', 'me' ); foreach my $id (keys %$hash) { print $id . ":" . $hash->{$id}->{mail} . "\n"; } # 2) Parse all sessions # a. get all sessions my $hash = Apache::Session::Browseable::MySQL->get_key_from_all_sessions(); # b. get some fields from all sessions my $hash = Apache::Session::Browseable::MySQL->get_key_from_all_sessions('uid', 'mail') # c. execute something with datas from each session : # Example : get uid and mail if mail domain is my $hash = Apache::Session::Browseable::MySQL->get_key_from_all_sessions( sub { my ( $session, $id ) = @_; if ( $session->{mail} =~ /mydomain.com$/ ) { return { $session->{uid}, $session->{mail} }; } } ); foreach my $id (keys %$hash) { print $id . ":" . $hash->{$id}->{uid} . "=>" . $hash->{$id}->{mail} . "\n"; } =head1 DESCRIPTION Apache::Session::browseable provides some class methods to manipulate all sessions and add the capability to index some fields to make research faster. =head1 SEE ALSO L =head1 AUTHOR Xavier Guimard, Ex.guimard@free.frE =head1 COPYRIGHT AND LICENSE =encoding utf8 Copyright (C) 2009-2017 by Xavier Guimard 2013-2017 by Clément Oudot This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.10.1 or, at your option, any later version of Perl 5 you may have available. =cut Apache-Session-Browseable-1.3.13/lib/Apache/Session/Browseable/MySQLJSON.pm000444001750001750 1614214451523531 25331 0ustar00yaddyadd000000000000package Apache::Session::Browseable::MySQLJSON; use strict; use Apache::Session; use Apache::Session::Lock::Null; use Apache::Session::Browseable::Store::MySQL; use Apache::Session::Generate::SHA256; use Apache::Session::Serialize::JSON; use Apache::Session::Browseable::DBI; our $VERSION = '1.3.9'; our @ISA = qw(Apache::Session::Browseable::DBI Apache::Session); sub populate { my $self = shift; $self->{object_store} = new Apache::Session::Browseable::Store::MySQL $self; $self->{lock_manager} = new Apache::Session::Lock::Null $self; $self->{generate} = \&Apache::Session::Generate::SHA256::generate; $self->{validate} = \&Apache::Session::Generate::SHA256::validate; $self->{serialize} = \&Apache::Session::Serialize::JSON::serialize; $self->{unserialize} = \&Apache::Session::Serialize::JSON::unserialize; return $self; } sub searchOn { my ( $class, $args, $selectField, $value, @fields ) = @_; $selectField =~ s/'/''/g; my $query = { query => qq'a_session->>"\$.$selectField" =?', values => [$value] }; return $class->_query( $args, $query, @fields ); } sub searchOnExpr { my ( $class, $args, $selectField, $value, @fields ) = @_; $selectField =~ s/'/''/g; $value =~ s/\*/%/g; my $query = { query => qq'a_session->>"\$.$selectField" like ?', values => [$value] }; return $class->_query( $args, $query, @fields ); } sub _query { my ( $class, $args, $query, @fields ) = @_; my %res = (); my $index = ref( $args->{Index} ) ? $args->{Index} : [ split /\s+/, $args->{Index} ]; my $dbh = $class->_classDbh($args); my $table_name = $args->{TableName} || $Apache::Session::Store::DBI::TableName; my $sth; my $fields = join( ',', 'id', map { s/'//g; qq(a_session->>"\$.$_" AS $_) } @fields ); $sth = $dbh->prepare("SELECT $fields from $table_name where $query->{query}"); $sth->execute( @{ $query->{values} } ); # In this case, PostgreSQL change field name in lowercase my $res = $sth->fetchall_hashref('id') or return {}; foreach (@fields) { if ( $_ ne lc($_) ) { foreach my $s ( keys %$res ) { $res->{$s}->{$_} = delete $res->{$s}->{ lc $_ }; } } } return $res; } sub deleteIfLowerThan { my ( $class, $args, $rule ) = @_; my $query; if ( $rule->{or} ) { $query = join ' OR ', map { qq{cast(a_session->>"\$.$_" as UNSIGNED) < $rule->{or}->{$_}} } keys %{ $rule->{or} }; } elsif ( $rule->{and} ) { $query = join ' AND ', map { qq{cast(a_session->>"\$.$_" as UNSIGNED) < $rule->{or}->{$_}} } keys %{ $rule->{or} }; } if ( $rule->{not} ) { $query = "($query) AND " . join( ' AND ', map { qq{a_session->>"\$.$_" <> '$rule->{not}->{$_}'} } keys %{ $rule->{not} } ); } return 0 unless ($query); my $dbh = $class->_classDbh($args); my $table_name = $args->{TableName} || $Apache::Session::Store::DBI::TableName; my $rows = $dbh->do("DELETE FROM $table_name WHERE $query"); return 0 unless defined $rows; if (wantarray) { $rows = 0 if $rows == -1; return ( 1, $rows ); } else { return 1; } } sub get_key_from_all_sessions { my ( $class, $args, $data ) = @_; my $table_name = $args->{TableName} || $Apache::Session::Store::DBI::TableName; my $dbh = $class->_classDbh($args); my $sth; # Special case if all wanted fields are indexed if ( $data and ref($data) ne 'CODE' ) { $data = [$data] unless ( ref($data) ); my $fields = join ',', map { s/'//g; qq{a_session->>"\$.$_" AS $_} } @$data; $sth = $dbh->prepare("SELECT $fields from $table_name"); $sth->execute; return $sth->fetchall_hashref('id'); } $sth = $dbh->prepare_cached("SELECT id,a_session from $table_name"); $sth->execute; my %res; while ( my @row = $sth->fetchrow_array ) { no strict 'refs'; my $self = eval "&${class}::populate();"; eval { my $sub = $self->{unserialize}; my $tmp = &$sub( { serialized => $row[1] } ); if ( ref($data) eq 'CODE' ) { $tmp = &$data( $tmp, $row[0] ); $res{ $row[0] } = $tmp if ( defined($tmp) ); } elsif ($data) { $data = [$data] unless ( ref($data) ); $res{ $row[0] }->{$_} = $tmp->{$_} foreach (@$data); } else { $res{ $row[0] } = $tmp; } }; if ($@) { print STDERR "Error in session $row[0]: $@\n"; delete $res{ $row[0] }; } } return \%res; } sub _classDbh { my ( $class, $args ) = @_; my $datasource = $args->{DataSource} or die "No datasource given !"; my $username = $args->{UserName}; my $password = $args->{Password}; my $dbh = DBI->connect_cached( $datasource, $username, $password, { RaiseError => 1, AutoCommit => 1 } ) || die $DBI::errstr; $dbh->{mysql_enable_utf8} = 1; return $dbh; } 1; __END__ =head1 NAME Apache::Session::Browseable::MySQL - Add index and search methods to Apache::Session::MySQL =head1 SYNOPSIS Create table with columns for indexed fields. Example for Lemonldap::NG with optional virtual tables and indexes: CREATE TABLE sessions ( id varchar(64) not null primary key, a_session json, as_wt varchar(32) AS (a_session->"$._whatToTrace") VIRTUAL, as_sk varchar(12) AS (a_session->"$._session_kind") VIRTUAL, as_ut bigint AS (a_session->"$._utime") VIRTUAL, as_ip varchar(40) AS (a_session->"$.ipAddr") VIRTUAL, KEY as_wt (as_wt), KEY as_sk (as_sk), KEY as_ut (as_ut), KEY as_ip (as_ip) ) ENGINE=InnoDB; Use it with Perl: use Apache::Session::Browseable::MySQLJSON; my $args = { DataSource => 'dbi:mysql:sessions', UserName => $db_user, Password => $db_pass, LockDataSource => 'dbi:mysql:sessions', LockUserName => $db_user, LockPassword => $db_pass, # Choose your browseable fileds Index => 'uid mail', }; Use it like L =head1 DESCRIPTION Apache::Session::browseable provides some class methods to manipulate all sessions and add the capability to index some fields to make research faster. Apache::Session::Browseable::MySQLJSON implements it for MySQL databases using "json" type to be able to browse sessions. THIS MODULE ISN'T USABLE WITH MARIADB FOR NOW. =head1 SEE ALSO L, L, L =head1 AUTHOR Xavier Guimard, Ex.guimard@free.frE =head1 COPYRIGHT AND LICENSE =encoding utf8 Copyright (C) 2009-2017 by Xavier Guimard 2013-2017 by Clément Oudot This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.10.1 or, at your option, any later version of Perl 5 you may have available. =cut Apache-Session-Browseable-1.3.13/lib/Apache/Session/Browseable/Oracle.pm000444001750001750 157014451523531 25056 0ustar00yaddyadd000000000000package Apache::Session::Browseable::Oracle; use strict; use Apache::Session; use Apache::Session::Lock::Null; use Apache::Session::Browseable::Store::Oracle; use Apache::Session::Generate::SHA256; use Apache::Session::Serialize::JSON; use Apache::Session::Browseable::DBI; our $VERSION = '1.2.2'; our @ISA = qw(Apache::Session::Browseable::DBI Apache::Session); sub populate { my $self = shift; $self->{object_store} = new Apache::Session::Browseable::Store::Oracle $self; $self->{lock_manager} = new Apache::Session::Lock::Null $self; $self->{generate} = \&Apache::Session::Generate::SHA256::generate; $self->{validate} = \&Apache::Session::Generate::SHA256::validate; $self->{serialize} = \&Apache::Session::Serialize::JSONserialize; $self->{unserialize} = \&Apache::Session::Serialize::JSONunserialize; return $self; } 1; Apache-Session-Browseable-1.3.13/lib/Apache/Session/Browseable/PgHstore.pm000444001750001750 1550514451523531 25427 0ustar00yaddyadd000000000000package Apache::Session::Browseable::PgHstore; use strict; use Apache::Session; use Apache::Session::Lock::Null; use Apache::Session::Browseable::Store::Postgres; use Apache::Session::Generate::SHA256; use Apache::Session::Serialize::Hstore; our $VERSION = '1.3.9'; our @ISA = qw(Apache::Session); sub populate { my $self = shift; $self->{object_store} = new Apache::Session::Browseable::Store::Postgres $self; $self->{lock_manager} = new Apache::Session::Lock::Null $self; $self->{generate} = \&Apache::Session::Generate::SHA256::generate; $self->{validate} = \&Apache::Session::Generate::SHA256::validate; $self->{serialize} = \&Apache::Session::Serialize::Hstore::serialize; $self->{unserialize} = \&Apache::Session::Serialize::Hstore::unserialize; return $self; } sub searchOn { my ( $class, $args, $selectField, $value, @fields ) = @_; $selectField =~ s/'/''/g; my $query = { query => "a_session -> '$selectField' =?", values => [$value] }; return $class->_query( $args, $query, @fields ); } sub searchOnExpr { my ( $class, $args, $selectField, $value, @fields ) = @_; $selectField =~ s/'/''/g; $value =~ s/\*/%/g; my $query = { query => "a_session -> '$selectField' like ?", values => [$value] }; return $class->_query( $args, $query, @fields ); } sub _query { my ( $class, $args, $query, @fields ) = @_; my %res = (); my $dbh = $class->_classDbh($args); my $table_name = $args->{TableName} || $Apache::Session::Store::DBI::TableName; my $sth; my $fields = @fields ? join( ',', 'id', map { s/'//g; "a_session -> '$_' AS $_" } @fields ) : '*'; $sth = $dbh->prepare("SELECT $fields from $table_name where $query->{query}"); $sth->execute( @{ $query->{values} } ); # In this case, PostgreSQL change field name in lowercase my $res = $sth->fetchall_hashref('id') or return {}; if (@fields) { foreach (@fields) { if ( $_ ne lc($_) ) { foreach my $s ( keys %$res ) { $res->{$s}->{$_} = delete $res->{$s}->{ lc $_ }; } } } } else { my $self = eval "&${class}::populate();"; my $sub = $self->{unserialize}; foreach my $s ( keys %$res ) { eval { my $tmp = &$sub( { serialized => $res->{$s}->{a_session} } ); $res->{$s} = $tmp; }; if ($@) { print STDERR "Error in session $s: $@\n"; delete $res->{$s}; } } } return $res; } sub deleteIfLowerThan { my ( $class, $args, $rule ) = @_; my $query; if ( $rule->{or} ) { $query = join ' OR ', map { "cast(a_session -> '$_' as bigint) < $rule->{or}->{$_}" } keys %{ $rule->{or} }; } elsif ( $rule->{and} ) { $query = join ' AND ', map { "cast(a_session -> '$_' as bigint) < $rule->{or}->{$_}" } keys %{ $rule->{or} }; } if ( $rule->{not} ) { $query = "($query) AND " . join( ' AND ', map { "a_session -> '$_' <> '$rule->{not}->{$_}'" } keys %{ $rule->{not} } ); } return 0 unless ($query); my $dbh = $class->_classDbh($args); my $table_name = $args->{TableName} || $Apache::Session::Store::DBI::TableName; my $rows = $dbh->do("DELETE FROM $table_name WHERE $query"); return 0 unless defined $rows; if (wantarray) { $rows = 0 if $rows == -1; return ( 1, $rows ); } else { return 1; } } sub get_key_from_all_sessions { my ( $class, $args, $data ) = @_; my $table_name = $args->{TableName} || $Apache::Session::Store::DBI::TableName; my $dbh = $class->_classDbh($args); my $sth; # Special case if all wanted fields are indexed if ( $data and ref($data) ne 'CODE' ) { $data = [$data] unless ( ref($data) ); my $fields = join ',', map { s/'//g; "a_session -> '$_' AS $_" } @$data; $sth = $dbh->prepare("SELECT $fields from $table_name"); $sth->execute; return $sth->fetchall_hashref('id'); } $sth = $dbh->prepare_cached("SELECT id,a_session from $table_name"); $sth->execute; my %res; while ( my @row = $sth->fetchrow_array ) { no strict 'refs'; my $self = eval "&${class}::populate();"; my $sub = $self->{unserialize}; my $tmp = &$sub( { serialized => $row[1] } ); if ( ref($data) eq 'CODE' ) { $tmp = &$data( $tmp, $row[0] ); $res{ $row[0] } = $tmp if ( defined($tmp) ); } elsif ($data) { $data = [$data] unless ( ref($data) ); $res{ $row[0] }->{$_} = $tmp->{$_} foreach (@$data); } else { $res{ $row[0] } = $tmp; } } return \%res; } sub _classDbh { my ( $class, $args ) = @_; my $datasource = $args->{DataSource} or die "No datasource given !"; my $username = $args->{UserName}; my $password = $args->{Password}; my $dbh = DBI->connect_cached( $datasource, $username, $password, { RaiseError => 1, AutoCommit => 1 } ) || die $DBI::errstr; $dbh->{pg_enable_utf8} = 1; return $dbh; } 1; __END__ =head1 NAME Apache::Session::Browseable::PgHstore - Hstore type support for L =head1 SYNOPSIS Enable "hstore" extension in PostgreSQL database CREATE EXTENSION hstore; Create table: CREATE UNLOGGED TABLE sessions ( id varchar(64) not null primary key, a_session hstore, ); Optionally, add indexes on some fields. Example for Lemonldap::NG: CREATE INDEX uid1 ON sessions USING BTREE ( (a_session -> '_whatToTrace') ); CREATE INDEX s1 ON sessions ( (a_session -> '_session_kind') ); CREATE INDEX u1 ON sessions ( ( cast(a_session -> '_utime' AS bigint) ) ); CREATE INDEX ip1 ON sessions USING BTREE ( (a_session -> 'ipAddr') ); Use it like L except that you don't need to declare indexes =head1 DESCRIPTION Apache::Session::Browseable provides some class methods to manipulate all sessions and add the capability to index some fields to make research faster. Apache::Session::Browseable::PgHstore implements it for PosqtgreSQL databases using "hstore" extension to be able to browse sessions. =head1 SEE ALSO L, L =head1 AUTHOR Xavier Guimard, Ex.guimard@free.frE =head1 COPYRIGHT AND LICENSE =encoding utf8 Copyright (C) 2009-2017 by Xavier Guimard 2013-2017 by Clément Oudot This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.10.1 or, at your option, any later version of Perl 5 you may have available. =cut Apache-Session-Browseable-1.3.13/lib/Apache/Session/Browseable/PgJSON.pm000444001750001750 1571214451523531 24734 0ustar00yaddyadd000000000000package Apache::Session::Browseable::PgJSON; use strict; use Apache::Session; use Apache::Session::Lock::Null; use Apache::Session::Browseable::Store::Postgres; use Apache::Session::Generate::SHA256; use Apache::Session::Serialize::JSON; our $VERSION = '1.3.9'; our @ISA = qw(Apache::Session); sub populate { my $self = shift; $self->{object_store} = new Apache::Session::Browseable::Store::Postgres $self; $self->{lock_manager} = new Apache::Session::Lock::Null $self; $self->{generate} = \&Apache::Session::Generate::SHA256::generate; $self->{validate} = \&Apache::Session::Generate::SHA256::validate; $self->{serialize} = \&Apache::Session::Serialize::JSON::serialize; $self->{unserialize} = \&Apache::Session::Serialize::JSON::unserialize; return $self; } sub searchOn { my ( $class, $args, $selectField, $value, @fields ) = @_; $selectField =~ s/'/''/g; my $query = { query => "a_session ->> '$selectField' =?", values => [$value] }; return $class->_query( $args, $query, @fields ); } sub searchOnExpr { my ( $class, $args, $selectField, $value, @fields ) = @_; $selectField =~ s/'/''/g; $value =~ s/\*/%/g; my $query = { query => "a_session ->> '$selectField' like ?", values => [$value] }; return $class->_query( $args, $query, @fields ); } sub _query { my ( $class, $args, $query, @fields ) = @_; my %res = (); my $dbh = $class->_classDbh($args); my $table_name = $args->{TableName} || $Apache::Session::Store::DBI::TableName; my $sth; my $fields = @fields ? join( ',', 'id', map { s/'//g; "a_session ->> '$_' AS $_" } @fields ) : '*'; $sth = $dbh->prepare("SELECT $fields from $table_name where $query->{query}"); $sth->execute( @{ $query->{values} } ); # In this case, PostgreSQL change field name in lowercase my $res = $sth->fetchall_hashref('id') or return {}; if (@fields) { foreach (@fields) { if ( $_ ne lc($_) ) { foreach my $s ( keys %$res ) { $res->{$s}->{$_} = delete $res->{$s}->{ lc $_ }; } } } } else { my $self = eval "&${class}::populate();"; my $sub = $self->{unserialize}; foreach my $s ( keys %$res ) { eval { my $tmp = &$sub( { serialized => $res->{$s}->{a_session} } ); $res->{$s} = $tmp; }; if ($@) { print STDERR "Error in session $s: $@\n"; delete $res->{$s}; } } } return $res; } sub deleteIfLowerThan { my ( $class, $args, $rule ) = @_; my $query; if ( $rule->{or} ) { $query = join ' OR ', map { "cast(a_session ->> '$_' as bigint) < $rule->{or}->{$_}" } keys %{ $rule->{or} }; } elsif ( $rule->{and} ) { $query = join ' AND ', map { "cast(a_session ->> '$_' as bigint) < $rule->{or}->{$_}" } keys %{ $rule->{or} }; } if ( $rule->{not} ) { $query = "($query) AND " . join( ' AND ', map { "a_session ->> '$_' <> '$rule->{not}->{$_}'" } keys %{ $rule->{not} } ); } return 0 unless ($query); my $dbh = $class->_classDbh($args); my $table_name = $args->{TableName} || $Apache::Session::Store::DBI::TableName; my $rows = $dbh->do("DELETE FROM $table_name WHERE $query"); return 0 unless defined $rows; if (wantarray) { $rows = 0 if $rows == -1; return ( 1, $rows ); } else { return 1; } } sub get_key_from_all_sessions { my ( $class, $args, $data ) = @_; my $table_name = $args->{TableName} || $Apache::Session::Store::DBI::TableName; my $dbh = $class->_classDbh($args); my $sth; # Special case if all wanted fields are indexed if ( $data and ref($data) ne 'CODE' ) { $data = [$data] unless ( ref($data) ); my $fields = join ',', map { s/'//g; "a_session ->> '$_' AS $_" } @$data; $sth = $dbh->prepare("SELECT $fields from $table_name"); $sth->execute; return $sth->fetchall_hashref('id'); } $sth = $dbh->prepare_cached("SELECT id,a_session from $table_name"); $sth->execute; my %res; while ( my @row = $sth->fetchrow_array ) { no strict 'refs'; my $self = eval "&${class}::populate();"; eval { my $sub = $self->{unserialize}; my $tmp = &$sub( { serialized => $row[1] } ); if ( ref($data) eq 'CODE' ) { $tmp = &$data( $tmp, $row[0] ); $res{ $row[0] } = $tmp if ( defined($tmp) ); } elsif ($data) { $data = [$data] unless ( ref($data) ); $res{ $row[0] }->{$_} = $tmp->{$_} foreach (@$data); } else { $res{ $row[0] } = $tmp; } }; if ($@) { print STDERR "Error in session $row[0]: $@\n"; delete $res{ $row[0] }; } } return \%res; } sub _classDbh { my ( $class, $args ) = @_; my $datasource = $args->{DataSource} or die "No datasource given !"; my $username = $args->{UserName}; my $password = $args->{Password}; my $dbh = DBI->connect_cached( $datasource, $username, $password, { RaiseError => 1, AutoCommit => 1 } ) || die $DBI::errstr; $dbh->{pg_enable_utf8} = 1; return $dbh; } 1; __END__ =head1 NAME Apache::Session::Browseable::PgJSON - Hstore type support for L =head1 SYNOPSIS Create table: CREATE UNLOGGED TABLE sessions ( id varchar(64) not null primary key, a_session jsonb, ); Optionally, add indexes on some fields. Example for Lemonldap::NG: CREATE INDEX uid1 ON sessions USING BTREE ( (a_session ->> '_whatToTrace') ); CREATE INDEX s1 ON sessions ( (a_session ->> '_session_kind') ); CREATE INDEX u1 ON sessions ( ( cast(a_session ->> '_utime' AS bigint) ) ); CREATE INDEX ip1 ON sessions USING BTREE ( (a_session ->> 'ipAddr') ); Use it like L except that you don't need to declare indexes =head1 DESCRIPTION Apache::Session::Browseable provides some class methods to manipulate all sessions and add the capability to index some fields to make research faster. Apache::Session::Browseable::PgJSON implements it for PosqtgreSQL databases using "json" or "jsonb" type to be able to browse sessions. =head1 SEE ALSO L, L =head1 AUTHOR Xavier Guimard, Ex.guimard@free.frE =head1 COPYRIGHT AND LICENSE =encoding utf8 Copyright (C) 2009-2017 by Xavier Guimard 2013-2017 by Clément Oudot This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.10.1 or, at your option, any later version of Perl 5 you may have available. =cut Apache-Session-Browseable-1.3.13/lib/Apache/Session/Browseable/Postgres.pm000444001750001750 1123614451523531 25477 0ustar00yaddyadd000000000000package Apache::Session::Browseable::Postgres; use strict; use Apache::Session; use Apache::Session::Lock::Null; use Apache::Session::Browseable::Store::Postgres; use Apache::Session::Generate::SHA256; use Apache::Session::Serialize::JSON; use Apache::Session::Browseable::DBI; our $VERSION = '1.3.1'; our @ISA = qw(Apache::Session::Browseable::DBI Apache::Session); sub populate { my $self = shift; $self->{object_store} = new Apache::Session::Browseable::Store::Postgres $self; $self->{lock_manager} = new Apache::Session::Lock::Null $self; $self->{generate} = \&Apache::Session::Generate::SHA256::generate; $self->{validate} = \&Apache::Session::Generate::SHA256::validate; $self->{serialize} = \&Apache::Session::Serialize::JSON::serialize; $self->{unserialize} = \&Apache::Session::Serialize::JSON::unserialize; return $self; } sub searchOn { my $class = shift; my ( $args, $selectField, $value, @fields ) = @_; my $res = $class->SUPER::searchOn(@_); # Ensure fields case is preserved foreach (@fields) { if ( $_ ne lc($_) ) { foreach my $s ( keys %$res ) { $res->{$s}->{$_} = delete $res->{$s}->{ lc $_ } if $res->{$s}->{ lc $_ }; } } } return $res; } sub searchOnExpr { my $class = shift; my ( $args, $selectField, $value, @fields ) = @_; my $res = $class->SUPER::searchOnExpr(@_); # Ensure fields case is preserved foreach (@fields) { if ( $_ ne lc($_) ) { foreach my $s ( keys %$res ) { $res->{$s}->{$_} = delete $res->{$s}->{ lc $_ } if $res->{$s}->{ lc $_ }; } } } return $res; } 1; __END__ =head1 NAME Apache::Session::Browseable::Postgres - Add index and search methods to L =head1 SYNOPSIS Create table with columns for indexed fields. Example for Lemonldap::NG: CREATE UNLOGGED TABLE sessions ( id varchar(64) not null primary key, a_session text, _whatToTrace text, _session_kind text, _utime bigint, ipAddr varchar(64) ); Add indexes: CREATE INDEX uid1 ON sessions USING BTREE (_whatToTrace); CREATE INDEX s1 ON sessions (_session_kind); CREATE INDEX u1 ON sessions (_utime); CREATE INDEX ip1 ON sessions USING BTREE (ipAddr); Use it with Perl: use Apache::Session::Browseable::Postgres; my $args = { DataSource => 'dbi:Pg:sessions', UserName => $db_user, Password => $db_pass, Commit => 1, # Choose your browseable fileds Index => '_whatToTrace _session_kind _utime iAddr', }; # Use it like Apache::Session my %session; tie %session, 'Apache::Session::Browseable::Postgres', $id, $args; $session{uid} = 'me'; $session{mail} = 'me@me.com'; $session{unindexedField} = 'zz'; untie %session; # Apache::Session::Browseable add some global class methods # # 1) search on a field (indexed or not) my $hash = Apache::Session::Browseable::Postgres->searchOn( $args, 'uid', 'me' ); foreach my $id (keys %$hash) { print $id . ":" . $hash->{$id}->{mail} . "\n"; } # 2) Parse all sessions # a. get all sessions my $hash = Apache::Session::Browseable::Postgres->get_key_from_all_sessions(); # b. get some fields from all sessions my $hash = Apache::Session::Browseable::Postgres->get_key_from_all_sessions('uid', 'mail') # c. execute something with datas from each session : # Example : get uid and mail if mail domain is my $hash = Apache::Session::Browseable::Postgres->get_key_from_all_sessions( sub { my ( $session, $id ) = @_; if ( $session->{mail} =~ /mydomain.com$/ ) { return { $session->{uid}, $session->{mail} }; } } ); foreach my $id (keys %$hash) { print $id . ":" . $hash->{$id}->{uid} . "=>" . $hash->{$id}->{mail} . "\n"; } =head1 DESCRIPTION Apache::Session::Browseable provides some class methods to manipulate all sessions and add the capability to index some fields to make research faster. Apache::Session::Browseable::Postgres implements it for PosqtgreSQL databases. =head1 SEE ALSO L, L =head1 AUTHOR Xavier Guimard, Ex.guimard@free.frE =head1 COPYRIGHT AND LICENSE =encoding utf8 Copyright (C) 2009-2017 by Xavier Guimard 2013-2017 by Clément Oudot This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.10.1 or, at your option, any later version of Perl 5 you may have available. =cut Apache-Session-Browseable-1.3.13/lib/Apache/Session/Browseable/Redis.pm000444001750001750 1445714451523531 24747 0ustar00yaddyadd000000000000package Apache::Session::Browseable::Redis; use strict; use Apache::Session; use Apache::Session::Browseable::Store::Redis; use Apache::Session::Generate::SHA256; use Apache::Session::Lock::Null; use Apache::Session::Serialize::JSON; use Apache::Session::Browseable::_common; our $VERSION = '1.3.9'; our @ISA = qw(Apache::Session); our $redis = $Apache::Session::Browseable::Store::Redis::redis; sub populate { my $self = shift; $self->{object_store} = new Apache::Session::Browseable::Store::Redis $self; $self->{lock_manager} = new Apache::Session::Lock::Null $self; $self->{generate} = \&Apache::Session::Generate::SHA256::generate; $self->{validate} = \&Apache::Session::Generate::SHA256::validate; $self->{serialize} = \&Apache::Session::Serialize::JSON::serialize; $self->{unserialize} = \&Apache::Session::Serialize::JSON::unserialize; return $self; } sub unserialize { my $session = shift; my $tmp = { serialized => $session }; Apache::Session::Serialize::JSON::unserialize($tmp); return $tmp->{data}; } sub searchOn { my ( $class, $args, $selectField, $value, @fields ) = @_; my %res = (); my $index = ref( $args->{Index} ) ? $args->{Index} : [ split /\s+/, $args->{Index} ]; if ( grep { $_ eq $selectField } @$index ) { my $redisObj = $class->_getRedis($args); my @keys = $redisObj->smembers("${selectField}_$value"); foreach my $k (@keys) { next unless ($k); my $tmp = $redisObj->get($k); next unless ($tmp); eval { $tmp = unserialize($tmp); if (@fields) { $res{$k}->{$_} = $tmp->{$_} foreach (@fields); } else { $res{$k} = $tmp; } }; if ($@) { print STDERR "Error in session $k: $@\n"; delete $res{$k}; } } } else { $class->get_key_from_all_sessions( $args, sub { my $entry = shift; my $id = shift; return undef unless ( defined $entry->{$selectField} and $entry->{$selectField} eq $value ); if (@fields) { $res{$id}->{$_} = $entry->{$_} foreach (@fields); } else { $res{$id} = $entry; } undef; } ); } return \%res; } sub get_key_from_all_sessions { my $class = shift; my $args = shift; my $data = shift; my %res; my $redisObj = $class->_getRedis($args); my @keys = $redisObj->keys('*'); foreach my $k (@keys) { next if ( !$k or $k =~ /_/ ); eval { my $v = $redisObj->get($k); next unless $v; my $tmp = unserialize($v); if ( ref($data) eq 'CODE' ) { $tmp = &$data( $tmp, $k ); $res{$k} = $tmp if ( defined($tmp) ); } elsif ($data) { $data = [$data] unless ( ref($data) ); $res{$k}->{$_} = $tmp->{$_} foreach (@$data); } else { $res{$k} = $tmp; } }; if ($@) { print STDERR "Error in session $k: $@\n"; delete $res{$k}; } } return \%res; } sub _getRedis { my $class = shift; my $args = shift; # Manage undef encoding $args->{encoding} = undef if ( $args->{encoding} and $args->{encoding} eq "undef" ); # If sentinels is not given as an array ref, try to parse # a comma delimited list instead if ( $args->{sentinels} and ref $args->{sentinels} ne 'ARRAY' ) { $args->{sentinels} = [ split /[,\s]+/, $args->{sentinels} ]; } my $redisObj = $redis->new( %{$args} ); # Manage database $redisObj->select( $args->{database} ) if defined $args->{database}; return $redisObj; } 1; __END__ =head1 NAME Apache::Session::Browseable::Redis - Add index and search methods to Apache::Session::Redis =head1 SYNOPSIS use Apache::Session::Browseable::Redis; my $args = { server => '127.0.0.1:6379', # Select database (optional) #database => 0, # Choose your browseable fields Index => 'uid mail', }; # Use it like Apache::Session my %session; tie %session, 'Apache::Session::Browseable::Redis', $id, $args; $session{uid} = 'me'; $session{mail} = 'me@me.com'; $session{unindexedField} = 'zz'; untie %session; # Apache::Session::Browseable add some global class methods # # 1) search on a field (indexed or not) my $hash = Apache::Session::Browseable::Redis->searchOn( $args, 'uid', 'me' ); foreach my $id (keys %$hash) { print $id . ":" . $hash->{$id}->{mail} . "\n"; } # 2) Parse all sessions # a. get all sessions my $hash = Apache::Session::Browseable::Redis->get_key_from_all_sessions($args); # b. get some fields from all sessions my $hash = Apache::Session::Browseable::Redis->get_key_from_all_sessions($args, 'uid', 'mail') # c. execute something with datas from each session : # Example : get uid and mail if mail domain is my $hash = Apache::Session::Browseable::Redis->get_key_from_all_sessions( $args, sub { my ( $session, $id ) = @_; if ( $session->{mail} =~ /mydomain.com$/ ) { return { $session->{uid}, $session->{mail} }; } } ); foreach my $id (keys %$hash) { print $id . ":" . $hash->{$id}->{uid} . "=>" . $hash->{$id}->{mail} . "\n"; } =head1 DESCRIPTION Apache::Session::browseable provides some class methods to manipulate all sessions and add the capability to index some fields to make research faster. This module use either L or L. =head1 SEE ALSO L =head1 AUTHOR Xavier Guimard, Ex.guimard@free.frE =head1 COPYRIGHT AND LICENSE Copyright (C) 2009-2018 by Xavier Guimard This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.10.1 or, at your option, any later version of Perl 5 you may have available. =cut Apache-Session-Browseable-1.3.13/lib/Apache/Session/Browseable/SQLite.pm000444001750001750 542714451523531 25017 0ustar00yaddyadd000000000000############################################################################# # # Apache::Session::Browseable::SQLite # Apache persistent user sessions in a SQLite database # Copyright(c) 2013-2017 Xavier Guimard # Inspired by Apache::Session::Postgres # (copyright(c) 1998, 1999, 2000 Jeffrey William Baker (jwbaker@acm.org)) # Distribute under the Perl License # ############################################################################ package Apache::Session::Browseable::SQLite; use strict; use Apache::Session; use Apache::Session::Lock::Null; use Apache::Session::Browseable::Store::SQLite; use Apache::Session::Generate::SHA256; use Apache::Session::Serialize::JSON; use Apache::Session::Browseable::DBI; our $VERSION = '1.2.2'; our @ISA = qw(Apache::Session::Browseable::DBI Apache::Session); sub populate { my $self = shift; $self->{object_store} = new Apache::Session::Browseable::Store::SQLite $self; $self->{lock_manager} = new Apache::Session::Lock::Null $self; $self->{generate} = \&Apache::Session::Generate::SHA256::generate; $self->{validate} = \&Apache::Session::Generate::SHA256::validate; $self->{serialize} = \&Apache::Session::Serialize::JSON::serialize; $self->{unserialize} = \&Apache::Session::Serialize::JSON::unserialize; return $self; } 1; =pod =head1 NAME Apache::Session::Browseable::SQLite - An implementation of Apache::Session =head1 SYNOPSIS use Apache::Session::Browseable::SQLite; #if you want Apache::Session to open new DB handles: tie %hash, 'Apache::Session::Browseable::SQLite', $id, { DataSource => 'dbi:Pg:dbname=sessions', UserName => $db_user, Password => $db_pass, Commit => 1 }; #or, if your handles are already opened: tie %hash, 'Apache::Session::Browseable::SQLite', $id, { Handle => $dbh, Commit => 1 }; L function are also available =head1 DESCRIPTION This module is an implementation of Apache::Session. It uses the SQLite backing store and no locking. See the example, and the documentation for Apache::Session::Browseable::Store::SQLite for more details. =head1 USAGE The special Apache::Session argument for this module is Commit. You MUST provide the Commit argument, which instructs this module to either commit the transaction when it is finished, or to simply do nothing. This feature is provided so that this module will not have adverse interactions with your local transaction policy, nor your local database handle caching policy. The argument is mandatory in order to make you think about this problem. =head1 AUTHOR This module was written by Xavier Guimard using Apache::Session::Postgres from Jeffrey William Baker as example. =head1 SEE ALSO L Apache-Session-Browseable-1.3.13/lib/Apache/Session/Browseable/Sybase.pm000444001750001750 200514451523531 25071 0ustar00yaddyadd000000000000package Apache::Session::Browseable::Sybase; use strict; use Apache::Session; use Apache::Session::Lock::Null; use Apache::Session::Browseable::Store::Sybase; use Apache::Session::Generate::SHA256; use Apache::Session::Serialize::Sybase; use Apache::Session::Browseable::DBI; our $VERSION = '1.2.2'; our @ISA = qw(Apache::Session::Browseable::DBI Apache::Session); *serialize = \&Apache::Session::Serialize::Sybase::serialize; *unserialize = \&Apache::Session::Serialize::Sybase::unserialize; sub populate { my $self = shift; $self->{object_store} = new Apache::Session::Browseable::Store::Sybase $self; $self->{lock_manager} = new Apache::Session::Lock::Null $self; $self->{generate} = \&Apache::Session::Generate::SHA256::generate; $self->{validate} = \&Apache::Session::Generate::SHA256::validate; $self->{serialize} = \&Apache::Session::Serialize::Sybase::serialize; $self->{unserialize} = \&Apache::Session::Serialize::Sybase::unserialize; return $self; } 1; Apache-Session-Browseable-1.3.13/lib/Apache/Session/Browseable/_common.pm000444001750001750 332714451523531 25302 0ustar00yaddyadd000000000000package Apache::Session::Browseable::_common; use strict; use AutoLoader 'AUTOLOAD'; our $VERSION = '1.2.2'; sub _tabInTab { my ( $class, $t1, $t2 ) = @_; # if no fields are required, return 0 return 0 unless(@$t1 and @$t2); foreach my $f (@$t1) { unless ( grep { $_ eq $f } @$t2 ) { return 0; } } return 1; } sub _fieldIsIndexed { my ( $class, $args, $field ) = @_; my $index = ref( $args->{Index} ) ? $args->{Index} : [ split /\s+/, $args->{Index} ]; return ( grep { $_ eq $field } @$index ); } 1; __END__ sub searchOn { my ( $class, $args, $selectField, $value, @fields ) = splice @_; my %res = (); $class->get_key_from_all_sessions( $args, sub { my $entry = shift; my $id = shift; return undef unless ( $entry->{$selectField} eq $value ); if (@fields) { $res{$id}->{$_} = $entry->{$_} foreach (@fields); } else { $res{$id} = $entry; } undef; } ); return \%res; } sub searchOnExpr { my ( $class, $args, $selectField, $value, @fields ) = splice @_; $value = quotemeta($value); $value =~ s/\\\*/\.\*/g; $value = qr/^$value$/; my %res = (); $class->get_key_from_all_sessions( $args, sub { my $entry = shift; my $id = shift; return undef unless ( $entry->{$selectField} =~ $value ); if (@fields) { $res{$id}->{$_} = $entry->{$_} foreach (@fields); } else { $res{$id} = $entry; } undef; } ); return \%res; } 1; Apache-Session-Browseable-1.3.13/lib/Apache/Session/Browseable/Store000755001750001750 014451523531 24247 5ustar00yaddyadd000000000000Apache-Session-Browseable-1.3.13/lib/Apache/Session/Browseable/Store/Cassandra.pm000444001750001750 672314451523531 26651 0ustar00yaddyadd000000000000package Apache::Session::Browseable::Store::Cassandra; use strict; use Apache::Session::Store::DBI; use Apache::Session::Browseable::Store::DBI; use Apache::Session::Browseable::Store::Cassandra; our @ISA = qw(Apache::Session::Browseable::Store::DBI); our $VERSION = '1.3.13'; our $DataSource = undef; our $UserName = undef; our $Password = undef; sub connection { my $self = shift; my $session = shift; return if ( defined $self->{dbh} ); if ( exists $session->{args}->{Handle} ) { $self->{dbh} = $session->{args}->{Handle}; return; } my $datasource = $session->{args}->{DataSource} || $DataSource; my $username = $session->{args}->{UserName} || $UserName; my $password = $session->{args}->{Password} || $Password; $self->{dbh} = DBI->connect( $datasource, $username, $password, { RaiseError => 1 } ) || die $DBI::errstr; #If we open the connection, we close the connection $self->{disconnect} = 1; } sub materialize { my $self = shift; my $session = shift; $self->connection($session); local $self->{dbh}->{RaiseError} = 1; local $self->{dbh}->{LongReadLen} = $session->{args}->{LongReadLen} || 8 * 2**10; if ( !defined $self->{materialize_sth} ) { $self->{materialize_sth} = $self->{dbh}->prepare_cached( qq{ SELECT a_session FROM sessions WHERE id = ? FOR UPDATE} ); } $self->{materialize_sth}->bind_param( 1, $session->{data}->{_session_id} ); $self->{materialize_sth}->execute; my $results = $self->{materialize_sth}->fetchrow_arrayref; if ( !( defined $results ) ) { die "Object does not exist in the data store"; } $self->{materialize_sth}->finish; $session->{serialized} = $results->[0]; } sub DESTROY { my $self = shift; if ( $self->{disconnect} ) { $self->{dbh}->disconnect; } } 1; =pod =head1 NAME Apache::Session::Browseable::Store::Cassandra - Store persistent data in a Cassandra database =head1 SYNOPSIS use Apache::Session::Browseable::Store::Cassandra; my $store = new Apache::Session::Browseable::Store::Cassandra; $store->insert($ref); $store->update($ref); $store->materialize($ref); $store->remove($ref); =head1 DESCRIPTION Apache::Session::Browseable::Store::Cassandra fulfills the storage interface of Apache::Session. Session data is stored in a Cassandra database. =head1 SCHEMA To use this module, you will need at least these columns in a table called 'sessions': id text a_session text To create this schema, you can execute this command using cqlsh: CREATE TABLE sessions ( id text PRIMARY KEY, a_session text ); =head1 CONFIGURATION The module must know what datasource, username, and password to use when connecting to the database. These values can be set using the options hash (see Apache::Session documentation). The options are DataSource, UserName, and Password. Example: tie %hash, 'Apache::Session::Cassandra', $id, { DataSource => 'dbi:Cassandra:host=localhost;keyspace=llng', UserName => 'database_user', Password => 'K00l' }; Instead, you may pass in an already-opened DBI handle to your database. tie %hash, 'Apache::Session::Cassandra', $id, { Handle => $dbh }; =head1 AUTHOR This module was written by Mike Langen , based on the original for Oracle. =head1 SEE ALSO L, L 1; Apache-Session-Browseable-1.3.13/lib/Apache/Session/Browseable/Store/DBI.pm000444001750001750 372214451523531 25344 0ustar00yaddyadd000000000000package Apache::Session::Browseable::Store::DBI; use strict; use Apache::Session::Store::DBI; our @ISA = qw(Apache::Session::Store::DBI); our $VERSION = 1.3.11; sub insert { my ( $self, $session ) = @_; $self->connection($session); local $self->{dbh}->{RaiseError} = 1; my $index = ref( $session->{args}->{Index} ) ? $session->{args}->{Index} : [ split /\s+/, $session->{args}->{Index} ]; if ( !defined $self->{insert_sth} ) { $self->{insert_sth} = $self->{dbh}->prepare_cached( "INSERT INTO $self->{table_name} (" . join( ',', 'id', 'a_session', map { s/'/''/g; $_ } @$index ) . ') VALUES (' . join( ',', ('?') x ( 2 + @$index ) ) . ')' ); } $self->{insert_sth}->bind_param( 1, $session->{data}->{_session_id} ); $self->{insert_sth}->bind_param( 2, $session->{serialized} ); my $i = 3; foreach my $f (@$index) { $self->{insert_sth}->bind_param( $i, $session->{data}->{$f} ); $i++; } $self->{insert_sth}->execute; $self->{insert_sth}->finish; } sub update { my $self = shift; my $session = shift; $self->connection($session); local $self->{dbh}->{RaiseError} = 1; my $index = ref( $session->{args}->{Index} ) ? $session->{args}->{Index} : [ split /\s+/, $session->{args}->{Index} ]; if ( !defined $self->{update_sth} ) { $self->{update_sth} = $self->{dbh}->prepare_cached( "UPDATE $self->{table_name} SET " . join( ' = ?, ', 'a_session', @$index ) . ' = ? WHERE id = ?' ); } $self->{update_sth}->bind_param( 1, $session->{serialized} ); my $i = 2; foreach my $f (@$index) { $self->{update_sth}->bind_param( $i, $session->{data}->{$f} ); $i++; } $self->{update_sth}->bind_param( $i, $session->{data}->{_session_id} ); $self->{update_sth}->execute; $self->{update_sth}->finish; } 1; Apache-Session-Browseable-1.3.13/lib/Apache/Session/Browseable/Store/File.pm000444001750001750 25514451523531 25603 0ustar00yaddyadd000000000000package Apache::Session::Browseable::Store::File; use strict; use Apache::Session::Store::File; our @ISA = qw(Apache::Session::Store::File); our $VERSION = 1.2.2; 1; Apache-Session-Browseable-1.3.13/lib/Apache/Session/Browseable/Store/Informix.pm000444001750001750 42014451523531 26511 0ustar00yaddyadd000000000000package Apache::Session::Browseable::Store::Informix; use strict; use Apache::Session::Browseable::Store::DBI; use Apache::Session::Store::Informix; our @ISA = qw(Apache::Session::Browseable::Store::DBI Apache::Session::Store::Informix); our $VERSION = '1.2.2'; 1; Apache-Session-Browseable-1.3.13/lib/Apache/Session/Browseable/Store/LDAP.pm000444001750001750 2062114451523531 25503 0ustar00yaddyadd000000000000package Apache::Session::Browseable::Store::LDAP; use strict; use Net::LDAP; our $VERSION = '1.3.8'; sub new { my $class = shift; return bless {}, $class; } sub insert { my $self = shift; my $session = shift; $self->{args} = $session->{args}; $self->{args}->{ldapObjectClass} ||= 'applicationProcess'; $self->{args}->{ldapAttributeId} ||= 'cn'; $self->{args}->{ldapAttributeContent} ||= 'description'; $self->{args}->{ldapAttributeIndex} ||= 'ou'; my $index = ref( $session->{args}->{Index} ) ? $session->{args}->{Index} : [ split /\s+/, $session->{args}->{Index} ]; my $id = $session->{data}->{_session_id}; my $attrIndex; foreach my $i (@$index) { my $t; next unless ( $t = $session->{data}->{$i} ); push @$attrIndex, "${i}_$t"; } my $attrs = [ objectClass => $self->{args}->{ldapObjectClass}, $self->{args}->{ldapAttributeId} => $session->{data}->{_session_id}, $self->{args}->{ldapAttributeContent} => $session->{serialized}, ]; push @$attrs, ( $self->{args}->{ldapAttributeIndex} => $attrIndex ) if ($attrIndex); my $msg = $self->ldap->add( $self->{args}->{ldapAttributeId} . "=$id," . $self->{args}->{ldapConfBase}, attrs => $attrs, ); $self->ldap->unbind() && delete $self->{ldap}; $self->logError($msg) if ( $msg->code ); } sub update { my $self = shift; my $session = shift; $self->{args} = $session->{args}; $self->{args}->{ldapObjectClass} ||= 'applicationProcess'; $self->{args}->{ldapAttributeId} ||= 'cn'; $self->{args}->{ldapAttributeContent} ||= 'description'; $self->{args}->{ldapAttributeIndex} ||= 'ou'; my $index = ref( $session->{args}->{Index} ) ? $session->{args}->{Index} : [ split /\s+/, $session->{args}->{Index} ]; my $id = $session->{data}->{_session_id}; my $attrIndex; foreach my $i (@$index) { my $t; next unless ( $t = $session->{data}->{$i} ); push @$attrIndex, "${i}_$t"; } my $attrs = { $self->{args}->{ldapAttributeContent} => $session->{serialized} }; $attrs->{ $self->{args}->{ldapAttributeIndex} } = $attrIndex if ($attrIndex); my $msg = $self->ldap->modify( $self->{args}->{ldapAttributeId} . "=" . $session->{data}->{_session_id} . "," . $self->{args}->{ldapConfBase}, replace => $attrs, ); $self->ldap->unbind() && delete $self->{ldap}; $self->logError($msg) if ( $msg->code ); } sub materialize { my $self = shift; my $session = shift; $self->{args} = $session->{args}; $self->{args}->{ldapObjectClass} ||= 'applicationProcess'; $self->{args}->{ldapAttributeId} ||= 'cn'; $self->{args}->{ldapAttributeContent} ||= 'description'; $self->{args}->{ldapAttributeIndex} ||= 'ou'; my $msg = $self->ldap->search( base => $self->{args}->{ldapAttributeId} . "=" . $session->{data}->{_session_id} . "," . $self->{args}->{ldapConfBase}, filter => '(objectClass=' . $self->{args}->{ldapObjectClass} . ')', scope => 'base', attrs => [ $self->{args}->{ldapAttributeContent} ], ); $self->ldap->unbind() && delete $self->{ldap}; $self->logError($msg) if ( $msg->code ); eval { $session->{serialized} = $msg->shift_entry() ->get_value( $self->{args}->{ldapAttributeContent} ); }; if ( !defined $session->{serialized} ) { die "Object does not exist in data store"; } } sub remove { my $self = shift; my $session = shift; $self->{args} = $session->{args}; $self->{args}->{ldapObjectClass} ||= 'applicationProcess'; $self->{args}->{ldapAttributeId} ||= 'cn'; $self->{args}->{ldapAttributeContent} ||= 'description'; $self->{args}->{ldapAttributeIndex} ||= 'ou'; $self->ldap->delete( $self->{args}->{ldapAttributeId} . "=" . $session->{data}->{_session_id} . "," . $self->{args}->{ldapConfBase} ); $self->ldap->unbind() && delete $self->{ldap}; } sub ldap { my $self = shift; return $self->{ldap} if ( $self->{ldap} ); # Parse servers configuration my $useTls = 0; my $tlsParam; my @servers = (); foreach my $server ( split /[\s,]+/, $self->{args}->{ldapServer} ) { if ( $server =~ m{^ldap\+tls://([^/]+)/?\??(.*)$} ) { $useTls = 1; $server = $1; $tlsParam = $2 || ""; } else { $useTls = 0; } push @servers, $server; } # Compatibility my $caFile = $self->{args}->{ldapCAFile} || $self->{args}->{caFile}; my $caPath = $self->{args}->{ldapCAPath} || $self->{args}->{caPath}; # Connect my $ldap = Net::LDAP->new( \@servers, onerror => undef, verify => $self->{args}->{ldapVerify} || "require", ( $caFile ? ( cafile => $caFile ) : () ), ( $caPath ? ( capath => $caPath ) : () ), ( $self->{args}->{ldapRaw} ? ( raw => $self->{args}->{ldapRaw} ) : () ), ( $self->{args}->{ldapPort} ? ( port => $self->{args}->{ldapPort} ) : () ), ) or die( 'Unable to connect to ' . join( ' ', @servers ) . ": " . $@ ); # Check SSL error for old Net::LDAP versions if ( $Net::LDAP::VERSION < '0.64' ) { # CentOS7 has a bug in which IO::Socket::SSL will return a broken # socket when certificate validation fails. Net::LDAP does not catch # it, and the process ends up crashing. # As a precaution, make sure the underlying socket is doing fine: if ( $ldap->socket->isa('IO::Socket::SSL') and $ldap->socket->errstr < 0 ) { die( "SSL connection error: " . $ldap->socket->errstr ); } } # Start TLS if needed if ($useTls) { my %h = split( /[&=]/, $tlsParam ); $h{verify} ||= ( $self->{args}->{ldapVerify} || "require" ); $h{cafile} ||= $caFile if ($caFile); $h{capath} ||= $caPath if ($caPath); my $start_tls = $ldap->start_tls(%h); if ( $start_tls->code ) { $self->logError($start_tls); return; } } # Bind with credentials my $bind = $ldap->bind( $self->{args}->{ldapBindDN}, password => $self->{args}->{ldapBindPassword} ); if ( $bind->code ) { $self->logError($bind); return; } $self->{ldap} = $ldap; return $ldap; } sub logError { my $self = shift; my $ldap_operation = shift; die "LDAP error " . $ldap_operation->code . ": " . $ldap_operation->error; } 1; =pod =head1 NAME Apache::Session::Browseable::Store::LDAP - Use LDAP to store persistent objects =head1 SYNOPSIS use Apache::Session::Browseable::Store::LDAP; my $store = new Apache::Session::Browseable::Store::LDAP; $store->insert($ref); $store->update($ref); $store->materialize($ref); $store->remove($ref); =head1 DESCRIPTION This module fulfills the storage interface of Apache::Session. The serialized objects are stored in an LDAP directory file using the Net::LDAP Perl module. =head1 OPTIONS This module requires one argument in the usual Apache::Session style. The keys ldapServer, ldapBase, ldapBindDN, ldapBindPassword are required. The key ldapPort, ldapObjectClass, ldapAttributeId, ldapAttributeContent, ldapAttributeIndex, and ldapRaw are optional. Example: tie %s, 'Apache::Session::Browseable::LDAP', undef, { ldapServer => 'localhost', ldapBase => 'dc=example,dc=com', ldapBindDN => 'cn=admin,dc=example,dc=com', ldapBindPassword => 'pass', Index => 'uid ipAddr', ldapObjectClass => 'applicationProcess', ldapAttributeId => 'cn', ldapAttributeContent => 'description', ldapAttributeIndex => 'ou', ldapRaw => '(?i:^jpegPhoto|;binary)', }; =head1 AUTHOR Xavier Guimard, Eguimard@E =head1 COPYRIGHT AND LICENSE Copyright (C) 2010-2017 by Xavier Guimard Copyright (C) 2015-2017 by Clement Oudot This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.10.0 or, at your option, any later version of Perl 5 you may have available. =head1 SEE ALSO L =cut Apache-Session-Browseable-1.3.13/lib/Apache/Session/Browseable/Store/MySQL.pm000444001750001750 61114451523531 25665 0ustar00yaddyadd000000000000package Apache::Session::Browseable::Store::MySQL; use strict; use Apache::Session::Browseable::Store::DBI; use Apache::Session::Store::MySQL; our @ISA = qw(Apache::Session::Browseable::Store::DBI Apache::Session::Store::MySQL); our $VERSION = '1.2.2'; sub connection { my($self,$session)=@_; $self->SUPER::connection($session); $self->{dbh}->{mysql_enable_utf8} = 1; } 1; Apache-Session-Browseable-1.3.13/lib/Apache/Session/Browseable/Store/Oracle.pm000444001750001750 41214451523531 26124 0ustar00yaddyadd000000000000package Apache::Session::Browseable::Store::Oracle; use strict; use Apache::Session::Browseable::Store::DBI; use Apache::Session::Store::Oracle; our @ISA = qw(Apache::Session::Browseable::Store::DBI Apache::Session::Store::Oracle); our $VERSION = '1.2.2'; 1; Apache-Session-Browseable-1.3.13/lib/Apache/Session/Browseable/Store/Postgres.pm000444001750001750 61714451523531 26534 0ustar00yaddyadd000000000000package Apache::Session::Browseable::Store::Postgres; use strict; use Apache::Session::Browseable::Store::DBI; use Apache::Session::Store::Postgres; our @ISA = qw(Apache::Session::Browseable::Store::DBI Apache::Session::Store::Postgres); our $VERSION = '1.2.2'; sub connection { my($self,$session)=@_; $self->SUPER::connection($session); $self->{dbh}->{pg_enable_utf8} = 1; } 1; Apache-Session-Browseable-1.3.13/lib/Apache/Session/Browseable/Store/Redis.pm000444001750001750 563514451523531 26021 0ustar00yaddyadd000000000000package Apache::Session::Browseable::Store::Redis; use strict; our $VERSION = '1.3.2'; our $redis; BEGIN { $redis = 'Redis::Fast'; eval 'use Redis::Fast'; if ($@) { require Redis; $redis = 'Redis'; } } sub new { my ( $class, $session ) = @_; my $self; # Manage undef encoding $session->{args}->{encoding} = undef if ( $session->{args}->{encoding} and $session->{args}->{encoding} eq "undef" ); # If sentinels is not given as an array ref, try to parse # a comma delimited list instead if ( $session->{args}->{sentinels} and ref $session->{args}->{sentinels} ne 'ARRAY' ) { $session->{args}->{sentinels} = [ split /[,\s]+/, $session->{args}->{sentinels} ]; } $self->{cache} = $redis->new( %{ $session->{args} } ); # Manage database $self->{cache}->select( $session->{args}->{database} ) if defined $session->{args}->{database}; bless $self, $class; } sub insert { my ( $self, $session ) = @_; my $index = ref( $session->{args}->{Index} ) ? $session->{args}->{Index} : [ split /\s+/, $session->{args}->{Index} ]; my $id = $session->{data}->{_session_id}; $self->{cache}->set( $id, $session->{serialized} ); foreach my $i (@$index) { my $t; next unless ( $t = $session->{data}->{$i} ); $self->{cache}->sadd( "${i}_$t", $id ); } } *update = *insert; sub materialize { my ( $self, $session ) = @_; $session->{serialized} = $self->{cache}->get( $session->{data}->{_session_id} ) or die 'Object does not exist in data store.'; } sub remove { my ( $self, $session ) = @_; my $index = ref( $session->{args}->{Index} ) ? $session->{args}->{Index} : [ split /\s+/, $session->{args}->{Index} ]; my $id = $session->{data}->{_session_id}; foreach my $i (@$index) { my $t; next unless ( $t = $session->{data}->{$i} ); eval { $self->{cache}->srem( "${i}_$t", $id ); }; } $self->{cache}->del($id); } 1; __END__ =pod =head1 NAME Apache::Session::Browseable::Store::Redis - An implementation of Apache::Session::Store =head1 SYNOPSIS use Apache::Session::Browseable::Redis; tie %hash, 'Apache::Session::Browseable::Redis', $id, { # optional: default to localhost server => '127.0.0.1:6379', }; =head1 DESCRIPTION This module is an implementation of Apache::Session::Browseable. It uses the Redis storage system =head1 SEE ALSO L, L, L =head1 AUTHOR This module was written by Xavier Guimard =head1 COPYRIGHT AND LICENSE Copyright (C) 2009-2018 by Xavier Guimard This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.10.1 or, at your option, any later version of Perl 5 you may have available. =cut Apache-Session-Browseable-1.3.13/lib/Apache/Session/Browseable/Store/SQLite.pm000444001750001750 1104614451523531 26125 0ustar00yaddyadd000000000000############################################################################# # # Apache::Session::Browseable::SQLite # Apache persistent user sessions in a SQLite database # Copyright(c) 2013 Xavier Guimard # Inspired by Apache::Session::Store::Postgres # (copyright(c) 1998, 1999, 2000 Jeffrey William Baker (jwbaker@acm.org)) # Distribute under the Perl License # ############################################################################ package Apache::Session::Browseable::Store::SQLite; use strict; use DBI; use Apache::Session::Store::DBI; use Apache::Session::Browseable::Store::DBI; our @ISA = qw(Apache::Session::Browseable::Store::DBI Apache::Session::Store::DBI); our $VERSION = '1.2.7'; $Apache::Session::Browseable::Store::SQLite::DataSource = undef; sub connection { my $self = shift; my $session = shift; return if ( defined $self->{dbh} ); $session->{args}->{Commit} = exists( $session->{args}->{Commit} ) ? $session->{args}->{Commit} : 1; $self->{'table_name'} = $session->{args}->{TableName} || $Apache::Session::Store::DBI::TableName; if ( exists $session->{args}->{Handle} ) { $self->{dbh} = $session->{args}->{Handle}; $self->{commit} = $session->{args}->{Commit}; return; } my $datasource = $session->{args}->{DataSource} || $Apache::Session::Store::MySQL::DataSource; $self->{dbh} = DBI->connect( $datasource, '', '', { RaiseError => 1, AutoCommit => 0 } ) || die $DBI::errstr; $self->{dbh}->{sqlite_unicode} = 1; #If we open the connection, we close the connection $self->{disconnect} = 1; #the programmer has to tell us what commit policy to use $self->{commit} = $session->{args}->{Commit}; } sub materialize { my $self = shift; my $session = shift; $self->connection($session); local $self->{dbh}->{RaiseError} = 1; if ( !defined $self->{materialize_sth} ) { $self->{materialize_sth} = $self->{dbh}->prepare_cached( qq{ SELECT a_session FROM $self->{'table_name'} WHERE id = ?} ); } $self->{materialize_sth}->bind_param( 1, $session->{data}->{_session_id} ); $self->{materialize_sth}->execute; my $results = $self->{materialize_sth}->fetchrow_arrayref; if ( !( defined $results ) ) { $self->{materialize_sth}->finish; die "Object does not exist in the data store"; } $self->{materialize_sth}->finish; $session->{serialized} = $results->[0]; } sub DESTROY { my $self = shift; if ( $self->{commit} ) { $self->{dbh}->commit; } if ( $self->{disconnect} ) { $self->{dbh}->disconnect; } } 1; =pod =head1 NAME Apache::Session::Browseable::Store::SQLite - Store persistent data in a SQLite database =head1 SYNOPSIS use Apache::Session::Browseable::Store::SQLite; my $store = new Apache::Session::Browseable::Store::SQLite; $store->insert($ref); $store->update($ref); $store->materialize($ref); $store->remove($ref); =head1 DESCRIPTION Apache::Session::Browseable::Store::SQLite fulfills the storage interface of Apache::Session. Session data is stored in a SQLite database. =head1 SCHEMA To use this module, you will need at least these columns in a table called 'sessions', or another name if you supply the TableName parameter. id char(32) # or however long your session IDs are. a_session text # This has an ~8 KB limit :( To create this schema, you can execute this command using the sqlite program: CREATE TABLE sessions ( id char(32) not null primary key, a_session text ); If you use some other command, ensure that there is a unique index on the table's id column. =head1 CONFIGURATION The module must know what datasource, username, and password to use when connecting to the database. These values can be set using the options hash (see Apache::Session documentation). The options are: =over 4 =item DataSource =item UserName =item Password =item Handle =item TableName =back Example: tie %hash, 'Apache::Session::Browseable::SQLite', $id, { DataSource => 'dbi:Pg:dbname=database', UserName => 'database_user', Password => 'K00l' }; Instead, you may pass in an already-opened DBI handle to your database. tie %hash, 'Apache::Session::Browseable::SQLite', $id, { Handle => $dbh }; =head1 AUTHOR This modules was written by Jeffrey William Baker A fix for the commit policy was contributed by Michael Schout =head1 SEE ALSO L, L Apache-Session-Browseable-1.3.13/lib/Apache/Session/Browseable/Store/Sybase.pm000444001750001750 41214451523531 26145 0ustar00yaddyadd000000000000package Apache::Session::Browseable::Store::Sybase; use strict; use Apache::Session::Browseable::Store::DBI; use Apache::Session::Store::Sybase; our @ISA = qw(Apache::Session::Browseable::Store::DBI Apache::Session::Store::Sybase); our $VERSION = '1.2.2'; 1; Apache-Session-Browseable-1.3.13/lib/Apache/Session/Generate000755001750001750 014451523531 22620 5ustar00yaddyadd000000000000Apache-Session-Browseable-1.3.13/lib/Apache/Session/Generate/SHA256.pm000444001750001750 175614451523531 24174 0ustar00yaddyadd000000000000# Directly copied from LemonLDAP::NG project (http://lemonldap-ng.org/) package Apache::Session::Generate::SHA256; use strict; use vars qw($VERSION); use Digest::SHA qw(sha256 sha256_hex sha256_base64); $VERSION = '1.2.2'; sub generate { my $session = shift; my $length = 64; if ( exists $session->{args}->{IDLength} ) { $length = $session->{args}->{IDLength}; } $session->{data}->{_session_id} = substr( Digest::SHA::sha256_hex( Digest::SHA::sha256_hex( time() . {} . rand() . $$ ) ), 0, $length ); } sub validate { #This routine checks to ensure that the session ID is in the form #we expect. This must be called before we start diddling around #in the database or the disk. my $session = shift; if ( $session->{data}->{_session_id} =~ /^([a-fA-F0-9]+)$/ ) { $session->{data}->{_session_id} = $1; } else { die "Invalid session ID: " . $session->{data}->{_session_id}; } } 1; Apache-Session-Browseable-1.3.13/lib/Apache/Session/Serialize000755001750001750 014451523531 23015 5ustar00yaddyadd000000000000Apache-Session-Browseable-1.3.13/lib/Apache/Session/Serialize/Hstore.pm000444001750001750 574014451523531 24762 0ustar00yaddyadd000000000000package Apache::Session::Serialize::Hstore; use strict; use JSON qw(to_json from_json); our $VERSION = '1.2.5'; sub serialize { my ($session) = @_; $session->{serialized} = {}; my $data = $session->{data}; my $res = ''; if ( ref $data and %$data ) { foreach ( keys %$data ) { my $v; if ( ref $data->{$_} ) { $v = '_json://' . to_json( $data->{$_} ); } else { $v = $data->{$_}; } $v =~ s/"/#%22/g; $res .= qq'"$_" => "$v",'; } } $res =~ s/,$//; $session->{serialized} = $res; } sub unserialize { my ($session) = @_; my $data = _unserialize( $session->{serialized} ); die "Session could not be unserialized" unless defined $data; $session->{data} = $data; } sub _unserialize { my ( $serialized, $next ) = @_; my $res = {}; while ( $serialized =~ s/\s*"([^"]*)"\s*=>\s*"([^"]*)"\s*,?// ) { my ( $k, $v ) = ( $1, $2 ); $v =~ s/#%22/"/g; if ( $v =~ s#^_json://## ) { my $tmp; eval { $tmp = from_json($v) }; if ($@) { print STDERR "JSON error: $@\n"; return undef; } $v = $tmp; } $res->{$k} = $v; } return $res; } 1; =pod =head1 NAME =encoding utf8 Apache::Session::Serialize::Hstore - Serialize/unserialize datas for PostgreSQL "hstore" storage. =head1 SYNOPSIS use Apache::Session::Serialize::Hstore; $zipped = Apache::Session::Serialize::Hstore::serialize($ref); $ref = Apache::Session::Serialize::Hstore::unserialize($zipped); =head1 DESCRIPTION This module fulfills the serialization interface of Apache::Session. It serializes only ref data value for PostgreSQL "hstore" fields. =head1 SEE ALSO L, L =head1 AUTHORS =over =item Clement Oudot, Eclem.oudot@gmail.comE =item François-Xavier Deltombe, Efxdeltombe@gmail.com.E =item Xavier Guimard, Ex.guimard@free.frE =item Thomas Chemineau, Ethomas.chemineau@gmail.comE =back =head1 BUG REPORT Use OW2 system to report bug or ask for features: L =head1 COPYRIGHT AND LICENSE =over =item Copyright (C) 2015-2017 by Clément Oudot, Eclem.oudot@gmail.comE =item Copyright (C) 2015-2017 by Xavier Guimard, Ex.guimard@free.frE =back This library 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 2, 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, see L. =cut Apache-Session-Browseable-1.3.13/lib/Apache/Session/Serialize/JSON.pm000444001750001750 471114451523531 24264 0ustar00yaddyadd000000000000# Directly copied from Lemonldap::NG project (http://lemonldap-ng.org/) package Apache::Session::Serialize::JSON; use strict; use JSON qw(to_json from_json); our $VERSION = '1.2.6'; sub serialize { my $session = shift; $session->{serialized} = to_json( $session->{data}, { allow_nonref => 1 } ); } sub unserialize { my ( $session, $next ) = @_; my $data = _unserialize( $session->{serialized}, $next ); die "Session could not be unserialized" unless defined $data; $session->{data} = $data; } sub _unserialize { my ( $serialized, $next ) = @_; my $tmp; eval { $tmp = from_json( $serialized, { allow_nonref => 1 } ) }; if ($@) { require Storable; $next ||= \&Storable::thaw; return &$next($serialized); } return $tmp; } 1; =pod =head1 NAME =encoding utf8 Apache::Session::Serialize::JSON - Use JSON to zip up data =head1 SYNOPSIS use Apache::Session::Serialize::JSON; $zipped = Apache::Session::Serialize::JSON::serialize($ref); $ref = Apache::Session::Serialize::JSON::unserialize($zipped); =head1 DESCRIPTION This module fulfills the serialization interface of Apache::Session. It serializes the data in the session object by use of JSON C and C. The serialized data is UTF-8 text. =head1 SEE ALSO L, L =head1 AUTHORS =over =item Clement Oudot, Eclem.oudot@gmail.comE =item François-Xavier Deltombe, Efxdeltombe@gmail.com.E =item Xavier Guimard, Ex.guimard@free.frE =item Thomas Chemineau, Ethomas.chemineau@gmail.comE =back =head1 BUG REPORT Use OW2 system to report bug or ask for features: L =head1 COPYRIGHT AND LICENSE =over =item Copyright (C) 2015-2017 by Clément Oudot, Eclem.oudot@gmail.comE =item Copyright (C) 2015-2017 by Xavier Guimard, Ex.guimard@free.frE =back This library 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 2, 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, see L. =cut Apache-Session-Browseable-1.3.13/rpm000755001750001750 014451523531 16312 5ustar00yaddyadd000000000000Apache-Session-Browseable-1.3.13/rpm/Apache-Session-Browseable.spec000444001750001750 472514451523531 24220 0ustar00yaddyadd000000000000#============================================================================== # Specification file for Apache::Session::Browseable #============================================================================== %define real_name Apache-Session-Browseable %define real_version 1.3.9 #============================================================================== # Main package #============================================================================== Name: perl-%{real_name} Version: %{real_version} Release: 1%{?dist} Summary: Add index and search methods to Apache::Session Group: Applications/System License: GPL+ or Artistic URL: http://search.cpan.org/dist/Apache-Session-Browseable/ Source0: http://search.cpan.org/CPAN/authors/id/G/GU/GUIMARD/%{real_name}-%{real_version}.tar.gz BuildRoot: %{_tmppath}/%{name}-%{version}-%{release} BuildArch: noarch BuildRequires: perl BuildRequires: perl(Apache::Session) BuildRequires: perl(Module::Build) Requires: perl(Apache::Session) %description Virutal Apache::Session backend allowing to browse sessions upon criteria. %prep %setup -n %{real_name}-%{real_version} -q # Redis not mandatory cat << \EOF > %{name}-req #!/bin/sh %{__perl_requires} $* |\ sed -e '/perl(Redis)/d' EOF %define __perl_requires %{_builddir}/%{real_name}-%{real_version}/%{name}-req chmod +x %{__perl_requires} %if 0%{?rhel} >= 7 %{?perl_default_filter} %global __requires_exclude perl\\(Redis %endif %build perl Build.PL --installdirs=vendor ./Build %install rm -rf %{buildroot} ./Build install --destdir=%{buildroot} --create_packlist=0 %check ./Build test %files %defattr(-,root,root,-) %doc %{_mandir}/man3/Apache::Session::*.3pm.gz %{perl_vendorlib}/Apache/Session/* %{perl_vendorlib}/auto/Apache/Session/* %changelog * Wed Aug 18 2021 Clement Oudot - 1.3.9-1 - Update to 1.3.9 * Sun Sep 06 2020 Clement Oudot - 1.3.8-1 - Update to 1.3.8 * Fri Sep 04 2020 Clement Oudot - 1.3.7-1 - Update to 1.3.7 * Fri Jan 17 2020 Clement Oudot - 1.3.5-1 - Update to 1.3.5 * Thu Sep 19 2019 Clement Oudot - 1.3.3-1 - Update to 1.3.3 * Thu Jul 04 2019 Clement Oudot - 1.3.2-1 - Update to 1.3.2 * Tue Jan 23 2018 Clement Oudot - 1.2.8-1 - Update to 1.2.8 * Mon Jan 12 2015 Clement Oudot - 1.0.2-1 - First package for 1.0.2 Apache-Session-Browseable-1.3.13/t000755001750001750 014451523531 15757 5ustar00yaddyadd000000000000Apache-Session-Browseable-1.3.13/t/Apache-Session-Browseable-Cassandra.t000444001750001750 31414451523531 25041 0ustar00yaddyadd000000000000use Test::More; plan skip_all => "Optional modules (DBD::Cassandra) not installed" unless eval { require DBD::Cassandra; }; plan tests => 1; use_ok('Apache::Session::Browseable::Cassandra'); Apache-Session-Browseable-1.3.13/t/Apache-Session-Browseable-DBI.t000444001750001750 26014451523531 23540 0ustar00yaddyadd000000000000use Test::More; plan skip_all => "Optional modules (DBI) not installed" unless eval { require DBI; }; plan tests => 1; use_ok('Apache::Session::Browseable::DBI'); Apache-Session-Browseable-1.3.13/t/Apache-Session-Browseable-File.t000444001750001750 14714451523531 24025 0ustar00yaddyadd000000000000use Test::More; plan tests => 1; $package = 'Apache::Session::Browseable::File'; use_ok($package); Apache-Session-Browseable-1.3.13/t/Apache-Session-Browseable-LDAP.t000444001750001750 33314451523531 23663 0ustar00yaddyadd000000000000use Test::More; plan skip_all => "Optional modules (Net::LDAP) not installed" unless eval { require Net::LDAP; }; plan tests => 1; $package = 'Apache::Session::Browseable::Store::LDAP'; use_ok($package); Apache-Session-Browseable-1.3.13/t/Apache-Session-Browseable-Redis.t000444001750001750 741514451523531 24241 0ustar00yaddyadd000000000000use Test::More; use JSON qw/from_json/; use utf8; our $test_dburl = $ENV{REDIS_URL} || 'localhost:6379'; our $test_dbnum = $ENV{REDIS_DBNUM} || 15; our $r; # Redis handle used for asserts plan skip_all => "Optional modules (Redis) not installed" unless eval { require Redis; }; plan skip_all => "Redis error : $@" unless eval { $r = Redis->new( server => $test_dburl ); $r->select($test_dbnum); $r->flushall(); }; plan tests => 19; $package = 'Apache::Session::Browseable::Redis'; use_ok($package); my $args = { server => $test_dburl, database => $test_dbnum, # Choose your browseable fileds Index => 'uid sn mail', }; use Data::Dumper; my $id; my $json; is( keys %{ $r->keys('*') }, 0, "Make sure database is empty" ); # Create new session my %session; tie %session, 'Apache::Session::Browseable::Redis', $id, $args; $session{uid} = 'mé'; $session{mail} = 'mé@me.com'; $session{color} = 'zz'; $id = $session{_session_id}; untie %session; # Make sure it was stored: ok( $r->exists($id), "Test if new session id exists as a key in Redis" ); ok( $r->exists("uid_mé"), "Test if index exists" ); ok( $json = from_json( $r->get($id) ), "Parse redis value as JSON" ); is( $json->{mail}, 'mé@me.com', "Test if session subkey was correctly stored" ); # Read existing session tie %session, 'Apache::Session::Browseable::Redis', $id, $args; is( $session{mail}, 'mé@me.com', "Test if session subkey can be read" ); # Delete session; tied(%session)->delete; ok( !$r->exists($id), "Test if new session id was removed" ); ok( !$r->exists("uid_mé"), "Test if index was removed" ); is( keys %{ $r->keys('*') }, 0, "Make sure database is empty after removal" ); untie %session; # Create a bunch of sessions to search on my ( %session1, %session2, %session3, %session4, %session5, $id1, $id2, $id3, $id4, $id5 ); tie %session1, 'Apache::Session::Browseable::Redis', undef, $args; $session1{uid} = 'obiwan'; $session1{sn} = 'Kenobi'; $session1{color} = 'blue'; $id1 = $session1{_session_id}; untie %session1; tie %session2, 'Apache::Session::Browseable::Redis', undef, $args; $session2{uid} = 'darthvader'; $session2{sn} = 'Skywalker'; $session2{color} = 'red'; $id2 = $session2{_session_id}; untie %session2; tie %session3, 'Apache::Session::Browseable::Redis', undef, $args; $session3{uid} = 'luke'; $session3{sn} = 'Skywalker'; $session3{color} = 'green'; $id3 = $session3{_session_id}; untie %session3; tie %session4, 'Apache::Session::Browseable::Redis', undef, $args; $session4{uid} = 'mace'; $session4{sn} = 'Windu'; $session4{color} = 'purple'; $id4 = $session4{_session_id}; untie %session4; tie %session5, 'Apache::Session::Browseable::Redis', undef, $args; $session5{uid} = 'yoda'; $session5{sn} = 'Yoda'; $session5{color} = 'green'; $id5 = $session5{_session_id}; untie %session5; # Search all keys my $hash = Apache::Session::Browseable::Redis->get_key_from_all_sessions( $args, "uid" ); is( keys %$hash, 5, "Found all 5 session" ); ok( exists( $hash->{$id4} ), "Found 'mace' in result" ); is( $hash->{$id4}->{uid}, 'mace', "Correct value in session 4" ); # Search on indexed field my $hash = Apache::Session::Browseable::Redis->searchOn( $args, 'sn', 'Skywalker' ); is( keys %$hash, 2, "Found 2 session" ); is( $hash->{$id2}->{uid}, 'darthvader', "Correct value" ); is( $hash->{$id3}->{uid}, 'luke', "Correct value" ); # Search on unindexed field my $hash = Apache::Session::Browseable::Redis->searchOn( $args, 'color', 'green' ); is( keys %$hash, 2, "Found 2 session" ); is( $hash->{$id3}->{uid}, 'luke', "Correct value" ); is( $hash->{$id5}->{uid}, 'yoda', "Correct value" ); $r->flushall; Apache-Session-Browseable-1.3.13/t/Apache-Session-Browseable-SQLite.t000444001750001750 206514451523531 24330 0ustar00yaddyadd000000000000# First test with SQLite: Basic Apache::Session usage #!/usr/bin/perl use strict; use Test::More; use File::Temp qw(mktemp); my $dbfile = mktemp('tmp.db_XXXX'); plan skip_all => "DBD::SQLite is needed for this test" unless eval { require DBI; require DBD::SQLite; 1; }; plan skip_all => "DBD::SQLite error : $@" unless eval { my $dbh; $dbh = DBI->connect( "dbi:SQLite:dbname=$dbfile", "", "" ) or die $dbh->errstr; $dbh->do( 'CREATE TABLE sessions(id char(32) not null primary key,a_session text);' ) or die $dbh->errstr; $dbh->disconnect() or die $dbh->errstr; }; plan tests => 5; use_ok('Apache::Session::Browseable::SQLite'); my %session; ok( tie %session, 'Apache::Session::Browseable::SQLite', undef, { DataSource => "dbi:SQLite:$dbfile", Index => '' } ); ok( $session{a} = 'foo' ); my $id = $session{_session_id}; untie %session; ok( tie %session, 'Apache::Session::Browseable::SQLite', $id, { DataSource => "dbi:SQLite:$dbfile" } ); ok( $session{a} eq 'foo' ); unlink $dbfile if ( -e $dbfile ); Apache-Session-Browseable-1.3.13/t/Apache-Session-Browseable-Store-DBI.t000444001750001750 26714451523531 24641 0ustar00yaddyadd000000000000use Test::More; plan skip_all => "Optional modules (DBI) not installed" unless eval { require DBI; }; plan tests => 1; use_ok('Apache::Session::Browseable::Store::DBI'); Apache-Session-Browseable-1.3.13/t/Apache-Session-Browseable-Store-MySQL.t000444001750001750 45014451523531 25202 0ustar00yaddyadd000000000000use Test::More; plan skip_all => "Optional modules (DBD::mysql, DBI) not installed" unless eval { require DBI; require DBD::mysql; }; plan tests => 2; $package = 'Apache::Session::Browseable::Store::MySQL'; use_ok($package); my $foo = $package->new; isa_ok $foo, $package; Apache-Session-Browseable-1.3.13/t/Apache-Session-Browseable-common.t000444001750001750 41214451523531 24431 0ustar00yaddyadd000000000000use Test::More; plan tests => 3; use_ok('Apache::Session::Browseable::_common'); my ( $a, $b ) = ( [qw(0 1 a)], [qw(0 1 a b)] ); ok( Apache::Session::Browseable::_common->_tabInTab( $a, $b ) ); ok( !Apache::Session::Browseable::_common->_tabInTab( $b, $a ) ); Apache-Session-Browseable-1.3.13/t/test-browseable-functions-using-File.t000444001750001750 673114451523531 25420 0ustar00yaddyadd000000000000# Complete tests with File use strict; use warnings; use Test::More; use constant SESSIONPATH => 't' . ( $^O and $^O =~ /(?:MSWin|Windows)/i ? '\\' : '/' ) . 'sessions'; eval { require File::Path; File::Path::remove_tree(SESSIONPATH); File::Path::mkpath(SESSIONPATH); }; plan skip_all => "Unable to use file system ($@)" if ($@); my @list = ( "aa" .. "ay", "aa" .. "ac" ); my $count = @list; plan tests => 27 + 5 * $count; use_ok('Apache::Session::Browseable::File'); my %session; my $args = { Directory => SESSIONPATH, Index => "f1 f2", }; foreach (@list) { ok( tie %session, 'Apache::Session::Browseable::File', undef, $args, "Create session $_" ); $session{f1} = "1_$_"; $session{f2} = "2_$_"; $session{f3} = "3_$_"; $session{f4} = "4_$_"; untie %session; } my $res; # 1. Get simply all sessions ok( $res = Apache::Session::Browseable::File->get_key_from_all_sessions($args), 'Get all sessions' ); ok( count($res) == $count, "get_key_from_all_sessions returns $count sessions (" . count($res) . ")" ); # 2. Test searchOn() on an indexed field ok( $res = Apache::Session::Browseable::File->searchOn( $args, 'f1', '1_aa' ) ); ok( count($res) == 2, 'Get 2 "aa" sessions (' . count($res) . ")" ); ok( $res = Apache::Session::Browseable::File->searchOn( $args, 'f1', '1_ad' ) ); ok( count($res) == 1, 'Get 1 "ad" sessions (' . count($res) . ")" ); # 3. Test searchOn() on an unindexed field ok( $res = Apache::Session::Browseable::File->searchOn( $args, 'f3', '3_aa' ) ); ok( count($res) == 2, 'Get 2 "aa" sessions (' . count($res) . ")" ); ok( $res = Apache::Session::Browseable::File->searchOn( $args, 'f3', '3_ad' ) ); ok( count($res) == 1, 'Get 1 "ad" sessions (' . count($res) . ")" ); # 4. Test searchOnExpr() on an indexed field ok( $res = Apache::Session::Browseable::File->searchOnExpr( $args, 'f1', '*aa' ) ); ok( count($res) == 2, 'Get 2 "aa" sessions (' . count($res) . ")" ); # 5. Test searchOnExpr() on an unindexed field ok( $res = Apache::Session::Browseable::File->searchOnExpr( $args, 'f3', '*aa' ) ); ok( count($res) == 2, 'Get 2 "aa" sessions (' . count($res) . ")" ); # 6. Test get_key_from_all_sessions to request for indexed fields ok( $res = Apache::Session::Browseable::File->get_key_from_all_sessions( $args, [ 'f1', 'f2' ] ) ); while ( my ( $id, $entry ) = each %$res ) { ok( $entry->{f1} =~ /^1_(\w{2})$/ ); my $t = $1; ok( $entry->{f2} =~ /^2_${t}$/ ); } # 7. Test searchOn to request for indexed fields ok( $res = Apache::Session::Browseable::File->searchOn( $args, 'f1', '1_aa', 'f1', 'f2' ) ); while ( my ( $id, $entry ) = each %$res ) { ok( $entry->{f1} =~ /^1_(\w{2})$/ ); my $t = $1; ok( $entry->{f2} =~ /^2_${t}$/ ); } # 8. Test get_key_from_all_sessions to request for unindexed fields ok( $res = Apache::Session::Browseable::File->get_key_from_all_sessions( $args, [ 'f1', 'f3' ] ) ); while ( my ( $id, $entry ) = each %$res ) { ok( $entry->{f1} =~ /^1_(\w{2})$/ ); my $t = $1; ok( $entry->{f3} =~ /^3_${t}$/ ); } # 9. Test searchOn to request for unindexed fields ok( $res = Apache::Session::Browseable::File->searchOn( $args, 'f1', '1_aa', 'f1', 'f3' ) ); eval { File::Path::remove_tree(SESSIONPATH) }; while ( my ( $id, $entry ) = each %$res ) { ok( $entry->{f1} =~ /^1_(\w{2})$/ ); my $t = $1; ok( $entry->{f3} =~ /^3_${t}$/ ); } sub count { my @c = keys %{ $_[0] }; return scalar @c; } 1; Apache-Session-Browseable-1.3.13/t/test-browseable-functions-using-SQLite.t000444001750001750 776314451523531 25710 0ustar00yaddyadd000000000000# Complete tests with SQLite use strict; use warnings; use Test::More; use File::Temp qw(mktemp); my $dbfile = mktemp('tmp.db_XXXX'); plan skip_all => "DBD::SQLite is needed for this test" unless eval { require DBI; require DBD::SQLite; 1; }; plan skip_all => "DBD::SQLite error : $@" unless eval { my $dbh; $dbh = DBI->connect( "dbi:SQLite:dbname=$dbfile", "", "" ) or die $dbh->errstr; $dbh->do( 'CREATE TABLE sessions(id char(32) not null primary key,a_session text,f1 text,f2 text);' ) or die $dbh->errstr; $dbh->do('CREATE INDEX f1_idx ON sessions (f1);') or die $dbh->errstr; $dbh->do('CREATE INDEX f2_idx ON sessions (f2);') or die $dbh->errstr; $dbh->disconnect() or die $dbh->errstr; }; my @list = ( "aa" .. "ay", "aa" .. "ac" ); my $count = @list; plan tests => 27 + 5 * $count; use_ok('Apache::Session::Browseable::SQLite'); my %session; my $args = { DataSource => "dbi:SQLite:$dbfile", Index => "f1 f2", }; foreach (@list) { ok( tie %session, 'Apache::Session::Browseable::SQLite', undef, $args, "Create session $_" ); $session{f1} = "1_$_"; $session{f2} = "2_$_"; $session{f3} = "3_$_"; $session{f4} = "4_$_"; untie %session; } my $res; # 1. Get simply all sessions ok( $res = Apache::Session::Browseable::SQLite->get_key_from_all_sessions($args), 'Get all sessions' ); ok( count($res) == $count, "get_key_from_all_sessions returns $count sessions (" . count($res) . ")" ); # 2. Test searchOn() on an indexed field ok( $res = Apache::Session::Browseable::SQLite->searchOn( $args, 'f1', '1_aa' ) ); ok( count($res) == 2, 'Get 2 "aa" sessions (' . count($res) . ")" ); ok( $res = Apache::Session::Browseable::SQLite->searchOn( $args, 'f1', '1_ad' ) ); ok( count($res) == 1, 'Get 1 "ad" sessions (' . count($res) . ")" ); # 3. Test searchOn() on an unindexed field ok( $res = Apache::Session::Browseable::SQLite->searchOn( $args, 'f3', '3_aa' ) ); ok( count($res) == 2, 'Get 2 "aa" sessions (' . count($res) . ")" ); ok( $res = Apache::Session::Browseable::SQLite->searchOn( $args, 'f3', '3_ad' ) ); ok( count($res) == 1, 'Get 1 "ad" sessions (' . count($res) . ")" ); # 4. Test searchOnExpr() on an indexed field ok( $res = Apache::Session::Browseable::SQLite->searchOnExpr( $args, 'f1', '*aa' ) ); ok( count($res) == 2, 'Get 2 "aa" sessions (' . count($res) . ")" ); # 5. Test searchOnExpr() on an unindexed field ok( $res = Apache::Session::Browseable::SQLite->searchOnExpr( $args, 'f3', '*aa' ) ); ok( count($res) == 2, 'Get 2 "aa" sessions (' . count($res) . ")" ); # 6. Test get_key_from_all_sessions to request for indexed fields ok( $res = Apache::Session::Browseable::SQLite->get_key_from_all_sessions( $args, [ 'f1', 'f2' ] ) ); while ( my ( $id, $entry ) = each %$res ) { ok( $entry->{f1} =~ /^1_(\w{2})$/ ); my $t = $1; ok( $entry->{f2} =~ /^2_${t}$/ ); } # 7. Test searchOn to request for indexed fields ok( $res = Apache::Session::Browseable::SQLite->searchOn( $args, 'f1', '1_aa', 'f1', 'f2' ) ); while ( my ( $id, $entry ) = each %$res ) { ok( $entry->{f1} =~ /^1_(\w{2})$/ ); my $t = $1; ok( $entry->{f2} =~ /^2_${t}$/ ); } # 8. Test get_key_from_all_sessions to request for unindexed fields ok( $res = Apache::Session::Browseable::SQLite->get_key_from_all_sessions( $args, [ 'f1', 'f3' ] ) ); while ( my ( $id, $entry ) = each %$res ) { ok( $entry->{f1} =~ /^1_(\w{2})$/ ); my $t = $1; ok( $entry->{f3} =~ /^3_${t}$/ ); } # 9. Test searchOn to request for unindexed fields ok( $res = Apache::Session::Browseable::SQLite->searchOn( $args, 'f1', '1_aa', 'f1', 'f3' ) ); unlink $dbfile if ( -e $dbfile ); while ( my ( $id, $entry ) = each %$res ) { ok( $entry->{f1} =~ /^1_(\w{2})$/ ); my $t = $1; ok( $entry->{f3} =~ /^3_${t}$/ ); } sub count { my @c = keys %{ $_[0] }; return scalar @c; } 1;