| Kea 3.0.2-git

isc::http::BasicHttpAuthConfig Class Reference

Basic HTTP authentication configuration. More...

`#include <basic_auth_config.h>`

Inheritance diagram for isc::http::BasicHttpAuthConfig:
[legend]

## Public Member Functions
virtual | ~BasicHttpAuthConfig ()
| Destructor.
void | add (const std::string &user, const std::string &user_file, const std::string &password, const std::string &password_file, bool password_file_only=false, const isc::data::ConstElementPtr &user_context=isc::data::ConstElementPtr())
| Add a client configuration.
virtual isc::http::HttpResponseJsonPtr | checkAuth (const isc::http::HttpResponseCreator &creator, const isc::http::HttpRequestPtr &request) const
| Validate HTTP request.
virtual void | clear ()
| Clear configuration.
virtual bool | empty () const
| Empty predicate.
const BasicHttpAuthClientList & | getClientList () const
| Returns the list of client configuration.
const BasicHttpAuthMap & | getCredentialMap () const
| Returns the credential and user id map.
std::string | getFileContent (const std::string &file_name) const
| Get the content of {directory}/{file-name} regular file.
void | parse (const isc::data::ConstElementPtr &config)
| Parses basic HTTP authentication configuration.
virtual isc::data::ElementPtr | toElement () const
| Unparses basic HTTP authentication configuration.
Public Member Functions inherited from isc::http::HttpAuthConfig
virtual | ~HttpAuthConfig ()
| Destructor.
const std::string & | getDirectory () const
| Returns the common part for file paths (usually a directory).
const std::string & | getRealm () const
| Returns the realm.
void | setDirectory (const std::string &directory)
| Set the common part for file paths (usually a directory).
void | setRealm (const std::string &realm)
| Set the realm.
Public Member Functions inherited from isc::data::UserContext
void | contextToElement (data::ElementPtr map) const
| Merge unparse a user_context object.
data::ConstElementPtr | getContext () const
| Returns const pointer to the user context.
void | setContext (const data::ConstElementPtr &ctx)
| Sets user context.
Public Member Functions inherited from isc::data::CfgToElement
virtual | ~CfgToElement ()
| Destructor.

## Additional Inherited Members
Static Public Member Functions inherited from isc::data::UserContext
static data::ElementPtr | toElement (data::ConstElementPtr map)
| Copy an Element map.
Protected Attributes inherited from isc::data::UserContext
data::ConstElementPtr | user_context_
| Pointer to the user context (may be NULL).

## Detailed Description

Basic HTTP authentication configuration.

Definition at line 117 of file basic_auth_config.h.

## Constructor & Destructor Documentation

## ◆ ~BasicHttpAuthConfig()

virtual isc::http::BasicHttpAuthConfig::~BasicHttpAuthConfig | ( |  | ) |
| inline virtual

Destructor.

Definition at line 120 of file basic_auth_config.h.

## Member Function Documentation

## ◆ add()

void isc::http::BasicHttpAuthConfig::add | ( | const std::string & | user,
|  | const std::string & | user_file,
|  | const std::string & | password,
|  | const std::string & | password_file,
|  | bool | password_file_only = false,
|  | const isc::data::ConstElementPtr & | user_context = isc::data::ConstElementPtr() )

Add a client configuration.

Parameters

  user | User id.
  user_file | File with the user id.
  password | Password.
  password_file | File with the password.
  password_file_only | Flag true if the password file includes the user id too.
  user_context | Optional user context.

Exceptions

  BadValue | if the user id contains the ':' character.

Definition at line 74 of file basic_auth_config.cc.

References isc::http::BasicHttpAuth::getCredential().

Referenced by parse().

Here is the call graph for this function:

## ◆ checkAuth()

HttpResponseJsonPtr isc::http::BasicHttpAuthConfig::checkAuth | ( | const isc::http::HttpResponseCreator & | creator,
|  | const isc::http::HttpRequestPtr & | request ) const
| virtual

Validate HTTP request.

Parameters

  creator | The HTTP response creator.
  request | The HTTP request to validate.

Returns
  Error HTTP response if validation failed, null otherwise.

Implements isc::http::HttpAuthConfig.

Definition at line 350 of file basic_auth_config.cc.

References isc::http::auth_logger, isc::http::HttpResponseCreator::createStockHttpResponse(), getCredentialMap(), isc::http::HttpAuthConfig::getRealm(), isc::http::HTTP_CLIENT_REQUEST_AUTHORIZED, isc::http::HTTP_CLIENT_REQUEST_BAD_AUTH_HEADER, isc::http::HTTP_CLIENT_REQUEST_NO_AUTH_HEADER, isc::http::HTTP_CLIENT_REQUEST_NOT_AUTHORIZED, isc_throw, LOG_INFO, isc::util::str::lowercase(), isc::http::HttpRequest::recordBasicAuth_, isc::util::str::trim(), isc::http::UNAUTHORIZED, and isc::Exception::what().

Here is the call graph for this function:

## ◆ clear()

void isc::http::BasicHttpAuthConfig::clear | ( |  | ) |
| virtual

Clear configuration.

Implements isc::http::HttpAuthConfig.

Definition at line 88 of file basic_auth_config.cc.

## ◆ empty()

bool isc::http::BasicHttpAuthConfig::empty | ( |  | ) | const
| virtual

Empty predicate.

Returns
  true if the configuration is empty so authentication is not required.

Implements isc::http::HttpAuthConfig.

Definition at line 94 of file basic_auth_config.cc.

## ◆ getClientList()

const BasicHttpAuthClientList & isc::http::BasicHttpAuthConfig::getClientList | ( |  | ) | const
| inline

Returns the list of client configuration.

Returns
  List of basic HTTP authentication client configuration.

Definition at line 157 of file basic_auth_config.h.

## ◆ getCredentialMap()

const BasicHttpAuthMap & isc::http::BasicHttpAuthConfig::getCredentialMap | ( |  | ) | const
| inline

Returns the credential and user id map.

Returns
  The basic HTTP authentication credential and user id map.

Definition at line 164 of file basic_auth_config.h.

Referenced by checkAuth().

## ◆ getFileContent()

string isc::http::BasicHttpAuthConfig::getFileContent | ( | const std::string & | file_name | ) | const

Get the content of {directory}/{file-name} regular file.

Parameters

  file_name | The file name.

Returns
  The content of the {directory}/{file-name} regular file.

Definition at line 99 of file basic_auth_config.cc.

References isc::util::file::getContent(), isc::http::HttpAuthConfig::getDirectory(), isc_throw, and isc::Exception::what().

Referenced by parse().

Here is the call graph for this function:

## ◆ parse()

void isc::http::BasicHttpAuthConfig::parse | ( | const isc::data::ConstElementPtr & | config | ) |
| virtual

Parses basic HTTP authentication configuration.

Parameters

  config | Element holding the basic HTTP authentication configuration to be parsed.

Exceptions

  DhcpConfigError | when the configuration is invalid.

Implements isc::http::HttpAuthConfig.

Definition at line 147 of file basic_auth_config.cc.

References add(), isc::data::DefaultCredentials::check(), getFileContent(), isc_throw, Element::list, Element::map, isc::data::UserContext::setContext(), isc::http::HttpAuthConfig::setDirectory(), isc::http::HttpAuthConfig::setRealm(), and Element::string.

Here is the call graph for this function:

## ◆ toElement()

ElementPtr isc::http::BasicHttpAuthConfig::toElement | ( |  | ) | const
| virtual

Unparses basic HTTP authentication configuration.

Returns
  A pointer to unparsed basic HTTP authentication configuration.

Implements isc::http::HttpAuthConfig.

Definition at line 121 of file basic_auth_config.cc.

References isc::data::UserContext::contextToElement(), Element::create(), Element::createList(), Element::createMap(), isc::http::HttpAuthConfig::getDirectory(), and isc::http::HttpAuthConfig::getRealm().

Here is the call graph for this function:

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

- basic_auth_config.h
- basic_auth_config.cc