]> git.proxmox.com Git - ceph.git/blob - ceph/src/auth/AuthServiceHandler.cc
bump version to 18.2.4-pve3
[ceph.git] / ceph / src / auth / AuthServiceHandler.cc
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 #include "AuthServiceHandler.h"
16 #include "cephx/CephxServiceHandler.h"
17 #ifdef HAVE_GSSAPI
18 #include "krb/KrbServiceHandler.hpp"
19 #endif
20 #include "none/AuthNoneServiceHandler.h"
21 #include "common/dout.h"
22
23 #define dout_subsys ceph_subsys_auth
24
25
26 std::ostream& operator<<(std::ostream& os,
27 global_id_status_t global_id_status)
28 {
29 switch (global_id_status) {
30 case global_id_status_t::NONE:
31 return os << "none";
32 case global_id_status_t::NEW_PENDING:
33 return os << "new_pending";
34 case global_id_status_t::NEW_OK:
35 return os << "new_ok";
36 case global_id_status_t::NEW_NOT_EXPOSED:
37 return os << "new_not_exposed";
38 case global_id_status_t::RECLAIM_PENDING:
39 return os << "reclaim_pending";
40 case global_id_status_t::RECLAIM_OK:
41 return os << "reclaim_ok";
42 case global_id_status_t::RECLAIM_INSECURE:
43 return os << "reclaim_insecure";
44 default:
45 ceph_abort();
46 }
47 }
48
49 int AuthServiceHandler::start_session(const EntityName& entity_name,
50 uint64_t global_id,
51 bool is_new_global_id,
52 ceph::buffer::list *result,
53 AuthCapsInfo *caps)
54 {
55 ceph_assert(!this->entity_name.get_type() && !this->global_id &&
56 global_id_status == global_id_status_t::NONE);
57
58 ldout(cct, 10) << __func__ << " entity_name=" << entity_name
59 << " global_id=" << global_id << " is_new_global_id="
60 << is_new_global_id << dendl;
61 this->entity_name = entity_name;
62 this->global_id = global_id;
63
64 return do_start_session(is_new_global_id, result, caps);
65 }
66
67 AuthServiceHandler *get_auth_service_handler(int type, CephContext *cct, KeyServer *ks)
68 {
69 switch (type) {
70 case CEPH_AUTH_CEPHX:
71 return new CephxServiceHandler(cct, ks);
72 case CEPH_AUTH_NONE:
73 return new AuthNoneServiceHandler(cct);
74 #ifdef HAVE_GSSAPI
75 case CEPH_AUTH_GSS:
76 return new KrbServiceHandler(cct, ks);
77 #endif
78 default:
79 return nullptr;
80 }
81 }