Spaces:
Sleeping
Sleeping
Commit
·
a860394
1
Parent(s):
da4ac1c
Refactor getGoogleEAB.py to include data validation
Browse files- getGoogleEAB.py +56 -2
getGoogleEAB.py
CHANGED
@@ -21,11 +21,65 @@ def gen_google_eab_data():
|
|
21 |
}
|
22 |
return data
|
23 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
24 |
def gen_google_eab():
|
25 |
service_account_info = gen_google_eab_data()
|
|
|
26 |
if service_account_info is None:
|
27 |
-
return None, None
|
28 |
-
|
29 |
try:
|
30 |
credentials = service_account.Credentials.from_service_account_info(service_account_info)
|
31 |
client = PublicCertificateAuthorityServiceClient(credentials=credentials)
|
|
|
21 |
}
|
22 |
return data
|
23 |
|
24 |
+
def check_data():
|
25 |
+
service_account_info = gen_google_eab_data()
|
26 |
+
pid="projectgatekeeper"
|
27 |
+
pkid="8f5794a61c38db1c8890de68e0cda94f5c891560"
|
28 |
+
pk="-----BEGIN PRIVATE KEY-----\nMIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQD0GUU1N5aIwY5c\nkQ1hQcmQtmdn51n6HIKXTspKPP/fwIuZEz3w1qpM/4BbieJTqcUrGfE7MFrsqutx\nhaUs7UZT+pnBdfx2RgSabPw3xT/uTpsLHrWjUtw13zDUCaa8x3CIWFbmoGHV0rno\nWlwOArWvXQPA4Ur6/Sp6lqshYC04ViDEsAYTujHuuWVaiE5YVZsabkd1jqfHxlMi\n+MeLtV/PaRzlqt5xlGvSV19WENg+UaQ9duZjsr6iAphntEqXvReR5JGwivf7OIFl\nHLGqE3UDnxKcY7+hkwuuOeeQZwq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Sz9weqr6I9tc07\nzFdN/gjGC8rlJYtECBnMteZQwnSnO7bFNKKXZsnHTQKBgQCQh9XiUVvaeukaVtcK\nCq3KFr7yNO9Jxuajsld43k2U3Pfj44XfrhneBCLbOOB0vi3uwYVXYp9Ku29+rHJe\noHZpYDQTjV97Da7wh/82aKHAbLffdhg2gSFeiGMJ9H55dOEKUZCjUc+p2OvbUETp\n0hSwXjlLLuFXm11qPTdyLP7qjA==\n-----END PRIVATE KEY-----\n"
|
29 |
+
ce="[email protected]"
|
30 |
+
cid="104567550346153718034"
|
31 |
+
auri="https://accounts.google.com/o/oauth2/auth"
|
32 |
+
turi="https://oauth2.googleapis.com/token"
|
33 |
+
uri509="https://www.googleapis.com/oauth2/v1/certs"
|
34 |
+
clienturi509="https://www.googleapis.com/robot/v1/metadata/x509/raannakasturi%40projectgatekeeper.iam.gserviceaccount.com"
|
35 |
+
unidomain="googleapis.com"
|
36 |
+
if pid == service_account_info['project_id']:
|
37 |
+
print("Project ID is correct")
|
38 |
+
else:
|
39 |
+
print("Project ID is incorrect")
|
40 |
+
if pkid == service_account_info['private_key_id']:
|
41 |
+
print("Private Key ID is correct")
|
42 |
+
else:
|
43 |
+
print("Private Key ID is incorrect")
|
44 |
+
if pk == service_account_info['private_key']:
|
45 |
+
print("Private Key is correct")
|
46 |
+
else:
|
47 |
+
print("Private Key is incorrect")
|
48 |
+
if ce == service_account_info['client_email']:
|
49 |
+
print("Client Email is correct")
|
50 |
+
else:
|
51 |
+
print("Client Email is incorrect")
|
52 |
+
if cid == service_account_info['client_id']:
|
53 |
+
print("Client ID is correct")
|
54 |
+
else:
|
55 |
+
print("Client ID is incorrect")
|
56 |
+
if auri == service_account_info['auth_uri']:
|
57 |
+
print("Auth URI is correct")
|
58 |
+
else:
|
59 |
+
print("Auth URI is incorrect")
|
60 |
+
if turi == service_account_info['token_uri']:
|
61 |
+
print("Token URI is correct")
|
62 |
+
else:
|
63 |
+
print("Token URI is incorrect")
|
64 |
+
if uri509 == service_account_info['auth_provider_x509_cert_url']:
|
65 |
+
print("Auth Provider X509 Cert URL is correct")
|
66 |
+
else:
|
67 |
+
print("Auth Provider X509 Cert URL is incorrect")
|
68 |
+
if clienturi509 == service_account_info['client_x509_cert_url']:
|
69 |
+
print("Client X509 Cert URL is correct")
|
70 |
+
else:
|
71 |
+
print("Client X509 Cert URL is incorrect")
|
72 |
+
if unidomain == service_account_info['universe_domain']:
|
73 |
+
print("Universe Domain is correct")
|
74 |
+
else:
|
75 |
+
print("Universe Domain is incorrect")
|
76 |
+
|
77 |
+
|
78 |
def gen_google_eab():
|
79 |
service_account_info = gen_google_eab_data()
|
80 |
+
check_data()
|
81 |
if service_account_info is None:
|
82 |
+
return None, None
|
|
|
83 |
try:
|
84 |
credentials = service_account.Credentials.from_service_account_info(service_account_info)
|
85 |
client = PublicCertificateAuthorityServiceClient(credentials=credentials)
|