I have the following function to check the authorization header.
bool is_authorized(http_request request)
{
bool isAuthorized = false;
int bitmask;
int maskResult;
ApplicationAuthorization returned_auth;
ApplicationAuthorizations authorizations;
char authHeader[255];
if (!request.headers().has(header_names::authorization)) return false;
returned_auth = authorizations.GetAuthorization(to_string_t("token {368EB89B-8A5E-5CF3-07AB-C16961D1A392}"));
bitmask = 1 << DATAENGINE;
maskResult = (returned_auth.GetApplicationId() & bitmask);
isAuthorized = maskResult;
return isAuthorized;
}
At the moment I have put in a temporary token just for testing and while I can see how to check if the Authorization header is present - it is not clear how to retrieve the value of that header.
Anyone got an idea how using the Casablanca REST API you can retrieve the header.
The headers are available by calling the headers() function of the request object. The following code puts the authorization header in the authHeader local variable.