All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
as_admin.h
Go to the documentation of this file.
1 /******************************************************************************
2  * Copyright 2008-2014 by Aerospike.
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a copy
5  * of this software and associated documentation files (the "Software"), to
6  * deal in the Software without restriction, including without limitation the
7  * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
8  * sell copies of the Software, and to permit persons to whom the Software is
9  * furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice shall be included in
12  * all copies or substantial portions of the Software.
13  *
14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20  * IN THE SOFTWARE.
21  *****************************************************************************/
22 #pragma once
23 
24 #include <aerospike/aerospike.h>
25 #include <aerospike/as_config.h>
26 
27 /******************************************************************************
28  * MACROS
29  *****************************************************************************/
30 
31 /**
32  * Maximum size of role string including null byte.
33  */
34 #define AS_ROLE_SIZE 32
35 
36 /******************************************************************************
37  * TYPES
38  *****************************************************************************/
39 
40 /**
41  * User and assigned roles.
42  */
43 typedef struct as_user_roles_s {
44  /**
45  * User name.
46  */
47  char user[AS_USER_SIZE];
48 
49  /**
50  * Length of roles array.
51  */
53 
54  /**
55  * Array of assigned roles.
56  */
57  char roles[][AS_ROLE_SIZE];
59 
60 /******************************************************************************
61  * FUNCTIONS
62  ******************************************************************************/
63 
64 /**
65  * Create user with password and roles. Clear-text password will be hashed using bcrypt before
66  * sending to server. Return zero on success.
67  */
68 int
69 as_create_user(aerospike* as, const as_policy_admin* policy, const char* user, const char* password, const char** roles, int roles_size);
70 
71 /**
72  * Remove user from cluster. Return zero on success.
73  */
74 int
75 as_drop_user(aerospike* as, const as_policy_admin* policy, const char* user);
76 
77 /**
78  * Change user's password. Clear-text password will be hashed using bcrypt before sending to server.
79  * Return zero on success.
80  */
81 int
82 as_change_password(aerospike* as, const as_policy_admin* policy, const char* user, const char* password);
83 
84 /**
85  * Add role to user's list of roles. Return zero on success..
86  */
87 int
88 as_grant_roles(aerospike* as, const as_policy_admin* policy, const char* user, const char** roles, int roles_size);
89 
90 /**
91  * Remove role from user's list of roles. Return zero on success.
92  */
93 int
94 as_revoke_roles(aerospike* as, const as_policy_admin* policy, const char* user, const char** roles, int roles_size);
95 
96 /**
97  * Replace user's list of roles with a new list of roles. Return zero on success.
98  */
99 int
100 as_replace_roles(aerospike* as, const as_policy_admin* policy, const char* user, const char** roles, int roles_size);
101 
102 /**
103  * Retrieve roles for a given user. Return zero on success..
104  */
105 int
106 as_query_user(aerospike* as, const as_policy_admin* policy, const char* user, as_user_roles** user_roles);
107 
108 /**
109  * Release as_user_roles memory.
110  */
111 void
113 
114 /**
115  * Retrieve all users and their roles. Return zero on success.
116  */
117 int
118 as_query_users(aerospike* as, const as_policy_admin* policy, as_user_roles** user_roles, int* user_roles_size);
119 
120 /**
121  * Release memory for as_user_roles array.
122  */
123 void
124 as_query_users_destroy(as_user_roles* user_roles, int user_roles_size);
125 
126 /**
127  * @private
128  * Authenticate user with a server node. This is done automatically after socket open.
129  * Do not use this method directly.
130  */
131 int
132 as_authenticate(int fd, const char* user, const char* credential, int timeout_ms);
int as_create_user(aerospike *as, const as_policy_admin *policy, const char *user, const char *password, const char **roles, int roles_size)
#define AS_USER_SIZE
Definition: as_password.h:24
int roles_size
Definition: as_admin.h:52
int as_query_users(aerospike *as, const as_policy_admin *policy, as_user_roles **user_roles, int *user_roles_size)
int as_replace_roles(aerospike *as, const as_policy_admin *policy, const char *user, const char **roles, int roles_size)
int as_revoke_roles(aerospike *as, const as_policy_admin *policy, const char *user, const char **roles, int roles_size)
void as_query_users_destroy(as_user_roles *user_roles, int user_roles_size)
int as_change_password(aerospike *as, const as_policy_admin *policy, const char *user, const char *password)
int as_grant_roles(aerospike *as, const as_policy_admin *policy, const char *user, const char **roles, int roles_size)
void as_query_user_destroy(as_user_roles *user_roles)
int as_drop_user(aerospike *as, const as_policy_admin *policy, const char *user)
int as_authenticate(int fd, const char *user, const char *credential, int timeout_ms)
#define AS_ROLE_SIZE
Definition: as_admin.h:34
int as_query_user(aerospike *as, const as_policy_admin *policy, const char *user, as_user_roles **user_roles)