[Jifty-commit] r6371 - in plugins/Jifty-Plugin-OAuth/trunk: lib/Jifty/Plugin/OAuth t/t

Jifty commits jifty-commit at lists.jifty.org
Fri Feb 20 18:06:47 EST 2009


Author: alexmv
Date: Fri Feb 20 18:06:47 2009
New Revision: 6371

Modified:
   plugins/Jifty-Plugin-OAuth/trunk/lib/Jifty/Plugin/OAuth/Dispatcher.pm
   plugins/Jifty-Plugin-OAuth/trunk/t/lib/TestApp/Plugin/OAuth/Dispatcher.pm
   plugins/Jifty-Plugin-OAuth/trunk/t/t/03-authorize.t

Log:
 * /oauth/authorized? should run _after_ app "before" rules, so they can tangent or auth first

Modified: plugins/Jifty-Plugin-OAuth/trunk/lib/Jifty/Plugin/OAuth/Dispatcher.pm
==============================================================================
--- plugins/Jifty-Plugin-OAuth/trunk/lib/Jifty/Plugin/OAuth/Dispatcher.pm	(original)
+++ plugins/Jifty-Plugin-OAuth/trunk/lib/Jifty/Plugin/OAuth/Dispatcher.pm	Fri Feb 20 18:06:47 2009
@@ -9,14 +9,17 @@
 use Net::OAuth::ProtectedResourceRequest;
 use URI::Escape 'uri_unescape';
 
-on     POST '/oauth/request_token' => \&request_token;
-before GET  '/oauth/authorize'     => \&authorize;
-on     POST '/oauth/authorize'     => \&authorize_post;
-on     POST '/oauth/access_token'  => \&access_token;
-on          '/oauth/authorized'    => run { redirect '/oauth/authorize' };
+# Let the app do auth, etc, before we let these rules run
+after app,
+  before      '/oauth/authorized'  => redirect '/oauth/authorize';
+after app, 
+  before GET  '/oauth/authorize'   => \&authorize;
+on       POST '/oauth/authorize'   => \&authorize_post;
 
-on     GET  '/oauth/request_token' => \&invalid_method;
 on     GET  '/oauth/access_token'  => \&invalid_method;
+on     POST '/oauth/access_token'  => \&access_token;
+on     GET  '/oauth/request_token' => \&invalid_method;
+on     POST '/oauth/request_token' => \&request_token;
 
 before '*' => \&try_oauth;
 

Modified: plugins/Jifty-Plugin-OAuth/trunk/t/lib/TestApp/Plugin/OAuth/Dispatcher.pm
==============================================================================
--- plugins/Jifty-Plugin-OAuth/trunk/t/lib/TestApp/Plugin/OAuth/Dispatcher.pm	(original)
+++ plugins/Jifty-Plugin-OAuth/trunk/t/lib/TestApp/Plugin/OAuth/Dispatcher.pm	Fri Feb 20 18:06:47 2009
@@ -4,7 +4,6 @@
 use Jifty::Dispatcher -base;
 
 my @login_required = qw{
-    oauth/authorize
     nuke/?
     =/?
 };

Modified: plugins/Jifty-Plugin-OAuth/trunk/t/t/03-authorize.t
==============================================================================
--- plugins/Jifty-Plugin-OAuth/trunk/t/t/03-authorize.t	(original)
+++ plugins/Jifty-Plugin-OAuth/trunk/t/t/03-authorize.t	Fri Feb 20 18:06:47 2009
@@ -35,7 +35,8 @@
 is($response->code, 401, "/oauth/authorize requires authentication");
 $umech->content_unlike(qr/If you trust this application/);
 
-$umech->get_ok('/oauth/authorized');
+$response = $umech->get('/oauth/authorized');
+is($response->code, 401, "/oauth/authorized requires authentication");
 $umech->content_unlike(qr/If you trust this application/);
 
 $umech->get_ok('/nuke/the/whales');


More information about the Jifty-commit mailing list