feat: 优化context
This commit is contained in:
parent
15854e5f63
commit
21487eadf6
@ -49,19 +49,8 @@ public class AxContextInterceptor implements HandlerInterceptor {
|
||||
|
||||
String authorization = request.getHeader("Authorization");
|
||||
if (!Strings.isNullOrEmpty(authorization) && appRuntime.getEnv() == AppEnvEnum.local) {
|
||||
AxContext authContext = tryGetContextAuthorization(authorization, request);
|
||||
if (authContext.getAxUser() != null) {
|
||||
context.setAxUser(authContext.getAxUser());
|
||||
}
|
||||
if (authContext.getOuId() != null) {
|
||||
context.setOuId(authContext.getOuId());
|
||||
}
|
||||
if (authContext.getWorkspaceId() != null) {
|
||||
context.setWorkspaceId(authContext.getWorkspaceId());
|
||||
}
|
||||
if (authContext.getTerminal() != null) {
|
||||
context.setTerminal(authContext.getTerminal());
|
||||
}
|
||||
AxContext localContext = tryGetContextAuthorization(authorization, request);
|
||||
merge(context, localContext);
|
||||
}
|
||||
AxContext.set(context);
|
||||
return true;
|
||||
@ -73,6 +62,24 @@ public class AxContextInterceptor implements HandlerInterceptor {
|
||||
AxContext.clear();
|
||||
}
|
||||
|
||||
private void merge(AxContext headerContext, AxContext localContext) {
|
||||
if (localContext == null) {
|
||||
return;
|
||||
}
|
||||
if (localContext.getAxUser() != null) {
|
||||
headerContext.setAxUser(localContext.getAxUser());
|
||||
}
|
||||
if (localContext.getOuId() != null) {
|
||||
headerContext.setOuId(localContext.getOuId());
|
||||
}
|
||||
if (localContext.getWorkspaceId() != null) {
|
||||
headerContext.setWorkspaceId(localContext.getWorkspaceId());
|
||||
}
|
||||
if (localContext.getTerminal() != null) {
|
||||
headerContext.setTerminal(localContext.getTerminal());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 支持传入明文的authentication 或者通过puge接口支持
|
||||
* 明文格式: authentication: Raw {ouid:xxx, axUser:{personId:xxx}}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user