Hcs.Plug.Basic_auth

hcs · API reference

Basic HTTP authentication plug.

Implements RFC 7617 Basic authentication.

val secure_compare : string -> string -> bool
val decode_credentials : string -> (string * string) option

Decode base64 credentials from Authorization header

val get_auth_header : Server.request -> string option

Get Authorization header value

val unauthorized : string -> Response.t

Create a 401 response with WWW-Authenticate header

val create : 
  realm:string ->
  validate:(string -> string -> bool) ->
  (Server.request -> Server.response) ->
  Server.request ->
  Server.response

Create basic auth plug with username/password validation.

parameter realm Authentication realm shown to user parameter validate Function to validate (username, password) -> bool

val create_static : 
  realm:string ->
  username:string ->
  password:string ->
  (Server.request -> Server.response) ->
  Server.request ->
  Server.response

Create basic auth plug with static credentials.

parameter realm Authentication realm parameter username Expected username parameter password Expected password

val create_with_map : 
  realm:string ->
  credentials:(string, string) Hashtbl.t ->
  (Server.request -> Server.response) ->
  Server.request ->
  Server.response

Create basic auth plug with credential map.

parameter realm Authentication realm parameter credentials Map of username -> password