Java Code Examples for org.springframework.cloud.netflix.zuul.filters.Route#getFullPath()

The following examples show how to use org.springframework.cloud.netflix.zuul.filters.Route#getFullPath() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AccessControlFilter.java    From flair-registry with Apache License 2.0 6 votes vote down vote up
/**
 * Filter requests on endpoints that are not in the list of authorized microservices endpoints.
 */
@Override
public boolean shouldFilter() {
    String requestUri = RequestContext.getCurrentContext().getRequest().getRequestURI();

    log.debug(requestUri);

    // If the request Uri does not start with the path of the authorized endpoints, we block the request
    for (Route route : routeLocator.getRoutes()) {
        String serviceUrl = route.getFullPath();
        String serviceName = route.getId();

        // If this route correspond to the current request URI
        // We do a substring to remove the "**" at the end of the route URL
        if (requestUri.startsWith(serviceUrl.substring(0, serviceUrl.length() - 2))) {
return !isAuthorizedRequest(serviceUrl, serviceName, requestUri);
        }
    }
    return true;
}
 
Example 2
Source File: AccessControlFilter.java    From java-microservices-examples with Apache License 2.0 6 votes vote down vote up
/**
 * Filter requests on endpoints that are not in the list of authorized microservices endpoints.
 */
@Override
public boolean shouldFilter() {
    String requestUri = RequestContext.getCurrentContext().getRequest().getRequestURI();
    String contextPath = RequestContext.getCurrentContext().getRequest().getContextPath();

    // If the request Uri does not start with the path of the authorized endpoints, we block the request
    for (Route route : routeLocator.getRoutes()) {
        String serviceUrl = contextPath + route.getFullPath();
        String serviceName = route.getId();

        // If this route correspond to the current request URI
        // We do a substring to remove the "**" at the end of the route URL
        if (requestUri.startsWith(serviceUrl.substring(0, serviceUrl.length() - 2))) {
return !isAuthorizedRequest(serviceUrl, serviceName, requestUri);
        }
    }
    return true;
}
 
Example 3
Source File: AccessControlFilter.java    From cubeai with Apache License 2.0 6 votes vote down vote up
/**
 * Filter requests on endpoints that are not in the list of authorized microservices endpoints.
 */
@Override
public boolean shouldFilter() {
    String requestUri = RequestContext.getCurrentContext().getRequest().getRequestURI();

    // 使用ng2-file-upload上传文件时,如果通过zuul路由,URL前面需要加'zuul'前缀
    if (requestUri.startsWith("/zuul")) {
        requestUri = requestUri.substring(5);
    }

    // If the request Uri does not start with the path of the authorized endpoints, we block the request
    for (Route route : routeLocator.getRoutes()) {
        String serviceUrl = route.getFullPath();
        String serviceName = route.getId();

        // If this route correspond to the current request URI
        // We do a substring to remove the "**" at the end of the route URL
        if (requestUri.startsWith(serviceUrl.substring(0, serviceUrl.length() - 2))) {
return !isAuthorizedRequest(serviceUrl, serviceName, requestUri);
        }
    }
    return true;
}
 
Example 4
Source File: AccessControlFilter.java    From okta-jhipster-microservices-oauth-example with Apache License 2.0 6 votes vote down vote up
/**
 * Filter requests on endpoints that are not in the list of authorized microservices endpoints.
 */
@Override
public boolean shouldFilter() {
    String requestUri = RequestContext.getCurrentContext().getRequest().getRequestURI();
    String contextPath = RequestContext.getCurrentContext().getRequest().getContextPath();

    // If the request Uri does not start with the path of the authorized endpoints, we block the request
    for (Route route : routeLocator.getRoutes()) {
        String serviceUrl = contextPath + route.getFullPath();
        String serviceName = route.getId();

        // If this route correspond to the current request URI
        // We do a substring to remove the "**" at the end of the route URL
        if (requestUri.startsWith(serviceUrl.substring(0, serviceUrl.length() - 2))) {
return !isAuthorizedRequest(serviceUrl, serviceName, requestUri);
        }
    }
    return true;
}
 
Example 5
Source File: AccessControlFilter.java    From e-commerce-microservice with Apache License 2.0 6 votes vote down vote up
/**
 * Filter requests on endpoints that are not in the list of authorized microservices endpoints.
 */
@Override
public boolean shouldFilter() {
    String requestUri = RequestContext.getCurrentContext().getRequest().getRequestURI();
    String contextPath = RequestContext.getCurrentContext().getRequest().getContextPath();

    // If the request Uri does not start with the path of the authorized endpoints, we block the request
    for (Route route : routeLocator.getRoutes()) {
        String serviceUrl = contextPath + route.getFullPath();
        String serviceName = route.getId();

        // If this route correspond to the current request URI
        // We do a substring to remove the "**" at the end of the route URL
        if (requestUri.startsWith(serviceUrl.substring(0, serviceUrl.length() - 2))) {
return !isAuthorizedRequest(serviceUrl, serviceName, requestUri);
        }
    }
    return true;
}
 
Example 6
Source File: AccessControlFilter.java    From jhipster-microservices-example with Apache License 2.0 6 votes vote down vote up
/**
 * Filter requests on endpoints that are not in the list of authorized microservices endpoints.
 */
@Override
public boolean shouldFilter() {
    String requestUri = RequestContext.getCurrentContext().getRequest().getRequestURI();

    // If the request Uri does not start with the path of the authorized endpoints, we block the request
    for (Route route : routeLocator.getRoutes()) {
        String serviceUrl = route.getFullPath();
        String serviceName = route.getId();

        // If this route correspond to the current request URI
        // We do a substring to remove the "**" at the end of the route URL
        if (requestUri.startsWith(serviceUrl.substring(0, serviceUrl.length() - 2))) {
return !isAuthorizedRequest(serviceUrl, serviceName, requestUri);
        }
    }
    return true;
}
 
Example 7
Source File: AccessControlFilter.java    From jhipster-microservices-example with Apache License 2.0 6 votes vote down vote up
/**
 * Filter requests on endpoints that are not in the list of authorized microservices endpoints.
 */
@Override
public boolean shouldFilter() {
    String requestUri = RequestContext.getCurrentContext().getRequest().getRequestURI();

    log.debug(requestUri);

    // If the request Uri does not start with the path of the authorized endpoints, we block the request
    for (Route route : routeLocator.getRoutes()) {
        String serviceUrl = route.getFullPath();
        String serviceName = route.getId();

        // If this route correspond to the current request URI
        // We do a substring to remove the "**" at the end of the route URL
        if (requestUri.startsWith(serviceUrl.substring(0, serviceUrl.length() - 2))) {
return !isAuthorizedRequest(serviceUrl, serviceName, requestUri);
        }
    }
    return true;
}
 
Example 8
Source File: AccessControlFilter.java    From jhipster-ribbon-hystrix with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Filter requests on endpoints that are not in the list of authorized microservices endpoints.
 */
@Override
public boolean shouldFilter() {
    String requestUri = RequestContext.getCurrentContext().getRequest().getRequestURI();

    // If the request Uri does not start with the path of the authorized endpoints, we block the request
    for (Route route : routeLocator.getRoutes()) {
        String serviceUrl = route.getFullPath();
        String serviceName = route.getId();

        // If this route correspond to the current request URI
        // We do a substring to remove the "**" at the end of the route URL
        if (requestUri.startsWith(serviceUrl.substring(0, serviceUrl.length() - 2))) {
            if (isAuthorizedRequest(serviceUrl, serviceName, requestUri)) {
                return false;
            }
        }
    }
    return true;
}
 
Example 9
Source File: _AccessControlFilter.java    From jhipster-ribbon-hystrix with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Filter requests on endpoints that are not in the list of authorized microservices endpoints.
 */
@Override
public boolean shouldFilter() {
    String requestUri = RequestContext.getCurrentContext().getRequest().getRequestURI();

    // If the request Uri does not start with the path of the authorized endpoints, we block the request
    for (Route route : routeLocator.getRoutes()) {
        String serviceUrl = route.getFullPath();
        String serviceName = route.getId();

        // If this route correspond to the current request URI
        // We do a substring to remove the "**" at the end of the route URL
        if (requestUri.startsWith(serviceUrl.substring(0, serviceUrl.length() - 2))) {
            if (isAuthorizedRequest(serviceUrl, serviceName, requestUri)) {
                return false;
            }
        }
    }
    return true;
}
 
Example 10
Source File: AccessControlFilter.java    From jhipster-registry with Apache License 2.0 6 votes vote down vote up
/**
 * Filter requests on endpoints that are not in the list of authorized microservices endpoints.
 */
@Override
public boolean shouldFilter() {
    String requestUri = RequestContext.getCurrentContext().getRequest().getRequestURI();
    String contextPath = RequestContext.getCurrentContext().getRequest().getContextPath();

    // If the request Uri does not start with the path of the authorized endpoints, we block the request
    for (Route route : routeLocator.getRoutes()) {
        String serviceUrl = contextPath + route.getFullPath();
        String serviceName = route.getId();

        // If this route correspond to the current request URI
        // We do a substring to remove the "**" at the end of the route URL
        if (requestUri.startsWith(serviceUrl.substring(0, serviceUrl.length() - 2))) {
            return !isAuthorizedRequest(serviceUrl, serviceName, requestUri);
        }
    }
    return true;
}
 
Example 11
Source File: AccessControlFilter.java    From tutorials with MIT License 6 votes vote down vote up
/**
 * Filter requests on endpoints that are not in the list of authorized microservices endpoints.
 */
@Override
public boolean shouldFilter() {
    String requestUri = RequestContext.getCurrentContext().getRequest().getRequestURI();

    // If the request Uri does not start with the path of the authorized endpoints, we block the request
    for (Route route : routeLocator.getRoutes()) {
        String serviceUrl = route.getFullPath();
        String serviceName = route.getId();

        // If this route correspond to the current request URI
        // We do a substring to remove the "**" at the end of the route URL
        if (requestUri.startsWith(serviceUrl.substring(0, serviceUrl.length() - 2))) {
return !isAuthorizedRequest(serviceUrl, serviceName, requestUri);
        }
    }
    return true;
}
 
Example 12
Source File: AccessControlFilter.java    From tutorials with MIT License 6 votes vote down vote up
/**
 * Filter requests on endpoints that are not in the list of authorized microservices endpoints.
 */
@Override
public boolean shouldFilter() {
    String requestUri = RequestContext.getCurrentContext().getRequest().getRequestURI();
    String contextPath = RequestContext.getCurrentContext().getRequest().getContextPath();

    // If the request Uri does not start with the path of the authorized endpoints, we block the request
    for (Route route : routeLocator.getRoutes()) {
        String serviceUrl = contextPath + route.getFullPath();
        String serviceName = route.getId();

        // If this route correspond to the current request URI
        // We do a substring to remove the "**" at the end of the route URL
        if (requestUri.startsWith(serviceUrl.substring(0, serviceUrl.length() - 2))) {
return !isAuthorizedRequest(serviceUrl, serviceName, requestUri);
        }
    }
    return true;
}