Skip to content

Commit a433efb

Browse files
authored
Check for open access enabled (#218)
1 parent 345122e commit a433efb

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

pic-sure-auth-services/src/main/java/edu/harvard/hms/dbmi/avillach/auth/rest/OpenAccessController.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import edu.harvard.hms.dbmi.avillach.auth.service.impl.authorization.AuthorizationService;
44
import io.swagger.v3.oas.annotations.Parameter;
55
import org.springframework.beans.factory.annotation.Autowired;
6+
import org.springframework.beans.factory.annotation.Value;
67
import org.springframework.http.ResponseEntity;
78
import org.springframework.stereotype.Controller;
89
import org.springframework.web.bind.annotation.RequestBody;
@@ -15,16 +16,22 @@
1516
public class OpenAccessController {
1617

1718
private final AuthorizationService authorizationService;
19+
private final boolean openIdpProviderIsEnabled;
1820

1921
@Autowired
20-
public OpenAccessController(AuthorizationService authorizationService) {
22+
public OpenAccessController(AuthorizationService authorizationService, @Value("${open.idp.provider.is.enabled}") boolean openIdpProviderIsEnabled) {
2123
this.authorizationService = authorizationService;
24+
this.openIdpProviderIsEnabled = openIdpProviderIsEnabled;
2225
}
2326

2427
@RequestMapping(value = "/validate", produces = "application/json")
2528
public ResponseEntity<?> validate(@Parameter(required = true, description = "A JSON object that at least" +
2629
" include a user the token for validation")
2730
@RequestBody Map<String, Object> inputMap) {
31+
if (!openIdpProviderIsEnabled) {
32+
return ResponseEntity.ok(false);
33+
}
34+
2835
boolean isValid = authorizationService.openAccessRequestIsValid(inputMap);
2936
return ResponseEntity.ok(isValid);
3037
}

0 commit comments

Comments
 (0)