Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

devise http basic auth for html format

I have the following configuration:

devise :database_authenticatable config.http_authenticatable = true

on request:

http://user:password@localhost:3000/

Devise ignores the http auth login and redirects to login page

any thoughts?

Regards

like image 893
Vitalis Avatar asked Sep 15 '25 23:09

Vitalis


1 Answers

This worked for me

  before_filter :check_auth

  def check_auth
    authenticate_or_request_with_http_basic do |username,password|
      resource = User.find(username)
      if resource.valid_password?(password)
        sign_in :user, resource
      end
    end
    warden.custom_failure! if performed?
  end
like image 150
Marwa Hack Avatar answered Sep 17 '25 13:09

Marwa Hack