-
Notifications
You must be signed in to change notification settings - Fork 1
/
deleteBypassCode.py
60 lines (48 loc) · 1.26 KB
/
deleteBypassCode.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
from __future__ import absolute_import
from __future__ import print_function
import pprint
import sys
import json
import pandas as pd
import csv
import base64, email.utils, hmac, hashlib, urllib
import duo_client
from six.moves import input
from IgnoreFolder.keys import *
from itertools import repeat
import pandas as pd
import time
import csv
import datetime
"""
*This pulls down a list of all bypass codes and then goes through and deletes all the codes.
"""
keyI = integration
keyS = secret
admin_api = duo_client.Admin(
ikey=keyI,
skey=keyS,
host=host,
ca_certs='DISABLE'
)
ts= time.time()
startTime=datetime.datetime.fromtimestamp(ts).strftime('%Y-%m-%d %H:%M:%S')
bypassData = pd.read_csv("bypassResponse.csv")
print(bypassData)
bypassIDs = bypassData['bypass_code_id'].tolist()
codesDeleted = 0
for i in bypassIDs:
bypassDeletion = admin_api.json_api_call(
'DELETE',
f"/admin/v1/bypass_codes/{i}",
{}
)
pprint.pprint("Bypass code has been deleted")
codesDeleted = codesDeleted + 1
ts2 = time.time()
endTime=datetime.datetime.fromtimestamp(ts2).strftime('%Y-%m-%d %H:%M:%S')
print(codesDeleted, "codes have been deleted. Application is exiting in 5 seconds")
print(startTime)
print(endTime)
time.sleep(5)
sys.exit()