Kea 3.3.4
isc::rbac::RoleConfig Class Reference

Per role configuration class. More...

#include <rbac.h>

Public Member Functions

 RoleConfig (const std::string &name, const AclPtr &accept, const AclPtr &reject, bool others, bool preference, const ResponseFilterList &response_filters)
 Constructor.
virtual ~RoleConfig ()=default
 Destructor.
bool filter (const std::string &command, data::ConstElementPtr body) const
 Filter a response.
bool match (const std::string &command) const
 Match access control list.

Static Public Member Functions

static http::HttpResponseJsonPtr createReject (const http::HttpRequestPtr &request, const http::HttpStatusCode &status_code)
 Create a reject response.
static RoleConfigPtr getConfig (const std::string &role)
 Return the role config.
static RoleConfigPtr parse (data::ConstElementPtr cfg, std::string name="")
 Parse a role config.

Public Attributes

AclPtr accept_
 Accept command access control list.
std::string name_
 Role name.
bool others_
 Action for other commands.
bool preference_
 Action for both matching.
AclPtr reject_
 Reject command access control list.
ResponseFilterList response_filters_
 Response filters.

Static Public Attributes

static const data::SimpleKeywords ROLE_PARAMETERS
 Role configuration parameters.

Detailed Description

Per role configuration class.

When a command does not match accept and reject ACLs it is an other commands: true is for the accept action, false for the reject one. When a command matches both accept and reject ACLs the preference true follows the accept ACL, false the deny ACL.

Definition at line 34 of file rbac.h.

Constructor & Destructor Documentation

◆ RoleConfig()

isc::rbac::RoleConfig::RoleConfig ( const std::string & name,
const AclPtr & accept,
const AclPtr & reject,
bool others,
bool preference,
const ResponseFilterList & response_filters )
inline

Constructor.

Parameters
nameRole name.
acceptAccept commands access.
rejectReject commands filter.
othersAction for other commands.
preferenceAction for matching both commands.
response_filtersResponse filters.

Definition at line 47 of file rbac.h.

References accept_, name_, others_, preference_, reject_, and response_filters_.

Referenced by parse().

◆ ~RoleConfig()

virtual isc::rbac::RoleConfig::~RoleConfig ( )
virtualdefault

Destructor.

Member Function Documentation

◆ createReject()

HttpResponseJsonPtr isc::rbac::RoleConfig::createReject ( const http::HttpRequestPtr & request,
const http::HttpStatusCode & status_code )
static

Create a reject response.

Parameters
requestThe request.
status_codeThe status code.

Definition at line 129 of file rbac.cc.

References Element::create(), Element::createMap(), isc_throw, isc::http::HttpVersion::major_, isc::http::HttpVersion::minor_, isc::http::HttpResponse::statusCodeToNumber(), and isc::http::HttpResponse::statusCodeToString().

Referenced by http_auth().

Here is the call graph for this function:

◆ filter()

bool isc::rbac::RoleConfig::filter ( const std::string & command,
data::ConstElementPtr body ) const
inline

Filter a response.

Parameters
commandThe command.
bodyThe JSON response body.
Returns
whether the body was modified.

Definition at line 105 of file rbac.h.

References response_filters_.

◆ getConfig()

RoleConfigPtr isc::rbac::RoleConfig::getConfig ( const std::string & role)
static

Return the role config.

Parameters
roleThe role name.
Returns
the role config, default if empty, unknown if not in table.

Definition at line 41 of file rbac.cc.

References isc::rbac::defaultRoleConfig, isc::rbac::roleConfigTable, and isc::rbac::unknownRoleConfig.

Referenced by http_auth().

◆ match()

bool isc::rbac::RoleConfig::match ( const std::string & command) const
inline

Match access control list.

Parameters
commandThe command.
Returns
whether accept (true) or reject (false) the command.

Definition at line 81 of file rbac.h.

References accept_, others_, preference_, and reject_.

Referenced by isc::rbac::ListCommandsResponseFilter::filter().

◆ parse()

RoleConfigPtr isc::rbac::RoleConfig::parse ( data::ConstElementPtr cfg,
std::string name = "" )
static

Parse a role config.

Parameters
cfgThe role config.
nameThe name (empty when to be get from the config).
Returns
the parsed role config.

Definition at line 53 of file rbac.cc.

References RoleConfig(), isc::data::SimpleParser::checkKeywords(), isc_throw, Element::map, isc::rbac::Acl::parse(), isc::rbac::ResponseFilter::parse(), and ROLE_PARAMETERS.

Referenced by isc::rbac::Config::parse().

Here is the call graph for this function:

Member Data Documentation

◆ accept_

AclPtr isc::rbac::RoleConfig::accept_

Accept command access control list.

Definition at line 63 of file rbac.h.

Referenced by RoleConfig(), and match().

◆ name_

std::string isc::rbac::RoleConfig::name_

Role name.

Definition at line 60 of file rbac.h.

Referenced by RoleConfig().

◆ others_

bool isc::rbac::RoleConfig::others_

Action for other commands.

Definition at line 69 of file rbac.h.

Referenced by RoleConfig(), and match().

◆ preference_

bool isc::rbac::RoleConfig::preference_

Action for both matching.

Definition at line 72 of file rbac.h.

Referenced by RoleConfig(), and match().

◆ reject_

AclPtr isc::rbac::RoleConfig::reject_

Reject command access control list.

Definition at line 66 of file rbac.h.

Referenced by RoleConfig(), and match().

◆ response_filters_

ResponseFilterList isc::rbac::RoleConfig::response_filters_

Response filters.

Definition at line 75 of file rbac.h.

Referenced by RoleConfig(), and filter().

◆ ROLE_PARAMETERS

const SimpleKeywords isc::rbac::RoleConfig::ROLE_PARAMETERS
static
Initial value:
= {
{ "name", Element::string },
{ "accept-commands", Element::any },
{ "reject-commands", Element::any },
{ "other-commands", Element::string },
{ "list-match-first", Element::string },
{ "response-filters", Element::list },
{ "comment", Element::string }
}
@ any
Definition data.h:161
@ list
Definition data.h:159
@ string
Definition data.h:157

Role configuration parameters.

Definition at line 37 of file rbac.h.

Referenced by parse().


The documentation for this class was generated from the following files: