Skip to content

Commit

Permalink
simplify auth method check
Browse files Browse the repository at this point in the history
Signed-off-by: Florian Bezannier <[email protected]>
  • Loading branch information
Florian Bezannier authored and flobz committed Sep 27, 2023
1 parent b073941 commit 04676d2
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/config-file.c
Original file line number Diff line number Diff line change
Expand Up @@ -261,15 +261,15 @@ Config* load_config_file(const gchar *config_file, GError **error)
&config->auth_token, NULL, NULL);
key_gateway_token_exists = get_key_string(ini_file, "client", "gateway_token",
&config->gateway_token, NULL, NULL);
if (!key_auth_token_exists && !key_gateway_token_exists) {
g_info("Neither auth_token nor gateway_token is set, using client certificates");
key_client_cert_exists = get_key_string(ini_file, "client", "client_cert", &config->client_cert, NULL, NULL);
key_client_key_exists = get_key_string(ini_file, "client", "client_key", &config->client_key, NULL, NULL);
if (!key_client_cert_exists || !key_client_key_exists) {
g_set_error(error, 1, 4, "Neither a token nor client certificate are set!");
return NULL;
}
} else if (key_auth_token_exists && key_gateway_token_exists) {
key_client_cert_exists = get_key_string(ini_file, "client", "client_cert", &config->client_cert, NULL, NULL);

key_client_key_exists = get_key_string(ini_file, "client", "client_key", &config->client_key, NULL, NULL);

if (!key_auth_token_exists && !key_gateway_token_exists && !(key_client_cert_exists && key_client_key_exists)) {
g_set_error(error, 1, 4, "Neither a token nor client certificate are set!");
return NULL;
}
else if (key_auth_token_exists && key_gateway_token_exists) {
g_set_error(error, G_KEY_FILE_ERROR, G_KEY_FILE_ERROR_INVALID_VALUE,
"Both 'auth_token' and 'gateway_token' set");
return NULL;
Expand Down

0 comments on commit 04676d2

Please sign in to comment.