Skip to content
Snippets Groups Projects
Commit 2680f19a authored by Maksim Kaitmazian's avatar Maksim Kaitmazian Committed by Dmitry Ivanov
Browse files

feat: implement user_auth_method_name

This function is used to determine the authentication method when
authenticating a postgres client.

part of picodata/picodata/sbroad!292

NO_DOC=exports
NO_CHANGELOG=exports
NO_TEST=exports
parent 780b5011
No related branches found
No related tags found
No related merge requests found
......@@ -646,3 +646,4 @@ coio_write_timeout
fiber_set_name_n
authenticate
user_auth_method_name
......@@ -273,6 +273,7 @@ set(api_headers
${PROJECT_SOURCE_DIR}/src/box/iterator_type.h
${PROJECT_SOURCE_DIR}/src/box/error.h
${PROJECT_SOURCE_DIR}/src/box/lua/tuple.h
${PROJECT_SOURCE_DIR}/src/box/user.h
${PROJECT_SOURCE_DIR}/src/lib/core/latch.h
${PROJECT_SOURCE_DIR}/src/lib/core/clock.h
${PROJECT_SOURCE_DIR}/src/box/decimal.h
......
......@@ -40,6 +40,7 @@
#include "sequence.h"
#include "tt_static.h"
#include "txn.h"
#include "authentication.h"
struct universe universe;
static struct user users[BOX_USER_MAX];
......@@ -436,6 +437,14 @@ user_reload_privs(struct user *user, struct txn_stmt *rolled_back_stmt)
return 0;
}
const char *
user_auth_method_name(const char *user_name, uint32_t user_name_len)
{
struct user *user = user_find_by_name(user_name, user_name_len);
struct authenticator *auth = user != NULL ? user->def->auth : NULL;
return auth != NULL ? auth->method->name : NULL;
}
/** }}} */
/* {{{ authentication tokens */
......
......@@ -144,6 +144,24 @@ credentials_reset(struct credentials *cr, struct user *new_user)
credentials_create(cr, new_user);
}
/** \cond public */
/**
* Get an auth method name used by a user.
* Returns method name on success and NULL on error.
*
* This function is used to determine the authentication method when
* authenticating a postgres client. There is an another way to determine auth
* method name: export user_find_by_name and extract the name from the name
* field of the authenticator contained in the user, but this approach seems to
* be more complicated, since we still need to export something, as well as
* add definition of user and its internal fields in module.h.
*/
const char *
user_auth_method_name(const char *name, uint32_t name_len);
/** \endcond public */
/**
* For best performance, all users are maintained in this array.
* Position in the array is store in user->auth_token and also
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment