The following Python script can be used to bulk delete configured applications using the Duo Admin API. Currently within the Duo Admin Panel, there is no option to bulk delete configured Applications and therefore I have created the following Python script. The script will list all Application by Integration ID and then interactively prompt you to enter all the Integration IDs that you would like to remove before removing them. The script is also available in my GitHub repository so feel free to pull it from there too.
Prerequsites
- duo_client library import
- Python 3.x
- Duo tenant configured with the Admin API
- Python file containing IKEY, SKEY and API Hostname for Admin API (my_duo_keys)
Python Script to Bulk Delete Configured Applications
import duo_client
from my_duo_keys import DUO_IKEY, DUO_SKEY, DUO_APIHOSTNAME # Import your Duo API credentials
# Initialize Duo Admin API
admin_api = duo_client.Admin(
ikey=DUO_IKEY,
skey=DUO_SKEY,
host=DUO_APIHOSTNAME
)
def list_integrations():
try:
limit = 100 # Adjust the limit as needed to retrieve integrations in batches
offset = 0
while True:
integrations = admin_api.get_integrations(limit=limit, offset=offset)
if not integrations:
break
print("Integration IDs and Names:")
for integration in integrations:
print(f"{integration['integration_key']}: {integration['name']}")
offset += limit
except Exception as e:
print(f"Error listing integrations: {str(e)}")
def delete_integration(integration_key):
try:
admin_api.delete_integration(integration_key)
print(f"Integration with ID {integration_key} has been deleted.")
except Exception as e:
print(f"Error deleting integration: {str(e)}")
def main():
list_integrations()
while True:
integration_keys = input("Enter the integration IDs to delete (separated by spaces): ").strip()
if not integration_keys:
print("No integration IDs provided. Exiting.")
return
integration_keys = integration_keys.split() # Split Integration IDs by spaces
for integration_key in integration_keys:
delete_integration(integration_key.strip())
continue_deletion = input("Do you want to delete another integration? (yes/no): ").strip().lower()
if continue_deletion != 'yes':
break
if __name__ == "__main__":
main()
Bulk Delete Duo Application Python Script in Use
The following is an example of the script in use.
- List of Integration IDs with their application names:
Integration IDs and Names:
DI2UWC31WWPIZZ7PAH4R: *Enablement Training FTD VPN
DILXCAS2S1L2B0O5WACB: *Enablement Session RDP
- Deleting both applications when prompted:
Enter the integration IDs to delete (separated by spaces): DI2UWC31WWPIZZ7PAH4R DILXCAS2S1L2B0O5WACB
- Both applications being deleted:
Integration with ID DI2UWC31WWPIZZ7PAH4R has been deleted.
Integration with ID DILXCAS2S1L2B0O5WACB has been deleted.
- Script asking if I want to delete anymore applications:
Do you want to delete another integration? (yes/no): no
- Duo Admin Panel Administrator Reports showing the that the Applications have been deleted using the Admin API:
Additional Links
https://github.com/duosecurity/duo_client_python
https://github.com/wiizkiid/Network-Wizkid-Scripts
Please like, share and comment if you’ve found this article useful.