1 #ifndef _FS_CEPH_AUTH_H
2 #define _FS_CEPH_AUTH_H
4 #include <linux/ceph/types.h>
5 #include <linux/ceph/buffer.h>
8 * Abstract interface for communicating with the authenticate module.
9 * There is some handshake that takes place between us and the monitor
10 * to acquire the necessary keys. These are used to generate an
11 * 'authorizer' that we use when connecting to a service (mds, osd).
14 struct ceph_auth_client;
16 struct ceph_authorizer {
17 void (*destroy)(struct ceph_authorizer *);
20 struct ceph_auth_handshake {
21 struct ceph_authorizer *authorizer;
23 size_t authorizer_buf_len;
24 void *authorizer_reply_buf;
25 size_t authorizer_reply_buf_len;
28 struct ceph_auth_client_ops {
32 * true if we are authenticated and can connect to
35 int (*is_authenticated)(struct ceph_auth_client *ac);
38 * true if we should (re)authenticate, e.g., when our tickets
39 * are getting old and crusty.
41 int (*should_authenticate)(struct ceph_auth_client *ac);
44 * build requests and process replies during monitor
45 * handshake. if handle_reply returns -EAGAIN, we build
48 int (*build_request)(struct ceph_auth_client *ac, void *buf, void *end);
49 int (*handle_reply)(struct ceph_auth_client *ac, int result,
50 void *buf, void *end);
53 * Create authorizer for connecting to a service, and verify
54 * the response to authenticate the service.
56 int (*create_authorizer)(struct ceph_auth_client *ac, int peer_type,
57 struct ceph_auth_handshake *auth);
58 /* ensure that an existing authorizer is up to date */
59 int (*update_authorizer)(struct ceph_auth_client *ac, int peer_type,
60 struct ceph_auth_handshake *auth);
61 int (*verify_authorizer_reply)(struct ceph_auth_client *ac,
62 struct ceph_authorizer *a, size_t len);
63 void (*invalidate_authorizer)(struct ceph_auth_client *ac,
66 /* reset when we (re)connect to a monitor */
67 void (*reset)(struct ceph_auth_client *ac);
69 void (*destroy)(struct ceph_auth_client *ac);
72 struct ceph_auth_client {
73 u32 protocol; /* CEPH_AUTH_* */
74 void *private; /* for use by protocol implementation */
75 const struct ceph_auth_client_ops *ops; /* null iff protocol==0 */
77 bool negotiating; /* true if negotiating protocol */
78 const char *name; /* entity name */
79 u64 global_id; /* our unique id in system */
80 const struct ceph_crypto_key *key; /* our secret key */
81 unsigned want_keys; /* which services we want */
86 extern struct ceph_auth_client *ceph_auth_init(const char *name,
87 const struct ceph_crypto_key *key);
88 extern void ceph_auth_destroy(struct ceph_auth_client *ac);
90 extern void ceph_auth_reset(struct ceph_auth_client *ac);
92 extern int ceph_auth_build_hello(struct ceph_auth_client *ac,
93 void *buf, size_t len);
94 extern int ceph_handle_auth_reply(struct ceph_auth_client *ac,
95 void *buf, size_t len,
96 void *reply_buf, size_t reply_len);
97 extern int ceph_entity_name_encode(const char *name, void **p, void *end);
99 extern int ceph_build_auth(struct ceph_auth_client *ac,
100 void *msg_buf, size_t msg_len);
102 extern int ceph_auth_is_authenticated(struct ceph_auth_client *ac);
103 extern int ceph_auth_create_authorizer(struct ceph_auth_client *ac,
105 struct ceph_auth_handshake *auth);
106 void ceph_auth_destroy_authorizer(struct ceph_authorizer *a);
107 extern int ceph_auth_update_authorizer(struct ceph_auth_client *ac,
109 struct ceph_auth_handshake *a);
110 extern int ceph_auth_verify_authorizer_reply(struct ceph_auth_client *ac,
111 struct ceph_authorizer *a,
113 extern void ceph_auth_invalidate_authorizer(struct ceph_auth_client *ac,