Couchbase C Client  3.2.2
Asynchronous C Client for Couchbase
auth.h
Go to the documentation of this file.
1 /* -*- Mode: C; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2 /*
3  * Copyright 2017-2020 Couchbase, Inc.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * 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,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 #ifndef LCB_AUTH_H
19 #define LCB_AUTH_H
20 
26 #ifdef __cplusplus
27 namespace lcb
28 {
29 class Authenticator;
30 }
31 typedef lcb::Authenticator lcb_AUTHENTICATOR;
32 extern "C" {
33 #else /* C only! */
34 typedef struct lcb_AUTHENTICATOR_Cdummy lcb_AUTHENTICATOR;
35 #endif
36 
142 LIBCOUCHBASE_API
144 
148 typedef enum {
150  LCBAUTH_F_CLUSTER = 1 << 1,
157  LCBAUTH_F_BUCKET = 1 << 2
159 
181 LIBCOUCHBASE_API
182 lcb_STATUS lcbauth_add_pass(lcb_AUTHENTICATOR *auth, const char *user, const char *pass, int flags);
183 
194 LIBCOUCHBASE_API
195 void lcbauth_ref(lcb_AUTHENTICATOR *auth);
196 
205 LIBCOUCHBASE_API
206 void lcbauth_unref(lcb_AUTHENTICATOR *auth);
207 
219 LIBCOUCHBASE_API
221 
233 typedef const char *(*lcb_AUTHCALLBACK)(void *cookie, const char *host, const char *port, const char *bucket);
234 
245 LCB_DEPRECATED2(LIBCOUCHBASE_API lcb_STATUS lcbauth_set_callbacks(lcb_AUTHENTICATOR *auth, void *cookie,
246  lcb_AUTHCALLBACK usercb, lcb_AUTHCALLBACK passcb),
247  "Use lcbauth_set_callback");
248 
249 typedef struct lcbauth_CREDENTIALS_ lcbauth_CREDENTIALS;
250 
260 LIBCOUCHBASE_API lcb_STATUS lcbauth_credentials_username(lcbauth_CREDENTIALS *credentials, const char *username,
261  size_t username_len);
271 LIBCOUCHBASE_API lcb_STATUS lcbauth_credentials_password(lcbauth_CREDENTIALS *credentials, const char *password,
272  size_t password_len);
273 
278 typedef enum {
279  LCBAUTH_RESULT_OK = 0,
280  LCBAUTH_RESULT_NOT_AVAILABLE,
282 
290 LIBCOUCHBASE_API lcb_STATUS lcbauth_credentials_result(lcbauth_CREDENTIALS *credentials, lcbauth_RESULT result);
291 
292 typedef enum {
293  LCBAUTH_SERVICE_UNSPECIFIED = 0,
294  LCBAUTH_SERVICE_KEY_VALUE,
295  LCBAUTH_SERVICE_QUERY,
296  LCBAUTH_SERVICE_SEARCH,
297  LCBAUTH_SERVICE_ANALYTICS,
298  LCBAUTH_SERVICE_MANAGEMENT,
299  LCBAUTH_SERVICE_EVENTING,
300  LCBAUTH_SERVICE_VIEWS,
301 } lcbauth_SERVICE;
302 
310 LIBCOUCHBASE_API lcbauth_SERVICE lcbauth_credentials_service(const lcbauth_CREDENTIALS *credentials);
311 
315 typedef enum {
316  LCBAUTH_REASON_NEW_OPERATION = 0,
317  LCBAUTH_REASON_AUTHENTICATION_FAILURE,
319 
327 LIBCOUCHBASE_API lcbauth_REASON lcbauth_credentials_reason(const lcbauth_CREDENTIALS *credentials);
328 
339 LIBCOUCHBASE_API lcb_STATUS lcbauth_credentials_hostname(const lcbauth_CREDENTIALS *credentials, const char **hostname,
340  size_t *hostname_len);
341 
352 LIBCOUCHBASE_API lcb_STATUS lcbauth_credentials_port(const lcbauth_CREDENTIALS *credentials, const char **port,
353  size_t *port_len);
354 
365 LIBCOUCHBASE_API lcb_STATUS lcbauth_credentials_bucket(const lcbauth_CREDENTIALS *credentials, const char **bucket,
366  size_t *bucket_len);
376 LIBCOUCHBASE_API lcb_STATUS lcbauth_credentials_cookie(const lcbauth_CREDENTIALS *credentials, void **cookie);
377 
386 LIBCOUCHBASE_API lcb_STATUS lcbauth_set_callback(lcb_AUTHENTICATOR *auth, void *cookie,
387  void (*callback)(lcbauth_CREDENTIALS *));
388 
389 typedef enum {
395 
403  LCBAUTH_MODE_RBAC = 1,
404 
411  LCBAUTH_MODE_DYNAMIC = 2
412 } lcbauth_MODE;
413 
426 LIBCOUCHBASE_API
428 
431 #ifdef __cplusplus
432 }
433 #endif
434 #endif /* LCB_AUTH_H */
lcb_AUTHENTICATOR * lcbauth_clone(const lcb_AUTHENTICATOR *src)
lcbauth_ADDPASSFLAGS
Flags to use when adding a new set of credentials to lcbauth_add_pass.
Definition: auth.h:149
lcb_STATUS lcbauth_set_mode(lcb_AUTHENTICATOR *src, lcbauth_MODE mode)
lcb_STATUS
Error codes returned by the library.
Definition: error.h:210
lcbauth_MODE
Definition: auth.h:394
lcb_AUTHENTICATOR * lcbauth_new(void)
Opaque pointer containing credentials for the library.
void lcbauth_ref(lcb_AUTHENTICATOR *auth)
Use "bucket-specific" credentials when authenticating.
Definition: auth.h:399
User is bucket name.
Definition: auth.h:158
User/Password is administrative; for cluster.
Definition: auth.h:151
lcbauth_REASON
Reason, why the library requests credentials.
Definition: auth.h:320
void lcbauth_unref(lcb_AUTHENTICATOR *auth)
Use role-based access control.
Definition: auth.h:408
lcbauth_RESULT
Result could be used to notify the library that credentials cannot be resolved (e.g.
Definition: auth.h:283
lcb_STATUS lcbauth_add_pass(lcb_AUTHENTICATOR *auth, const char *user, const char *pass, int flags)