KHTTPBASIC_VALIDATE(3)

πŸ“¦
version 1.0.1 Β· 2 versions
, in alpine 3.24

okay so bestie, this is the KHTTPBASIC_VALIDATE(3) page and we’re gonna get you comfy with it πŸ’…βœ¨

πŸŽ€ NAME πŸŽ€

khttpbasic_validate β€” validate an HTTP basic authorisation request

🫢 LIBRARY 🫢

This cutie lives in the library β€œlibkcgi” πŸ’–

✨ SYNOPSIS ✨

#include <sys/types.h>
#include <stdarg.h>
#include <stdint.h>
#include <kcgi.h>

int
khttpbasic_validate(struct kreq *req, const char *user,
    const char *password);

🌸 DESCRIPTION 🌸

The khttpbasic_validate() function validates the given user and password with the HTTP β€œbasic” or β€œbearer” authorised request req as returned by khttp_parse(3) or khttp_fcgi_parse(3) πŸ¦‹

In both cases, the request is validated by base64-encoding user:password and comparing it to the given token. That’s the whole little ritual, no cap πŸ”₯

πŸ’œ RETURN VALUES πŸ’œ

  • zero β€” validation failed, bestie 😭
  • less than zero β€” the request was not properly set up for HTTP basic or bearer validation: no HTTP method, not a basic or bearer request, not already authenticated by the web server πŸ™ˆ
  • greater than zero β€” validation succeeded, slay πŸ‘‘βœ¨

πŸ“ EXAMPLES πŸ“

In the following fragment, assume r is a pointer to a struct kreq successfully initialised by khttp_parse(3). If validation is not provided, it returns an HTTP 401. The expected principle is "james", password "bond". Otherwise, it returns an HTTP 200 πŸ’–

      if (khttpbasic_validate(r, "james", "bond") <= 0) {
        khttp_head(r, kresps[KRESP_STATUS],
          "%s", khttps[KHTTP_401]);
        khttp_head(r, kresps[KRESP_WWW_AUTHENTICATE],
          "basic realm=\"%s\"", "some realm");
      } else
        khttp_head(r, kresps[KRESP_STATUS],
          "%s", khttps[KHTTP_200]);

🌈 SEE ALSO 🌈

⭐ AUTHORS ⭐

Written by Kristaps Dzonsons <kristaps@bsd.lv> πŸ’Œ


okay that’s the whole vibe β€” brought to you by Debian, stamped $Mdocdate$, and filed under KHTTPBASIC_VALIDATE(3) πŸŽ€πŸ’œ

πŸ“¦ where this page comes from
  • alpine 3.24: kcgi-doc 1.0.1-r0 Β· ISC
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms