s some of the API details and throws rich
# exceptions rather than requiring the caller deal with JSON data structures
# directly.
#
# This module is intended primarily for use as a base class for mor
ict;
use warnings;
use Carp qw(croak);
use Digest::SHA qw(hmac_sha1_hex);
use HTTP::Request;
use JSON ();
use LWP::UserAgent 6.00;
use Net::Duo::Exception;
use Perl6::Slurp;
use POSIX qw(strftime);
u
if ($args_ref->{key_file}) {
my $json = JSON->new->relaxed(1);
my $key_data = slurp($args_ref->{key_file});
$keys = eval { $json->decode($key_data) };
if ($@) {
use strict;
use warnings;
use parent qw(Net::Duo::Object);
# Data specification for converting JSON into our object representation. See
# the Net::Duo::Object documentation for syntax information.
rs;
# Override the new method to support creating an integration from an ID
# instead of decoded JSON data.
#
# $class - Class of object to create
# $duo - Net::Duo object to use to creat
data)) {
my $uri = "/admin/v1/integrations/$id_or_data";
$id_or_data = $duo->call_json('GET', $uri);
}
return $class->SUPER::new($duo, $id_or_data);
}
# Override the create me
Helper base class for Duo objects.
#
# The Duo API contains a variety of objects, represented as JSON objects with
# multiple fields. This objects often embed other objects inside them. To
# provid
as a base class for such objects and does the dirty work
# of constructing an object from decoded JSON data and building the accessors
# automatically from a field specification.
#
# SPDX-License-Iden
IT
package Net::Duo::Object 1.02;
use 5.014;
use strict;
use warnings;
use Carp qw(croak);
use JSON ();
use Sub::Install;
# Helper function to parse the data for a particular field specification.
some of the API details, and throws rich exceptions rather than
# requiring the caller deal with JSON data structures directly.
#
# SPDX-License-Identifier: MIT
package Net::Duo::Admin 1.02;
use 5.
y ($self) = @_;
# Make the Duo call and get the decoded result.
my $result = $self->call_json_paged('GET', '/admin/v1/integrations');
# Convert the returned integrations into Net::Duo::A
=> $mintime } : {};
my $uri = '/admin/v1/logs/administrator';
my $result = $self->call_json('GET', $uri, $args);
# Return the result as a list.
return @{$result};
}
# Retrieve aut
Digest::SHA qw(hmac_sha1_hex);
use Encode qw(decode);
use HTTP::Request;
use HTTP::Response;
use JSON ();
use Perl6::Slurp;
use Test::More;
use URI::Escape qw(uri_unescape);
########################
if ($args_ref->{key_file}) {
my $json = JSON->new()->relaxed(1);
my $key_data = slurp($args_ref->{key_file});
$keys = $json->decode($key_data);
}
# Integration
$args_ref->{$key} // $keys->{$key};
}
# Create the JSON decoder that we'll use for subsequent operations.
$self->{json} = JSON->new->utf8(1);
# Create the queue of expected requests
to a call to protocol().
#
# $class - Class of the exception to create
# $object - The decoded JSON object representing the error reply
# $content - The undecoded content of the server reply
#
# Re
key.
if (!defined($object->{stat})) {
return $class->protocol('missing stat value in JSON reply', $content);
} elsif ($object->{stat} ne 'FAIL') {
my $e = $class->protocol('in
detail} = $object->{stat};
return $e;
}
# Set the exception information from the JSON object.
my $self = {
code => $object->{code} // 50000,
message => $obje
d => $self->{id} };
my $uri = '/auth/v2/auth_status';
my $result = $self->{_duo}->call_json('GET', $uri, $data);
# Ensure the response included a result field.
if (!defined($result
NTS
Perl 5.14 or later and the modules HTTP::Request and HTTP::Response (part
of HTTP::Message), JSON, LWP (also known as libwww-perl), Perl6::Slurp,
Sub::Install, and URI::Escape (part of URI), all
:Phone;
use Net::Duo::Admin::Token;
use Net::Duo::Exception;
# Data specification for converting JSON into our object representation. See
# the Net::Duo::Object documentation for syntax information.
d_phone');
}
my $uri = "/admin/v1/users/$self->{user_id}/phones";
$self->{_duo}->call_json('POST', $uri, { phone_id => $phone->phone_id });
return;
}
## use critic
# Add a token to th
d_token');
}
my $uri = "/admin/v1/users/$self->{user_id}/tokens";
$self->{_duo}->call_json('POST', $uri, { token_id => $token->token_id });
return;
}
## use critic
# Get one or more b
use strict;
use warnings;
use parent qw(Net::Duo::Object);
# Data specification for converting JSON into our object representation. See
# the Net::Duo::Object documentation for syntax information.
(Subroutines::ProhibitBuiltinHomonyms)
sub delete {
my ($self) = @_;
$self->{_duo}->call_json('DELETE', "/admin/v1/groups/$self->{group_id}");
return;
}
## use critic
1;
__END__
=for st
presentation of a Duo group
=head1 SYNOPSIS
my $decoded_json = get_json();
my $group = Net::Duo::Admin::Group->new($decoded_json);
say $group->desc;
=head1 REQUIREMENTS
Perl 5.14 or la
use parent qw(Net::Duo::Object);
use Net::Duo::Admin::User;
# Data specification for converting JSON into our object representation. See
# the Net::Duo::Object documentation for syntax information.
accessors;
# Override the new method to support creating a phone from an ID instead
# of decoded JSON data.
#
# $class - Class of object to create
# $duo - Net::Duo object to use to creat
y ($class, $duo, $id_or_data) = @_;
if (!ref($id_or_data)) {
$id_or_data = $duo->call_json('GET', "/admin/v1/phones/$id_or_data");
}
return $class->SUPER::new($duo, $id_or_data);
}
use parent qw(Net::Duo::Object);
use Net::Duo::Admin::User;
# Data specification for converting JSON into our object representation. See
# the Net::Duo::Object documentation for syntax information.
accessors;
# Override the new method to support creating a token from an ID instead
# of decoded JSON data.
#
# $class - Class of object to create
# $duo - Net::Duo object to use to creat
y ($class, $duo, $id_or_data) = @_;
if (!ref($id_or_data)) {
$id_or_data = $duo->call_json('GET', "/admin/v1/tokens/$id_or_data");
}
return $class->SUPER::new($duo, $id_or_data);
}
some of the API details, and throws rich exceptions rather than
# requiring the caller deal with JSON data structures directly.
#
# SPDX-License-Identifier: MIT
package Net::Duo::Auth 1.02;
use 5.0
lf->_canonicalize_auth_args($args_ref);
# Make the call to Duo.
my $result = $self->call_json('POST', '/auth/v2/auth', $args);
# Ensure we got a valid result.
if (!defined($result->{
rgs($args_ref);
$args->{async} = 1;
# Make the call to Duo.
my $result = $self->call_json('POST', '/auth/v2/auth', $args);
# Return the transaction ID.
if (!defined($result->{txi