UserManWebAuthenticator

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.

Constructors

this
this(UserManAPI api, string prefix)
Undocumented in source.
this
deprecated this(UserManController controller, string prefix)
Undocumented in source.

Members

Functions

auth
HTTPServerRequestDelegate auth(void delegate(HTTPServerRequest, HTTPServerResponse, User) callback)
Undocumented in source. Be warned that the author may not have intended to support it.
auth
HTTPServerRequestDelegate auth(HTTPServerRequestDelegate callback)
Undocumented in source. Be warned that the author may not have intended to support it.
ifAuth
HTTPServerRequestDelegate ifAuth(void delegate(HTTPServerRequest, HTTPServerResponse, User) callback)
Undocumented in source. Be warned that the author may not have intended to support it.
performAuth
User performAuth(HTTPServerRequest req, HTTPServerResponse res)
Undocumented in source. Be warned that the author may not have intended to support it.

Examples

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)));
}

See Also

authenticate

Meta