1
0
Fork 0

authentication realm

This commit is contained in:
Jan Steemann 2015-02-13 10:12:35 +01:00
parent a0299f903b
commit 3ffdfe0756
5 changed files with 36 additions and 4 deletions

View File

@ -96,12 +96,24 @@ bool VocbaseContext::useClusterAuthentication () const {
return false; return false;
} }
////////////////////////////////////////////////////////////////////////////////
/// @brief return authentication realm
////////////////////////////////////////////////////////////////////////////////
char const* VocbaseContext::getRealm () const {
if (_vocbase == nullptr) {
return nullptr;
}
return _vocbase->_name;
}
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
/// @brief checks the authentication /// @brief checks the authentication
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
HttpResponse::HttpResponseCode VocbaseContext::authenticate () { HttpResponse::HttpResponseCode VocbaseContext::authenticate () {
TRI_ASSERT(_vocbase != 0); TRI_ASSERT(_vocbase != nullptr);
if (! _vocbase->_settings.requireAuthentication) { if (! _vocbase->_settings.requireAuthentication) {
// no authentication required at all // no authentication required at all

View File

@ -96,6 +96,12 @@ namespace triagens {
bool useClusterAuthentication () const; bool useClusterAuthentication () const;
////////////////////////////////////////////////////////////////////////////////
/// @brief return authentication realm
////////////////////////////////////////////////////////////////////////////////
char const* getRealm () const;
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
/// @brief checks the authentication /// @brief checks the authentication
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////

View File

@ -206,7 +206,15 @@ bool HttpHandlerFactory::setRequestContext (HttpRequest* request) {
/// @brief returns the authentication realm /// @brief returns the authentication realm
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
string const& HttpHandlerFactory::authenticationRealm (HttpRequest*) const { string HttpHandlerFactory::authenticationRealm (HttpRequest* request) const {
auto context = request->getRequestContext();
if (context != nullptr) {
auto realm = context->getRealm();
if (realm != nullptr) {
return _authenticationRealm + "/" + std::string(realm);
}
}
return _authenticationRealm; return _authenticationRealm;
} }

View File

@ -177,7 +177,7 @@ namespace triagens {
/// @brief returns the authentication realm /// @brief returns the authentication realm
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
virtual std::string const& authenticationRealm (HttpRequest*) const; virtual std::string authenticationRealm (HttpRequest*) const;
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
/// @brief creates a new request /// @brief creates a new request

View File

@ -80,9 +80,15 @@ namespace triagens {
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
virtual RequestUser* getRequestUser () { virtual RequestUser* getRequestUser () {
return 0; return nullptr;
} }
////////////////////////////////////////////////////////////////////////////////
/// @brief return authentication realm
////////////////////////////////////////////////////////////////////////////////
virtual char const* getRealm () const = 0;
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
/// @brief authenticate user /// @brief authenticate user
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////