Leosac  0.8.0
Open Source Access Control
AuthDBModule.cpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2014-2016 Leosac
3 
4  This file is part of Leosac.
5 
6  Leosac is free software: you can redistribute it and/or modify
7  it under the terms of the GNU Affero General Public License as published by
8  the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  Leosac is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU Affero General Public License for more details.
15 
16  You should have received a copy of the GNU Affero General Public License
17  along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19 
21 #include "core/CoreUtils.hpp"
22 #include "core/kernel.hpp"
23 #include <tools/db/database.hpp>
24 
25 using namespace Leosac;
26 using namespace Leosac::Module::Auth;
27 
28 AuthDBModule::AuthDBModule(zmqpp::context &ctx, zmqpp::socket *pipe,
29  const boost::property_tree::ptree &cfg,
30  CoreUtilsPtr utils)
31  : AsioModule(ctx, pipe, cfg, utils)
32 {
34 
35  /* for (auto authenticator : authenticators_)
36  {
37  reactor_.add(authenticator->bus_sub(),
38  std::bind(&AuthDBInstance::handle_bus_msg, authenticator));
39  }*/
40 }
41 
43 {
44 }
45 
47 {
49 }
50 
52 {
53 }
54 
56 {
57  using namespace odb;
58  using namespace odb::core;
59  auto db = utils_->database();
60  schema_version v = db->schema_version("module_auth-db");
61  schema_version cv(schema_catalog::current_version(*db, "module_auth-db"));
62  if (v == 0)
63  {
64  transaction t(db->begin());
65  schema_catalog::create_schema(*db, "module_auth-db");
66  t.commit();
67  }
68  else if (v < cv)
69  {
70  INFO("AuthDB Module performing database migration. Going from version "
71  << v << " to version " << cv);
72  transaction t(db->begin());
73  schema_catalog::migrate(*db, cv, "module_auth-db");
74  t.commit();
75  }
76 }
Leosac::Module::Auth::AuthDBModule::on_service_event
void on_service_event(const service_event::Event &event) override
Function invoked when a service event is triggered.
Definition: AuthDBModule.cpp:51
database.hpp
INFO
@ INFO
Definition: log.hpp:34
odb
Provide ODB magic to be able to store an Leosac::Audit::EventType (FlagSet) object.
Definition: AuditEventMaskODB.hpp:31
AuthDBModule.hpp
Leosac::Module::Auth::AuthDBModule::setup_database
void setup_database()
Definition: AuthDBModule.cpp:55
Leosac
This is the header file for a generated source file, GitSHA1.cpp.
Definition: APIStatusCode.hpp:22
kernel.hpp
Leosac::Module::AsioModule
This is a base class for boost::asio 'aware' module.
Definition: AsioModule.hpp:40
Leosac::Module::BaseModule::utils_
CoreUtilsPtr utils_
Pointer to the core utils, which gives access to scheduler and others.
Definition: BaseModule.hpp:198
Leosac::Module::Auth::AuthDBModule::AuthDBModule
AuthDBModule(zmqpp::context &ctx, zmqpp::socket *pipe, const boost::property_tree::ptree &cfg, CoreUtilsPtr utils)
Definition: AuthDBModule.cpp:28
Leosac::Module::Auth::AuthDBModule::process_config
void process_config()
Definition: AuthDBModule.cpp:46
Leosac::Module::Auth::AuthDBModule::~AuthDBModule
~AuthDBModule()
Definition: AuthDBModule.cpp:42
CoreUtils.hpp
Leosac::service_event::Event
Definition: ServiceRegistry.hpp:37
Leosac::Module::Auth
Authentication backend modules live here.
Leosac::CoreUtilsPtr
std::shared_ptr< CoreUtils > CoreUtilsPtr
Definition: LeosacFwd.hpp:35