Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

httpauth: basic challenge creation and verification functions #875

Merged
merged 5 commits into from
Jul 13, 2023

Conversation

cHuberCoffee
Copy link
Contributor

  • create and encode HTTP Basic requests.
  • verify HTTP basic authentication header
  • test cases for httpauth_basic verification and request encoding
  • httpauth_basic is tested against wget, curl and an chromium based browser (Brave Browser)

if (!req)
return 0;

if (req->charset && str_len(req->charset))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is better to use "str_isset" here

return re_hprintf(pf, "Basic realm=\"%s\", charset=\"%s\"",
req->realm, req->charset);
else
return re_hprintf(pf, "Basic realm=\"%s\"", req->realm);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this code can be simplified.

Print "basic realm" every time. If charset is set, append charset.

goto out;

err = mbuf_printf(mb, "%b:%b",
user, str_len(user), passwd, str_len(passwd));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can also use %s:%s here ...

if (err)
goto out;

if (memcmp(mb->buf, c, clen) != 0)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is more secure to use this function:

int mem_seccmp(const uint8_t *s1, const uint8_t *s2, size_t n);

@alfredh
Copy link
Contributor

alfredh commented Jul 13, 2023

looks good. Please merge to main...

@sreimers sreimers merged commit bc549f5 into baresip:main Jul 13, 2023
29 checks passed
@cHuberCoffee cHuberCoffee deleted the httpauth_basic_verification branch July 14, 2023 07:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants