CatalystX-OAuth2

 view release on metacpan or  search on metacpan

META.yml  view on Meta::CPAN

  Catalyst::Controller: '0'
  Catalyst::Controller::ActionRole: '0'
  Catalyst::Model::DBIC::Schema: '0'
  Catalyst::Plugin::Authentication: '0'
  Catalyst::Plugin::ConfigLoader: '0'
  Catalyst::Plugin::Session: '0'
  Catalyst::Plugin::Session::State::Cookie: '0'
  Catalyst::Test: '0'
  Devel::Dwarn: '0'
  File::Spec: '0'
  HTTP::Request: '0'
  IO::Handle: '0'
  IPC::Open3: '0'
  Plack::Builder: '0'
  Plack::Test: '0'
  SQL::Translator: '0.11006'
  Test::Exception: '0'
  Test::MockObject: '0'
  Test::More: '0'
  Test::WWW::Mechanize::PSGI: '0'
  blib: '1.01'

META.yml  view on Meta::CPAN

license: perl
meta-spec:
  url: http://module-build.sourceforge.net/META-spec-v1.4.html
  version: '1.4'
name: CatalystX-OAuth2
requires:
  Class::Load: '0'
  DBIx::Class: '0'
  DBIx::Class::ResultSet: '0'
  DBIx::Class::Schema: '0'
  HTTP::Request::Common: '0'
  JSON::Any: '0'
  LWP::UserAgent: '0'
  Moose: '0'
  Moose::Role: '0'
  Moose::Util: '0'
  Moose::Util::TypeConstraints: '0'
  MooseX::NonMoose: '0'
  MooseX::SetOnce: '0'
  MooseX::Types::Common::String: '0'
  Scalar::Util: '0'

Makefile.PL  view on Meta::CPAN

  },
  "DISTNAME" => "CatalystX-OAuth2",
  "LICENSE" => "perl",
  "MIN_PERL_VERSION" => "5.006",
  "NAME" => "CatalystX::OAuth2",
  "PREREQ_PM" => {
    "Class::Load" => 0,
    "DBIx::Class" => 0,
    "DBIx::Class::ResultSet" => 0,
    "DBIx::Class::Schema" => 0,
    "HTTP::Request::Common" => 0,
    "JSON::Any" => 0,
    "LWP::UserAgent" => 0,
    "Moose" => 0,
    "Moose::Role" => 0,
    "Moose::Util" => 0,
    "Moose::Util::TypeConstraints" => 0,
    "MooseX::NonMoose" => 0,
    "MooseX::SetOnce" => 0,
    "MooseX::Types::Common::String" => 0,
    "Scalar::Util" => 0,

Makefile.PL  view on Meta::CPAN

    "Catalyst::Controller" => 0,
    "Catalyst::Controller::ActionRole" => 0,
    "Catalyst::Model::DBIC::Schema" => 0,
    "Catalyst::Plugin::Authentication" => 0,
    "Catalyst::Plugin::ConfigLoader" => 0,
    "Catalyst::Plugin::Session" => 0,
    "Catalyst::Plugin::Session::State::Cookie" => 0,
    "Catalyst::Test" => 0,
    "Devel::Dwarn" => 0,
    "File::Spec" => 0,
    "HTTP::Request" => 0,
    "IO::Handle" => 0,
    "IPC::Open3" => 0,
    "Plack::Builder" => 0,
    "Plack::Test" => 0,
    "SQL::Translator" => "0.11006",
    "Test::Exception" => 0,
    "Test::MockObject" => 0,
    "Test::More" => 0,
    "Test::WWW::Mechanize::PSGI" => 0,
    "blib" => "1.01",

Makefile.PL  view on Meta::CPAN

  "Catalyst::Plugin::ConfigLoader" => 0,
  "Catalyst::Plugin::Session" => 0,
  "Catalyst::Plugin::Session::State::Cookie" => 0,
  "Catalyst::Test" => 0,
  "Class::Load" => 0,
  "DBIx::Class" => 0,
  "DBIx::Class::ResultSet" => 0,
  "DBIx::Class::Schema" => 0,
  "Devel::Dwarn" => 0,
  "File::Spec" => 0,
  "HTTP::Request" => 0,
  "HTTP::Request::Common" => 0,
  "IO::Handle" => 0,
  "IPC::Open3" => 0,
  "JSON::Any" => 0,
  "LWP::UserAgent" => 0,
  "Moose" => 0,
  "Moose::Role" => 0,
  "Moose::Util" => 0,
  "Moose::Util::TypeConstraints" => 0,
  "MooseX::NonMoose" => 0,
  "MooseX::SetOnce" => 0,

lib/Catalyst/Authentication/Credential/OAuth2.pm  view on Meta::CPAN

package Catalyst::Authentication::Credential::OAuth2;
use Moose;
use MooseX::Types::Common::String qw(NonEmptySimpleStr);
use LWP::UserAgent;
use HTTP::Request::Common;
use JSON::Any;
use Moose::Util;

# ABSTRACT: Authenticate against OAuth2 servers


has [qw(grant_uri token_uri client_id)] => (
  is       => 'ro',
  isa      => NonEmptySimpleStr,
  required => 1,

t/lib/ClientApp/Controller/Root.pm  view on Meta::CPAN

package ClientApp::Controller::Root;
use Moose;
use namespace::autoclean;
use HTTP::Request;

BEGIN { extends 'Catalyst::Controller' }

__PACKAGE__->config( namespace => '' );

sub auth : Local Args(0) {
  my ( $self, $c ) = @_;
  $c->res->body('auth ok') if $c->authenticate();
}

sub lead : Local Args(0) {
  my ( $self, $c ) = @_;
  $c->res->body('ok');
}

sub gold : Local Args(0) {
  my ( $self, $c ) = @_;
  return unless $c->user_exists;
  my $res = $c->user->oauth2->request(
    HTTP::Request->new( GET => 'http://resourceserver/gold' )
  );

  $c->res->body( $res->content );
}

1;

t/unit/100-controller-role-provider.t  view on Meta::CPAN

use strictures 1;
use Test::More;
use Test::Exception;
use Plack::Test;
use HTTP::Request::Common;

use lib 't/lib';
use AuthServer;

my $ctl = AuthServer->controller('OAuth2::Provider');
lives_ok { $ctl->check_provider_actions };
is( $ctl->_request_auth_action, $ctl->action_for('request') );
is( $ctl->_get_auth_token_via_auth_grant_action, $ctl->action_for('grant') );

package AuthServer::Mock::Controller;

t/unit/200-actionrole-request-auth.t  view on Meta::CPAN

use strictures 1;
use Test::More;
use Test::Exception;
use Plack::Test;
use HTTP::Request::Common;
use URI;
use Moose::Util;

use lib 't/lib';
use Catalyst::Test 'AuthServer';



{
  my ($res, $c) = ctx_request('/request');

t/unit/300-actionrole-grant-auth.t  view on Meta::CPAN

use strictures 1;
use Test::More;

use HTTP::Request::Common;
use lib 't/lib';
use Catalyst::Test 'AuthServer';


my $code =
  AuthServer->model('DB::Code')
  ->create( { client => { endpoint => '/client/foo' } } );

# try grant with invalid code and no approval param
# should display form

t/unit/400-actionrole-auth-token-via-auth-grant.t  view on Meta::CPAN

use strictures 1;
use Test::More;
use JSON::Any;
use HTTP::Request::Common;
use lib 't/lib';
use Catalyst::Test 'AuthServer';

my $json = JSON::Any->new;


my $code = AuthServer->model('DB::Code')
  ->create( { client => { endpoint => '/client/foo' } } );

{

t/unit/500-actionrole-auth-token-via-refresh-token.t  view on Meta::CPAN

use strictures 1;
use Test::More;
use JSON::Any;
use HTTP::Request::Common;
use lib 't/lib';
use Catalyst::Test 'AuthServer';

my $json = JSON::Any->new;


my $code = AuthServer->model('DB::Code')->create(
  { client    => { endpoint => '/client/foo' },
    is_active => 1
  }

t/unit/600-actionrole-protected-resource.t  view on Meta::CPAN

use strictures 1;
use Test::More;
use HTTP::Request::Common;
use HTTP::Request;
use lib 't/lib';
use Catalyst::Test 'AuthServer';

my $client = AuthServer->model('DB::Client')->first;
my $code = $client->codes->create( { tokens => [ {} ], owner => {} } );

my $token = $code->tokens->first;

{
  my ($res2, $c) = ctx_request('/gold');
  $c->dispatch;
  is_deeply( $c->error, [] );
  is( $c->res->status, 401 );
}

{
  my $request = HTTP::Request->new(GET => '/gold', [Authorization => 'Bearer ' . $token->as_string]);
  my ($res2, $c) = ctx_request($request);

  $c->dispatch;
  is( $c->req->oauth2->token->as_string, $token->as_string );
  is( $token->owner->id,                 $c->req->oauth2->token->owner->id );
  is_deeply( $c->error, [] );
  is( $c->res->body, 'gold' );
}

done_testing();

t/unit/700-client.t  view on Meta::CPAN

use strictures 1;
use Test::More;
use Test::MockObject;
use HTTP::Request::Common;
use JSON::Any;
use lib 't/lib';
use AuthServer;
use ClientApp;

use Catalyst::Authentication::Credential::OAuth2;

# can't use Test::Mock::Object here because mocked methods aren't recognized
# by the requires 'method'; role application constraint
package Test::Mock::Store;



( run in 1.251 second using v1.01-cache-2.11-cpan-de7293f3b23 )