motor-admin / motor-admin-rails

Low-code Admin panel and Business intelligence Rails engine. No DSL - configurable from the UI. Rails Admin, Active Admin, Blazer modern alternative.
https://app.getmotoradmin.com/demo/
MIT License
752 stars 76 forks source link

Basic auth example? #159

Closed alinazulfiqar closed 3 months ago

alinazulfiqar commented 6 months ago

I see this in the documentation:

Admin panel can be secured with 'Basic authentication' by specifying MOTOR_AUTH_USERNAME and MOTOR_AUTH_PASSWORD environment variables.

but I'm not sure how to set up routes.rb to trigger a basic username/password prompt from the browser when hitting /motor_admin

dpedoneze commented 4 months ago

You just have to mount it on your app route:

Rails.application.routes.draw do
  mount Motor::Admin => '/motor_admin'
end

And set the env variables MOTOR_AUTH_USERNAME and MOTOR_AUTH_PASSWORD. If you use dotenv, you can have a .env file with:

MOTOR_AUTH_USERNAME="my-user"
MOTOR_AUTH_PASSWORD="s3cr3tp4ssw0rd"