mod_auth(3)

πŸ“¦
version 29.0.6 Β· 3 versions
, in ubuntu stonking

πŸ’– mod_auth(3) πŸ’– β€” the Erlang Module Definition energy, bestie

okay so you found the mod_auth(3) page in your terminal and you're like "what is this" β€” don't worry, I gotchu. This is the Erlang module definition for mod_auth, and it's literally the girl who checks IDs at the door. Let's go. πŸŽ€


✨ NAME ✨

mod_auth β€” user authentication using text files, Dets, or Mnesia database. periodt.


🌸 DESCRIPTION 🌸

So this module is the one that handles basic user authentication, and she does it with textual files, Dets databases, or Mnesia databases β€” dealer's choice, she's flexible like that. πŸ’…

See also πŸ”

  • httpd
  • mod_alias

πŸ¦‹ DATA TYPES πŸ¦‹

okay here's the two record types she works with:

httpd_group() :: #httpd_group{}.
httpd_user() :: #httpd_user{}.

that's the whole type table, no cap. cute and contained. ✨


πŸ‘‘ FUNCTIONS πŸ‘‘

add_group_member(GroupName, UserName, Address, Port, Directory) -> true | {error, Reason}

add_group_member(GroupName, UserName, Address, Port, Directory) ->
                        true | {error, Reason}
                        when
                            GroupName :: string(),
                            UserName :: string(),
                            Port :: inet:port_number(),
                            Address ::
                                inet:ip4_address() |
                                inet:ip6_address() |
                                string() |
                                undefined,
                            Directory :: string(),
                            Reason :: term().

okay so add_group_member/3, add_group_member/4, and add_group_member/5 each add a user to a group. and if the group doesn't even exist yet? she creates it and adds the user anyway β€” main character energy, no hesitation. πŸ’… If it all goes well you get true back. And heads up, when add_group_members/3 is called, the options Port and Dir are mandatory β€” do not skip them. 🫢

add_user(UserName, Password, UserData, Address, Port, Directory) -> true | {error, Reason}

add_user(UserName, Password, UserData, Address, Port, Directory) ->
                    true | {error, Reason}
                    when
                        UserName :: string(),
                        Password :: string(),
                        UserData :: term(),
                        Port :: inet:port_number(),
                        Address ::
                            inet:ip4_address() |
                            inet:ip6_address() |
                            string() |
                            undefined,
                        Directory :: string(),
                        Reason :: term().
add_user(UserName, Password, UserData, Address, Port, Dir) ->
true | {error, Reason}

so add_user/2, add_user/5, and add_user/6 each add a user to the user database. successful operation β†’ true, simple as. but if an error happens you're getting {error, Reason} bestie, sorry. 😭 And when add_user/2 is called, the options Password, UserData, Port, and Dir are mandatory β€” all four, don't play. ✨

delete_group(GroupName, Address, Port, Directory) -> true | {error, Reason}

delete_group(GroupName, Address, Port, Directory) ->
                        true | {error, Reason}
                        when
                            GroupName :: string(),
                            Port :: inet:port_number(),
                            Address ::
                                inet:ip4_address() |
                                inet:ip6_address() |
                                string() |
                                undefined,
                            Directory :: string(),
                            Reason :: term().

delete_group/2, delete_group/3, and delete_group/4 each delete the group you specified and hand you back true. if something's off, you get {error, Reason} instead. And when delete_group/2 is called, the option Port and Dir are mandatory. πŸ’€ don't forget em.

delete_group_member(GroupName, UserName, Address, Port, Directory) -> true | {error, Reason}

delete_group_member(GroupName, UserName, Address, Port, Directory) ->
                               true | {error, Reason}
                               when
                                   GroupName :: string(),
                                   UserName :: string(),
                                   Port :: inet:port_number(),
                                   Address ::
                                       inet:ip4_address() |
                                       inet:ip6_address() |
                                       string() |
                                       undefined,
                                   Directory :: string(),
                                   Reason :: term().

delete_group_member/3, delete_group_member/4, and delete_group_member/5 each delete a user from a group. If the group or the user doesn't exist, this function returns an error β€” otherwise true. And when delete_group_member/3 is called, the options Port and Dir are mandatory. 🫢

delete_user(UserName, Address, Port, Directory) -> true | {error, Reason}

delete_user(UserName, Address, Port, Directory) ->
                       true | {error, Reason}
                       when
                           UserName :: string(),
                           Port :: inet:port_number(),
                           Address ::
                               inet:ip4_address() |
                               inet:ip6_address() |
                               string() |
                               undefined,
                           Directory :: string(),
                           Reason :: term().

delete_user/2, delete_user/3, and delete_user/4 each delete a user from the user database. If the operation is successful this function returns true. If an error occurs, {error, Reason} is returned. And when delete_user/2 is called, the options Port and Dir are mandatory. 🌸

get_user(UserName, Address, Port, Directory) -> {ok, User} | {error, Reason}

get_user(UserName, Address, Port, Directory) ->
                    {ok, User} | {error, Reason}
                    when
                        UserName :: string(),
                        User :: httpd_user(),
                        Port :: inet:port_number(),
                        Address ::
                            inet:ip4_address() |
                            inet:ip6_address() |
                            string() |
                            undefined,
                        Directory :: string(),
                        Reason :: term().

get_user/2, get_user/3, and get_user/4 each returns an httpd_user/0 record containing the userdata for a specific user. If the user can't be found, {error, Reason} comes back instead. And when get_user/2 is called, the options Port and Dir are mandatory. πŸ”₯

list_group_members(GroupName, Address, Port, Directory) -> {ok, Users} | {error, Reason}

list_group_members(GroupName, Address, Port, Directory) ->
                              {ok, Users} | {error, Reason}
                              when
                                  GroupName :: string(),
                                  Port :: inet:port_number(),
                                  Address ::
                                      inet:ip4_address() |
                                      inet:ip6_address() |
                                      string() |
                                      undefined,
                                  Directory :: string(),
                                  Users :: [httpd_user()],
                                  Reason :: term().

list_group_members/2, list_group_members/3, and list_group_members/4 each lists the members of a specified group. If the group doesn't exist, or there's an error, {error, Reason} is what you get. And when list_group_members/2 is called, the options Port and Dir are mandatory. πŸŽ€

list_groups(Address, Port, Directory) -> {ok, Groups} | {error, Reason}

list_groups(Address, Port, Directory) ->
                       {ok, Groups} | {error, Reason}
                       when
                           Port :: inet:port_number(),
                           Address ::
                               inet:ip4_address() |
                               inet:ip6_address() |
                               string() |
                               undefined,
                           Directory :: string(),
                           Groups :: [httpd_group()],
                           Reason :: term().

list_groups/1, list_groups/2, and list_groups/3 each lists all the groups available β€” the whole roster, bestie. πŸ‘‘ If there's an error, {error, Reason} is returned. And when list_groups/1 is called, the options Port and Dir are mandatory. πŸ’–

list_users(Address, Port, Directory) -> {ok, Users} | {error, Reason}

list_users(Address, Port, Directory) ->
                      {ok, Users} | {error, Reason}
                      when
                          Port :: inet:port_number(),
                          Address ::
                              inet:ip4_address() |
                              inet:ip6_address() |
                              string() |
                              undefined,
                          Directory :: string(),
                          Users :: [httpd_user()],
                          Reason :: atom().

list_users/1, list_users/2, and list_users/3 each returns a list of users in the user database for a specific Port/Dir. And when list_users/1 is called, the options Port and Dir are mandatory. ✨

update_password(Address, Port, Dir, OldPassword, NewPassword, NewPassword) -> ok | {error, Reason}

update_password(Address, Port, Dir, OldPassword, NewPassword,
                        NewPassword) ->
                           ok | {error, Reason}
                           when
                               Address ::
                                   inet:ip4_address() |
                                   inet:ip6_address() |
                                   string() |
                                   undefined,
                               Port :: inet:port_number(),
                               Dir :: string(),
                               OldPassword :: string(),
                               NewPassword :: string(),
                               Reason :: term().

update_password/5 and update_password/6 each updates AuthAccessPassword for the specified directory. πŸ”

and now the important part, listen up:

If NewPassword is equal to "NoPassword", no password is required to change authorisation data. But if NewPassword is equal to "DummyPassword", no changes can be done without changing the password first. 🚨

those are two very different vibes, don't mix them up. πŸ’€


🌈 sign-off 🌈

and that's the whole page bestie, you ate it πŸ’… β€” this cutie pie comes to you from Ericsson AB, shipping with inets 9.7.2, and it's the mod_auth(3) page, fr fr. go authenticate something iconic. πŸ¦‹βœ¨πŸŽ€

πŸ“¦ where this page comes from