Bug #11301 » 0002-WT-11301-add-WServer-addResource-taking-a-shared_ptr.patch
ReleaseNotes.html | ||
---|---|---|
When the user tries to log in now, an info message will be shown saying they need to verify their email first along with a new button to resend the verification email. The user must then enter the email address again in a dialog before the email is sent.<br/>
|
||
The virtual methods <a href="classWt_1_1Auth_1_1AuthWidget.html#a42f87508868746e5ccef5695fcbd8763">AuthWidget::letResendEmailVerification()</a> and <a href="classWt_1_1Auth_1_1AuthWidget.html#af45dea06ac5751e96499d62507fea69d">AuthWidget::createResendEmailVerificationView()</a> can be used to customize the UI.
|
||
</li>
|
||
<li>
|
||
<a href="classWt_1_1WServer.html#aa17f85dc130b616b3fcf63aa857ff579">WServer::addResource()</a>
|
||
can now take a <code>shared_ptr</code> instead of a raw pointer,
|
||
enforcing that the resource lives at least as long as the server, unless removed with
|
||
<a href="classWt_1_1WServer.html#a9f5a82118198a1d2341fb89572fd8693">WServer::removeEntryPoint()</a>.
|
||
The overload that takes a raw pointer is now deprecated.
|
||
This also fixes <a href="https://redmine.webtoolkit.eu/issues/11301" target="_blank">issue #11301</a>, where there
|
||
could be a use-after-free in <code>test.http</code>.
|
||
</li>
|
||
</ul>
|
||
<h2>Release 4.9.2 (TBD)</h2>
|
examples/blog/blog.C | ||
---|---|---|
std::unique_ptr<Wt::Dbo::SqlConnectionPool> blogDb
|
||
= BlogSession::createConnectionPool(server.appRoot() + "blog.db");
|
||
BlogRSSFeed rssFeed(*blogDb, "Wt blog example", "", "It's just an example.");
|
||
auto rssFeed = std::make_shared<BlogRSSFeed>(*blogDb, "Wt blog example", "", "It's just an example.");
|
||
server.addResource(&rssFeed, FeedUrl);
|
||
server.addResource(rssFeed, FeedUrl);
|
||
//When the blog application is deployed in ISAPI on the path "/blog"
|
||
//the resources (css+images) are not fetched correctly
|
||
server.addEntryPoint(Wt::EntryPointType::Application,
|
examples/feature/oidc/Oidc.C | ||
---|---|---|
});
|
||
Session tokenSession(dbPath);
|
||
Wt::Auth::OAuthTokenEndpoint tokenEndpoint{tokenSession.users(), deployUrl};
|
||
server.addResource(&tokenEndpoint, "/oauth2/token");
|
||
auto tokenEndpoint = std::make_shared<Wt::Auth::OAuthTokenEndpoint>(tokenSession.users(), deployUrl);
|
||
server.addResource(tokenEndpoint, "/oauth2/token");
|
||
Session userInfoSession(dbPath);
|
||
Wt::Auth::OidcUserInfoEndpoint userInfoEndpoint{userInfoSession.users()};
|
||
server.addResource(&userInfoEndpoint, "/oidc/userinfo");
|
||
auto userInfoEndpoint = std::make_shared<Wt::Auth::OidcUserInfoEndpoint>(userInfoSession.users());
|
||
server.addResource(userInfoEndpoint, "/oidc/userinfo");
|
||
Session::configureAuth();
|
||
examples/feature/urlparams/urlparams.C | ||
---|---|---|
int main(int argc, char *argv[])
|
||
{
|
||
Resource resource;
|
||
try {
|
||
Wt::WServer server{argc, argv, WTHTTP_CONFIGURATION};
|
||
server.addResource(&resource, "/users");
|
||
server.addResource(&resource, "/users/${user}");
|
||
server.addResource(&resource, "/users/${user}/posts");
|
||
server.addResource(&resource, "/users/${user}/posts/${post}");
|
||
auto resource = std::make_shared<Resource>();
|
||
server.addResource(resource, "/users");
|
||
server.addResource(resource, "/users/${user}");
|
||
server.addResource(resource, "/users/${user}/posts");
|
||
server.addResource(resource, "/users/${user}/posts/${post}");
|
||
server.run();
|
||
} catch (const Wt::WServer::Exception &e) {
|
examples/te-benchmark/benchmark.cpp | ||
---|---|---|
bundle->use(server.appRoot() + "fortunes");
|
||
server.setLocalizedStrings(bundle);
|
||
JsonResource jsonResource;
|
||
server.addResource(&jsonResource, "/json");
|
||
server.addResource(std::make_shared<JsonResource>(), "/json");
|
||
DbResource dbResource;
|
||
server.addResource(&dbResource, "/db");
|
||
server.addResource(std::make_shared<DbResource>(), "/db");
|
||
QueriesResource queriesResource;
|
||
server.addResource(&queriesResource, "/queries");
|
||
server.addResource(std::make_shared<QueriesResource>(), "/queries");
|
||
FortuneResource fortuneResource;
|
||
server.addResource(&fortuneResource, "/fortune");
|
||
server.addResource(std::make_shared<FortuneResource>(), "/fortune");
|
||
UpdateResource updateResource;
|
||
server.addResource(&updateResource, "/updates");
|
||
server.addResource(std::make_shared<UpdateResource>(), "/updates");
|
||
PlaintextResource plaintextResource;
|
||
server.addResource(&plaintextResource, "/plaintext");
|
||
server.addResource(std::make_shared<PlaintextResource>(), "/plaintext");
|
||
if (server.start()) {
|
||
int sig = Wt::WServer::waitForShutdown();
|
examples/wt-homepage/main.C | ||
---|---|---|
std::unique_ptr<Dbo::SqlConnectionPool> blogDb
|
||
= BlogSession::createConnectionPool(server.appRoot() + "blog.db");
|
||
BlogRSSFeed rssFeed(*blogDb, "Wt and JWt blog",
|
||
"http://www.webtoolkit.eu/wt/blog",
|
||
"We care about our webtoolkits.");
|
||
auto rssFeed = std::make_shared<BlogRSSFeed>(*blogDb,
|
||
"Wt and JWt blog",
|
||
"http://www.webtoolkit.eu/wt/blog",
|
||
"We care about our webtoolkits.");
|
||
server.addResource(&rssFeed, "/wt/blog/feed/");
|
||
server.addResource(rssFeed, "/wt/blog/feed/");
|
||
server.addEntryPoint(EntryPointType::Application,
|
||
std::bind(&createJWtHomeApplication, std::placeholders::_1, blogDb.get()),
|
src/Wt/Auth/OAuthService.C | ||
---|---|---|
#include "WebSession.h"
|
||
#include "WebRequest.h"
|
||
#include <memory>
|
||
#ifdef WT_THREADED
|
||
#include <mutex>
|
||
#endif // WT_THREADED
|
||
... | ... | |
const OAuthService& service_;
|
||
};
|
||
std::unique_ptr<RedirectEndpoint> redirectResource_;
|
||
std::shared_ptr<RedirectEndpoint> redirectResource_;
|
||
std::string secret_;
|
||
};
|
||
... | ... | |
std::unique_lock<std::mutex> guard(impl_->mutex_);
|
||
#endif
|
||
if (!impl_->redirectResource_) {
|
||
auto r = std::unique_ptr<Impl::RedirectEndpoint>(new Impl::RedirectEndpoint(*this));
|
||
auto r = std::make_shared<Impl::RedirectEndpoint>(*this);
|
||
std::string path = redirectEndpointPath();
|
||
LOG_INFO("deploying endpoint at " << path);
|
||
... | ... | |
else
|
||
server = WServer::instance();
|
||
server->addResource(r.get(), path);
|
||
server->addResource(r, path);
|
||
impl_->redirectResource_ = std::move(r);
|
||
impl_->redirectResource_ = r;
|
||
}
|
||
}
|
||
}
|
src/Wt/Auth/Saml/Service.C | ||
---|---|---|
void Service::generateAcsEndpoint()
|
||
{
|
||
auto resource = std::make_unique<StaticAcsResource>(*this);
|
||
auto resource = std::make_shared<StaticAcsResource>(*this);
|
||
std::string path = acsPath();
|
||
LOG_INFO("deploying endpoint at " << path);
|
||
... | ... | |
server = WServer::instance();
|
||
}
|
||
server->addResource(resource.get(), path);
|
||
staticAcsResource_ = std::move(resource);
|
||
server->addResource(resource, path);
|
||
}
|
||
void Service::generateMetadataEndpoint()
|
||
... | ... | |
if (metadataPath_.empty())
|
||
return;
|
||
metadataResource_ = std::make_unique<MetadataResource>(*this);
|
||
auto resource = std::make_shared<MetadataResource>(*this);
|
||
WApplication *app = WApplication::instance();
|
||
WServer *server = nullptr;
|
||
if (app) {
|
||
... | ... | |
server = WServer::instance();
|
||
}
|
||
server->addResource(metadataResource_.get(), metadataPath_);
|
||
server->addResource(resource, metadataPath_);
|
||
}
|
||
std::string Service::metadata() const
|
src/Wt/Auth/Saml/Service.h | ||
---|---|---|
// state
|
||
std::unique_ptr<ServiceImpl> impl_;
|
||
std::unique_ptr<StaticAcsResource> staticAcsResource_;
|
||
std::unique_ptr<MetadataResource> metadataResource_;
|
||
// configuration
|
||
std::string secret_;
|
src/Wt/WServer.C | ||
---|---|---|
}
|
||
}
|
||
void WServer::addResource(const std::shared_ptr<WResource> &resource,
|
||
const std::string &path)
|
||
{
|
||
bool success = configuration().tryAddResource(EntryPoint(resource, prependDefaultPath(path)));
|
||
if (success) {
|
||
resource->setInternalPath(path);
|
||
} else {
|
||
WString error(Wt::utf8("WServer::addResource() error: "
|
||
"a static resource was already deployed on path '{1}'"));
|
||
throw WServer::Exception(error.arg(path).toUTF8());
|
||
}
|
||
}
|
||
void WServer::removeEntryPoint(const std::string& path){
|
||
configuration().removeEntryPoint(path);
|
||
}
|
src/Wt/WServer.h | ||
---|---|---|
* public. Use this method to add a public resource with a fixed
|
||
* path.
|
||
*
|
||
* \throw Exception if an entrypoint was already registered at the given path
|
||
*
|
||
* \sa removeEntryPoint()
|
||
*/
|
||
WT_API void addResource(const std::shared_ptr<WResource>& resource, const std::string& path);
|
||
/*! \brief Binds a resource to a fixed path.
|
||
*
|
||
* Resources may either be private to a single session or
|
||
* public. Use this method to add a public resource with a fixed
|
||
* path.
|
||
*
|
||
* \note Ownership of the resource is external to %WServer. The resource first needs
|
||
* to be \link removeEntryPoint() removed\endlink (while the server is
|
||
* \link stop() stopped\endlink) before being destroyed, or has to outlive the %WServer.
|
||
*
|
||
* \throw Exception if an entrypoint was already registered at the given path
|
||
*
|
||
* \sa removeEntryPoint()
|
||
*
|
||
* \deprecated Use addResource(const std::shared_ptr<WResource>&, const std::string&) instead.
|
||
*/
|
||
WT_DEPRECATED("Use addResource(const std::shared_ptr<WResource>&, const std::string&) instead")
|
||
WT_API void addResource(WResource *resource, const std::string& path);
|
||
/*! \brief Removes an entry point.
|
src/web/EntryPoint.C | ||
---|---|---|
path_(path)
|
||
{ }
|
||
EntryPoint::EntryPoint(const std::shared_ptr<WResource>& resource, const std::string& path)
|
||
: type_(EntryPointType::StaticResource),
|
||
resource_(resource.get()),
|
||
ownedResource_(resource),
|
||
appCallback_(nullptr),
|
||
path_(path)
|
||
{ }
|
||
EntryPoint::~EntryPoint()
|
||
{
|
||
}
|
src/web/EntryPoint.h | ||
---|---|---|
const std::string& path,
|
||
const std::string& favicon);
|
||
EntryPoint(WResource *resource, const std::string& path);
|
||
EntryPoint(const std::shared_ptr<WResource>& resource, const std::string& path);
|
||
~EntryPoint();
|
||
void setPath(const std::string& path);
|
||
... | ... | |
private:
|
||
EntryPointType type_;
|
||
WResource *resource_;
|
||
std::shared_ptr<WResource> ownedResource_;
|
||
ApplicationCreator appCallback_;
|
||
std::string path_;
|
||
std::string favicon_;
|
test/http/HttpClientServerTest.C | ||
---|---|---|
"--docroot", "."
|
||
};
|
||
setServerConfiguration(argc, (char **)argv);
|
||
addResource(&resource_, "/test");
|
||
resource_ = std::make_shared<TestResource>();
|
||
addResource(resource_, "/test");
|
||
}
|
||
std::string address()
|
||
... | ... | |
return "127.0.0.1:" + std::to_string(httpPort());
|
||
}
|
||
TestResource& resource() { return resource_; }
|
||
TestResource& resource() { return *resource_; }
|
||
private:
|
||
TestResource resource_;
|
||
std::shared_ptr<TestResource> resource_;
|
||
};
|
||
class Client : public Wt::WObject {
|