diff options
Diffstat (limited to 'src/auth/none')
-rw-r--r-- | src/auth/none/AuthNoneAuthorizeHandler.cc | 56 | ||||
-rw-r--r-- | src/auth/none/AuthNoneAuthorizeHandler.h | 39 | ||||
-rw-r--r-- | src/auth/none/AuthNoneClientHandler.h | 61 | ||||
-rw-r--r-- | src/auth/none/AuthNoneProtocol.h | 38 | ||||
-rw-r--r-- | src/auth/none/AuthNoneServiceHandler.h | 46 | ||||
-rw-r--r-- | src/auth/none/AuthNoneSessionHandler.h | 19 |
6 files changed, 259 insertions, 0 deletions
diff --git a/src/auth/none/AuthNoneAuthorizeHandler.cc b/src/auth/none/AuthNoneAuthorizeHandler.cc new file mode 100644 index 000000000..bc553fed6 --- /dev/null +++ b/src/auth/none/AuthNoneAuthorizeHandler.cc @@ -0,0 +1,56 @@ +// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- +// vim: ts=8 sw=2 smarttab +/* + * Ceph - scalable distributed file system + * + * Copyright (C) 2009-2011 New Dream Network + * + * This is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software + * Foundation. See file COPYING. + * + */ + +#include "AuthNoneAuthorizeHandler.h" +#include "common/debug.h" + +#define dout_subsys ceph_subsys_auth + +bool AuthNoneAuthorizeHandler::verify_authorizer( + CephContext *cct, + const KeyStore& keys, + const ceph::buffer::list& authorizer_data, + size_t connection_secret_required_len, + ceph::buffer::list *authorizer_reply, + EntityName *entity_name, + uint64_t *global_id, + AuthCapsInfo *caps_info, + CryptoKey *session_key, + std::string *connection_secret, + std::unique_ptr<AuthAuthorizerChallenge> *challenge) +{ + using ceph::decode; + auto iter = authorizer_data.cbegin(); + + try { + __u8 struct_v = 1; + decode(struct_v, iter); + decode(*entity_name, iter); + decode(*global_id, iter); + } catch (const ceph::buffer::error &err) { + ldout(cct, 0) << "AuthNoneAuthorizeHandle::verify_authorizer() failed to decode" << dendl; + return false; + } + + caps_info->allow_all = true; + + return true; +} + +// Return type of crypto used for this session's data; for none, no crypt used + +int AuthNoneAuthorizeHandler::authorizer_session_crypto() +{ + return SESSION_CRYPTO_NONE; +} diff --git a/src/auth/none/AuthNoneAuthorizeHandler.h b/src/auth/none/AuthNoneAuthorizeHandler.h new file mode 100644 index 000000000..3d5ca58d5 --- /dev/null +++ b/src/auth/none/AuthNoneAuthorizeHandler.h @@ -0,0 +1,39 @@ +// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- +// vim: ts=8 sw=2 smarttab +/* + * Ceph - scalable distributed file system + * + * Copyright (C) 2004-2009 Sage Weil <sage@newdream.net> + * + * This is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software + * Foundation. See file COPYING. + * + */ + +#ifndef CEPH_AUTHNONEAUTHORIZEHANDLER_H +#define CEPH_AUTHNONEAUTHORIZEHANDLER_H + +#include "auth/AuthAuthorizeHandler.h" +#include "include/common_fwd.h" + +struct AuthNoneAuthorizeHandler : public AuthAuthorizeHandler { + bool verify_authorizer( + CephContext *cct, + const KeyStore& keys, + const ceph::buffer::list& authorizer_data, + size_t connection_secret_required_len, + ceph::buffer::list *authorizer_reply, + EntityName *entity_name, + uint64_t *global_id, + AuthCapsInfo *caps_info, + CryptoKey *session_key, + std::string *connection_secret, + std::unique_ptr<AuthAuthorizerChallenge> *challenge) override; + int authorizer_session_crypto() override; +}; + + + +#endif diff --git a/src/auth/none/AuthNoneClientHandler.h b/src/auth/none/AuthNoneClientHandler.h new file mode 100644 index 000000000..66b4d59fc --- /dev/null +++ b/src/auth/none/AuthNoneClientHandler.h @@ -0,0 +1,61 @@ +// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- +// vim: ts=8 sw=2 smarttab +/* + * Ceph - scalable distributed file system + * + * Copyright (C) 2004-2009 Sage Weil <sage@newdream.net> + * + * This is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software + * Foundation. See file COPYING. + * + */ + +#ifndef CEPH_AUTHNONECLIENTHANDLER_H +#define CEPH_AUTHNONECLIENTHANDLER_H + +#include "auth/AuthClientHandler.h" +#include "AuthNoneProtocol.h" +#include "common/ceph_context.h" +#include "common/config.h" + +class AuthNoneClientHandler : public AuthClientHandler { + +public: + AuthNoneClientHandler(CephContext *cct_) + : AuthClientHandler(cct_) {} + + AuthNoneClientHandler* clone() const override { + return new AuthNoneClientHandler(*this); + } + + void reset() override { } + + void prepare_build_request() override {} + int build_request(ceph::buffer::list& bl) const override { return 0; } + int handle_response(int ret, ceph::buffer::list::const_iterator& iter, + CryptoKey *session_key, + std::string *connection_secret) override { return 0; } + bool build_rotating_request(ceph::buffer::list& bl) const override { return false; } + + int get_protocol() const override { return CEPH_AUTH_NONE; } + + AuthAuthorizer *build_authorizer(uint32_t service_id) const override { + AuthNoneAuthorizer *auth = new AuthNoneAuthorizer(); + if (auth) { + auth->build_authorizer(cct->_conf->name, global_id); + } + return auth; + } + + bool need_tickets() override { return false; } + + void set_global_id(uint64_t id) override { + global_id = id; + } +private: + void validate_tickets() override {} +}; + +#endif diff --git a/src/auth/none/AuthNoneProtocol.h b/src/auth/none/AuthNoneProtocol.h new file mode 100644 index 000000000..d23fdcc67 --- /dev/null +++ b/src/auth/none/AuthNoneProtocol.h @@ -0,0 +1,38 @@ +// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- +// vim: ts=8 sw=2 smarttab +/* + * Ceph - scalable distributed file system + * + * Copyright (C) 2004-2009 Sage Weil <sage@newdream.net> + * + * This is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software + * Foundation. See file COPYING. + * + */ + +#ifndef CEPH_AUTHNONEPROTOCOL_H +#define CEPH_AUTHNONEPROTOCOL_H + +#include "auth/Auth.h" +#include "include/common_fwd.h" + +struct AuthNoneAuthorizer : public AuthAuthorizer { + AuthNoneAuthorizer() : AuthAuthorizer(CEPH_AUTH_NONE) { } + bool build_authorizer(const EntityName &ename, uint64_t global_id) { + __u8 struct_v = 1; // see AUTH_MODE_* in Auth.h + using ceph::encode; + encode(struct_v, bl); + encode(ename, bl); + encode(global_id, bl); + return 0; + } + bool verify_reply(ceph::buffer::list::const_iterator& reply, + std::string *connection_secret) override { return true; } + bool add_challenge(CephContext *cct, const ceph::buffer::list& ch) override { + return true; + } +}; + +#endif diff --git a/src/auth/none/AuthNoneServiceHandler.h b/src/auth/none/AuthNoneServiceHandler.h new file mode 100644 index 000000000..e6fcee8fc --- /dev/null +++ b/src/auth/none/AuthNoneServiceHandler.h @@ -0,0 +1,46 @@ +// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- +// vim: ts=8 sw=2 smarttab +/* + * Ceph - scalable distributed file system + * + * Copyright (C) 2004-2009 Sage Weil <sage@newdream.net> + * + * This is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software + * Foundation. See file COPYING. + * + */ + +#ifndef CEPH_AUTHNONESERVICEHANDLER_H +#define CEPH_AUTHNONESERVICEHANDLER_H + +#include "auth/AuthServiceHandler.h" +#include "auth/Auth.h" +#include "include/common_fwd.h" + +class AuthNoneServiceHandler : public AuthServiceHandler { +public: + explicit AuthNoneServiceHandler(CephContext *cct_) + : AuthServiceHandler(cct_) {} + ~AuthNoneServiceHandler() override {} + + int handle_request(ceph::buffer::list::const_iterator& indata, + size_t connection_secret_required_length, + ceph::buffer::list *result_bl, + AuthCapsInfo *caps, + CryptoKey *session_key, + std::string *connection_secret) override { + return 0; + } + +private: + int do_start_session(bool is_new_global_id, + ceph::buffer::list *result_bl, + AuthCapsInfo *caps) override { + caps->allow_all = true; + return 1; + } +}; + +#endif diff --git a/src/auth/none/AuthNoneSessionHandler.h b/src/auth/none/AuthNoneSessionHandler.h new file mode 100644 index 000000000..ca1451f79 --- /dev/null +++ b/src/auth/none/AuthNoneSessionHandler.h @@ -0,0 +1,19 @@ +// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- +// vim: ts=8 sw=2 smarttab +/* + * Ceph - scalable distributed file system + * + * Copyright (C) 2004-2009 Sage Weil <sage@newdream.net> + * + * This is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software + * Foundation. See file COPYING. + * + */ + +#include "auth/AuthSessionHandler.h" + +struct AuthNoneSessionHandler : DummyAuthSessionHandler { +}; + |