Couchbase C Client  3.3.12
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
27namespace lcb
28{
29class Authenticator;
30}
31typedef lcb::Authenticator lcb_AUTHENTICATOR;
32extern "C" {
33#else /* C only! */
34typedef struct lcb_AUTHENTICATOR_Cdummy lcb_AUTHENTICATOR;
35#endif
36
142LIBCOUCHBASE_API
144
148typedef enum {
151
157 LCBAUTH_F_BUCKET = 1 << 2
159
181LIBCOUCHBASE_API
182lcb_STATUS lcbauth_add_pass(lcb_AUTHENTICATOR *auth, const char *user, const char *pass, int flags);
183
194LIBCOUCHBASE_API
196
205LIBCOUCHBASE_API
207
219LIBCOUCHBASE_API
221
233typedef const char *(*lcb_AUTHCALLBACK)(void *cookie, const char *host, const char *port, const char *bucket);
234
245LCB_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
249typedef struct lcbauth_CREDENTIALS_ lcbauth_CREDENTIALS;
250
260LIBCOUCHBASE_API lcb_STATUS lcbauth_credentials_username(lcbauth_CREDENTIALS *credentials, const char *username,
261 size_t username_len);
271LIBCOUCHBASE_API lcb_STATUS lcbauth_credentials_password(lcbauth_CREDENTIALS *credentials, const char *password,
272 size_t password_len);
273
278typedef enum {
279 LCBAUTH_RESULT_OK = 0,
280 LCBAUTH_RESULT_NOT_AVAILABLE,
282
290LIBCOUCHBASE_API lcb_STATUS lcbauth_credentials_result(lcbauth_CREDENTIALS *credentials, lcbauth_RESULT result);
291
292typedef 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
310LIBCOUCHBASE_API lcbauth_SERVICE lcbauth_credentials_service(const lcbauth_CREDENTIALS *credentials);
311
315typedef enum {
316 LCBAUTH_REASON_NEW_OPERATION = 0,
317 LCBAUTH_REASON_AUTHENTICATION_FAILURE,
318 LCBAUTH_REASON_AUTHORIZATION_FAILURE,
320
328LIBCOUCHBASE_API lcbauth_REASON lcbauth_credentials_reason(const lcbauth_CREDENTIALS *credentials);
329
340LIBCOUCHBASE_API lcb_STATUS lcbauth_credentials_hostname(const lcbauth_CREDENTIALS *credentials, const char **hostname,
341 size_t *hostname_len);
342
353LIBCOUCHBASE_API lcb_STATUS lcbauth_credentials_port(const lcbauth_CREDENTIALS *credentials, const char **port,
354 size_t *port_len);
355
366LIBCOUCHBASE_API lcb_STATUS lcbauth_credentials_bucket(const lcbauth_CREDENTIALS *credentials, const char **bucket,
367 size_t *bucket_len);
377LIBCOUCHBASE_API lcb_STATUS lcbauth_credentials_cookie(const lcbauth_CREDENTIALS *credentials, void **cookie);
378
387LIBCOUCHBASE_API lcb_STATUS lcbauth_set_callback(lcb_AUTHENTICATOR *auth, void *cookie,
388 void (*callback)(lcbauth_CREDENTIALS *));
389
390typedef enum {
396
405
412 LCBAUTH_MODE_DYNAMIC = 2
414
427LIBCOUCHBASE_API
429
432#ifdef __cplusplus
433}
434#endif
435#endif /* LCB_AUTH_H */
Opaque pointer containing credentials for the library.
lcbauth_MODE
Definition auth.h:390
lcb_STATUS lcbauth_add_pass(lcb_AUTHENTICATOR *auth, const char *user, const char *pass, int flags)
void lcbauth_unref(lcb_AUTHENTICATOR *auth)
lcbauth_ADDPASSFLAGS
Flags to use when adding a new set of credentials to lcbauth_add_pass.
Definition auth.h:148
lcb_AUTHENTICATOR * lcbauth_new(void)
lcbauth_RESULT
Result could be used to notify the library that credentials cannot be resolved (e....
Definition auth.h:278
lcb_AUTHENTICATOR * lcbauth_clone(const lcb_AUTHENTICATOR *src)
lcbauth_REASON
Reason, why the library requests credentials.
Definition auth.h:315
lcb_STATUS lcbauth_set_mode(lcb_AUTHENTICATOR *src, lcbauth_MODE mode)
void lcbauth_ref(lcb_AUTHENTICATOR *auth)
@ LCBAUTH_MODE_RBAC
Use role-based access control.
Definition auth.h:404
@ LCBAUTH_MODE_CLASSIC
Use "bucket-specific" credentials when authenticating.
Definition auth.h:395
@ LCBAUTH_F_CLUSTER
User/Password is administrative; for cluster.
Definition auth.h:150
@ LCBAUTH_F_BUCKET
User is bucket name.
Definition auth.h:157
lcb_STATUS
Error codes returned by the library.
Definition error.h:212