mirror of
https://github.com/FerretDB/documentdb.git
synced 2026-11-08 03:52:41 -05:00
### Does this PR have any customer impact? Yes ### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc) Feature ### Does it involve schema level changes? (Table, Column, Index, UDF, etc level changes) Yes, the API schema ### Are you introducing any new config? If yes, do you have tests with and without them being set? No ### ChangeLog (Refer [Template](../oss/CHANGELOG.md)) 1.05 ### Description We are adding support for the Connection Status command, which exists in native Mongo, and allows users to see their authenticated user, authenticated roles, and user privileges. For more information, visit connectionStatus.md. This PR is the second of three PRs for this feature. The first one added extensible role privileges to our `users_info` command, allowing users to retrieve role privileges with `showPrivileges: true`. This second PR adds a callable `connection_status` command to our API, that utilizes the role privileges. The last PR will add a gateway change that calls this `connection_status` command. Related work items: #4287246
77 lines
1.5 KiB
C
77 lines
1.5 KiB
C
/*-------------------------------------------------------------------------
|
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
*
|
|
* include/users.h
|
|
*
|
|
* User CRUD functions.
|
|
*
|
|
*-------------------------------------------------------------------------
|
|
*/
|
|
|
|
#ifndef EXTENSION_USERS_H
|
|
#define EXTENSION_USERS_H
|
|
|
|
#include "postgres.h"
|
|
#include "utils/string_view.h"
|
|
|
|
enum DocumentDB_BuiltInRoles
|
|
{
|
|
DocumentDB_Role_Read_AnyDatabase = 0x1,
|
|
DocumentDB_Role_ReadWrite_AnyDatabase = 0x2,
|
|
DocumentDB_Role_Cluster_Admin = 0x4,
|
|
};
|
|
|
|
typedef struct
|
|
{
|
|
/* "createUser" field */
|
|
const char *createUser;
|
|
|
|
/* "pwd" field */
|
|
const char *pwd;
|
|
|
|
/* "roles" field */
|
|
bson_value_t roles;
|
|
|
|
/* "identityProvider" field*/
|
|
bson_value_t identityProviderData;
|
|
|
|
/* pgRole the passed in role maps to */
|
|
char *pgRole;
|
|
|
|
/* principalType */
|
|
char *principalType;
|
|
|
|
/* has_identity_provider */
|
|
bool has_identity_provider;
|
|
} CreateUserSpec;
|
|
|
|
typedef struct
|
|
{
|
|
/* "updateUser" field */
|
|
const char *updateUser;
|
|
|
|
/* "pwd" field */
|
|
const char *pwd;
|
|
} UpdateUserSpec;
|
|
|
|
typedef struct
|
|
{
|
|
StringView user;
|
|
|
|
bool showPrivileges;
|
|
} GetUserSpec;
|
|
|
|
/* GUC that controls the blocked role prefix list */
|
|
extern char *BlockedRolePrefixList;
|
|
|
|
/* Method to validate and obtain user role */
|
|
char * ValidateAndObtainUserRole(const bson_value_t *rolesDocument);
|
|
|
|
/* Method to verify if username is valid */
|
|
bool IsUserNameInvalid(const char *userName);
|
|
|
|
/* Method to call Connection Status command */
|
|
Datum connection_status(pgbson *showPrivilegesSpec);
|
|
|
|
#endif
|