CatalystX-OAuth2-Provider
view release on metacpan or search on metacpan
lib/CatalystX/OAuth2/Provider/Controller/OAuth.pm view on Meta::CPAN
96979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
error_description
=>
'Invalid grant type'
);
$ctx
->res->body( JSON::XS->new->pretty(1)->encode( \
%data
) );
}
sub
handle_grant_type : Private {
my
(
$self
,
$ctx
,
$grant_type
) =
@_
;
}
=head2 authorize
Authorize endpoint
=cut
sub
authorize
:Chained(
'logged_in_required'
)
:PathPart(
'authorize'
)
#Configurable?
:Args(0)
{
my
(
$self
,
$ctx
) =
@_
;
if
(
$ctx
->req->method eq
'GET'
) {
$ctx
->stash(
authorize_endpoint
=>
$ctx
->uri_for_action(
$ctx
->action) );
$ctx
->stash(
template
=>
$self
->{authorize_form}->{template}
||
'oauth/authorize.tt'
);
}
if
(
$ctx
->req->method eq
'POST'
) {
my
$uri
=
$ctx
->uri_for(
$ctx
->req->param(
"redirect_uri"
),
{
code
=>
$ctx
->sessionid,
redirect_uri
=>
$ctx
->req->param(
"redirect_uri"
),
} );
t/lib/TestApp/root/oauth/authorize.tt view on Meta::CPAN
123456789<form method=
"POST"
action=
"[% authorize_endpoint %]"
>
Do you wish to allow the service named <b>
'[% client.client_name %]'
</b> to access this application on your behalf?
<input type=
"submit"
value=
"Yes"
name=
"authorize"
/>
<input type=
"submit"
value=
"No"
name=
"authorize"
/>
<input type=
"hidden"
name=
"client_id"
id=
"client_id"
value=
"[% client.client_id %]"
/>
<input type=
"hidden"
name=
"redirect_uri"
id=
"redirect_uri"
value=
"[% c.req.params.redirect_uri %]"
/>
<input type=
"hidden"
name=
"response_type"
id=
"response_type"
value=
"code"
/>
t/live-test.t view on Meta::CPAN
161718192021222324252627282930313233343536373839# make sure testapp works
# a live test against TestApp, the test application
my
$mech
= Test::WWW::Mechanize::Catalyst->new;
$mech
->content_like(
qr/it works/
i,
'see if it has our text'
);
subtest
'simple test for endpoint'
,
sub
{
my
$client_id
=
"36d24a484e8782decbf82a46459220a10518239e"
;
is(
$mech
->status, 200,
"Login required"
);
};
subtest
'test for protected resource'
,
sub
{
my
$mac
=
"MAC token=h480djs93hd8,"
;
$mac
.=
"timestamp=137131200,"
;
$mac
.=
"nonce=dj83hs9s,"
;
$mac
.=
"signature=U2FsdGVkX1/3UV6R0SnZvqNDtP7evqzSY12FQoAhemnSJhLDhXpwb2sjPeeBJH14cb3fD1kdREMVyQGl8UlwSg=="
;
$mech
->add_header(
Authorization
=>
$mac
);
( run in 0.527 second using v1.01-cache-2.11-cpan-3cd7ad12f66 )