Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1.增加dataway页面UI请求是否启用跨域配置,默认不开启 #97

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ protected void loadAdminService(WebApiBinder apiBinder, String apiBaseUri, Strin
AdminUiAuthorization uiAuthorization = new AdminUiAuthorization(adminBaseUri, apiBinder.getEnvironment());
apiBinder.filter(fixUrl(adminBaseUri + "/*")).through(Integer.MAX_VALUE, HasorUtils.autoAware(apiBinder.getEnvironment(), uiAuthorization));
apiBinder.filter(fixUrl(adminBaseUri + "/*")).through(Integer.MAX_VALUE, new InterfaceAuthorizationFilter(adminBaseUri));
apiBinder.filter(fixUrl(adminBaseUri + "/*")).through(Integer.MAX_VALUE, new InterfaceUiFilter(adminBaseUri));
apiBinder.filter(fixUrl(adminBaseUri + "/*")).through(Integer.MAX_VALUE, new InterfaceUiFilter(apiBinder.getEnvironment(), adminBaseUri));
}

private void loadController(WebApiBinder apiBinder, Class<?> aClass, String adminBaseUri, String apiBaseUri) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package net.hasor.dataway.service;
import com.alibaba.fastjson.JSON;
import net.hasor.core.Environment;
import net.hasor.dataway.config.DatawayUtils;
import net.hasor.utils.ResourcesUtils;
import net.hasor.utils.StringUtils;
Expand Down Expand Up @@ -47,8 +48,10 @@ public class InterfaceUiFilter implements InvokerFilter {
private final String uiBaseUri;
private final String uiAdminBaseUri;
private final Map<String, Integer> resourceSize;
private final Boolean enableCross;

public InterfaceUiFilter(String uiBaseUri) {
public InterfaceUiFilter(Environment environment, String uiBaseUri) {
this.enableCross = environment.getSettings().getBoolean("hasor.dataway.interfaceUICross", false);
this.uiBaseUri = uiBaseUri;
this.uiAdminBaseUri = fixUrl(uiBaseUri + "/api/");
this.resourceIndexUri = fixUrl(uiBaseUri + "/index.html");
Expand All @@ -64,7 +67,9 @@ public Object doInvoke(Invoker invoker, InvokerChain chain) throws Throwable {
HttpServletRequest httpRequest = invoker.getHttpRequest();
HttpServletResponse httpResponse = invoker.getHttpResponse();
String requestURI = invoker.getRequestPath();
setupInner(invoker);
if (this.enableCross) {
setupInner(invoker);
}
if (requestURI.startsWith(this.uiAdminBaseUri)) {
try {
DatawayUtils.resetLocalTime();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
<HASOR_DATAQL_DATAWAY_AUTHORIZATION_PASSWORD>admin</HASOR_DATAQL_DATAWAY_AUTHORIZATION_PASSWORD>
<!-- 登陆页面资源 -->
<HASOR_DATAQL_DATAWAY_AUTHORIZATION_LOGIN_PAGE>classpath:/META-INF/hasor-framework/dataway-ui/login.html</HASOR_DATAQL_DATAWAY_AUTHORIZATION_LOGIN_PAGE>
<!-- 是否启用UI界面跨域功能 -->
<HASOR_DATAQL_DATAWAY_INTERFACE_UI_CROSS>false</HASOR_DATAQL_DATAWAY_INTERFACE_UI_CROSS>

<!-- nacos 的服务地址 -->
<HASOR_NACOS_ADDR></HASOR_NACOS_ADDR>
Expand Down Expand Up @@ -72,6 +74,8 @@
<!-- dataway-ui 的工作路径,必须开启管理功能 -->
<baseAdminUrl>${HASOR_DATAQL_DATAWAY_UI_URL}</baseAdminUrl>

<!-- dataway-interface-ui 是否启用跨域(一般测试时开启) -->
<interfaceUICross>${HASOR_DATAQL_DATAWAY_INTERFACE_UI_CROSS}</interfaceUICross>
<!-- 是否启用 Admin UI 的登陆认证 -->
<!-- enable : 是否启用,默认 true 启用、false 为不启用 -->
<authorization enable="${HASOR_DATAQL_DATAWAY_AUTHORIZATION_ENABLE}">
Expand Down