Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

add README with basic usage instructions

  • Loading branch information...
commit 3ad8ef0452d78a4035fdb862a55bbbe7eefe1564 1 parent c13344d
@martinrehfeld martinrehfeld authored
Showing with 31 additions and 0 deletions.
  1. +31 −0 README.md
View
31 README.md
@@ -0,0 +1,31 @@
+# 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}]).
Please sign in to comment.
Something went wrong with that request. Please try again.