Net::D...n::User(3pm)
π NAME π
Net::Duo::Admin::User β the lil Perl glow-up of a Duo user, bestie β¨
β¨ SYNOPSIS β¨
my $decoded_json = get_json();
my $user = Net::Duo::Admin::User->new($decoded_json);
say $user->realname;
π«Ά REQUIREMENTS π«Ά
Okay so before you even breathe near this module, you need Perl 5.14 or later πͺ plus these CPAN besties: HTTP::Request and HTTP::Response (they live inside HTTP::Message), JSON, LWP (aka libwww-perl, yes the same one), Perl6::Slurp, Sub::Install, and URI::Escape (which lives inside URI). All of them are on CPAN, so like, go get them, no cap π
πΈ DESCRIPTION πΈ
A Net::Duo::Admin::User object is literally just a Perl representation of a Duo user, exactly how the Duo Admin API hands it over β usually by way of the users() method π«Ά It's stuffed with everything about that user, including their groups, phones, and tokens. It's giving "one object, all the lore" β¨
π CLASS METHODS π
create(DUO, DATA)
Makes a brand-new user over in Duo and hands you back the resulting user as a fresh new Net::Duo::Admin::User object π DUO is the Net::Duo object you're using to do the creating. DATA is a reference to a hash, and here's what can go in it:
emailβ the user's email address. Optional.notesβ notes about this user. Optional.realnameβ the user's real name. Optional.statusβ the user's status. Peep thestatus()method below for the possible values. Optional, and if you don't give one it gets set to"active".usernameβ the name of the user you're creating. It needs to be unique within this Duo account, and you can use it to pull the user object back later with theuser()method ofNet::Duo::Admin. Required π¨
new(DUO, DATA)
Builds a new Net::Duo::Admin::User object from a full data set. DUO is the Net::Duo object used for any further actions on this object. DATA should be the data structure the Duo REST API returns for a single user, after JSON decoding π§
π₯ INSTANCE ACTION METHODS π₯
add_phone(PHONE)
Associates the Net::Duo::Admin::Phone object PHONE with this user. Every other phone already linked to this user stays exactly as it was, untouched π
add_token(TOKEN)
Associates the Net::Duo::Admin::Token object TOKEN with this user. Same deal: other tokens already linked stay unchanged π
bypass_codes(DATA)
Asks for bypass codes for the user and returns them as a reference to an array π₯ DATA is a reference to a hash of parameters picked from the keys below β every single one of them is optional:
countβ how many bypass codes to request. At most 10 codes (which is the default whencodesisn't given) can be created at a time. If you pass this one, you may not passcodes.codesβ a reference to an array of codes to set as bypass codes for this user. If you pass this one, you may not passcount.reuse_countβ how many times each code in the list can be reused. Defaults to 1. Set it to 0 and the codes can be reused indefinitely βΎοΈvalid_secsβ how many seconds these codes stay valid. Set it to 0 (the default) and the codes will never expire.
commit()
Commits every change you made through the set_*() methods over to Duo π
Until you call this, anything you did with set_*() is only internal to the object and is not reflected in Duo. Important.
After commit(), the internal representation of the object gets refreshed to match the new data the Duo API sends back for that object. So like, other fields of the object may change after commit() if some other user changed other, unrelated fields in the object π
Honestly the best way to think about this method is as a synchronize operation: your changed data gets written back, overwriting what's in Duo, and your unchanged data may get overwritten by whatever is currently in Duo, if it's different. Periodt.
delete()
Deletes this user from Duo ποΈ Once this call completes successfully, you should treat the Net::Duo::Admin::User object as read-only, since no further changes to the object can be meaningfully sent to Duo. It's done, bestie, let it go π
json()
Converts the data stored in the object to JSON and returns the results β¨ The JSON you get should match the JSON you'd get back from the Duo web service when retrieving that same object (plus any changes you made locally via the set_*() methods). This is mainly for debugging dumps, or for passing Duo objects along to other systems through further JSON APIs π¦
remove_phone(PHONE)
Disassociates the Net::Duo::Admin::Phone object PHONE from this user. Other phones associated with this user are left unchanged π
remove_token(TOKEN)
Disassociates the Net::Duo::Admin::Token object TOKEN from this user. Other tokens associated with this user are left unchanged π
π INSTANCE DATA METHODS π
So some of these fields come with set_*() methods. Those methods replace the value of the field in its entirety with the new value you pass in. And bestie, listen: that change is only made locally inside the object until commit() gets called π
email(), set_email(EMAIL)
The user's email address π§
groups()
The list of groups this user belongs to, as Net::Duo::Admin::Group objects π
last_login()
The last time this user logged in, as a UNIX timestamp β or undef if the user has never logged in π°οΈ
notes(), set_notes(NOTES)
Notes about this user π
phones()
The list of phones this user can use, as Net::Duo::Admin::Phone objects π±
realname(), set_realname(NAME)
The user's real name π
status(), set_status(STATUS)
One of these values, no others:
"active"β the user must complete secondary authentication."bypass"β the user will bypass secondary authentication after completing primary authentication."disabled"β the user will not be able to log in."locked out"β the user has been automatically locked out due to excessive authentication attempts. (oops π)
tokens()
The list of tokens this user can use, as Net::Duo::Admin::Token objects π
user_id()
The unique ID of this user, as generated by Duo when the user was created β
username(), set_username(USERNAME)
The username of this user π¦
π AUTHOR π
Russ Allbery <rra@cpan.org> β icon, legend, the moment π
β COPYRIGHT AND LICENSE β
Copyright 2014 The Board of Trustees of the Leland Stanford Junior University.
Okay so this next part is the legal text and I am not touching it, it stays exactly as written, do not edit, iykyk π:
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.
π SEE ALSO π
Net::Duo::Adminπ«Ά- Duo Admin API for users β
https://www.duo.com/docs/adminapi#users - This module is part of the Net::Duo distribution. The current version of Net::Duo is 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!! Sourced straight from perl v5.36.0, dated 2022-12-18 β go forth and manage your Duo users responsibly πβ¨π
π¦ 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