use of org.springframework.boot.actuate.autoconfigure.cloudfoundry.CloudFoundryAuthorizationException in project spring-boot by spring-projects.
the class CloudFoundrySecurityInterceptor method check.
private void check(HttpServletRequest request, EndpointId endpointId) throws Exception {
Token token = getToken(request);
this.tokenValidator.validate(token);
AccessLevel accessLevel = this.cloudFoundrySecurityService.getAccessLevel(token.toString(), this.applicationId);
if (!accessLevel.isAccessAllowed((endpointId != null) ? endpointId.toLowerCaseString() : "")) {
throw new CloudFoundryAuthorizationException(Reason.ACCESS_DENIED, "Access denied");
}
request.setAttribute(AccessLevel.REQUEST_ATTRIBUTE, accessLevel);
}
use of org.springframework.boot.actuate.autoconfigure.cloudfoundry.CloudFoundryAuthorizationException in project spring-boot by spring-projects.
the class ReactiveCloudFoundrySecurityInterceptorTests method preHandleWhenCloudFoundrySecurityServiceIsNullShouldReturnError.
@Test
void preHandleWhenCloudFoundrySecurityServiceIsNullShouldReturnError() {
this.interceptor = new CloudFoundrySecurityInterceptor(this.tokenValidator, null, "my-app-id");
MockServerWebExchange request = MockServerWebExchange.from(MockServerHttpRequest.get("/a").header(HttpHeaders.AUTHORIZATION, mockAccessToken()).build());
StepVerifier.create(this.interceptor.preHandle(request, "/a")).consumeErrorWith((ex) -> assertThat(((CloudFoundryAuthorizationException) ex).getReason()).isEqualTo(Reason.SERVICE_UNAVAILABLE)).verify();
}
Aggregations