active_for_authentication? (which you already know) method is used to control if devise should allow a user to login. If you return false for omniauth user then it will also disable login for omniauth user when user is trying to login using omniauth flow. So it's not an option.
Option 1:
active_for_authentication? does not know if user tries to login using password or omniauth. If we manage to know which flow is followed then we can return false when omniauth user tries to login using password.
One way to know which path is followed by setting session when user tries to login using omniauth flow and check for it in active_for_authentication?
In omniauth flow:
session[:omniauth_login] = true
and in active_for_authentication?
def active_for_authentication?
super && (!omniauth_user? || session[:omniauth_login])
end
It will allow regular users to sign in, block omniauth users sign in by password and allow omniauth users to sign in using omniauth flow (where session is set.). Also reset session after login.
Option 2:
You can override sessions_controller and block access for omniauth enabled users.
class SessionsController < Devise::SessionsController
def create
#Allow login with password for all except omniauth users
#Define your own logic inside omniauth_user?
if omniauth_user?(sign_in_params)
redirect_to new_user_session_path, alert: "You can't login using password"
return
end
super
end
end