wisp_basic_auth
Types
pub type ClientAuth =
  #(String, String)
      
    Values
pub fn parse_credentials(
  credentials: String,
) -> List(#(String, String))
    
    Parse a list of credentials in the format client:password
separated by semi-colons.
parse_credentials("a:A;b:B")
// -> [#("a", "A"), #("b", "B")]
pub fn validate_basic_auth(
  request: request.Request(wisp.Connection),
  realm: String,
  known_clients: List(#(String, String)),
  handler: fn(request.Request(wisp.Connection)) -> response.Response(
    wisp.Body,
  ),
) -> response.Response(wisp.Body)
    
    Middleware that validates an Authorization: Basic header
against a known list of client ids and passwords within a realm.
The basic authentication scheme is based on the model that the user agent must authenticate itself with a user-ID and a password for each realm.
The realm value should be considered an opaque string which can only be compared for equality with other realms on that server.
Example header: Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==
Using curl to set the header:
curl -X POST -u "client:password" ... https://example.com
Set the middleware in your router:
use request <- validate_basic_auth("Agrabah", [#("Aladdin", "open sesame")])