agent retrieves new token_endpoint if it suspects that it changed
@@ -151,11 +151,21 @@ void handleAdd(char* q, int sock, struct oidc_provider** loaded_p, size_t* loade
ipc_write(sock, RESPONSE_ERROR, "provider already loaded");
return;
}
+ if(retrieveAccessToken(provider, FORCE_NEW_TOKEN)!=0) {
+ char* newTokenEndpoint = getTokenEndpoint(provider_getConfigEndpoint(*provider), provider_getCertPath(*provider));
+ if(newTokenEndpoint && strcmp(newTokenEndpoint, provider_getTokenEndpoint(*provider))!=0) {
+ provider_setTokenEndpoint(provider, newTokenEndpoint);
if(retrieveAccessToken(provider, FORCE_NEW_TOKEN)!=0) {
freeProvider(provider);
- ipc_write(sock, RESPONSE_ERROR, "misconfiguration or network issues");
+ ipc_write(sock, RESPONSE_ERROR, "network issues");
return;
}
+ } else {
+ freeProvider(provider);
+ ipc_write(sock, RESPONSE_ERROR, "network issues");
+ return;
+ }
+ }
*loaded_p = addProvider(*loaded_p, loaded_p_count, *provider);
free(provider);
ipc_write(sock, RESPONSE_STATUS, "success");
