@@ -57,7 +57,7 @@ def create_authenticated_app(
57
57
print (error )
58
58
59
59
60
- def create_common_api_credential (api_config , client_id , secret , namespace , db_connection ):
60
+ def create_common_api_credential (api_config , internal_config , client_id , secret , namespace , db_connection ):
61
61
"""
62
62
Creates all the services with endpoints in the vng_api_common_apicredential table
63
63
So that each api trusts all the other internal apis
@@ -72,20 +72,27 @@ def create_common_api_credential(api_config, client_id, secret, namespace, db_co
72
72
try :
73
73
print (f"adding vng_api_common_apicredential with client_id: { client_id } " )
74
74
cursor = db_connection .cursor ()
75
- for name in api_config :
75
+ for name in internal_config :
76
76
print (f"label set to api: { name } " )
77
- print (f"api_root set to: { api_config [name ]} " )
77
+ print (f"api_root set to: { internal_config [name ]} " )
78
78
internal_address = f"http://{ name } .{ namespace } .svc.cluster.local:8000/api/v1"
79
79
print (f"internal_address set to: { internal_address } " )
80
80
cursor .execute (
81
81
"INSERT INTO vng_api_common_apicredential (api_root, client_id, secret, label, user_id, user_representation) VALUES(%s, %s, %s, %s, %s, %s)" ,
82
- (api_config [name ], client_id , secret , name , client_id , client_id ),
82
+ (internal_config [name ], client_id , secret , name , client_id , client_id ),
83
83
)
84
84
85
85
cursor .execute (
86
86
"INSERT INTO vng_api_common_apicredential (api_root, client_id, secret, label, user_id, user_representation) VALUES(%s, %s, %s, %s, %s, %s)" ,
87
87
(internal_address , client_id , secret , name , client_id , client_id ),
88
88
)
89
+
90
+ for n in api_config :
91
+ cursor .execute (
92
+ "INSERT INTO vng_api_common_apicredential (api_root, client_id, secret, label, user_id, user_representation) VALUES(%s, %s, %s, %s, %s, %s)" ,
93
+ (api_config [n ], client_id , secret , n , client_id , client_id ),
94
+ )
95
+
89
96
db_connection .commit ()
90
97
cursor .close ()
91
98
except (Exception , psycopg2 .DatabaseError ) as error :
@@ -134,7 +141,7 @@ def create_auth_config(auth_service, component, db_connection):
134
141
135
142
if __name__ == "__main__" :
136
143
# variables will be read from the config.ini
137
- env = os .environ .get ("ENV" , "kubernetes " )
144
+ env = os .environ .get ("ENV" , "test " )
138
145
139
146
# variables related to the db connection
140
147
DB_NAME = os .environ .get ("DB_NAME" , "zrc" )
@@ -166,6 +173,7 @@ def create_auth_config(auth_service, component, db_connection):
166
173
167
174
config = configparser .ConfigParser ()
168
175
config .read ("config.ini" )
176
+ internal_config = config ['kubernetes' ]
169
177
api_config = config [env ]
170
178
171
179
print (f"seeding db { DB_NAME } " )
@@ -192,6 +200,7 @@ def create_auth_config(auth_service, component, db_connection):
192
200
# add all endpoints with the secret so that the SERVICE_NAME will trust the other apis
193
201
create_common_api_credential (
194
202
api_config = api_config ,
203
+ internal_config = internal_config ,
195
204
client_id = SERVICE_NAME ,
196
205
secret = INTERNAL_API_SECRET ,
197
206
namespace = NAMESPACE ,
0 commit comments