Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Basic Authentication middleware for the Elli webserver
Erlang
Tree: ded21f4896

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
src
test
.gitignore
README.md
rebar
rebar.config

README.md

Basic Authentication Middleware for Elli

Use it like this:

PasswordCheck =
    fun (User, Password) ->
        case {User, Password} of
            {undefined, undefined}      -> unauthorized;
            {<<"admin">>, <<"secret">>} -> ok;
            {User, Password}            -> forbidden
        end
    end,

AuthFun =
    fun (Req, User, Password) ->
            case elli_request:path(Req) of
                [<<"protected">>] -> PasswordCheck(User, Password);
                _ ->                 ok
            end
    end,

BasicauthConfig = [{auth_fun, AuthFun}],

Config = [
          {mods, [
                  {elli_basicauth, BasicauthConfig},
                  {elli_example_callback, []}
                 ]}
         ],

elli:start_link([{callback, elli_middleware}, {callback_args, Config}]).
Something went wrong with that request. Please try again.