Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Pass all tests?
  • Loading branch information
ovadbar committed Jun 6, 2022
commit 59bf0e60e91610399c124fa9b93dbb0272e4e170
6 changes: 4 additions & 2 deletions src/mod/applications/mod_http_cache/gcs.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,13 @@ switch_status_t gcs_refresh_authorization (http_profile_t *profile)
assertion = malloc(sizeof(char) * (1 + token_length + 343));
sprintf(assertion, "%s.%s", token, encoded);
free(token);
free(encoded);
signature_url_encoded = switch_string_replace(assertion, "+", "%2B");
sprintf(content,"%s%s", "grant_type=urn%3Aietf%3Aparams%3Aoauth%3Agrant-type%3Ajwt-bearer&assertion=", signature_url_encoded);
free(signature_url_encoded);
auth = gcs_auth_request(content, profile->region);
profile->gcs_credentials = auth;
free(auth);
exp = now + 3540;
profile->expires = exp;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Credentials Expries Unix Time: %ld", exp);
Expand Down Expand Up @@ -201,7 +204,6 @@ switch_status_t gcs_config_profile(switch_xml_t xml, http_profile_t *profile,swi
status = switch_file_close(fd);
return SWITCH_STATUS_FALSE;
}

status = switch_file_close(fd);
if (status != SWITCH_STATUS_SUCCESS) {
//switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERR, "Could not close credencial file\n", profile->bytes_per_block);
Expand Down Expand Up @@ -273,7 +275,6 @@ switch_status_t gcs_config_profile(switch_xml_t xml, http_profile_t *profile,swi
if (status != SWITCH_STATUS_SUCCESS){
return status;
}

if (base_domain_xml) {
profile->base_domain = switch_strip_whitespace(switch_xml_txt(base_domain_xml));
if (zstr(profile->base_domain)) {
Expand Down Expand Up @@ -347,6 +348,7 @@ char *gcs_auth_request(char *content, char *url) {
}
cJSON_Delete(json);
}
switch_safe_free(http_data.stream.data);
return response;
}
#endif
Expand Down
1 change: 1 addition & 0 deletions src/mod/applications/mod_http_cache/test/test_gcs.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ FST_TEST_BEGIN(parse_xml_config_with_gcs)
switch_safe_free(http_profile.aws_s3_access_key_id);
switch_safe_free(http_profile.secret_access_key);
switch_safe_free(http_profile.base_domain);
switch_safe_free(http_profile.gcs_email);
switch_core_destroy_memory_pool(&pool);
}

Expand Down