]> git.proxmox.com Git - ceph.git/blame - ceph/src/auth/AuthServiceHandler.h
import ceph 15.2.11
[ceph.git] / ceph / src / auth / AuthServiceHandler.h
CommitLineData
7c673cae
FG
1// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2// vim: ts=8 sw=2 smarttab
3/*
4 * Ceph - scalable distributed file system
5 *
6 * Copyright (C) 2004-2009 Sage Weil <sage@newdream.net>
7 *
8 * This is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License version 2.1, as published by the Free Software
11 * Foundation. See file COPYING.
12 *
13 */
14
15#ifndef CEPH_AUTHSERVICEHANDLER_H
16#define CEPH_AUTHSERVICEHANDLER_H
17
31f18b77
FG
18#include <stddef.h> // for NULL
19#include <stdint.h> // for uint64_t
20#include "common/entity_name.h" // for EntityName
9f95a23c
TL
21#include "include/common_fwd.h"
22#include "include/buffer_fwd.h" // for ceph::buffer::list
7c673cae 23
7c673cae 24class KeyServer;
11fdf7f2 25class CryptoKey;
31f18b77 26struct AuthCapsInfo;
7c673cae 27
c5c27e9a
TL
28enum class global_id_status_t {
29 NONE,
30 // fresh client (global_id == 0); waiting for CephXAuthenticate
31 NEW_PENDING,
32 // connected client; new enough to correctly reclaim global_id
33 NEW_OK,
34 // connected client; unknown whether it can reclaim global_id correctly
35 NEW_NOT_EXPOSED,
36 // reconnecting client (global_id != 0); waiting for CephXAuthenticate
37 RECLAIM_PENDING,
38 // reconnected client; correctly reclaimed global_id
39 RECLAIM_OK,
40 // reconnected client; did not properly prove prior global_id ownership
41 RECLAIM_INSECURE
42};
43
44std::ostream& operator<<(std::ostream& os,
45 global_id_status_t global_id_status);
46
7c673cae
FG
47struct AuthServiceHandler {
48protected:
49 CephContext *cct;
7c673cae 50 EntityName entity_name;
c5c27e9a
TL
51 uint64_t global_id = 0;
52 global_id_status_t global_id_status = global_id_status_t::NONE;
7c673cae 53
c5c27e9a
TL
54public:
55 explicit AuthServiceHandler(CephContext *cct_) : cct(cct_) {}
7c673cae
FG
56
57 virtual ~AuthServiceHandler() { }
58
c5c27e9a
TL
59 int start_session(const EntityName& entity_name,
60 uint64_t global_id,
61 bool is_new_global_id,
62 ceph::buffer::list *result,
63 AuthCapsInfo *caps);
9f95a23c 64 virtual int handle_request(ceph::buffer::list::const_iterator& indata,
11fdf7f2 65 size_t connection_secret_required_length,
9f95a23c 66 ceph::buffer::list *result,
11fdf7f2
TL
67 AuthCapsInfo *caps,
68 CryptoKey *session_key,
69 std::string *connection_secret) = 0;
7c673cae 70
c5c27e9a
TL
71 const EntityName& get_entity_name() { return entity_name; }
72 uint64_t get_global_id() { return global_id; }
73 global_id_status_t get_global_id_status() { return global_id_status; }
74
75private:
76 virtual int do_start_session(bool is_new_global_id,
77 ceph::buffer::list *result,
78 AuthCapsInfo *caps) = 0;
7c673cae
FG
79};
80
81extern AuthServiceHandler *get_auth_service_handler(int type, CephContext *cct, KeyServer *ks);
82
83#endif