Blame view

include/linux/ceph/auth.h 2.94 KB
4e7a5dcd1   Sage Weil   ceph: negotiate a...
1
2
  #ifndef _FS_CEPH_AUTH_H
  #define _FS_CEPH_AUTH_H
3d14c5d2b   Yehuda Sadeh   ceph: factor out ...
3
4
  #include <linux/ceph/types.h>
  #include <linux/ceph/buffer.h>
4e7a5dcd1   Sage Weil   ceph: negotiate a...
5
6
7
8
9
10
11
12
13
14
15
16
  
  /*
   * Abstract interface for communicating with the authenticate module.
   * There is some handshake that takes place between us and the monitor
   * to acquire the necessary keys.  These are used to generate an
   * 'authorizer' that we use when connecting to a service (mds, osd).
   */
  
  struct ceph_auth_client;
  struct ceph_authorizer;
  
  struct ceph_auth_client_ops {
559c1e007   Sage Weil   ceph: include aut...
17
  	const char *name;
4e7a5dcd1   Sage Weil   ceph: negotiate a...
18
19
20
21
22
23
24
  	/*
  	 * true if we are authenticated and can connect to
  	 * services.
  	 */
  	int (*is_authenticated)(struct ceph_auth_client *ac);
  
  	/*
a41359fa3   Sage Weil   ceph: renew auth ...
25
26
27
28
29
30
  	 * true if we should (re)authenticate, e.g., when our tickets
  	 * are getting old and crusty.
  	 */
  	int (*should_authenticate)(struct ceph_auth_client *ac);
  
  	/*
4e7a5dcd1   Sage Weil   ceph: negotiate a...
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
  	 * build requests and process replies during monitor
  	 * handshake.  if handle_reply returns -EAGAIN, we build
  	 * another request.
  	 */
  	int (*build_request)(struct ceph_auth_client *ac, void *buf, void *end);
  	int (*handle_reply)(struct ceph_auth_client *ac, int result,
  			    void *buf, void *end);
  
  	/*
  	 * Create authorizer for connecting to a service, and verify
  	 * the response to authenticate the service.
  	 */
  	int (*create_authorizer)(struct ceph_auth_client *ac, int peer_type,
  				 struct ceph_authorizer **a,
  				 void **buf, size_t *len,
  				 void **reply_buf, size_t *reply_len);
  	int (*verify_authorizer_reply)(struct ceph_auth_client *ac,
  				       struct ceph_authorizer *a, size_t len);
  	void (*destroy_authorizer)(struct ceph_auth_client *ac,
  				   struct ceph_authorizer *a);
9bd2e6f8b   Sage Weil   ceph: allow renew...
51
52
  	void (*invalidate_authorizer)(struct ceph_auth_client *ac,
  				      int peer_type);
4e7a5dcd1   Sage Weil   ceph: negotiate a...
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
  
  	/* reset when we (re)connect to a monitor */
  	void (*reset)(struct ceph_auth_client *ac);
  
  	void (*destroy)(struct ceph_auth_client *ac);
  };
  
  struct ceph_auth_client {
  	u32 protocol;           /* CEPH_AUTH_* */
  	void *private;          /* for use by protocol implementation */
  	const struct ceph_auth_client_ops *ops;  /* null iff protocol==0 */
  
  	bool negotiating;       /* true if negotiating protocol */
  	const char *name;       /* entity name */
  	u64 global_id;          /* our unique id in system */
8323c3aa7   Tommi Virtanen   ceph: Move secret...
68
  	const struct ceph_crypto_key *key;     /* our secret key */
4e7a5dcd1   Sage Weil   ceph: negotiate a...
69
70
71
72
  	unsigned want_keys;     /* which services we want */
  };
  
  extern struct ceph_auth_client *ceph_auth_init(const char *name,
8323c3aa7   Tommi Virtanen   ceph: Move secret...
73
  					       const struct ceph_crypto_key *key);
4e7a5dcd1   Sage Weil   ceph: negotiate a...
74
75
76
77
78
79
80
81
82
83
  extern void ceph_auth_destroy(struct ceph_auth_client *ac);
  
  extern void ceph_auth_reset(struct ceph_auth_client *ac);
  
  extern int ceph_auth_build_hello(struct ceph_auth_client *ac,
  				 void *buf, size_t len);
  extern int ceph_handle_auth_reply(struct ceph_auth_client *ac,
  				  void *buf, size_t len,
  				  void *reply_buf, size_t reply_len);
  extern int ceph_entity_name_encode(const char *name, void **p, void *end);
9bd2e6f8b   Sage Weil   ceph: allow renew...
84
85
86
87
  extern int ceph_build_auth(struct ceph_auth_client *ac,
  		    void *msg_buf, size_t msg_len);
  
  extern int ceph_auth_is_authenticated(struct ceph_auth_client *ac);
4e7a5dcd1   Sage Weil   ceph: negotiate a...
88
  #endif