Skip to content

Commit

Permalink
Check for open access enabled (#218)
Browse files Browse the repository at this point in the history
  • Loading branch information
Gcolon021 authored Oct 1, 2024
1 parent 345122e commit a433efb
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import edu.harvard.hms.dbmi.avillach.auth.service.impl.authorization.AuthorizationService;
import io.swagger.v3.oas.annotations.Parameter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
Expand All @@ -15,16 +16,22 @@
public class OpenAccessController {

private final AuthorizationService authorizationService;
private final boolean openIdpProviderIsEnabled;

@Autowired
public OpenAccessController(AuthorizationService authorizationService) {
public OpenAccessController(AuthorizationService authorizationService, @Value("${open.idp.provider.is.enabled}") boolean openIdpProviderIsEnabled) {
this.authorizationService = authorizationService;
this.openIdpProviderIsEnabled = openIdpProviderIsEnabled;
}

@RequestMapping(value = "/validate", produces = "application/json")
public ResponseEntity<?> validate(@Parameter(required = true, description = "A JSON object that at least" +
" include a user the token for validation")
@RequestBody Map<String, Object> inputMap) {
if (!openIdpProviderIsEnabled) {
return ResponseEntity.ok(false);
}

boolean isValid = authorizationService.openAccessRequestIsValid(inputMap);
return ResponseEntity.ok(isValid);
}
Expand Down

0 comments on commit a433efb

Please # to comment.