mirror of
https://github.com/hapifhir/hapi-fhir.git
synced 2025-03-09 14:33:32 +00:00
update restful server to prompt user for credentials on authorization exception if request came from a browser
This commit is contained in:
parent
04fc0827ef
commit
7ef8640ef7
@ -625,6 +625,11 @@ public class RestfulServer extends HttpServlet {
|
||||
resourceMethod.invokeServer(this, r, theResponse);
|
||||
|
||||
} catch (AuthenticationException e) {
|
||||
String userAgent = theRequest.getHeader("User-Agent");
|
||||
if (userAgent != null && userAgent.contains("Mozilla")) {
|
||||
//if request is coming from a browser, prompt the user to enter login credentials
|
||||
theResponse.setHeader("WWW-Authenticate", "BASIC realm=\"FHIR\"");
|
||||
}
|
||||
theResponse.setStatus(e.getStatusCode());
|
||||
addHeadersToResponse(theResponse);
|
||||
theResponse.setContentType("text/plain");
|
||||
|
Loading…
x
Reference in New Issue
Block a user