Sha256: 02c9c44a714dbbd6f8b2251cf041ac310874a3cd2802d020489a3cd4f30ce5a5

Contents?: true

Size: 1.18 KB

Versions: 1

Compression:

Stored size: 1.18 KB

Contents

# Roda Basic Authentication

Adds functionality for simple http authentication with Roda.

## Configuration

Configure your Roda application to use this plugin:

```ruby
plugin :basic_auth
```

You can pass global options, in this context they'll be shared between all
basic\_auth calls.

```ruby
plugin :basic_auth, authenticator: proc {|user, pass| [user, pass] == %w[foo bar]},
                    realm: 'Restricted Area' # default
```

## Usage

Call `r.basic_auth` when you want to authenticate the user, it halts the
request with 401 response code if the authenticator is false.

You can specify the local authenticator with a block:

```ruby
r.basic_auth { |user, pass| [user, pass] == %w[foo bar] }
```

## Warden

To avoid having your 401 responses intercepted by warden, you need to configure
the unauthenticated callback that is called just before the request is halted:

```ruby
plugin :basic_auth, unauthorized: proc {|r| r.env['warden'].custom_failure! }
```

## Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/badosu/roda-basic-auth.

## License

The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
roda-basic-auth-0.1.0 README.md