+ if (strcasecmp(auth_header_type, "Negotiate") == 0) {
+ auth_type = "Negotiate";
+
+ auth_header_value = ap_getword_white(req->pool, &auth_header);
+ if (!auth_header_value) goto done;
+ input.length = apr_base64_decode_len(auth_header_value) + 1;
+ input.value = apr_pcalloc(req->pool, input.length);
+ if (!input.value) goto done;
+ input.length = apr_base64_decode(input.value, auth_header_value);
+ } else if (strcasecmp(auth_header_type, "Basic") == 0) {
+ auth_type = "Basic";
+ is_basic = true;
+
+ gss_buffer_desc ba_user;
+ gss_buffer_desc ba_pwd;
+
+ switch (cfg->basic_auth) {
+ case BA_ON:
+ /* handle directly */
+ break;
+ case BA_FORWARD:
+ /* decline to handle ourselves, let other modules do it */
+ ret = DECLINED;
+ goto done;
+ case BA_OFF:
+ goto done;
+ default:
+ goto done;
+ }
+ ba_pwd.value = ap_pbase64decode(req->pool, auth_header);
+ if (!ba_pwd.value) goto done;
+ ba_user.value = ap_getword_nulls_nc(req->pool,
+ (char **)&ba_pwd.value, ':');
+ if (!ba_user.value) goto done;
+ if (((char *)ba_user.value)[0] == '\0' ||
+ ((char *)ba_pwd.value)[0] == '\0') {
+ ap_log_rerror(APLOG_MARK, APLOG_ERR|APLOG_NOERRNO, 0, req,
+ "Invalid empty user or password for Basic Auth");
+ goto done;
+ }
+ ba_user.length = strlen(ba_user.value);
+ ba_pwd.length = strlen(ba_pwd.value);
+ maj = gss_import_name(&min, &ba_user, GSS_C_NT_USER_NAME, &client);
+ if (GSS_ERROR(maj)) {
+ ap_log_rerror(APLOG_MARK, APLOG_ERR|APLOG_NOERRNO, 0, req,
+ "In Basic Auth, %s",
+ mag_error(req, "gss_import_name() failed",
+ maj, min));
+ goto done;
+ }
+ maj = gss_acquire_cred_with_password(&min, client, &ba_pwd,
+ GSS_C_INDEFINITE,
+ GSS_C_NO_OID_SET,
+ GSS_C_INITIATE,
+ &user_cred, NULL, NULL);
+ if (GSS_ERROR(maj)) {
+ ap_log_rerror(APLOG_MARK, APLOG_ERR|APLOG_NOERRNO, 0, req,
+ "In Basic Auth, %s",
+ mag_error(req, "gss_acquire_cred_with_password() "
+ "failed", maj, min));
+ goto done;
+ }
+ gss_release_name(&min, &client);
+ } else {
+ goto done;
+ }