Sage Weil | 4e7a5dc | 2009-11-18 16:19:57 -0800 | [diff] [blame] | 1 | #ifndef _FS_CEPH_AUTH_H |
| 2 | #define _FS_CEPH_AUTH_H |
| 3 | |
| 4 | #include "types.h" |
| 5 | #include "buffer.h" |
| 6 | |
| 7 | /* |
| 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). |
| 12 | */ |
| 13 | |
| 14 | struct ceph_auth_client; |
| 15 | struct ceph_authorizer; |
| 16 | |
| 17 | struct ceph_auth_client_ops { |
Sage Weil | 559c1e0 | 2010-05-14 09:55:18 -0700 | [diff] [blame^] | 18 | const char *name; |
| 19 | |
Sage Weil | 4e7a5dc | 2009-11-18 16:19:57 -0800 | [diff] [blame] | 20 | /* |
| 21 | * true if we are authenticated and can connect to |
| 22 | * services. |
| 23 | */ |
| 24 | int (*is_authenticated)(struct ceph_auth_client *ac); |
| 25 | |
| 26 | /* |
| 27 | * build requests and process replies during monitor |
| 28 | * handshake. if handle_reply returns -EAGAIN, we build |
| 29 | * another request. |
| 30 | */ |
| 31 | int (*build_request)(struct ceph_auth_client *ac, void *buf, void *end); |
| 32 | int (*handle_reply)(struct ceph_auth_client *ac, int result, |
| 33 | void *buf, void *end); |
| 34 | |
| 35 | /* |
| 36 | * Create authorizer for connecting to a service, and verify |
| 37 | * the response to authenticate the service. |
| 38 | */ |
| 39 | int (*create_authorizer)(struct ceph_auth_client *ac, int peer_type, |
| 40 | struct ceph_authorizer **a, |
| 41 | void **buf, size_t *len, |
| 42 | void **reply_buf, size_t *reply_len); |
| 43 | int (*verify_authorizer_reply)(struct ceph_auth_client *ac, |
| 44 | struct ceph_authorizer *a, size_t len); |
| 45 | void (*destroy_authorizer)(struct ceph_auth_client *ac, |
| 46 | struct ceph_authorizer *a); |
Sage Weil | 9bd2e6f | 2010-02-02 16:21:06 -0800 | [diff] [blame] | 47 | void (*invalidate_authorizer)(struct ceph_auth_client *ac, |
| 48 | int peer_type); |
Sage Weil | 4e7a5dc | 2009-11-18 16:19:57 -0800 | [diff] [blame] | 49 | |
| 50 | /* reset when we (re)connect to a monitor */ |
| 51 | void (*reset)(struct ceph_auth_client *ac); |
| 52 | |
| 53 | void (*destroy)(struct ceph_auth_client *ac); |
| 54 | }; |
| 55 | |
| 56 | struct ceph_auth_client { |
| 57 | u32 protocol; /* CEPH_AUTH_* */ |
| 58 | void *private; /* for use by protocol implementation */ |
| 59 | const struct ceph_auth_client_ops *ops; /* null iff protocol==0 */ |
| 60 | |
| 61 | bool negotiating; /* true if negotiating protocol */ |
| 62 | const char *name; /* entity name */ |
| 63 | u64 global_id; /* our unique id in system */ |
| 64 | const char *secret; /* our secret key */ |
| 65 | unsigned want_keys; /* which services we want */ |
| 66 | }; |
| 67 | |
| 68 | extern struct ceph_auth_client *ceph_auth_init(const char *name, |
| 69 | const char *secret); |
| 70 | extern void ceph_auth_destroy(struct ceph_auth_client *ac); |
| 71 | |
| 72 | extern void ceph_auth_reset(struct ceph_auth_client *ac); |
| 73 | |
| 74 | extern int ceph_auth_build_hello(struct ceph_auth_client *ac, |
| 75 | void *buf, size_t len); |
| 76 | extern int ceph_handle_auth_reply(struct ceph_auth_client *ac, |
| 77 | void *buf, size_t len, |
| 78 | void *reply_buf, size_t reply_len); |
| 79 | extern int ceph_entity_name_encode(const char *name, void **p, void *end); |
| 80 | |
Sage Weil | 9bd2e6f | 2010-02-02 16:21:06 -0800 | [diff] [blame] | 81 | extern int ceph_build_auth(struct ceph_auth_client *ac, |
| 82 | void *msg_buf, size_t msg_len); |
| 83 | |
| 84 | extern int ceph_auth_is_authenticated(struct ceph_auth_client *ac); |
| 85 | |
Sage Weil | 4e7a5dc | 2009-11-18 16:19:57 -0800 | [diff] [blame] | 86 | #endif |