forked from External/greenlight
Prevented LDAP sign in without password (#1092)
Co-authored-by: Jesus Federico <jesus@123it.ca>
This commit is contained in:
parent
fab3b479c9
commit
c72d77dbcb
|
@ -139,6 +139,8 @@ class SessionsController < ApplicationController
|
||||||
ldap_config[:base] = ENV['LDAP_BASE']
|
ldap_config[:base] = ENV['LDAP_BASE']
|
||||||
ldap_config[:uid] = ENV['LDAP_UID']
|
ldap_config[:uid] = ENV['LDAP_UID']
|
||||||
|
|
||||||
|
return redirect_to(ldap_signin_path, alert: I18n.t("invalid_credentials")) unless session_params[:password].present?
|
||||||
|
|
||||||
result = send_ldap_request(params[:session], ldap_config)
|
result = send_ldap_request(params[:session], ldap_config)
|
||||||
|
|
||||||
return redirect_to(ldap_signin_path, alert: I18n.t("invalid_credentials")) unless result
|
return redirect_to(ldap_signin_path, alert: I18n.t("invalid_credentials")) unless result
|
||||||
|
|
|
@ -591,5 +591,19 @@ describe SessionsController, type: :controller do
|
||||||
expect(response).to redirect_to(ldap_signin_path)
|
expect(response).to redirect_to(ldap_signin_path)
|
||||||
expect(flash[:alert]).to eq(I18n.t("invalid_credentials"))
|
expect(flash[:alert]).to eq(I18n.t("invalid_credentials"))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "redirects to signin if no password provided" do
|
||||||
|
allow_any_instance_of(Net::LDAP).to receive(:bind_as).and_return(false)
|
||||||
|
|
||||||
|
post :ldap, params: {
|
||||||
|
session: {
|
||||||
|
user: "test",
|
||||||
|
password: '',
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
expect(response).to redirect_to(ldap_signin_path)
|
||||||
|
expect(flash[:alert]).to eq(I18n.t("invalid_credentials"))
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue