challenger

OAuth 2.0-based authentication service that validates user can receive messages at a certain address
Log | Files | Refs | Submodules | README | LICENSE

commit 428d44407d6e504afd43cff30c80679ef2cf4de0
parent 7513c512f23a286a60c991cc6295e53d6b35e550
Author: Christian Grothoff <christian@grothoff.org>
Date:   Thu,  2 Nov 2023 23:18:17 +0100

return id from /info endpoint, fix argument misordering bug

Diffstat:
Msrc/challenger/challenger-httpd_common.c | 2+-
Msrc/challenger/challenger-httpd_info.c | 21++++++++++-----------
Msrc/challengerdb/pg_info_get_token.c | 6+++++-
Msrc/challengerdb/pg_info_get_token.h | 2++
Msrc/include/challenger_database_plugin.h | 2++
5 files changed, 20 insertions(+), 13 deletions(-)

diff --git a/src/challenger/challenger-httpd_common.c b/src/challenger/challenger-httpd_common.c @@ -74,11 +74,11 @@ CH_compute_code (const struct CHALLENGER_ValidationNonceP *nonce, sizeof (nonce), client_secret, strlen (client_secret), - client_scope, address, strlen (address), client_redirect_uri, strlen (client_redirect_uri), + client_scope, NULL != client_scope ? strlen (client_scope) : 0, diff --git a/src/challenger/challenger-httpd_info.c b/src/challenger/challenger-httpd_info.c @@ -79,6 +79,7 @@ CH_handler_info (struct CH_HandlerContext *hc, /* Check token is valid */ { + uint64_t id; char *address; enum GNUNET_DB_QueryStatus qs; struct GNUNET_TIME_Timestamp address_expiration; @@ -86,6 +87,7 @@ CH_handler_info (struct CH_HandlerContext *hc, qs = CH_db->info_get_token (CH_db->cls, &grant, + &id, &address, &address_expiration); switch (qs) @@ -111,17 +113,14 @@ CH_handler_info (struct CH_HandlerContext *hc, mret = TALER_MHD_REPLY_JSON_PACK ( hc->connection, MHD_HTTP_OK, - GNUNET_JSON_pack_string ("status", - "success"), - GNUNET_JSON_pack_object_steal ( - "data", - GNUNET_JSON_PACK ( - GNUNET_JSON_pack_string ("address", - address), - GNUNET_JSON_pack_string ("address_type", - CH_address_type), - GNUNET_JSON_pack_timestamp ("expires", - address_expiration)))); + GNUNET_JSON_pack_uint64 ("id", + id), + GNUNET_JSON_pack_string ("address", + address), + GNUNET_JSON_pack_string ("address_type", + CH_address_type), + GNUNET_JSON_pack_timestamp ("expires", + address_expiration)); GNUNET_free (address); return mret; } diff --git a/src/challengerdb/pg_info_get_token.c b/src/challengerdb/pg_info_get_token.c @@ -30,6 +30,7 @@ enum GNUNET_DB_QueryStatus CH_PG_info_get_token ( void *cls, const struct CHALLENGER_AccessTokenP *token, + uint64_t *rowid, char **address, struct GNUNET_TIME_Timestamp *address_expiration) { @@ -43,6 +44,8 @@ CH_PG_info_get_token ( }; struct GNUNET_TIME_Absolute at; struct GNUNET_PQ_ResultSpec rs[] = { + GNUNET_PQ_result_spec_uint64 ("rowid", + rowid), GNUNET_PQ_result_spec_string ("address", address), GNUNET_PQ_result_spec_absolute_time ("address_expiration_time", @@ -54,7 +57,8 @@ CH_PG_info_get_token ( PREPARE (pg, "info_get_token", "SELECT " - " address" + " grant_serial_id AS rowid" + " ,address" " ,address_expiration_time" " FROM tokens" " WHERE access_token=$1" diff --git a/src/challengerdb/pg_info_get_token.h b/src/challengerdb/pg_info_get_token.h @@ -31,6 +31,7 @@ * * @param cls closure * @param grant grant token that grants access + * @param[out] rowid account identifier within challenger * @param[out] address set to the address under @a grant * @param[out] address_expiration set to how long we consider @a address to be valid * @return transaction status @@ -39,6 +40,7 @@ enum GNUNET_DB_QueryStatus CH_PG_info_get_token ( void *cls, const struct CHALLENGER_AccessTokenP *grant, + uint64_t *rowid, char **address, struct GNUNET_TIME_Timestamp *address_expiration); diff --git a/src/include/challenger_database_plugin.h b/src/include/challenger_database_plugin.h @@ -347,6 +347,7 @@ struct CHALLENGER_DatabasePlugin * * @param cls closure * @param grant grant token that grants access + * @param[out] rowid account identifier within challenger * @param[out] address set to the address under @a grant * @param[out] address_expiration set to how long we consider @a address to be valid * @return transaction status @@ -354,6 +355,7 @@ struct CHALLENGER_DatabasePlugin enum GNUNET_DB_QueryStatus (*info_get_token)(void *cls, const struct CHALLENGER_AccessTokenP *grant, + uint64_t *rowid, char **address, struct GNUNET_TIME_Timestamp *address_expiration);