在 druid 中设置基本身份验证
Posted
技术标签:
【中文标题】在 druid 中设置基本身份验证【英文标题】:Setting up basic authentication in druid 【发布时间】:2018-06-15 11:56:24 【问题描述】:我想为 Druid 设置身份验证。我按照示例从http://druid.io/docs/latest/tutorials/quickstart.html设置druid
完成后,我按照此文档设置身份验证:http://druid.io/docs/latest/development/extensions-core/druid-basic-security.html
这些是 common.runtime.properties 文件中的以下更改
# Basic authentication
# Basic authentication: Authenticator settings
druid.auth.authenticatorChain=["MyBasicAuthenticator"]
druid.auth.authenticator.MyBasicAuthenticator.type=basic
druid.auth.authenticator.MyBasicAuthenticator.initialAdminPassword=password1
druid.auth.authenticator.MyBasicAuthenticator.initialInternalClientPassword=password2
druid.auth.authenticator.MyBasicAuthenticator.authorizerName=MyBasicAuthorizer
druid.auth.authorizers=["MyBasicAuthorizer"]
druid.auth.authorizer.MyBasicAuthorizer.type=basic
当我向 url 发出 POST 请求时:http://localhost:8082/druid/v2/?pretty
与身体:
"queryType" : "topN",
"dataSource" : "wikiticker",
"intervals" : ["2015-09-12/2015-09-13"],
"granularity" : "all",
"dimension" : "page",
"metric" : "edits",
"threshold" : 25,
"aggregations" : [
"type" : "longSum",
"name" : "edits",
"fieldName" : "count"
]
用户名:druid_system,密码:password2
我收到以下错误:
io.druid.java.util.common.IAE: No authenticator found with prefix: [MyBasicAuthenticator]
有人知道吗?
【问题讨论】:
你是否包含了 druid 基本安全扩展 是的,Madhu,我将它们添加如下:druid.extensions.loadList=["druid-basic-security"] 请贴出MyBasicAuthenticator的代码。感觉你的Json类型注解定义不正确。 【参考方案1】:您的配置缺少escalator
。
添加以下内容:
# Escalator for the internal client that is used for the internal druid communication
druid.escalator.type=basic
druid.escalator.internalClientUsername=druid_system
druid.escalator.internalClientPassword=password2
druid.escalator.authorizerName=BasicAuthorizer
【讨论】:
以上是关于在 druid 中设置基本身份验证的主要内容,如果未能解决你的问题,请参考以下文章
在 tomcat webapp 中设置身份验证的最佳方法是啥?