[Catalyst-commits] r6889 - in
trunk/Catalyst-Plugin-Session-PerUser: .
lib/Catalyst/Plugin/Session t
bricas at dev.catalyst.perl.org
bricas at dev.catalyst.perl.org
Fri Sep 14 15:46:57 GMT 2007
Author: bricas
Date: 2007-09-14 15:46:57 +0100 (Fri, 14 Sep 2007)
New Revision: 6889
Added:
trunk/Catalyst-Plugin-Session-PerUser/Makefile.PL
trunk/Catalyst-Plugin-Session-PerUser/README
trunk/Catalyst-Plugin-Session-PerUser/t/01-use.t
trunk/Catalyst-Plugin-Session-PerUser/t/99_pod.t
trunk/Catalyst-Plugin-Session-PerUser/t/99_podcoverage.t
Removed:
trunk/Catalyst-Plugin-Session-PerUser/Build.PL
Modified:
trunk/Catalyst-Plugin-Session-PerUser/Changes
trunk/Catalyst-Plugin-Session-PerUser/MANIFEST.SKIP
trunk/Catalyst-Plugin-Session-PerUser/lib/Catalyst/Plugin/Session/PerUser.pm
trunk/Catalyst-Plugin-Session-PerUser/t/live_app.t
Log:
switch to module::install. add some tests. skip live_app if Test::WWW::Mechanize::Catalyst <= 0.40 is missing (RT #29041)
Deleted: trunk/Catalyst-Plugin-Session-PerUser/Build.PL
===================================================================
--- trunk/Catalyst-Plugin-Session-PerUser/Build.PL 2007-09-14 14:22:45 UTC (rev 6888)
+++ trunk/Catalyst-Plugin-Session-PerUser/Build.PL 2007-09-14 14:46:57 UTC (rev 6889)
@@ -1,18 +0,0 @@
-use strict;
-use Module::Build;
-
-my $build = Module::Build->new(
- create_makefile_pl => 'traditional',
- license => 'perl',
- module_name => 'Catalyst::Plugin::Session::PerUser',
- requires => {
- 'Catalyst::Plugin::Session' => '0.01',
- 'Catalyst::Plugin::Authentication' => '0.01',
- 'Hash::Merge' => 0,
- 'Object::Signature' => 0,
- },
- create_readme => 1,
-# sign => 1,
-);
-$build->create_build_script;
-
Modified: trunk/Catalyst-Plugin-Session-PerUser/Changes
===================================================================
--- trunk/Catalyst-Plugin-Session-PerUser/Changes 2007-09-14 14:22:45 UTC (rev 6888)
+++ trunk/Catalyst-Plugin-Session-PerUser/Changes 2007-09-14 14:46:57 UTC (rev 6889)
@@ -1,5 +1,10 @@
Revision history for Perl extension Catalyst::Plugin::Session::PerUser
+0.04 2007-XX-XX
+ - switch to Module::Install
+ - add basic use test, plus pod/pod coverage tests
+ - skip live_app test if Test::WWW::Mechanize::Catalyst <= 0.40 is missing
+
0.03 2006-06-30 01:06:29
- cleaned up internals to be a bit more efficient
- split session_data api on user objects into get_session_data and
Modified: trunk/Catalyst-Plugin-Session-PerUser/MANIFEST.SKIP
===================================================================
--- trunk/Catalyst-Plugin-Session-PerUser/MANIFEST.SKIP 2007-09-14 14:22:45 UTC (rev 6888)
+++ trunk/Catalyst-Plugin-Session-PerUser/MANIFEST.SKIP 2007-09-14 14:46:57 UTC (rev 6889)
@@ -26,3 +26,6 @@
\#$
\b\.#
^..*\.sw[po]$
+
+# No tarballs!
+\.gz$
Added: trunk/Catalyst-Plugin-Session-PerUser/Makefile.PL
===================================================================
--- trunk/Catalyst-Plugin-Session-PerUser/Makefile.PL (rev 0)
+++ trunk/Catalyst-Plugin-Session-PerUser/Makefile.PL 2007-09-14 14:46:57 UTC (rev 6889)
@@ -0,0 +1,12 @@
+use inc::Module::Install 0.67;
+
+name 'Catalyst-Plugin-Session-PerUser';
+all_from 'lib/Catalyst/Plugin/Session/PerUser.pm';
+
+requires 'Catalyst::Plugin::Session' => '0.06';
+requires 'Catalyst::Plugin::Authentication';
+requires 'Hash::Merge';
+requires 'Object::Signature';
+
+auto_install;
+WriteAll;
Added: trunk/Catalyst-Plugin-Session-PerUser/README
===================================================================
--- trunk/Catalyst-Plugin-Session-PerUser/README (rev 0)
+++ trunk/Catalyst-Plugin-Session-PerUser/README 2007-09-14 14:46:57 UTC (rev 6889)
@@ -0,0 +1,116 @@
+NAME
+ Catalyst::Plugin::Session::PerUser - Per user sessions (instead of per
+ browser sessions).
+
+SYNOPSIS
+ use Catalyst qw/
+ Session
+ Authentication
+ Authentication::Store::Foo
+ Session::PerUser
+ /;
+
+ sub action : Local {
+ my ( $self, $c ) = @_;
+ $c->user_session->{foo} = "bar";
+ }
+
+DESCRIPTION
+ This plugin allows you to write e.g. shopping cart code which should
+ behave well for guests as well as permanent users.
+
+ The basic idea is both logged in and not logged in users can get the
+ same benefits from sessions where it doesn't matter, but that logged in
+ users can keep their sessions accross logins, and will even get the data
+ they added/changed assimilated to their permanent account if they made
+ the changes as guests and then logged in.
+
+ This is probably most useful for e-commerce sites, where the shopping
+ cart is typically used before login, and should be equally accessible to
+ both guests and logged in users.
+
+STORING SESSION DATA
+ This module can store session data in two ways:
+
+ Within the User
+ If "$c->user->supports("session_data")" then
+ "$c->user->get_session_data" and "$c->user->store_session_data($data)"
+ are used to access and store the per-user session hash reference.
+
+ This is useful for Catalyst::Plugin::Authentication::Store
+ implementations that rely on a database or another fast, extensible
+ format.
+
+ Within the Session Store
+ If the user does not support the "session_data" feature, the
+ Catalyst::Plugin::Session::Store plugin in use will be used to save the
+ session data instead.
+
+ The session ID used to save this data is set by "user_session_sid".
+
+ Note that this method could potentially have security issues if you
+ override the default "user_session_sid" or "validate_session_id" in
+ Catalyst::Plugin::Session. See "CAVEATS" for details.
+
+METHODS
+ user_session
+ If no user is logged in, returns "$c->session".
+
+ If a user is logged in, and "$user->supports("session_data")" it
+ will return "$c->user->get_session_data". Otherwise it will return
+ data from the normal session store, using "user_session_sid" as a
+ session ID.
+
+INTERNAL METHODS
+ merge_session_to_user
+ Uses Hash::Merge to merge the browser session into the user session,
+ omitting the special keys from the browser session.
+
+ Should be overloaded to e.g. merge shopping cart items more
+ intelligently.
+
+ user_session_sid
+ By default returns
+
+ "user:" . $c->user->id
+
+EXTENDED METHODS
+ set_authenticated
+ Calls "merge_session_to_user".
+
+CONFIGURATION
+ $c->config->{user_session} = {
+ ...
+ };
+
+ migrate
+ Whether "$c->session" should be merged over "$c->user_session" on
+ login. On by default.
+
+ merge_type
+ Passed to "set_behavior" in Hash::Merge. Defaults to
+ "RIGHT_PRECEDENT".
+
+ *
+
+ CAVEATS
+ If you override "validate_session_id" in Catalyst::Plugin::Session make
+ sure its format DOES NOT ALLOW the format returned by
+ "user_session_sid", or malicious users could potentially set their
+ cookies to have sessions formatted like a string returned by
+ "user_session_sid", and steal or destroy another user's session without
+ authenticating. =back
+
+SEE ALSO
+ Catalyst::Plugin::Authentication, Catalyst::Plugin::Session
+
+AUTHORS
+ David Kamholz, "dkamholz at cpan.org"
+
+ Yuval Kogman, "nothingmuch at woobling.org"
+
+COPYRIGHT & LICENSE
+ Copyright (c) 2005 the aforementioned authors. All rights
+ reserved. This program is free software; you can redistribute
+ it and/or modify it under the same terms as Perl itself.
+
Modified: trunk/Catalyst-Plugin-Session-PerUser/lib/Catalyst/Plugin/Session/PerUser.pm
===================================================================
--- trunk/Catalyst-Plugin-Session-PerUser/lib/Catalyst/Plugin/Session/PerUser.pm 2007-09-14 14:22:45 UTC (rev 6888)
+++ trunk/Catalyst-Plugin-Session-PerUser/lib/Catalyst/Plugin/Session/PerUser.pm 2007-09-14 14:46:57 UTC (rev 6889)
@@ -6,7 +6,7 @@
use strict;
use warnings;
-our $VERSION = "0.03";
+our $VERSION = "0.04";
use Hash::Merge ();
use Object::Signature ();
@@ -141,8 +141,7 @@
=head1 NAME
-Catalyst::Plugin::Session::PerUser - Per user sessions (instead of per
-browser sessions).
+Catalyst::Plugin::Session::PerUser - Per user sessions (instead of per browser sessions).
=head1 SYNOPSIS
@@ -239,6 +238,12 @@
Calls C<merge_session_to_user>.
+=item setup
+
+=item finalize
+
+=item logout
+
=back
=head1 CONFIGURATION
@@ -262,7 +267,7 @@
=back
-=item CAVEATS
+=head1 CAVEATS
If you override L<Catalyst::Plugin::Session/validate_session_id> make sure its
format B<DOES NOT ALLOW> the format returned by C<user_session_sid>, or
Added: trunk/Catalyst-Plugin-Session-PerUser/t/01-use.t
===================================================================
--- trunk/Catalyst-Plugin-Session-PerUser/t/01-use.t (rev 0)
+++ trunk/Catalyst-Plugin-Session-PerUser/t/01-use.t 2007-09-14 14:46:57 UTC (rev 6889)
@@ -0,0 +1,5 @@
+use Test::More tests => 1;
+
+BEGIN {
+ use_ok( 'Catalyst::Plugin::Session::PerUser' );
+}
Added: trunk/Catalyst-Plugin-Session-PerUser/t/99_pod.t
===================================================================
--- trunk/Catalyst-Plugin-Session-PerUser/t/99_pod.t (rev 0)
+++ trunk/Catalyst-Plugin-Session-PerUser/t/99_pod.t 2007-09-14 14:46:57 UTC (rev 6889)
@@ -0,0 +1,7 @@
+use Test::More;
+
+eval "use Test::Pod 1.14";
+plan skip_all => 'Test::Pod 1.14 required' if $@;
+plan skip_all => 'set TEST_POD to enable this test' unless $ENV{TEST_POD};
+
+all_pod_files_ok();
Added: trunk/Catalyst-Plugin-Session-PerUser/t/99_podcoverage.t
===================================================================
--- trunk/Catalyst-Plugin-Session-PerUser/t/99_podcoverage.t (rev 0)
+++ trunk/Catalyst-Plugin-Session-PerUser/t/99_podcoverage.t 2007-09-14 14:46:57 UTC (rev 6889)
@@ -0,0 +1,7 @@
+use Test::More;
+
+eval "use Test::Pod::Coverage 1.04";
+plan skip_all => 'Test::Pod::Coverage 1.04 required' if $@;
+plan skip_all => 'set TEST_POD to enable this test' unless $ENV{TEST_POD};
+
+all_pod_coverage_ok();
Modified: trunk/Catalyst-Plugin-Session-PerUser/t/live_app.t
===================================================================
--- trunk/Catalyst-Plugin-Session-PerUser/t/live_app.t 2007-09-14 14:22:45 UTC (rev 6888)
+++ trunk/Catalyst-Plugin-Session-PerUser/t/live_app.t 2007-09-14 14:46:57 UTC (rev 6889)
@@ -3,8 +3,17 @@
use strict;
use warnings;
-use Test::More tests => 43;
+use Test::More;
+BEGIN {
+ eval { require Test::WWW::Mechanize::Catalyst };
+ plan skip_all =>
+ "This test requires Test::WWW::Mechanize::Catalyst in order to run"
+ if $@;
+ plan skip_all => 'Test::WWW::Mechanize::Catalyst >= 0.40 required' if $Test::WWW::Mechanize::Catalyst::VERSION < 0.40;
+ plan tests => 43;
+}
+
{
package User::WithSession;
More information about the Catalyst-commits
mailing list