Skip to content

Conversation

@cisco-shivamk
Copy link
Contributor

Updated the duo_client_python code to be able to set the subaccount role in the admin api

Description

  1. Updated add_admin() in admin.py for including subaccount role.
  2. Created an example for creating admin.
  3. Modified the test_admins.py to include tests for admin creation.

Motivation and Context

We have recently added subaccount role to admin API, exactly the below endpoint. And, thus this repo needs an update to be able to use this addition to admin API.

endpoint: /admin/v1/admins

How Has This Been Tested?

  1. Unit testing done.
  2. Manually Tested using the example created.
    Output:
(.env) shikalra@SHIKALRA-M-CR33 duo_client_python % python examples/Admin/create_admin.py
Admin API integration key ("DI..."): DIB659A1OZJL56C4CMS1
integration secret key: ZqRCqa9N3QFklAMoh1eEIWTqVekDxRW42pvhafBK
API hostname ("api-....duosecurity.com"): api-duo1.duo.test
Admin name: Test Admin SK API 90
Email: testadmin90@testsk.com
Phone number (e.g. 2154567890): 2154567890
Password: test-pwd
Administrative Role: Administrator
Subaccount Role: Billing
Created Admin: 
{'activation_url': 'https://admin-duo1.duo.test/admins/activation/DA6N7OXLH6BABW4APTZM/5389a2f357ac5bb12529c263ca14c548',
 'activation_url_expires': 1742466501,
 'admin_id': 'DEHZLM8F681FJRY3CQWV',
 'admin_units': [],
 'created': 1741861701,
 'email': 'testadmin90@testsk.com',
 'hardtoken': None,
 'last_directory_sync': None,
 'last_login': None,
 'name': 'Test Admin SK API 90',
 'password_change_required': False,
 'phone': '+12154567890',
 'restricted_by_admin_units': False,
 'role': 'Administrator',
 'status': 'Pending Activation',
 'subaccount_role': 'Billing',
 'webauthncredentials': []}

Types of Changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

@cisco-shivamk cisco-shivamk marked this pull request as ready for review March 13, 2025 11:52
@cisco-shivamk cisco-shivamk changed the title [ZTMSP-1517] Add subaccount role to add admin and create tests and example [ZTMSP-1517] Added subaccount role to add admin and created tests and example Mar 13, 2025
@AaronAtDuo AaronAtDuo merged commit e8789c1 into duosecurity:master Mar 17, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants