Net::Duo::Admin(3pm)
π Net::Duo::Admin π
okay so bestie, welcome to Net::Duo::Admin β it's the Perl interface for the Duo Admin API. yes THE Duo. the auth one. she's a Perl module, she's a whole manual page (3pm, in case you were wondering), and she's here to let you talk to Duo from inside your Perl like it's nothing. π¦
β¨ SYNOPSIS β¨
my $duo = Net::Duo::Admin->new({ key_file => '/path/to/keys.json' });
my @users = $duo->users;
like. that's it. that's the whole vibe. π
πΈ REQUIREMENTS πΈ
you're gonna need Perl 5.14 or later, plus these modules, and no you cannot skip them:
HTTP::RequestandHTTP::Responseβ these two live insideHTTP::Message, they're a package deal π«ΆJSONLWP(also known aslibwww-perl, same girl different name)Perl6::SlurpSub::InstallURI::Escapeβ part ofURI
all of them are available from CPAN, so like, go get them. β¨
π DESCRIPTION π
Net::Duo::Admin is an implementation of the Duo Admin REST API for Perl. method calls correspond to endpoints in the REST API β so like, every method is basically a lil doorway into an endpoint. her goal is to give you a native, natural interface for all the Duo operations in the API from inside Perl, while abstracting away as many details of the API as can be reasonably handled automatically. she's doing the emotional labor so you don't have to. ππ
currently, only a tiny number of available methods are implemented. she's growing. be patient with her.
for calls that return complex data structures, the return from the call will generally be an object in the Net::Duo::Admin namespace. these objects all have methods matching the name of the field in the Duo API documentation that returns that field value. and where it makes sense, there's also a method with the same name but with set_ prepended that changes that value. no changes are made to the Duo record itself until the commit() method is called on the object, which is the moment that makes the underlying Duo API call to actually update the data. so like, you can be feral with your set_ calls and nothing happens to Duo until you commit. periodt. π
some objects have associated lists of other objects. for example, a user has a list of phones and a list of tokens. wherever this pattern occurs, new objects can be added to that list with a method starting with add_ and removed with a method starting with remove_. heads up though β these changes are pushed to Duo immediately and do not wait for the next commit(). so add_ and remove_ are the impulsive ones. no vibe check, straight to Duo. πβοΈπ¨
on failure, all methods throw a Net::Duo::Exception object. you can interpolate it into a string for a simple error message, or inspect it with method calls for more details. and this is also true of all methods in all objects in the Net::Duo namespace. consistent queen. π
β CLASS METHODS β
new(ARGS)β create a newNet::Duo::Adminobject, which is used for all subsequent calls. this constructor is inherited fromNet::Duo, so seeNet::Duofor documentation of the possible arguments. she's not reinventing the wheel, she's borrowing it. π
π INSTANCE METHODS π
integrations()β retrieves all the integrations currently present in this Duo account and returns them as a list ofNet::Duo::Admin::Integrationobjects. be aware that this list may be quite long if the Duo account supports many integrations, and the entire list is read into memory. so like, all of it. at once. in your RAM. πlogs_administrator([MINTIME])β returns a list of administrative actions. each member of this list will be a reference to a hash with the following keys:timestampβ the time of the event in seconds since UNIX epoch.usernameβ the username of the administrator, or"API"if the action was performed via the Admin API.actionβ the administrator action. see the Duo Admin API documentation for a full list of valid values.objectβ an identifier for the object that was acted on. what fields are used as an identifier will vary by type of object.descriptionβ the details of what was changed.
at most 1,000 log entries will be returned. if MINTIME is provided, only records with a time stamp after MINTIME will be returned. so you can retrieve all the records by calling this method repeatedly β first with no MINTIME, and then with MINTIME matching the timestamp of the last returned record from the previous call. it's a lil loop, bestie. you got this. π
logs_authentication([MINTIME])β returns a list of authentication attempts. each member of the list will be a reference to a hash with the following keys:timestampβ the time of the event in seconds since UNIX epoch.usernameβ the authenticating user's username.factorβ the authentication factor, chosen from"phone call","passcode","bypass code","sms passcode","sms refresh", or"duo push".resultβ the result of the authentication, chosen from"success","failure","error", or"fraud".ipβ the IP address from which the authentication attempt originated.integrationβ the name of the integration from which the authentication attempt originated.
at most 1,000 authentication log entries will be returned. if MINTIME is provided, only records with a time stamp after MINTIME will be returned. all records can therefore be retrieved by calling this method repeatedly, first with no MINTIME and then with MINTIME matching the timestamp of the last returned record from the previous call. same lil loop, different log. π«
logs_telephony([MINTIME])β returns a list of telephony events. each member of this list will be a reference to a hash with the following keys:timestampβ the time of the event in seconds since UNIX epoch.contextβ how this telephony event was initiated. this will be one of"administrator login","authentication","enrollment", or"verify".typeβ the event type. one of"sms"or"phone".phoneβ the phone number that initiated this event.creditsβ how many telephony credits this event cost.
at most 1,000 log entries will be returned. if MINTIME is provided, only records with a time stamp after MINTIME will be returned. all records can therefore be retrieved by calling this method repeatedly, first with no MINTIME and then with MINTIME matching the timestamp of the last returned record from the previous call. π₯
user(USERNAME)β retrieves a single user by username and returns it as aNet::Duo::Admin::Userobject if found. if no user with that username exists, returnsundef, and does not throw an exception. she's chill about it. no drama. justundef. π«Άusers()β retrieves all the users currently present in this Duo account and returns them as a list ofNet::Duo::Admin::Userobjects. be aware that this list may be quite long and consume a lot of resources for accounts with many users. she said what she said. π
π AUTHOR π
Russ Allbery <rra@cpan.org>
π COPYRIGHT AND LICENSE π
Copyright 2014 The Board of Trustees of the Leland Stanford Junior University
Copyright 2019 Russ Allbery <rra@cpan.org>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
so like, yeah, all caps legal text, but the whole point is: it's free, use it, just keep the notice, and don't come for the authors if it breaks. π§
π¦ SEE ALSO π¦
- Duo Auth API
<https://www.duo.com/docs/authapi> - this module is part of the
Net::Duodistribution. the current version ofNet::Duois available from CPAN, or directly from its web site at<https://www.eyrie.org/~eagle/software/net-duo/>.
and that's the whole page, bestie! this one shipped as perl v5.36.0, dated 2022-12-18 β iconic, timeless, no notes. go call an endpoint. mwah. πβ¨πΈππ«Ά
π¦ where this page comes from
- debian bookworm: libnet-duo-perl 1.02-3 Β· MIT
- debian trixie: libnet-duo-perl 1.02-3 Β· MIT
- ubuntu noble: libnet-duo-perl 1.02-3 Β· MIT
- ubuntu resolute: libnet-duo-perl 1.02-3 Β· MIT
- ubuntu stonking: libnet-duo-perl 1.02-3 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms