[Jifty-commit] r4256 - in jifty/trunk: lib/Jifty/Plugin
lib/Jifty/Plugin/OAuth lib/Jifty/Plugin/OAuth/Action
lib/Jifty/Plugin/OAuth/Model
jifty-commit at lists.jifty.org
jifty-commit at lists.jifty.org
Thu Oct 18 17:13:33 EDT 2007
Author: sartak
Date: Thu Oct 18 17:13:32 2007
New Revision: 4256
Modified:
jifty/trunk/ (props changed)
jifty/trunk/lib/Jifty/Plugin/OAuth.pm
jifty/trunk/lib/Jifty/Plugin/OAuth/Action/AuthorizeRequestToken.pm
jifty/trunk/lib/Jifty/Plugin/OAuth/Dispatcher.pm
jifty/trunk/lib/Jifty/Plugin/OAuth/Model/AccessToken.pm
jifty/trunk/lib/Jifty/Plugin/OAuth/Model/Consumer.pm
jifty/trunk/lib/Jifty/Plugin/OAuth/View.pm
Log:
r43845 at onn: sartak | 2007-10-18 17:13:26 -0400
Turns out we can't (so easily) have the URLs be configurable. Not too much of a problem though
Other fixes
Modified: jifty/trunk/lib/Jifty/Plugin/OAuth.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Plugin/OAuth.pm (original)
+++ jifty/trunk/lib/Jifty/Plugin/OAuth.pm Thu Oct 18 17:13:32 2007
@@ -28,36 +28,4 @@
=cut
-=head2 init
-
-Provides defaults for the three URLs that OAuth needs:
-
-=over 4
-
-=item request_token: Request a RequestToken
-
-/oauth/request_token
-
-=item authorize: Authorize a RequestToken
-
-/oauth/authorize
-
-=item access_token: Exchange a RequestToken for an Accesstoken
-
-/oauth/access_token
-
-=cut
-
-our %CONFIG;
-
-sub init {
- my $self = shift;
- %CONFIG = (
- request_token => '/oauth/request_token',
- authorize => '/oauth/authorize',
- access_token => '/oauth/access_token',
- @_
- );
-}
-
1;
Modified: jifty/trunk/lib/Jifty/Plugin/OAuth/Action/AuthorizeRequestToken.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Plugin/OAuth/Action/AuthorizeRequestToken.pm (original)
+++ jifty/trunk/lib/Jifty/Plugin/OAuth/Action/AuthorizeRequestToken.pm Thu Oct 18 17:13:32 2007
@@ -15,7 +15,8 @@
param 'token',
render as 'text',
max_length is 30,
- hints are 'The site you just came from should have provided it';
+ hints are 'The site you just came from should have provided it',
+ ajax validates;
param 'authorize',
valid_values are qw(allow deny);
@@ -55,7 +56,7 @@
my $token = Jifty::Plugin::OAuth::Model::RequestToken->new(current_user => Jifty::CurrentUser->superuser);
$token->load_by_cols(
token => $self->argument_value('token'),
- user => Jifty->web->current_user->id
+ auth_as => Jifty->web->current_user->id
);
if ($self->argument_value('authorize') eq 'allow') {
Modified: jifty/trunk/lib/Jifty/Plugin/OAuth/Dispatcher.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Plugin/OAuth/Dispatcher.pm (original)
+++ jifty/trunk/lib/Jifty/Plugin/OAuth/Dispatcher.pm Thu Oct 18 17:13:32 2007
@@ -8,9 +8,9 @@
use Net::OAuth::AccessTokenRequest;
use Net::OAuth::ProtectedResourceRequest;
-before POST $Jifty::Plugin::OAuth::CONFIG{request_token} => \&request_token;
-before GET $Jifty::Plugin::OAuth::CONFIG{authorize} => \&authorize;
-before POST $Jifty::Plugin::OAuth::CONFIG{access_token} => \&access_token;
+before POST '/oauth/request_token' => \&request_token;
+before GET '/oauth/authorize' => \&authorize;
+before POST '/oauth/access_token' => \&access_token;
# a consumer wants a request token
sub request_token {
@@ -23,7 +23,7 @@
# Net::OAuth::Request will die hard if it doesn't get everything it wants
my $request = eval { Net::OAuth::RequestTokenRequest->new(
- request_url => Jifty->web->url(path => $Jifty::Plugin::OAuth::CONFIG{request_token}),
+ request_url => Jifty->web->url(path => '/oauth/request_token'),
request_method => Jifty->handler->apache->method(),
consumer_secret => $consumer->secret,
@@ -61,6 +61,7 @@
my %oauth_params = get_parameters(@params);
set next => $oauth_params{callback};
+ set consumer => 'Some application';
if ($oauth_params{token}) {
my $request_token = Jifty::Plugin::OAuth::Model::RequestToken->new(current_user => Jifty::CurrentUser->superuser);
@@ -71,8 +72,6 @@
set token => $oauth_params{token};
}
}
-
- default consumer => 'Some application';
}
# the consumer is trying to trade a request token for an access token
@@ -92,7 +91,7 @@
# Net::OAuth::Request will die hard if it doesn't get everything it wants
my $request = eval { Net::OAuth::AccessTokenRequest->new(
- request_url => Jifty->web->url(path => $Jifty::Plugin::OAuth::CONFIG{access_token}),
+ request_url => Jifty->web->url(path => '/oauth/access_token'),
request_method => Jifty->handler->apache->method(),
consumer_secret => $consumer->secret,
token_secret => $request_token->secret,
@@ -109,7 +108,7 @@
my ($ok) = eval {
$token->create(consumer => $consumer,
- user => $request_token->authorized_by,
+ auth_as => $request_token->authorized_by,
map { $_ => $oauth_params{$_} } qw/timestamp nonce/);
};
@@ -121,7 +120,7 @@
sub get_consumer {
my $key = shift;
my $consumer = Jifty::Plugin::OAuth::Model::Consumer->new(current_user => Jifty::CurrentUser->superuser);
- $consumer->load_by_cols(key => $key);
+ $consumer->load_by_cols(consumer_key => $key);
abort(401) if !$consumer->id;
return $consumer;
}
@@ -148,7 +147,7 @@
$p{version} ||= '1.0';
unless (get 'no_abort') {
- abort(400) if grep { !defined($p{$_}) } @_
+ #abort(400) if grep { !defined($p{$_}) } @_
}
return %p;
Modified: jifty/trunk/lib/Jifty/Plugin/OAuth/Model/AccessToken.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Plugin/OAuth/Model/AccessToken.pm (original)
+++ jifty/trunk/lib/Jifty/Plugin/OAuth/Model/AccessToken.pm Thu Oct 18 17:13:32 2007
@@ -13,7 +13,7 @@
use Jifty::Record schema {
# kludge 2: this kind of plugin cannot yet casually refer_to app models
- column user =>
+ column auth_as =>
type is 'integer';
#refers_to $app_user;
Modified: jifty/trunk/lib/Jifty/Plugin/OAuth/Model/Consumer.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Plugin/OAuth/Model/Consumer.pm (original)
+++ jifty/trunk/lib/Jifty/Plugin/OAuth/Model/Consumer.pm Thu Oct 18 17:13:32 2007
@@ -9,7 +9,7 @@
use Jifty::Record schema {
# the unique key that identifies a consumer
- column key =>
+ column consumer_key =>
type is 'varchar',
is distinct,
is required;
Modified: jifty/trunk/lib/Jifty/Plugin/OAuth/View.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Plugin/OAuth/View.pm (original)
+++ jifty/trunk/lib/Jifty/Plugin/OAuth/View.pm Thu Oct 18 17:13:32 2007
@@ -21,15 +21,15 @@
dl {
dt {
outs "Request a Request Token";
- dd { Jifty->web->url(path => $Jifty::Plugin::OAuth::CONFIG{request_token}) }
+ dd { Jifty->web->url(path => '/oauth/request_token') }
}
dt {
outs "Obtain user authorization for a Request Token";
- dd { Jifty->web->url(path => $Jifty::Plugin::OAuth::CONFIG{authorize}) }
+ dd { Jifty->web->url(path => '/oauth/authorize') }
}
dt {
outs "Exchange a Request Token for an Access Token";
- dd { Jifty->web->url(path => $Jifty::Plugin::OAuth::CONFIG{access_token}) }
+ dd { Jifty->web->url(path => '/oauth/access_token') }
}
}
@@ -63,7 +63,7 @@
class => 'AuthorizeRequestToken',
);
- Jifty->web->form->start( call => get('next') );
+ Jifty->web->form->start( call => get 'next' );
# if the site put the token in the request, then use it
# otherwise, prompt the user for it
@@ -76,15 +76,15 @@
$authorize->form_field('token')->render;
}
- $authorize->button(
+ outs_raw($authorize->button(
label => 'Allow',
arguments => { %args, authorize => 'allow' },
- );
+ ));
- $authorize->button(
+ outs_raw($authorize->button(
label => 'Deny',
arguments => { %args, authorize => 'deny' },
- );
+ ));
Jifty->web->form->end();
};
More information about the Jifty-commit
mailing list