dovecot-2.2: lib-http auth: Implemented client-side handling of ...
dovecot at dovecot.org
dovecot at dovecot.org
Tue Aug 18 18:02:25 UTC 2015
details: http://hg.dovecot.org/dovecot-2.2/rev/3e1ab97a392c
changeset: 18956:3e1ab97a392c
user: Stephan Bosch <stephan at rename-it.nl>
date: Tue Aug 18 20:39:24 2015 +0300
description:
lib-http auth: Implemented client-side handling of basic authentication scheme.
diffstat:
src/lib-http/http-auth.c | 21 ++++++++++++++++++++-
src/lib-http/http-auth.h | 2 ++
2 files changed, 22 insertions(+), 1 deletions(-)
diffs (54 lines):
diff -r cc09fc9194d1 -r 3e1ab97a392c src/lib-http/http-auth.c
--- a/src/lib-http/http-auth.c Tue Aug 18 20:39:24 2015 +0300
+++ b/src/lib-http/http-auth.c Tue Aug 18 20:39:24 2015 +0300
@@ -2,6 +2,7 @@
#include "lib.h"
#include "str.h"
+#include "base64.h"
#include "array.h"
#include "http-parser.h"
@@ -420,7 +421,7 @@
const char *realm)
{
memset(chlng, 0, sizeof(*chlng));
- chlng->scheme = "basic";
+ chlng->scheme = "Basic";
if (realm != NULL) {
struct http_auth_param param;
@@ -432,3 +433,21 @@
array_append(&chlng->params, ¶m, 1);
}
}
+
+void http_auth_basic_credentials_init(struct http_auth_credentials *crdts,
+ const char *username, const char *password)
+{
+ const char *auth;
+ string_t *data;
+
+ i_assert(username != NULL && *username != '\0');
+ i_assert(strchr(username, ':') == NULL);
+
+ data = t_str_new(64);
+ auth = t_strconcat(username, ":", password, NULL);
+ base64_encode(auth, strlen(auth), data);
+
+ memset(crdts, 0, sizeof(*crdts));
+ crdts->scheme = "Basic";
+ crdts->data = str_c(data);
+}
diff -r cc09fc9194d1 -r 3e1ab97a392c src/lib-http/http-auth.h
--- a/src/lib-http/http-auth.h Tue Aug 18 20:39:24 2015 +0300
+++ b/src/lib-http/http-auth.h Tue Aug 18 20:39:24 2015 +0300
@@ -65,6 +65,8 @@
void http_auth_basic_challenge_init(struct http_auth_challenge *chlng,
const char *realm);
+void http_auth_basic_credentials_init(struct http_auth_credentials *crdts,
+ const char *username, const char *password);
#endif
More information about the dovecot-cvs
mailing list