* @param user
*/
@Override
+ @Deprecated
public void setCookie(HttpServletResponse response, UserModel user) {
+ setCookie(null, response, user);
+ }
+
+ /**
+ * Sets a cookie for the specified user.
+ *
+ * @param request
+ * @param response
+ * @param user
+ */
+ @Override
+ public void setCookie(HttpServletRequest request, HttpServletResponse response, UserModel user) {
if (settings.getBoolean(Keys.web.allowCookieAuthentication, true)) {
GitBlitWebSession session = GitBlitWebSession.get();
boolean standardLogin = session.authenticationType.isStandard();
userCookie.setMaxAge((int) TimeUnit.DAYS.toSeconds(7));
}
}
- userCookie.setPath("/");
+ String path = "/";
+ if (request != null) {
+ if (!StringUtils.isEmpty(request.getContextPath())) {
+ path = request.getContextPath();
+ }
+ }
+ userCookie.setPath(path);
response.addCookie(userCookie);
}
}
/**
* Logout a user.
*
+ * @param response
* @param user
*/
@Override
+ @Deprecated
public void logout(HttpServletResponse response, UserModel user) {
- setCookie(response, null);
+ setCookie(null, response, null);
+ }
+
+ /**
+ * Logout a user.
+ *
+ * @param request
+ * @param response
+ * @param user
+ */
+ @Override
+ public void logout(HttpServletRequest request, HttpServletResponse response, UserModel user) {
+ setCookie(request, response, null);
}
/**
}
@Override
+ @Deprecated
public void setCookie(HttpServletResponse response, UserModel user) {
authenticationManager.setCookie(response, user);
}
@Override
+ public void setCookie(HttpServletRequest request, HttpServletResponse response, UserModel user) {
+ authenticationManager.setCookie(request, response, user);
+ }
+
+ @Override
+ @Deprecated
public void logout(HttpServletResponse response, UserModel user) {
authenticationManager.logout(response, user);
}
+ @Override
+ public void logout(HttpServletRequest request, HttpServletResponse response, UserModel user) {
+ authenticationManager.logout(request, response, user);
+ }
+
@Override
public boolean supportsCredentialChanges(UserModel user) {
return authenticationManager.supportsCredentialChanges(user);
* @param user
* @since 1.4.0
*/
+ @Deprecated
void setCookie(HttpServletResponse response, UserModel user);
+ /**
+ * Sets a cookie for the specified user.
+ *
+ * @param request
+ * @param response
+ * @param user
+ * @since 1.6.1
+ */
+ void setCookie(HttpServletRequest request, HttpServletResponse response, UserModel user);
+
/**
* Logout a user.
*
* @param user
* @since 1.4.0
*/
+ @Deprecated
void logout(HttpServletResponse response, UserModel user);
+ /**
+ * Logout a user.
+ *
+ * @param request
+ * @param response
+ * @param user
+ * @since 1.6.1
+ */
+ void logout(HttpServletRequest request, HttpServletResponse response, UserModel user);
+
/**
* Does the user service support changes to credentials?
*
import org.apache.wicket.markup.html.form.StatelessForm;\r
import org.apache.wicket.model.IModel;\r
import org.apache.wicket.model.Model;\r
+import org.apache.wicket.protocol.http.WebRequest;\r
import org.apache.wicket.protocol.http.WebResponse;\r
\r
import com.gitblit.GitBlitException;\r
try {\r
app().gitblit().reviseUser(user.username, user);\r
if (app().settings().getBoolean(Keys.web.allowCookieAuthentication, false)) {\r
+ WebRequest request = (WebRequest) getRequestCycle().getRequest();\r
WebResponse response = (WebResponse) getRequestCycle().getResponse();\r
- app().authentication().setCookie(response.getHttpServletResponse(), user);\r
+ app().authentication().setCookie(request.getHttpServletRequest(),\r
+ response.getHttpServletResponse(), user);\r
}\r
} catch (GitBlitException e) {\r
error(e.getMessage());\r
super();\r
GitBlitWebSession session = GitBlitWebSession.get();\r
UserModel user = session.getUser();\r
- app().authentication().logout(((WebResponse) getResponse()).getHttpServletResponse(), user);\r
+ app().authentication().logout(((WebRequest) getRequest()).getHttpServletRequest(),\r
+ ((WebResponse) getResponse()).getHttpServletResponse(), user);\r
session.invalidate();\r
\r
/*\r
import org.apache.wicket.markup.repeater.data.ListDataProvider;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.Model;
+import org.apache.wicket.protocol.http.WebRequest;
import org.apache.wicket.protocol.http.WebResponse;
import com.gitblit.Constants;
// Set Cookie
if (app().settings().getBoolean(Keys.web.allowCookieAuthentication, false)) {
+ WebRequest request = (WebRequest) getRequestCycle().getRequest();
WebResponse response = (WebResponse) getRequestCycle().getResponse();
- app().authentication().setCookie(response.getHttpServletResponse(), user);
+ app().authentication().setCookie(request.getHttpServletRequest(),
+ response.getHttpServletResponse(), user);
}
if (!session.continueRequest()) {
\r
if (user == null || user.disabled) {\r
// user was deleted/disabled during session\r
+ HttpServletRequest request = ((WebRequest) getRequestCycle().getRequest())\r
+ .getHttpServletRequest();\r
HttpServletResponse response = ((WebResponse) getRequestCycle().getResponse())\r
.getHttpServletResponse();\r
- app().authentication().logout(response, user);\r
+ app().authentication().logout(request, response, user);\r
session.setUser(null);\r
session.invalidateNow();\r
return;\r
// cookie was changed during our session\r
HttpServletResponse response = ((WebResponse) getRequestCycle().getResponse())\r
.getHttpServletResponse();\r
- app().authentication().logout(response, user);\r
+ app().authentication().logout(request, response, user);\r
session.setUser(null);\r
session.invalidateNow();\r
return;\r
session.setUser(user);\r
\r
// Set Cookie\r
+ WebRequest request = (WebRequest) getRequestCycle().getRequest();\r
WebResponse response = (WebResponse) getRequestCycle().getResponse();\r
- app().authentication().setCookie(response.getHttpServletResponse(), user);\r
+ app().authentication().setCookie(request.getHttpServletRequest(),\r
+ response.getHttpServletResponse(), user);\r
\r
session.continueRequest();\r
}\r