duosecurity / duo_client_python

Python library for interacting with the Duo Auth, Admin, and Accounts APIs
https://duo.com/docs/
Other
136 stars 135 forks source link

add method to update Passport configuration via the AdminAPI #279

Closed kmahan-duo closed 1 month ago

kmahan-duo commented 1 month ago

Description

Create a method to call the API endpoint that creates or updates a customer's Passport configuration https://duo.com/docs/adminapi#passport

Motivation and Context

Make it easier for tools and automations to update the Passport configuration

How Has This Been Tested?

Added a unit test to ensure arguments are passed correctly.

❯ nose2
........................................................................................................................................................................................................................
----------------------------------------------------------------------
Ran 216 tests in 0.140s

OK

Tested locally against a development server:

>>> client = duo_client.admin.Admin(ikey=..., skey=..., host="api-duo1.duo.test", ca_certs="DISABLE")
>>> client.get_passport_config()
{'disabled_groups': [], 'enabled_groups': [], 'enabled_status': 'enabled'}
>>> client.update_passport_config(enabled_status="enabled-for-groups", enabled_groups=["DGC4RP5EMSL1M5EX0321", "DG3MVJRRM9PFDGG3P2CJ"])
''
>>> client.get_passport_config()
{'disabled_groups': [], 'enabled_groups': [{'group_id': 'DGC4RP5EMSL1M5EX0321', 'group_name': 'group_foo'}, {'group_id': 'DG3MVJRRM9PFDGG3P2CJ', 'group_name': 'group_bar'}], 'enabled_status': 'enabled-for-groups'}
image
>>> client.update_passport_config(enabled_status="enabled-with-exceptions", disabled_groups=["DGC4RP5EMSL1M5EX0321", "DG3MVJRRM9PFDGG3P2CJ"])
''
>>> client.get_passport_config()
{'disabled_groups': [{'group_id': 'DGC4RP5EMSL1M5EX0321', 'group_name': 'group_foo'}, {'group_id': 'DG3MVJRRM9PFDGG3P2CJ', 'group_name': 'group_bar'}], 'enabled_groups': [], 'enabled_status': 'enabled-with-exceptions'}
image

Types of Changes