Solr 身份验证(使用 Django Haystack)

发布于 2024-12-06 04:26:23 字数 1452 浏览 4 评论 0 原文

我的 solr 服务无需 HTTP 身份验证即可工作,但我的网络主机提供了它,我想利用它。

dotcloud 以 url 的形式向我提供了访问 solr 服务的用户名和密码:

'http://dotcloud:[电子邮件受保护]/solr/'

当我将浏览器指向该地址时,它工作得很好。

在我的 settings.py 文件中,我有以下行:

    HAYSTACK_SOLR_URL = 'http://dotcloud:[email protected]/solr/' 

但是当我运行 ./manage.py build_solr_schema 时,出现以下错误:

ValueError:以 10 为基数的 int() 的文字无效:'[电子邮件受保护]'

如果删除 URL,构建架构不会有任何问题,但随后我无法构建索引(“错误 401:未经授权”),这当然是有道理的。

我在 haystack 文档中找不到任何有关身份验证的内容。这似乎可以通过在 settings.py 中添加几行来解决,例如:

    HAYSTACK_SOLR_USER = 'dotcloud'
    HAYSTACK_SOLR_PSSWD = 'XXXXXXXXXXXXXXXXXXX'

但是,没有骰子。 Haystack 设置的完整列表没有显示任何内容: http://docs.haystacksearch.org/ dev/settings.html

有什么想法吗?

谢谢。

My solr service works without HTTP authentication, but my webhost provides it and I'd like to take advantage of it.

I've been given a username and password to access my solr service by dotcloud in the form of a url:

'http://dotcloud:[email protected]/solr/'

When I point my browser to this address, it works just fine.

In my settings.py file I have the following line:

    HAYSTACK_SOLR_URL = 'http://dotcloud:[email protected]/solr/' 

but when I run ./manage.py build_solr_schema, I get the following error:

ValueError: invalid literal for int() with base 10: '[email protected]'

I don't have any problem building a schema if I remove the URL, but then I am unable to build an index ("Error 401: UNAUTHORIZED") which, of course, makes sense.

I can't find anything in the haystack docs that talks about authentication. This seems like something that would be solved by an extra couple of lines in settings.py like:

    HAYSTACK_SOLR_USER = 'dotcloud'
    HAYSTACK_SOLR_PSSWD = 'XXXXXXXXXXXXXXXXXXX'

but, no dice. A complete list of the Haystack settings reveals nothing along those lines: http://docs.haystacksearch.org/dev/settings.html .

Any ideas??

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

南笙 2024-12-13 04:26:23

我在 dotcloud 上遇到了同样的问题。该错误实际上不在 Haystack 中,而是在 pysolr 中。 Pysolr 假设如果 url 中有冒号,则其后面的所有内容都必须是端口号。

一种短期修复方法是在 dotcloud solr 服务上使用以下配置来禁用身份验证:

配置:
solr_authentication: false

我只会在开发环境中执行此操作,并且如果您那里有不敏感的数据(因为任何人都可以访问该网址)。最终的解决方案是修补 pysolr。

I ran into the same issue on dotcloud. The error actually isn't in Haystack -- it's in pysolr. Pysolr assumes that if there's a colon in the url, everything after it must be a port number.

One short term fix would be to use the following config on your dotcloud solr service to disable authentication:

config:
solr_authentication: false

I would only do this in a dev environment and if you have data up there that isn't sensitive (since anybody could get to that url). The ultimate solution is to patch pysolr.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文