Auth0::Algorithm is not loaded by `require "auth0"`, so ID token validation raises NameError
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 83/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- ruby
调研方向
阅读 lib/auth0/mixins/validation.rb、lib/auth0/api/authentication_endpoints.rb 和顶层 require 路径,了解 Auth0::Algorithm 是如何加载的。添加一个回归测试,仅使用 require "auth0" 加载库并执行 ID token 验证。完成标准是算法常量可用,且伪造的 token 会触发预期的 Auth0::InvalidIdToken 错误。
由索引模型根据 Issue 内容生成。
描述
Description
In v6.7.0, require "auth0" does not load auth0/algorithm, so Auth0::Algorithm is undefined. Auth0::Mixins::Validation::IdTokenValidator refers to Auth0::Algorithm::RS256 and Auth0::Algorithm::HS256 (lib/auth0/mixins/validation.rb), and validate_id_token uses Auth0::Algorithm::RS256 as its default (lib/auth0/api/authentication_endpoints.rb). Validating an ID token therefore raises a NameError, unless the application requires auth0/algorithm itself.
EXAMPLES.md documents algorithm: Auth0::Algorithm::RS256.jwks_url(...) and Auth0::Algorithm::HS256.secret(...), which do not work after a plain require "auth0" either.
Reproduction
require "auth0"
defined?(Auth0::Algorithm)
# => nil
alg = Auth0::Mixins::Validation::Algorithm::RS256.jwks_url("https://samples.auth0.com/.well-known/jwks.json")
validator = Auth0::Mixins::Validation::IdTokenValidator.new(
algorithm: alg, leeway: 60, issuer: "https://samples.auth0.com/", audience: "x"
)
validator.validate("eyJhbGciOiJSUzI1NiIsImtpZCI6ImsxIn0.e30.c2ln")
# => NameError: uninitialized constant Auth0::Algorithm
require "auth0/algorithm"
validator.validate("eyJhbGciOiJSUzI1NiIsImtpZCI6ImsxIn0.e30.c2ln")
# => Auth0::InvalidIdToken (the expected error for this made-up token)
Cause
v5's lib/auth0.rb contained require 'auth0/algorithm'. The v6 rewrite (e7c21e79) did not carry the require over, and nothing else requires lib/auth0/algorithm.rb.
Suggested fix
Require auth0/algorithm where the validation mixin is loaded (for example from lib/auth0/mixins.rb or lib/auth0/auth_client.rb), and add a test that validates an ID token after only requiring auth0.
Environment
auth0gem v6.7.0 (repository at18167468), Ruby 3.3.14
- 主要语言
- Ruby
- 星标
- 205
- 派生
- 144
- 平均合并
- 1 天 13 小时
- 30 天内合并 PR
- 9
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
auth0/ruby-auth0 的其他 Issue
-
bug
难度 2/5 1-3 小时 新手友好度 80/100
auth0/ruby-auth0#840 ·
维护者通常 1 天内回复
-
Retrying a multipart request raises "Cannot write to closed encoder"可能已有人在做 @RaphaelFakhri 于 40 天前认领。 未关闭
难度 3/5 1-2 天 新手友好度 56/100
auth0/ruby-auth0#818 ·
维护者通常 1 天内回复
-
feature request
难度 3/5 1-2 天 新手友好度 45/100
auth0/ruby-auth0#709 ·
维护者通常 1 天内回复
-
bug
难度 1/5 1 小时以内 新手友好度 50/100
auth0/ruby-auth0#610 · 1 条评论 ·
维护者通常 1 天内回复
-
feature request
难度 5/5 一周以上 新手友好度 32/100
auth0/ruby-auth0#606 · 2 条评论 · 1 个 reaction ·
维护者通常 1 天内回复
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 83/100
riscv/riscv-unified-db#2909 ·
维护者通常 2 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 78/100
we-promise/sure#6115 ·
维护者通常 1 天内回复
-
Drop cameratron-eprun: the collection renderer no longer loads it and collation is native in rhoella可能已有人在做 @ronaldtse 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 75/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 86/100
WikiEducationFoundation/WikiEduDashboard#7362 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 74/100
维护者通常 1 天内回复