-
Notifications
You must be signed in to change notification settings - Fork 10
Closed
Description
Hello,
I'm trying to implement the authorization logic in my project,
I face a CORS problem when I get the Unauthorized (401) response from the oatpp server
I know there is a macro ADD_CORS that can handle the CORS problem at each END POINT
but Is it possible to add CORS configuration in my authorize callback function?
class BearerAuthorizationObject : public oatpp::web::server::handler::AuthorizationObject {
public:
// oatpp::String user;
// oatpp::String password;
oatpp::String token;
};
class MyBearerAuthorizationHandler : public oatpp::web::server::handler::BearerAuthorizationHandler {
public:
MyBearerAuthorizationHandler() : oatpp::web::server::handler::BearerAuthorizationHandler("my-realm") {}
std::shared_ptr<AuthorizationObject> authorize(const oatpp::String& token) override {
if (token == "4e99e8c12de7e01535248d2bac85e732") {
auto obj = std::make_shared<BearerAuthorizationObject>();
obj->user = "foo";
obj->password = "bar";
obj->token = token;
return obj;
}
return nullptr;
}
};
Metadata
Metadata
Assignees
Labels
No labels
