-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Improve] Shiro session cannot expire bug fixed (#3939)
* [Improve] Shiro session cannot expire bug fixed * [Improve] accessToken check exists bug fixed. * [Improve] "savepoint" word typo improvement * [Improve] login minor improvement * [Improve] e2e bug fixed. * [Improve] JWT verify bug fixed. * [Improve] jwt test bug fixed.
- Loading branch information
Showing
58 changed files
with
566 additions
and
461 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,6 +45,7 @@ | |
String defaultValue() default ""; | ||
|
||
String bindFor() default ""; | ||
|
||
} | ||
|
||
} |
52 changes: 52 additions & 0 deletions
52
...service/src/main/java/org/apache/streampark/console/core/aspect/AppChangeEventAspect.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.streampark.console.core.aspect; | ||
|
||
import org.apache.streampark.console.core.watcher.FlinkAppHttpWatcher; | ||
|
||
import lombok.extern.slf4j.Slf4j; | ||
import org.aspectj.lang.ProceedingJoinPoint; | ||
import org.aspectj.lang.annotation.Around; | ||
import org.aspectj.lang.annotation.Aspect; | ||
import org.aspectj.lang.annotation.Pointcut; | ||
import org.aspectj.lang.reflect.MethodSignature; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Slf4j | ||
@Component | ||
@Aspect | ||
public class AppChangeEventAspect { | ||
|
||
@Autowired | ||
private FlinkAppHttpWatcher flinkAppHttpWatcher; | ||
|
||
@Pointcut("@annotation(org.apache.streampark.console.core.annotation.AppChangeEvent)") | ||
public void appChangeEventPointcut() { | ||
} | ||
|
||
@Around("appChangeEventPointcut()") | ||
public Object appChangeEvent(ProceedingJoinPoint joinPoint) throws Throwable { | ||
MethodSignature methodSignature = (MethodSignature) joinPoint.getSignature(); | ||
log.debug("appUpdated aspect, method:{}", methodSignature.getName()); | ||
Object target = joinPoint.proceed(); | ||
flinkAppHttpWatcher.init(); | ||
return target; | ||
} | ||
|
||
} |
104 changes: 104 additions & 0 deletions
104
...onsole-service/src/main/java/org/apache/streampark/console/core/aspect/OpenAPIAspect.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.streampark.console.core.aspect; | ||
|
||
import org.apache.streampark.common.util.DateUtils; | ||
import org.apache.streampark.common.util.ReflectUtils; | ||
import org.apache.streampark.console.base.domain.RestResponse; | ||
import org.apache.streampark.console.base.exception.ApiAlertException; | ||
import org.apache.streampark.console.core.annotation.OpenAPI; | ||
import org.apache.streampark.console.system.entity.AccessToken; | ||
|
||
import org.apache.commons.lang3.StringUtils; | ||
import org.apache.shiro.SecurityUtils; | ||
|
||
import lombok.extern.slf4j.Slf4j; | ||
import org.aspectj.lang.ProceedingJoinPoint; | ||
import org.aspectj.lang.annotation.Around; | ||
import org.aspectj.lang.annotation.Aspect; | ||
import org.aspectj.lang.annotation.Pointcut; | ||
import org.aspectj.lang.reflect.MethodSignature; | ||
import org.springframework.stereotype.Component; | ||
import org.springframework.web.context.request.RequestContextHolder; | ||
import org.springframework.web.context.request.ServletRequestAttributes; | ||
|
||
import javax.servlet.http.HttpServletRequest; | ||
|
||
import java.lang.reflect.Field; | ||
import java.util.Date; | ||
import java.util.TimeZone; | ||
|
||
@Slf4j | ||
@Component | ||
@Aspect | ||
public class OpenAPIAspect { | ||
|
||
@Pointcut("execution(public" | ||
+ " org.apache.streampark.console.base.domain.RestResponse" | ||
+ " org.apache.streampark.console.core.controller.*.*(..))") | ||
public void openAPIPointcut() { | ||
} | ||
|
||
@SuppressWarnings("checkstyle:SimplifyBooleanExpression") | ||
@Around(value = "openAPIPointcut()") | ||
public RestResponse openAPI(ProceedingJoinPoint joinPoint) throws Throwable { | ||
MethodSignature methodSignature = (MethodSignature) joinPoint.getSignature(); | ||
log.debug("restResponse aspect, method:{}", methodSignature.getName()); | ||
Boolean isApi = (Boolean) SecurityUtils.getSubject().getSession().getAttribute(AccessToken.IS_API_TOKEN); | ||
if (isApi != null && isApi) { | ||
HttpServletRequest request = | ||
((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); | ||
OpenAPI openAPI = methodSignature.getMethod().getAnnotation(OpenAPI.class); | ||
if (openAPI == null) { | ||
String url = request.getRequestURI(); | ||
throw new ApiAlertException("openapi unsupported: " + url); | ||
} else { | ||
Object[] objects = joinPoint.getArgs(); | ||
for (OpenAPI.Param param : openAPI.param()) { | ||
String bingFor = param.bindFor(); | ||
if (StringUtils.isNotBlank(bingFor)) { | ||
String name = param.name(); | ||
for (Object args : objects) { | ||
Field bindForField = ReflectUtils.getField(args.getClass(), bingFor); | ||
if (bindForField != null) { | ||
Object value = request.getParameter(name); | ||
bindForField.setAccessible(true); | ||
if (value != null) { | ||
if (param.type().equals(String.class)) { | ||
bindForField.set(args, value.toString()); | ||
} else if (param.type().equals(Boolean.class) | ||
|| param.type().equals(boolean.class)) { | ||
bindForField.set(args, Boolean.parseBoolean(value.toString())); | ||
} else if (param.type().equals(Integer.class) || param.type().equals(int.class)) { | ||
bindForField.set(args, Integer.parseInt(value.toString())); | ||
} else if (param.type().equals(Long.class) || param.type().equals(long.class)) { | ||
bindForField.set(args, Long.parseLong(value.toString())); | ||
} else if (param.type().equals(Date.class)) { | ||
bindForField.set(args, DateUtils.parse(value.toString(), DateUtils.fullFormat(), | ||
TimeZone.getDefault())); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
return (RestResponse) joinPoint.proceed(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.