summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorEd Tanous <ed.tanous@intel.com>2019-03-05 04:35:53 +0300
committerEd Tanous <ed.tanous@intel.com>2019-03-07 00:53:46 +0300
commit39e77504ba0d1e8de273cd54e1f000166bfa6d0d (patch)
tree1dcb4a60df9460d8479db5282c5082058f4401fe /include
parentf1eebf06f717d8561ff9bef2828c420ef051cb05 (diff)
downloadbmcweb-39e77504ba0d1e8de273cd54e1f000166bfa6d0d.tar.xz
bmcweb: /s/boost::string_view/std::string_view/g
With boost 1.69, we get the new option, BOOST_BEAST_USE_STD_STRING_VIEW which allows us to use std::string for all beast interfaces, instead of boost string_view. This was originally intended to try to reduce the binary size, but the comparison shows only a minor improvement. boost::string_view: 7420780 bytes std::string_view: 7419948 bytes 832 bytes saved ! ! ! ! ! So instead, we will use the argument that it's more standard and easier for people to grok. Tested By: Pulled down some bmcweb endpoints, and observed no change. Because the two objects are essentially drop in replacements for one another, there should be no change. Change-Id: I001e8cf2a0124de4792a7154bf246e3c35ef3f97 Signed-off-by: Ed Tanous <ed.tanous@intel.com>
Diffstat (limited to 'include')
-rw-r--r--include/http_utility.hpp4
-rw-r--r--include/pam_authenticate.hpp8
-rw-r--r--include/sessions.hpp6
-rw-r--r--include/token_authorization_middleware.hpp24
4 files changed, 21 insertions, 21 deletions
diff --git a/include/http_utility.hpp b/include/http_utility.hpp
index 0f5bb8ce32..e2b1a11f64 100644
--- a/include/http_utility.hpp
+++ b/include/http_utility.hpp
@@ -5,7 +5,7 @@ namespace http_helpers
{
inline bool requestPrefersHtml(const crow::Request& req)
{
- boost::string_view header = req.getHeaderValue("accept");
+ std::string_view header = req.getHeaderValue("accept");
std::vector<std::string> encodings;
// chrome currently sends 6 accepts headers, firefox sends 4.
encodings.reserve(6);
@@ -25,7 +25,7 @@ inline bool requestPrefersHtml(const crow::Request& req)
return false;
}
-inline std::string urlEncode(const boost::string_view value)
+inline std::string urlEncode(const std::string_view value)
{
std::ostringstream escaped;
escaped.fill('0');
diff --git a/include/pam_authenticate.hpp b/include/pam_authenticate.hpp
index 7f2a33c866..f211a29ec7 100644
--- a/include/pam_authenticate.hpp
+++ b/include/pam_authenticate.hpp
@@ -17,7 +17,7 @@ inline int pamFunctionConversation(int numMsg, const struct pam_message** msg,
char* appPass = reinterpret_cast<char*>(appdataPtr);
size_t appPassSize = std::strlen(appPass);
char* pass = reinterpret_cast<char*>(malloc(appPassSize + 1));
- if (!pass)
+ if (pass == nullptr)
{
return PAM_AUTH_ERR;
}
@@ -27,7 +27,7 @@ inline int pamFunctionConversation(int numMsg, const struct pam_message** msg,
*resp = reinterpret_cast<pam_response*>(
calloc(numMsg, sizeof(struct pam_response)));
- if (resp == NULL)
+ if (resp == nullptr)
{
return PAM_AUTH_ERR;
}
@@ -47,8 +47,8 @@ inline int pamFunctionConversation(int numMsg, const struct pam_message** msg,
return PAM_SUCCESS;
}
-inline bool pamAuthenticateUser(const boost::string_view username,
- const boost::string_view password)
+inline bool pamAuthenticateUser(const std::string_view username,
+ const std::string_view password)
{
std::string userStr(username);
std::string passStr(password);
diff --git a/include/sessions.hpp b/include/sessions.hpp
index 510f566476..6bc1c99f04 100644
--- a/include/sessions.hpp
+++ b/include/sessions.hpp
@@ -102,7 +102,7 @@ class SessionStore
{
public:
std::shared_ptr<UserSession> generateUserSession(
- const boost::string_view username,
+ const std::string_view username,
PersistenceType persistence = PersistenceType::TIMEOUT)
{
// TODO(ed) find a secure way to not generate session identifiers if
@@ -148,7 +148,7 @@ class SessionStore
}
std::shared_ptr<UserSession>
- loginSessionByToken(const boost::string_view token)
+ loginSessionByToken(const std::string_view token)
{
applySessionTimeouts();
auto sessionIt = authTokens.find(std::string(token));
@@ -161,7 +161,7 @@ class SessionStore
return userSession;
}
- std::shared_ptr<UserSession> getSessionByUid(const boost::string_view uid)
+ std::shared_ptr<UserSession> getSessionByUid(const std::string_view uid)
{
applySessionTimeouts();
// TODO(Ed) this is inefficient
diff --git a/include/token_authorization_middleware.hpp b/include/token_authorization_middleware.hpp
index b186a5fb51..c5c65230a1 100644
--- a/include/token_authorization_middleware.hpp
+++ b/include/token_authorization_middleware.hpp
@@ -39,7 +39,7 @@ class Middleware
}
if (ctx.session == nullptr)
{
- boost::string_view authHeader = req.getHeaderValue("Authorization");
+ std::string_view authHeader = req.getHeaderValue("Authorization");
if (!authHeader.empty())
{
// Reject any kind of auth other than basic or token
@@ -104,12 +104,12 @@ class Middleware
private:
const std::shared_ptr<crow::persistent_data::UserSession>
- performBasicAuth(boost::string_view auth_header) const
+ performBasicAuth(std::string_view auth_header) const
{
BMCWEB_LOG_DEBUG << "[AuthMiddleware] Basic authentication";
std::string authData;
- boost::string_view param = auth_header.substr(strlen("Basic "));
+ std::string_view param = auth_header.substr(strlen("Basic "));
if (!crow::utility::base64Decode(param, authData))
{
return nullptr;
@@ -146,11 +146,11 @@ class Middleware
}
const std::shared_ptr<crow::persistent_data::UserSession>
- performTokenAuth(boost::string_view auth_header) const
+ performTokenAuth(std::string_view auth_header) const
{
BMCWEB_LOG_DEBUG << "[AuthMiddleware] Token authentication";
- boost::string_view token = auth_header.substr(strlen("Token "));
+ std::string_view token = auth_header.substr(strlen("Token "));
auto session =
persistent_data::SessionStore::getInstance().loginSessionByToken(
token);
@@ -162,7 +162,7 @@ class Middleware
{
BMCWEB_LOG_DEBUG << "[AuthMiddleware] X-Auth-Token authentication";
- boost::string_view token = req.getHeaderValue("X-Auth-Token");
+ std::string_view token = req.getHeaderValue("X-Auth-Token");
if (token.empty())
{
return nullptr;
@@ -178,7 +178,7 @@ class Middleware
{
BMCWEB_LOG_DEBUG << "[AuthMiddleware] Cookie authentication";
- boost::string_view cookieValue = req.getHeaderValue("Cookie");
+ std::string_view cookieValue = req.getHeaderValue("Cookie");
if (cookieValue.empty())
{
return nullptr;
@@ -195,7 +195,7 @@ class Middleware
{
endIndex = cookieValue.size();
}
- boost::string_view authKey =
+ std::string_view authKey =
cookieValue.substr(startIndex, endIndex - startIndex);
const std::shared_ptr<crow::persistent_data::UserSession> session =
@@ -209,7 +209,7 @@ class Middleware
// RFC7231 defines methods that need csrf protection
if (req.method() != "GET"_method)
{
- boost::string_view csrf = req.getHeaderValue("X-XSRF-TOKEN");
+ std::string_view csrf = req.getHeaderValue("X-XSRF-TOKEN");
// Make sure both tokens are filled
if (csrf.empty() || session->csrfToken.empty())
{
@@ -274,9 +274,9 @@ template <typename... Middlewares> void requestRoutes(Crow<Middlewares...>& app)
BMCWEB_ROUTE(app, "/login")
.methods(
"POST"_method)([&](const crow::Request& req, crow::Response& res) {
- boost::string_view contentType = req.getHeaderValue("content-type");
- boost::string_view username;
- boost::string_view password;
+ std::string_view contentType = req.getHeaderValue("content-type");
+ std::string_view username;
+ std::string_view password;
bool looksLikeIbm = false;