mirror of
https://github.com/FerretDB/documentdb.git
synced 2026-11-25 11:49:53 -05:00
### Does this PR have any customer impact? ### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc) ### Does it involve schema level changes? (Table, Column, Index, UDF, etc level changes) ### Are you introducing any new config? If yes, do you have tests with and without them being set? ### ChangeLog (Refer [Template](../oss/CHANGELOG.md)) ### Description ---- #### AI description (iteration 1) #### PR Classification New feature #### PR Summary This pull request introduces CRUD operations for Entra users in the DataPlane. - `authentication.c`: Added functions to create users with external identity providers, validate identity provider info, and check if the current user is an Entra admin. - `users.h`: Added new header file defining user CRUD functions and related structures. - `users.c`: Updated user creation logic to handle external identity providers and added parsing for custom data. - `api_hooks.c`: Added hooks for creating users with external identity providers and checking user privileges. <!-- GitOpsUserAgent=GitOps.Apps.Server.pullrequestcopilot -->
67 lines
1.3 KiB
C
67 lines
1.3 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"
|
|
|
|
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;
|
|
|
|
/* 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);
|
|
|
|
#endif
|