KeycloakClient strips realm path when realm URL lacks trailing slash
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 88/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- go
- Lĩnh vực
- authentication
Hướng nghiên cứu
Bắt đầu với pkg/connectors/keycloak_client.go, đặc biệt là NewKeycloakClientWithContext, sau đó xem lại pkg/connectors/keycloak_client_test.go. Chạy các bài kiểm tra connector và xác minh rằng URL realm không có dấu gạch chéo ở cuối vẫn giữ đường dẫn realm trong các yêu cầu cấu hình token và OIDC; hoàn thành khi bài kiểm tra hồi quy cho đầu vào đó vượt qua.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Describe the bug
When initializing a KeycloakClient using connectors.NewKeycloakClient or connectors.NewKeycloakClientWithContext, if the provided realmURL does not include a trailing slash (e.g., http://keycloak.example.com/realms/microcks), subsequent requests to obtain tokens or fetch OIDC configuration fail with HTTP 404.
This happens because relative endpoints (protocol/openid-connect/token and .well-known/openid-configuration) are resolved against kc.BaseURL using c.BaseURL.ResolveReference(rel).
Under RFC 3986 relative URL resolution rules, resolving a relative path against a base URL without a trailing slash strips the final path segment (microcks).
As a result, the request resolves to:
http://keycloak.example.com/realms/protocol/openid-connect/token
instead of:
http://keycloak.example.com/realms/microcks/protocol/openid-connect/token
In comparison, MicrocksClient in pkg/connectors/microcks_client.go defensively normalizes its incoming base URL, but KeycloakClient does not.
Expected behavior
NewKeycloakClient and NewKeycloakClientWithContext should ensure that kc.BaseURL.Path ends with a trailing /, so relative endpoints always resolve under the specified realm.
For example:
http://keycloak.example.com/realms/microcks/protocol/openid-connect/token
This should work regardless of whether the input URL includes a trailing slash.
Actual behavior
The realm name is stripped from the URL path.
- Configured URL:
http://keycloak.example.com/realms/microcks - Resolved Token URL:
http://keycloak.example.com/realms/protocol/openid-connect/token(HTTP 404)
How to Reproduce?
-
Initialize a
KeycloakClientwith a realm URL that omits the trailing slash:kc, err := connectors.NewKeycloakClientWithContext( context.Background(), "http://keycloak.example.com/realms/microcks", "client-id", "client-secret", ) -
Call
kc.ConnectAndGetToken()orkc.GetOIDCConfig(). -
Inspect the resolved request URL. The realm segment
/microckswill be stripped from the path.
Microcks version or git rev
master
Install method (docker-compose, helm chart, operator, docker-desktop extension,...)
No response
Additional information
This can be addressed in pkg/connectors/keycloak_client.go, inside NewKeycloakClientWithContext, by ensuring that the URL path always ends with a trailing slash:
if !strings.HasSuffix(u.Path, "/") {
u.Path += "/"
}
Along with a unit test in pkg/connectors/keycloak_client_test.go covering a realm URL with a subpath.
- Ngôn ngữ chính
- Go
- Star
- 59
- Fork
- 74
- Merge trung bình
- 4 ngày 5 giờ
- Pull request đã merge (30 ngày)
- 15
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của microcks/microcks-cli
-
Malformed local configuration is silently accepted and can be overwrittenCó thể đã có người làm @aniket866 đã nhận 2 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
microcks/microcks-cli#615 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
microcks/microcks-cli#610 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug: microcks test get swallows test failure details and operation results in text output modeĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
microcks/microcks-cli#608 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Windows test failures in MockFileSystem.Walk due to path separatorCó thể đã có người làm @dipak0000812 đã nhận 2 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
microcks/microcks-cli#601 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Bug: `testEndpoint` URL Scheme Not ValidatedCó thể đã có người làm @aniket866 đã nhận 2 ngày trước. Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
microcks/microcks-cli#598 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của microcks/microcks-cli
Issue tương tự
-
needs-area
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Azure/typespec-azure#5936 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 70/100
-
Fix mode unpins a reusable workflow call when the same repository is also used as a step actionĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
github/gh-actions-lock#261 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug documentation
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
labmonkeys-space/nl6#974 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100