Skip to content

Commit

Permalink
Update bypass code endpoint with new parameter (#274)
Browse files Browse the repository at this point in the history
  • Loading branch information
cmkeefer authored Aug 29, 2024
1 parent eef3b40 commit 3879780
Showing 1 changed file with 27 additions and 9 deletions.
36 changes: 27 additions & 9 deletions duo_client/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -941,16 +941,31 @@ def enroll_user(self, username, email, valid_secs=None):

return self.json_api_call('POST', path, params)

def add_user_bypass_codes(self, user_id, count=None, valid_secs=None, remaining_uses=None, codes=None, preserve_existing=None):
def add_user_bypass_codes(
self,
user_id,
count=None,
valid_secs=None,
remaining_uses=None,
codes=None,
preserve_existing=None,
endpoint_verification=None,
):
"""
Replace a user's bypass codes with new codes.
user_id - User ID
count - Number of new codes to randomly generate
valid_secs - Seconds before codes expire (if 0 they will never expire)
remaining_uses - The number of times this code can be used (0 is unlimited)
codes - Optionally provide custom codes, otherwise will be random
count and codes are mutually exclusive
Generate bypass codes for user.
Replaces a user's bypass codes with new codes unless
`preserve_existing=True` is passed.
user_id User ID
count Number of new codes to randomly generate
valid_secs Seconds before codes expire (if 0 they will never expire)
remaining_uses The number of times this code can be used (0 is unlimited)
codes Optionally provide custom codes, otherwise will be random
count and codes are mutually exclusive
preserve_existing whether to preserve existing codes when creating new ones,
default is to remove existing bypass codes
endpoint_verification New argument for unreleased feature. Will be ignored if used.
Client will be updated again in the future when feature is released.
Returns a list of newly created codes.
Expand All @@ -966,6 +981,9 @@ def add_user_bypass_codes(self, user_id, count=None, valid_secs=None, remaining_
if valid_secs is not None:
params['valid_secs'] = str(int(valid_secs))

if endpoint_verification is not None:
params["endpoint_verification"] = str(endpoint_verification).lower()

if remaining_uses is not None:
params['reuse_count'] = str(int(remaining_uses))

Expand Down

0 comments on commit 3879780

Please sign in to comment.