Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/matsumotory/mod_mruby_basic_auth

Basic Auth by mod_mruby
https://github.com/matsumotory/mod_mruby_basic_auth

Last synced: about 2 months ago
JSON representation

Basic Auth by mod_mruby

Awesome Lists containing this project

README

        

# Basic Auth Module by mod_mruby

Basic Auth Module using mod_mruby.

- mrbgem dependency for mod_mruby

`Nothing`

## How to Use

- Intall mod_mruby previously

See https://github.com/matsumoto-r/mod_mruby

- Copy `.conf`

```bash
cp mod_mruby_basic_auth.conf ${HTTPD_ROOT}/conf.d/.
```

- Change `.conf` for you

```apache


AuthType basic
AuthName "Message for clients"
AuthBasicProvider mruby
mrubyAuthnCheckPassword /path/to/mruby_basic_auth.rb
require valid-user


```

- Change `/path/to/.rb` for you

```ruby
user_list = {
"bilbo" => "foo",
"frodo" => "bar",
"samwise" => "baz",
"aragorn" => "qux",
"legolas" => "quux",
"gimli" => "corge",
}

anp = Apache::AuthnProvider.new

if user_list[anp.user] == anp.password
Apache.return(Apache::AuthnProvider::AUTH_GRANTED)
else
Apache.return(Apache::AuthnProvider::AUTH_DENIED)
end
```

- httpd restart

```bash
service httpd restart
```