Search in sources :

Example 11 with BizSystemModule

use of com.mendmix.gateway.model.BizSystemModule in project jeesuite-libs by vakinge.

the class GatewayReactiveCustomAuthnHandler method customAuthentication.

@Override
public boolean customAuthentication(ServerWebExchange exchange) {
    BizSystemModule module = RuequestHelper.getCurrentModule(exchange);
    ServerHttpRequest request = exchange.getRequest();
    if (module.getAnonUriMatcher() != null && module.getAnonUriMatcher().match(request.getPath().value())) {
        return true;
    }
    boolean pass = request.getHeaders().containsKey(GatewayConstants.X_SIGN_HEADER);
    if (!pass) {
        pass = isIpWhilelistAccess(request);
    }
    if (!pass) {
        pass = isInternalTrustedAccess(request);
    }
    if (!pass) {
        pass = isCrossClusterTrustedAccess(request);
    }
    return pass;
}
Also used : BizSystemModule(com.mendmix.gateway.model.BizSystemModule) ServerHttpRequest(org.springframework.http.server.reactive.ServerHttpRequest)

Example 12 with BizSystemModule

use of com.mendmix.gateway.model.BizSystemModule in project jeesuite-libs by vakinge.

the class GatewaySecurityDecisionProvider method getAllApiPermissions.

@Override
public List<ApiPermission> getAllApiPermissions() {
    Collection<BizSystemModule> modules = CurrentSystemHolder.getModules();
    List<ApiPermission> result = new ArrayList<>();
    Collection<ApiInfo> apis;
    ApiPermission apiPermission;
    for (BizSystemModule module : modules) {
        if (module.getApiInfos() == null)
            continue;
        apis = module.getApiInfos().values();
        for (ApiInfo apiInfo : apis) {
            apiPermission = new ApiPermission();
            apiPermission.setGrantType(apiInfo.getPermissionType().name());
            apiPermission.setHttpMethod(apiInfo.getMethod());
            apiPermission.setUri(apiInfo.getUrl());
            result.add(apiPermission);
        }
    }
    return result;
}
Also used : ApiInfo(com.mendmix.common.model.ApiInfo) BizSystemModule(com.mendmix.gateway.model.BizSystemModule) ApiPermission(com.mendmix.security.model.ApiPermission) ArrayList(java.util.ArrayList)

Aggregations

BizSystemModule (com.mendmix.gateway.model.BizSystemModule)12 ApiInfo (com.mendmix.common.model.ApiInfo)4 JeesuiteBaseException (com.mendmix.common.JeesuiteBaseException)3 HashMap (java.util.HashMap)3 RouteDefinition (org.springframework.cloud.gateway.route.RouteDefinition)3 ServerHttpRequest (org.springframework.http.server.reactive.ServerHttpRequest)3 ArrayList (java.util.ArrayList)2 Entry (java.util.Map.Entry)2 Properties (java.util.Properties)2 GatewayProperties (org.springframework.cloud.gateway.config.GatewayProperties)2 GlobalRuntimeContext (com.mendmix.common.GlobalRuntimeContext)1 HttpRequestEntity (com.mendmix.common.http.HttpRequestEntity)1 ResourceUtils (com.mendmix.common.util.ResourceUtils)1 SystemMgtApi (com.mendmix.gateway.api.SystemMgtApi)1 RewriteBodyServerHttpResponse (com.mendmix.gateway.filter.post.RewriteBodyServerHttpResponse)1 BizSystemPortal (com.mendmix.gateway.model.BizSystemPortal)1 ActionLog (com.mendmix.logging.integrate.ActionLog)1 ApiPermission (com.mendmix.security.model.ApiPermission)1 InstanceFactory (com.mendmix.spring.InstanceFactory)1 AppMetadataHolder (com.mendmix.springweb.exporter.AppMetadataHolder)1