Skip to content
Snippets Groups Projects
Commit da466c08 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 c4fb01d3
No related branches found
No related tags found
No related merge requests found
......@@ -640,3 +640,4 @@ coio_write_timeout
fiber_set_name_n
authenticate
user_auth_method_name
......@@ -231,6 +231,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
......
......@@ -39,6 +39,7 @@
#include "scoped_guard.h"
#include "sequence.h"
#include "tt_static.h"
#include "authentication.h"
struct universe universe;
static struct user users[BOX_USER_MAX];
......@@ -396,6 +397,14 @@ user_reload_privs(struct user *user)
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 */
......
......@@ -143,6 +143,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