add more flexibility to endpoint naming for KYC

This commit is contained in:
Christian Grothoff 2022-04-16 17:51:27 +02:00
parent fc1383ebd1
commit b496b8fed5
No known key found for this signature in database
GPG Key ID: 939E6BE1E29FC3CC
6 changed files with 49 additions and 14 deletions

View File

@ -1413,12 +1413,12 @@ parse_kyc_oauth_cfg (void)
if (GNUNET_OK != if (GNUNET_OK !=
GNUNET_CONFIGURATION_get_value_string (TEH_cfg, GNUNET_CONFIGURATION_get_value_string (TEH_cfg,
"exchange-kyc-oauth2", "exchange-kyc-oauth2",
"KYC_OAUTH2_URL", "KYC_OAUTH2_AUTH_URL",
&s)) &s))
{ {
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
"exchange-kyc-oauth2", "exchange-kyc-oauth2",
"KYC_OAUTH2_URL"); "KYC_OAUTH2_AUTH_URL");
return GNUNET_SYSERR; return GNUNET_SYSERR;
} }
if ( (! TALER_url_valid_charset (s)) || if ( (! TALER_url_valid_charset (s)) ||
@ -1431,12 +1431,40 @@ parse_kyc_oauth_cfg (void)
{ {
GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_ERROR, GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_ERROR,
"exchange-kyc-oauth2", "exchange-kyc-oauth2",
"KYC_OAUTH2_URL", "KYC_OAUTH2_AUTH_URL",
"not a valid URL"); "not a valid URL");
GNUNET_free (s); GNUNET_free (s);
return GNUNET_SYSERR; return GNUNET_SYSERR;
} }
TEH_kyc_config.details.oauth2.url = s; TEH_kyc_config.details.oauth2.auth_url = s;
if (GNUNET_OK !=
GNUNET_CONFIGURATION_get_value_string (TEH_cfg,
"exchange-kyc-oauth2",
"KYC_OAUTH2_LOGIN_URL",
&s))
{
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
"exchange-kyc-oauth2",
"KYC_OAUTH2_LOGIN_URL");
return GNUNET_SYSERR;
}
if ( (! TALER_url_valid_charset (s)) ||
( (0 != strncasecmp (s,
"http://",
strlen ("http://"))) &&
(0 != strncasecmp (s,
"https://",
strlen ("https://"))) ) )
{
GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_ERROR,
"exchange-kyc-oauth2",
"KYC_OAUTH2_LOGIN_URL",
"not a valid URL");
GNUNET_free (s);
return GNUNET_SYSERR;
}
TEH_kyc_config.details.oauth2.login_url = s;
if (GNUNET_OK != if (GNUNET_OK !=
GNUNET_CONFIGURATION_get_value_string (TEH_cfg, GNUNET_CONFIGURATION_get_value_string (TEH_cfg,

View File

@ -93,8 +93,14 @@ struct TEH_KycOptions
/** /**
* URL of the OAuth2.0 endpoint for KYC checks. * URL of the OAuth2.0 endpoint for KYC checks.
* (token/auth)
*/ */
char *url; char *auth_url;
/**
* URL of the OAuth2.0 endpoint for KYC checks.
*/
char *login_url;
/** /**
* URL of the user info access endpoint. * URL of the user info access endpoint.

View File

@ -395,8 +395,8 @@ TEH_handler_kyc_check (
redirect_uri_encoded = TALER_urlencode (redirect_uri); redirect_uri_encoded = TALER_urlencode (redirect_uri);
GNUNET_free (redirect_uri); GNUNET_free (redirect_uri);
GNUNET_asprintf (&url, GNUNET_asprintf (&url,
"%s/login?client_id=%s&redirect_uri=%s", "%s?client_id=%s&redirect_uri=%s",
TEH_kyc_config.details.oauth2.url, TEH_kyc_config.details.oauth2.login_url,
TEH_kyc_config.details.oauth2.client_id, TEH_kyc_config.details.oauth2.client_id,
redirect_uri_encoded); redirect_uri_encoded);
GNUNET_free (redirect_uri_encoded); GNUNET_free (redirect_uri_encoded);

View File

@ -579,8 +579,8 @@ TEH_handler_kyc_proof (
"curl_easy_init"); "curl_easy_init");
} }
GNUNET_asprintf (&kpc->token_url, GNUNET_asprintf (&kpc->token_url,
"%stoken", "%s",
TEH_kyc_config.details.oauth2.url); TEH_kyc_config.details.oauth2.auth_url);
GNUNET_assert (CURLE_OK == GNUNET_assert (CURLE_OK ==
curl_easy_setopt (eh, curl_easy_setopt (eh,
CURLOPT_URL, CURLOPT_URL,
@ -603,8 +603,8 @@ TEH_handler_kyc_proof (
char *request_uri; char *request_uri;
GNUNET_asprintf (&request_uri, GNUNET_asprintf (&request_uri,
"%slogin?client_id=%s", "%s?client_id=%s",
TEH_kyc_config.details.oauth2.url, TEH_kyc_config.details.oauth2.login_url,
TEH_kyc_config.details.oauth2.client_id); TEH_kyc_config.details.oauth2.client_id);
redirect_uri = curl_easy_escape (eh, redirect_uri = curl_easy_escape (eh,
request_uri, request_uri,

View File

@ -432,7 +432,7 @@ run (void *cls,
/* Try resolving a deposit's WTID, as we never triggered /* Try resolving a deposit's WTID, as we never triggered
* execution of transactions, the answer should be that * execution of transactions, the answer should be that
* the exchange knows about the deposit, but has no WTID yet. * the exchange knows about the deposit, but has no WTID yet.
*/// */
TALER_TESTING_cmd_track_transaction ("deposit-wtid-found", TALER_TESTING_cmd_track_transaction ("deposit-wtid-found",
"deposit-simple", "deposit-simple",
0, 0,
@ -458,7 +458,7 @@ run (void *cls,
* happen here, as each deposit operation is run with a * happen here, as each deposit operation is run with a
* fresh merchant public key, so the aggregator will treat * fresh merchant public key, so the aggregator will treat
* them as "different" merchants and do the wire transfers * them as "different" merchants and do the wire transfers
* individually. */// * individually. */
CMD_EXEC_AGGREGATOR ("run-aggregator"), CMD_EXEC_AGGREGATOR ("run-aggregator"),
/** /**
* Check all the transfers took place. * Check all the transfers took place.

View File

@ -56,7 +56,8 @@ KYC_WITHDRAW_LIMIT = EUR:8
[exchange-kyc-oauth2] [exchange-kyc-oauth2]
KYC_OAUTH2_URL = http://localhost:6666/oauth/v2/login KYC_OAUTH2_AUTH_URL = http://localhost:6666/oauth/v2/token
KYC_OAUTH2_LOGIN_URL = http://localhost:6666/oauth/v2/login
KYC_INFO_URL = http://localhost:6666/api/user/me KYC_INFO_URL = http://localhost:6666/api/user/me
KYC_OAUTH2_CLIENT_ID = taler-exchange KYC_OAUTH2_CLIENT_ID = taler-exchange
KYC_OAUTH2_CLIENT_SECRET = exchange-secret KYC_OAUTH2_CLIENT_SECRET = exchange-secret