Bundle-WATERKIP

 view release on metacpan or  search on metacpan

lib/Bundle/WATERKIP/CLI/JWT/Validate.pm  view on Meta::CPAN

package Bundle::WATERKIP::CLI::JWT::Validate;
our $VERSION = '0.003';
use Moo;
use namespace::autoclean;
with 'YA::CLI::ActionRole';
use feature qw(say);

# ABSTRACT: Validate JWT tokens

use Crypt::JWT qw(decode_jwt);
use Types::Standard qw(Enum);
use LWP::UserAgent;
use List::Util qw(any);

my $providers = Enum(
  [
    qw(
      google_v1
      google_v2
      azure_v1
      azure_v2
    )
  ]
);

my %providers = (
    google_v2 => 'https://www.googleapis.com/oauth2/v2/certs',
    google_v1 => 'https://www.googleapis.com/oauth2/v1/certs',
    azure_v1  => 'https://login.microsoftonline.com/tenantid/discovery/v1.0/keys',
    azure_v2  => 'https://login.microsoftonline.com/tenantid/discovery/v2.0/keys',
);

has provider => (
    is => 'ro',
    isa => $providers,
    predicate => 'has_provider',
);

sub usage_pod { 1 }

sub cli_options {
  return (
    'jwt=s', 'provider=s', 'key_uri=s',
    'tenant_id|tenant-id=s', 'ignore_signature|ignore-signature'
  );
}

sub _croak {
    my $self = shift;
    my $msg = shift;
    return $self->as_help(1, $msg)->run;

}

sub action { 'main' }

sub run {
  my $self = shift;

  my $token = $self->_cli_args->{jwt};

  $self->_croak("You must supply a JWT token") unless defined $token;

  my $uri = $self->_cli_args->{key_uri};



( run in 0.663 second using v1.01-cache-2.11-cpan-39bf76dae61 )