This commit is contained in:
parent
2534882296
commit
cb6525636c
@ -68,14 +68,25 @@ Application::Application(const Wt::WEnvironment &env, bool embedded)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
LOG(info) << "url: " << url();
|
|
||||||
LOG(info) << "relative resources url: " << relativeResourcesUrl();
|
|
||||||
LOG(info) << "resources url: " << resourcesUrl();
|
|
||||||
LOG(info) << "internal path: " << internalPath();
|
|
||||||
LOG(info) << "bookmark url: " << bookmarkUrl("/");
|
|
||||||
LOG(info) << "relative url: " << resolveRelativeUrl("/");
|
|
||||||
|
|
||||||
auto app = Amass::Singleton<WebToolkit::Server>::instance();
|
auto app = Amass::Singleton<WebToolkit::Server>::instance();
|
||||||
|
bool authTokensEnabled = app->authService().authTokensEnabled();
|
||||||
|
std::string authTokenCookieName = app->authService().authTokenCookieName();
|
||||||
|
std::string authTokenCookieDomain = app->authService().authTokenCookieDomain();
|
||||||
|
if (env.hostName().find("amass.fun") != std::string::npos) {
|
||||||
|
if (authTokenCookieDomain != AuthModel::CookieDomain) {
|
||||||
|
app->authService().setAuthTokensEnabled(authTokensEnabled, authTokenCookieName, AuthModel::CookieDomain);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (!authTokenCookieDomain.empty()) {
|
||||||
|
app->authService().setAuthTokensEnabled(authTokensEnabled, authTokenCookieName, "");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
LOG(info) << "url: " << url() << ", host name: " << env.hostName();
|
||||||
|
LOG(info) << "resources url: " << resourcesUrl() << ", relative resources url: " << relativeResourcesUrl();
|
||||||
|
LOG(info) << "internal path: " << internalPath() << ", bookmark url: " << bookmarkUrl();
|
||||||
|
|
||||||
m_loginPage = std::make_unique<LoginPage>(app->authService(), m_session->users(), m_session->login());
|
m_loginPage = std::make_unique<LoginPage>(app->authService(), m_session->users(), m_session->login());
|
||||||
if (externalPath.empty()) {
|
if (externalPath.empty()) {
|
||||||
m_loginPage->processEnvironment();
|
m_loginPage->processEnvironment();
|
||||||
@ -130,6 +141,7 @@ void Application::authEvent() {
|
|||||||
auto token = env.getCookie(service.authTokenCookieName());
|
auto token = env.getCookie(service.authTokenCookieName());
|
||||||
if (token == nullptr) {
|
if (token == nullptr) {
|
||||||
Wt::Http::Cookie cookie(service.authTokenCookieName(), service.createAuthToken(u));
|
Wt::Http::Cookie cookie(service.authTokenCookieName(), service.createAuthToken(u));
|
||||||
|
cookie.setDomain(service.authTokenCookieDomain());
|
||||||
cookie.setPath(AuthModel::CookiePath);
|
cookie.setPath(AuthModel::CookiePath);
|
||||||
cookie.setExpires(Wt::WDateTime());
|
cookie.setExpires(Wt::WDateTime());
|
||||||
setCookie(cookie);
|
setCookie(cookie);
|
||||||
@ -248,6 +260,7 @@ void Server::insertCookie(const std::string &cookie) {
|
|||||||
Wt::Http::Cookie Server::updateCookie(const std::string &oldCookie, const Wt::Auth::AuthTokenResult &result, bool secure) {
|
Wt::Http::Cookie Server::updateCookie(const std::string &oldCookie, const Wt::Auth::AuthTokenResult &result, bool secure) {
|
||||||
Wt::Http::Cookie cookie(m_authService->authTokenCookieName());
|
Wt::Http::Cookie cookie(m_authService->authTokenCookieName());
|
||||||
cookie.setPath(AuthModel::CookiePath);
|
cookie.setPath(AuthModel::CookiePath);
|
||||||
|
cookie.setDomain(m_authService->authTokenCookieDomain());
|
||||||
cookie.setSecure(secure);
|
cookie.setSecure(secure);
|
||||||
if (result.state() == Wt::Auth::AuthTokenState::Invalid) {
|
if (result.state() == Wt::Auth::AuthTokenState::Invalid) {
|
||||||
if (m_cookies.contains(oldCookie)) {
|
if (m_cookies.contains(oldCookie)) {
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
class AuthModel : public Wt::Auth::AuthModel {
|
class AuthModel : public Wt::Auth::AuthModel {
|
||||||
public:
|
public:
|
||||||
static constexpr auto CookiePath = "/";
|
static constexpr auto CookiePath = "/";
|
||||||
|
static constexpr auto CookieDomain = ".amass.fun";
|
||||||
AuthModel(const Wt::Auth::AuthService &baseAuth, Wt::Auth::AbstractUserDatabase &users);
|
AuthModel(const Wt::Auth::AuthService &baseAuth, Wt::Auth::AbstractUserDatabase &users);
|
||||||
Wt::Auth::User processAuthToken() final;
|
Wt::Auth::User processAuthToken() final;
|
||||||
void setRememberMeCookie(const Wt::Auth::User &user) final;
|
void setRememberMeCookie(const Wt::Auth::User &user) final;
|
||||||
|
Loading…
Reference in New Issue
Block a user