Main Page
Modules
Data Structures
Files
File List
Globals
All
Data Structures
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
aerospike
as_admin.h
Go to the documentation of this file.
1
/*
2
* Copyright 2008-2014 Aerospike, Inc.
3
*
4
* Portions may be licensed to Aerospike, Inc. under one or more contributor
5
* license agreements.
6
*
7
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
8
* use this file except in compliance with the License. You may obtain a copy of
9
* the License at http://www.apache.org/licenses/LICENSE-2.0
10
*
11
* Unless required by applicable law or agreed to in writing, software
12
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
* License for the specific language governing permissions and limitations under
15
* the License.
16
*/
17
#pragma once
18
19
#include <
aerospike/aerospike.h
>
20
#include <
aerospike/as_config.h
>
21
22
/******************************************************************************
23
* MACROS
24
*****************************************************************************/
25
26
/**
27
* Maximum size of role string including null byte.
28
*/
29
#define AS_ROLE_SIZE 32
30
31
/******************************************************************************
32
* TYPES
33
*****************************************************************************/
34
35
/**
36
* User and assigned roles.
37
*/
38
typedef
struct
as_user_roles_s {
39
/**
40
* User name.
41
*/
42
char
user[
AS_USER_SIZE
];
43
44
/**
45
* Length of roles array.
46
*/
47
int
roles_size
;
48
49
/**
50
* Array of assigned roles.
51
*/
52
char
roles[][
AS_ROLE_SIZE
];
53
}
as_user_roles
;
54
55
/******************************************************************************
56
* FUNCTIONS
57
******************************************************************************/
58
59
/**
60
* Create user with password and roles. Clear-text password will be hashed using bcrypt before
61
* sending to server. Return zero on success.
62
*/
63
int
64
aerospike_create_user
(
aerospike
* as,
const
as_policy_admin
* policy,
const
char
* user,
const
char
* password,
const
char
** roles,
int
roles_size);
65
66
/**
67
* Remove user from cluster. Return zero on success.
68
*/
69
int
70
aerospike_drop_user
(
aerospike
* as,
const
as_policy_admin
* policy,
const
char
* user);
71
72
/**
73
* Set user's password by user administrator. Clear-text password will be hashed using bcrypt before sending to server.
74
* Return zero on success.
75
*/
76
int
77
aerospike_set_password
(
aerospike
* as,
const
as_policy_admin
* policy,
const
char
* user,
const
char
* password);
78
79
/**
80
* Change user's password by user. Clear-text password will be hashed using bcrypt before sending to server.
81
* Return zero on success.
82
*/
83
int
84
aerospike_change_password
(
aerospike
* as,
const
as_policy_admin
* policy,
const
char
* user,
const
char
* password);
85
86
/**
87
* Add role to user's list of roles. Return zero on success.
88
*/
89
int
90
aerospike_grant_roles
(
aerospike
* as,
const
as_policy_admin
* policy,
const
char
* user,
const
char
** roles,
int
roles_size);
91
92
/**
93
* Remove role from user's list of roles. Return zero on success.
94
*/
95
int
96
aerospike_revoke_roles
(
aerospike
* as,
const
as_policy_admin
* policy,
const
char
* user,
const
char
** roles,
int
roles_size);
97
98
/**
99
* Replace user's list of roles with a new list of roles. Return zero on success.
100
*/
101
int
102
aerospike_replace_roles
(
aerospike
* as,
const
as_policy_admin
* policy,
const
char
* user,
const
char
** roles,
int
roles_size);
103
104
/**
105
* Retrieve roles for a given user. Return zero on success.
106
* When successful, as_user_roles_destroy() must be called to free resources.
107
*/
108
int
109
aerospike_query_user
(
aerospike
* as,
const
as_policy_admin
* policy,
const
char
* user,
as_user_roles
** user_roles);
110
111
/**
112
* Release as_user_roles memory.
113
*/
114
void
115
as_user_roles_destroy
(
as_user_roles
* user_roles);
116
117
/**
118
* Retrieve all users and their roles. Return zero on success.
119
* When successful, as_user_roles_destroy_array() must be called to free resources.
120
*/
121
int
122
aerospike_query_users
(
aerospike
* as,
const
as_policy_admin
* policy,
as_user_roles
*** user_roles,
int
* user_roles_size);
123
124
/**
125
* Release memory for as_user_roles array.
126
*/
127
void
128
as_user_roles_destroy_array
(
as_user_roles
** user_roles,
int
user_roles_size);
129
130
/**
131
* @private
132
* Authenticate user with a server node. This is done automatically after socket open.
133
* Do not use this method directly.
134
*/
135
int
136
as_authenticate
(
int
fd,
const
char
* user,
const
char
* credential,
int
timeout_ms);