Sha256: 1b0449b1049efc3ac143b9b314cc7ec0ab36a85ca6fc117eabd3229dd6239747

Contents?: true

Size: 1.72 KB

Versions: 18

Compression:

Stored size: 1.72 KB

Contents

---
title: Authenticating admin users
---

Authentication is left for you to implement after you install Administrate into
your app. It's expected that you can plugin your existing authentication
system.

The base `Admin::ApplicationController` has a `TODO` to be completed:

```ruby
class Admin::ApplicationController < Administrate::ApplicationController
  before_action :authenticate_admin

  def authenticate_admin
    # TODO Add authentication logic here.
  end
end
```

## Using Clearance

[Clearance][clearance] provides Rails authentication with email & password.

```ruby
class Admin::ApplicationController < Administrate::ApplicationController
  include Clearance::Controller
  before_action :require_login
end
```

## Using Devise

[Devise][devise] is an authentication solution for Rails with Warden. Include
the authentication method for your model as a `before_action`:

```ruby
class Admin::ApplicationController < Administrate::ApplicationController
  before_action :authenticate_user!
end
```

## Using HTTP Basic authentication

Rails includes the [`http_basic_authenticate_with`][rails-http-basic-auth]
method which can be added to your base admin controller:

```ruby
class Admin::ApplicationController < Administrate::ApplicationController
  http_basic_authenticate_with(
    name: ENV.fetch("ADMIN_NAME"),
    password: ENV.fetch("ADMIN_PASSWORD")
  )
end
```

With this approach consider using [dotenv][dotenv] to setup your environment and
avoid committing secrets in your repository.

[clearance]: https://github.com/thoughtbot/clearance
[devise]: https://github.com/plataformatec/devise
[rails-http-basic-auth]: http://api.rubyonrails.org/classes/ActionController/HttpAuthentication/Basic.html
[dotenv]: https://github.com/bkeepers/dotenv

Version data entries

18 entries across 18 versions & 2 rubygems

Version Path
administrate-1.0.0.beta3 docs/authentication.md
administrate-1.0.0.beta2 docs/authentication.md
administrate-1.0.0.beta1 docs/authentication.md
administrate-0.20.1 docs/authentication.md
administrate-0.20.0 docs/authentication.md
administrate-0.19.0 docs/authentication.md
administrate-0.18.0 docs/authentication.md
administrate-0.17.0 docs/authentication.md
administrate-0.16.0 docs/authentication.md
administrate-0.15.0 docs/authentication.md
administrate-0.14.0 docs/authentication.md
viniBaxterDesk-22.0.0 docs/authentication.md
viniBaxterDesk-0.21.0 docs/authentication.md
viniBaxterDesk-0.20.0 docs/authentication.md
viniBaxterDesk-0.14.0 docs/authentication.md
viniBaxterDesk-0.13.2 docs/authentication.md
viniBaxterDesk-0.13.1 docs/authentication.md
administrate-0.13.0 docs/authentication.md