Skip to content

The Unified and Autonomous Development Platform

Several bug fixes and improvements

Robin Shen5291a7224d6d
diff --git a/server-core/src/main/java/io/onedev/server/web/asset/codemirror/addon/scroll/simplescrollbars.css b/server-core/src/main/java/io/onedev/server/web/asset/codemirror/addon/scroll/simplescrollbars.css
index cbf574290e..9f27473a7d 100644
--- a/server-core/src/main/java/io/onedev/server/web/asset/codemirror/addon/scroll/simplescrollbars.css
+++ b/server-core/src/main/java/io/onedev/server/web/asset/codemirror/addon/scroll/simplescrollbars.css
@@ -23,7 +23,7 @@
.CodeMirror-simplescroll-horizontal {
bottom: 0;
left: 0;
- height: 6px;
+ height: 10px;
}
.CodeMirror-simplescroll-horizontal div {
bottom: 0;
@@ -33,7 +33,7 @@
.CodeMirror-simplescroll-vertical {
right: 0;
top: 0;
- width: 6px;
+ width: 10px;
}
.CodeMirror-simplescroll-vertical div {
right: 0;
diff --git a/server-core/src/main/java/io/onedev/server/web/page/admin/ssosetting/SsoProcessPage.java b/server-core/src/main/java/io/onedev/server/web/page/admin/ssosetting/SsoProcessPage.java
index 9b95eedea7..2251e6ff3c 100644
--- a/server-core/src/main/java/io/onedev/server/web/page/admin/ssosetting/SsoProcessPage.java
+++ b/server-core/src/main/java/io/onedev/server/web/page/admin/ssosetting/SsoProcessPage.java
@@ -96,6 +96,15 @@ public class SsoProcessPage extends BasePage {
public static Cookie getConnectorCookie() {
return ((WebRequest) RequestCycle.get().getRequest()).getCookie(COOKIE_CONNECTOR);
}
+
+ public static void clearConnectorCookie() {
+ // Use servlet api to clear cookie which will work even if page is redirected
+ HttpServletResponse response = (HttpServletResponse) RequestCycle.get().getResponse().getContainerResponse();
+ Cookie cookie = new Cookie(COOKIE_CONNECTOR, "");
+ cookie.setMaxAge(0);
+ cookie.setPath("/");
+ response.addCookie(cookie);
+ }
public static PageParameters paramsOf(String stage, String connector) {
PageParameters params = new PageParameters();
diff --git a/server-core/src/main/java/io/onedev/server/web/page/base/BasePage.java b/server-core/src/main/java/io/onedev/server/web/page/base/BasePage.java
index 46416118f6..50003c4784 100644
--- a/server-core/src/main/java/io/onedev/server/web/page/base/BasePage.java
+++ b/server-core/src/main/java/io/onedev/server/web/page/base/BasePage.java
@@ -120,6 +120,17 @@ public abstract class BasePage extends WebPage {
protected void onInitialize() {
super.onInitialize();
+ if (getLoginUser() == null) {
+ Cookie cookie = SsoProcessPage.getConnectorCookie();
+ if (cookie != null) {
+ SsoProcessPage.clearConnectorCookie();
+ new RestartResponseAtInterceptPageException(getPage().getClass());
+ String serverUrl = OneDev.getInstance(SettingManager.class).getSystemSetting().getServerUrl();
+ String redirectUrl = serverUrl + "/" + MOUNT_PATH + "/" + STAGE_INITIATE + "/" + cookie.getValue();
+ throw new RedirectToUrlException(redirectUrl);
+ }
+ }
+
if (!isPermitted())
unauthorized();
@@ -340,24 +351,10 @@ public abstract class BasePage extends WebPage {
}
public void unauthorized() {
- if (getLoginUser() != null) {
+ if (getLoginUser() != null)
throw new UnauthorizedException("You are not allowed to perform this operation");
- } else {
- Cookie cookie = SsoProcessPage.getConnectorCookie();
-
- // Instantiate here to record current page url even if we are redirecting to
- // sso initiating url
- RestartResponseAtInterceptPageException redirectToLoginException =
- new RestartResponseAtInterceptPageException(LoginPage.class);
- if (cookie != null) {
- String serverUrl = OneDev.getInstance(SettingManager.class).getSystemSetting().getServerUrl();
-
- String redirectUrl = serverUrl + "/" + MOUNT_PATH + "/" + STAGE_INITIATE + "/" + cookie.getValue();
- throw new RedirectToUrlException(redirectUrl);
- } else {
- throw redirectToLoginException;
- }
- }
+ else
+ throw new RestartResponseAtInterceptPageException(LoginPage.class);
}
protected String getPageTitle() {
diff --git a/server-core/src/main/java/io/onedev/server/web/page/simple/security/LogoutPage.java b/server-core/src/main/java/io/onedev/server/web/page/simple/security/LogoutPage.java
index 3135a114ec..2f6d54dcaa 100644
--- a/server-core/src/main/java/io/onedev/server/web/page/simple/security/LogoutPage.java
+++ b/server-core/src/main/java/io/onedev/server/web/page/simple/security/LogoutPage.java
@@ -1,10 +1,6 @@
package io.onedev.server.web.page.simple.security;
-import javax.servlet.http.Cookie;
-import javax.servlet.http.HttpServletResponse;
-
import org.apache.wicket.RestartResponseException;
-import org.apache.wicket.request.cycle.RequestCycle;
import org.apache.wicket.request.mapper.parameter.PageParameters;
import io.onedev.server.OneDev;
@@ -21,12 +17,7 @@ public class LogoutPage extends BasePage {
WebSession.get().logout();
- // Use servlet api to clear cookie which will work even if page is redirected
- HttpServletResponse response = (HttpServletResponse) RequestCycle.get().getResponse().getContainerResponse();
- Cookie cookie = new Cookie(SsoProcessPage.COOKIE_CONNECTOR, "");
- cookie.setMaxAge(0);
- cookie.setPath("/");
- response.addCookie(cookie);
+ SsoProcessPage.clearConnectorCookie();
if (getLoginUser() != null || OneDev.getInstance(SettingManager.class).getSecuritySetting().isEnableAnonymousAccess())
getSession().warn("You've been logged out");
diff --git a/server-product/system/incompatibilities/incompatibilities.md b/server-product/system/incompatibilities/incompatibilities.md
index 5513650581..4d3a9a0f93 100644
--- a/server-product/system/incompatibilities/incompatibilities.md
+++ b/server-product/system/incompatibilities/incompatibilities.md
@@ -1,11 +1,12 @@
# 7.8.0
-To be more user friendly, OneDev now uses project path instead of project id to access project via web UI, for instance `https://code.onedev.io/projects/160` has been changed to `https://code.onedev.io/onedev/server`. To avoid conflicting with this url scheme,
-other service urls have been re-organized and this causes two incompatibitlities:
+To use consistent project url for web and git access, OneDev now uses project path instead of project id to access projects via web UI, for instance `https://code.onedev.io/projects/160` has been changed to `https://code.onedev.io/onedev/server`. To avoid conflicting with this url scheme,
+some service urls have been changed and this causes some incompatibitlities:
-1. The RESTful api url now starts with `~api` instead of `api`, for instance url to access project information is now
-`/~api/projects/{projectId}` instead of `/api/projects/{projectId}`
-2. Agents can not upgrade itself for this version, as url connecting to server has been changed. You will need to re-download
+1. The RESTful api url now starts with `~api` instead of `api`, for instance url to access project information is now `/~api/projects/{projectId}`
+2. SSO callback url now takes the form `https://<onedev root url>/~sso/callback/<Provider Name>` (use `~sso` instead of `sso`)
+3. If you are using OAuth based Office365 or Gmail mail service, make sure to change redirect url as `https://<onedev root url>/~oauth/callback` (use `~oauth` instead of `oauth`)
+4. Agents can not upgrade itself for this version, as url connecting to server has been changed. You will need to re-download
agent package from server if running in bare-metal mode, or re-pull the agent image if running in docker mode
# 7.7.0