e '200';
return $tx->res->headers->content_type =~ m!^(application/json|text/javascript)(;\s*charset=\S+)?$!
? $tx->res->json
: Mojo::Parameters->new($tx->res->body)->to_hash;
}
sub _warmup
a->get_p($provider->{well_known_url})->then(sub {
my $tx = shift;
my $res = $tx->result->json;
$provider->{authorize_url} = $res->{authorization_endpoint};
$provider->{end_session_u
})->then(sub {
my $tx = shift;
$provider->{jwt} = Mojo::JWT->new->add_jwkset($tx->result->json);
return $provider;
})->catch(sub {
my $err = shift;
$app->log->error("[OAuth2] Fai
require MIME::Base64;
return $c->render(
template => 'oauth2/mock/keys',
format => 'json',
n => MIME::Base64::encode_base64url($n->to_bin),
e => MIME::Base64::encod
)->to_string
);
}
sub _action_token_endpoint {
my ($self, $c) = @_;
return $c->render(json => {error => 'invalid_request'}, status => 500)
unless (($c->param('client_secret') and $c->p
_KEY'}
);
return $c->render(
template => 'oauth2/mock/token',
format => 'json',
id_token => $id_token->expires(Mojo::JWT->now + 3600)->encode,
refresh_token => $c