influxdata / influxdata/influxdb-client-python

Token authentication for influx1.8 not working?

未关闭
#551 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

bug
主要语言
Python
星标
793
派生
186
平均合并
3 小时 2 分钟
30 天内合并 PR
1

描述

Specifications
  • Client Version: 1.35.0
  • InfluxDB Version: 1.8.2
  • Platform: Ubuntu 20.04.5 LTS
Code sample to reproduce problem
client = InfluxDBClient(
                    url=influx_url,
                    verify_ssl=False,
                    token=influx_token,
                    debug=True
                    )

where influx_token is jwt token in string format. example: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6ImFkbWluIiwiZXhwIjoxNzAxODIwODAwfQ.LraKXlamiE9pr0owDgSdDt3FMKR3pVNolLVxm4ULG-8"

Used following payload when generating jwt:

{
  "username": "admin",
  "exp": 1701820800
}
Expected behavior

Should authenticate using token in V2 client. Use of same token in V1 python client works fine. Am I missing something required to parse the token before feeding it to the InfluxDBClient instantiation in V2 python client?

Actual behavior

I receive a parsing error for the token authentication:

[2023-01-06 16:23:27,933] [7642] [ERROR] [influx_connector.py:154] InfluxDB Error: (401)
Reason: Unauthorized
HTTP response headers: HTTPHeaderDict({'Content-Type': 'application/json', 'Request-Id': 'be28dbc8-8e10-11ed-800a-0242ac130003', 'Www-Authenticate': 'Basic realm="InfluxDB"', 'X-Influxdb-Build': 'OSS', 'X-Influxdb-Version': '1.8.3', 'X-Request-Id': 'be28dbc8-8e10-11ed-800a-0242ac130003', 'Date': 'Fri, 06 Jan 2023 22:23:27 GMT', 'Content-Length': '55'})
HTTP response body: b'{"error":"unable to parse authentication credentials"}\n'

Additional info

If I change how I feed the token parameter to something like below, the error changes to:
Reason: Unauthorized
HTTP response headers: HTTPHeaderDict({'Content-Type': 'application/json', 'Request-Id': '64052e35-8e0d-11ed-8032-0242ac130003', 'Www-Authenticate': 'Basic realm="InfluxDB"', 'X-Influxdb-Build': 'OSS', 'X-Influxdb-Version': '1.8.3', 'X-Request-Id': '64052e35-8e0d-11ed-8032-0242ac130003', 'Date': 'Fri, 06 Jan 2023 21:59:28 GMT', 'Content-Length': '33'})
HTTP response body: b'{"error":"authorization failed"}\n

This leads me to believe something more than just passing the token itself as a string is the problem I'm having. Are there other parameters required when using the token. Do I need to add/edit something to the token string itself?

client = InfluxDBClient(
                    url=influx_url,
                    verify_ssl=False,
                    token=f'{influx_user}:{influx_token}',
                    debug=True
                    )

贡献指南

这个仓库没有索引到贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

从使用 token 参数的 InfluxDBClient 入口点开始,使用提供的 JWT 和两种 token 形式,在 InfluxDB 1.8.2 或 1.8.3 上重现 401 响应。将 V2 客户端的身份验证请求与服务器预期的凭据进行比较;完成的标准是确认支持的用法或不兼容性,并修复或记录该行为。

由索引模型根据 Issue 内容生成。

评估

技术栈
python
领域
authentication, databases
Issue 类型
缺陷
难度
3/5
预计耗时
1-2 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。