An example using a plain vibe.http.router.URLRouter based authentication approach.
import std.functional; // toDelegate import vibe.http.router; import vibe.http.server; void getIndex(HTTPServerRequest req, HTTPServerResponse res) { //render!"welcome.dt" } void getPrivatePage(HTTPServerRequest req, HTTPServerResponse res, User user) { // render a private page with some user specific information //render!("private_page.dt", _user); } void registerMyService(URLRouter router, UserManAPI userman) { auto authenticator = new UserManWebAuthenticator(userman); router.registerUserManWebInterface(userman); router.get("/", &getIndex); router.any("/private_page", authenticator.auth(toDelegate(&getPrivatePage))); }
authenticate
Used to provide request authentication for web applications.
Note that it is generally recommended to use the vibe.web.auth mechanism together with authenticate instead of using this class.