Skip to content

Commit c25888e

Browse files
committed
client certificate setting bypasses password requirements #4378 Signed-off-by: Asif Bashar <[email protected]>
1 parent 280d8e5 commit c25888e

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/main/java/org/opensearch/security/auth/BackendRegistry.java

+13
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
import org.opensearch.identity.UserSubject;
5858
import org.opensearch.security.auditlog.AuditLog;
5959
import org.opensearch.security.auth.blocking.ClientBlockRegistry;
60+
import org.opensearch.security.auth.internal.InternalAuthenticationBackend;
6061
import org.opensearch.security.auth.internal.NoOpAuthenticationBackend;
6162
import org.opensearch.security.configuration.AdminDNs;
6263
import org.opensearch.security.filter.SecurityRequest;
@@ -103,6 +104,8 @@ public class BackendRegistry {
103104
private Cache<AuthCredentials, User> userCache; // rest standard
104105
private Cache<String, User> restImpersonationCache; // used for rest impersonation
105106
private Cache<User, Set<String>> restRoleCache; //
107+
private static final String OPENSEARCH_PRODUCT_ORIGIN_HTTP_HEADER = "X-opensearch-product-origin";
108+
private static final String OPENSEARCH_PRODUCT_DASHBOARD_ORIGIN = "opensearch-dashboards";
106109

107110
private void createCaches() {
108111
userCache = CacheBuilder.newBuilder()
@@ -363,6 +366,16 @@ public boolean authenticate(final SecurityRequestChannel request) {
363366
request
364367
);
365368
}
369+
370+
if ( request.header(OPENSEARCH_PRODUCT_ORIGIN_HTTP_HEADER)!= null && request.header(OPENSEARCH_PRODUCT_ORIGIN_HTTP_HEADER).equals(OPENSEARCH_PRODUCT_DASHBOARD_ORIGIN) && authDomain.getBackend().getClass().getName().equals(InternalAuthenticationBackend.class.getName()) ) {
371+
log.error("Cannot authenticate rest user because user authentication failed from browser.");
372+
auditLog.logFailedLogin(ac.getUsername(), true, null, request);
373+
request.queueForSending(
374+
new SecurityResponse(SC_FORBIDDEN, "Cannot authenticate user because authentication failed from browser login via HTTP")
375+
);
376+
return false;
377+
378+
}
366379
continue;
367380
}
368381

0 commit comments

Comments
 (0)