mirror of
https://repository.entgra.net/community/device-mgt-core.git
synced 2025-10-06 02:01:45 +00:00
restricted basic auth support
This commit is contained in:
parent
fc15f43b31
commit
8a842e8f8e
@ -39,6 +39,11 @@
|
||||
<param-name>doAuthentication</param-name>
|
||||
<param-value>true</param-value>
|
||||
</context-param>
|
||||
<!--This is to support basic auth.-->
|
||||
<context-param>
|
||||
<param-name>basicAuth</param-name>
|
||||
<param-value>true</param-value>
|
||||
</context-param>
|
||||
|
||||
<!--publish to apim-->
|
||||
<context-param>
|
||||
|
||||
@ -49,6 +49,9 @@ public class BasicAuthAuthenticator implements WebappAuthenticator {
|
||||
|
||||
@Override
|
||||
public boolean canHandle(Request request) {
|
||||
if (!isSupportsAuthentication(request)) {
|
||||
return false;
|
||||
}
|
||||
MessageBytes authorization =
|
||||
request.getCoyoteRequest().getMimeHeaders().getValue(Constants.HTTPHeaders.HEADER_HTTP_AUTHORIZATION);
|
||||
if (authorization != null) {
|
||||
@ -156,4 +159,9 @@ public class BasicAuthAuthenticator implements WebappAuthenticator {
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isSupportsAuthentication(Request request) {
|
||||
String param = request.getContext().findParameter("basicAuth");
|
||||
return (param == null || !Boolean.parseBoolean(param));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user