Skip to content
This repository

current user is nil, after adding http basic authentication in production environment #329

Open
loganathan-techmixin opened this Issue · 0 comments

1 participant

Loganathan
Loganathan

Hi ,

I have implemented http basic authentication in my application, after basic http authentication current user is always nil in production mode. Pasted below my code for your reference.

In Application controller:

def authenticate_user
if (Rails.env.production? && current_user_session.nil?)
authenticate_or_request_with_http_basic do |username, password|
username == HTTP_AUTHENTICATION_USERNAME && password == HTTP_AUTHENTICATION_PASSWORD
end
end
end

Where HTTP credentials are take from initializer file.
HTTP_AUTHENTICATION_USERNAME="xxxx"
HTTP_AUTHENTICATION_PASSWORD="yyy"

Also I tried "allow_http_basic_auth false" in user session model but it didnt solve the problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.