Skip to content

Commit 0cda970

Browse files
committed
fix: allow UI-only binding flow without CLI-provided cluster identity
Signed-off-by: Karol Szwaj <karol.szwaj@gmail.com> On-behalf-of: @SAP karol.szwaj@sap.com
1 parent d904a78 commit 0cda970

2 files changed

Lines changed: 14 additions & 10 deletions

File tree

backend/http/handler.go

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -360,14 +360,20 @@ func (h *handler) handleBind(w http.ResponseWriter, r *http.Request) {
360360
return
361361
}
362362

363-
// TODO: Move to validating admission.
364-
if bindRequest.Spec.ClusterIdentity.Identity == "" {
365-
logger.Error(fmt.Errorf("missing cluster identity"), "invalid bind request")
366-
writeErrorResponse(w, http.StatusBadRequest, kubebindv1alpha2.ErrorCodeBadRequest, "Missing cluster identity in bind request", "The cluster identity must be provided in the bind request")
367-
return
363+
// Use the cluster identity from the request, or derive from the authenticated session
364+
// for UI-only flows where no consumer_id is available.
365+
identity := bindRequest.Spec.ClusterIdentity.Identity
366+
if identity == "" {
367+
identity = state.Token.Issuer + "/" + state.Token.Subject
368+
logger.Info("Using session-derived identity for UI-only flow", "identity", identity)
369+
}
370+
371+
consumerID := params.ConsumerID
372+
if consumerID == "" {
373+
consumerID = identity
368374
}
369375

370-
handleResult, err := h.kubeManager.HandleResources(r.Context(), state.Token.Subject, params.ConsumerID, params.ClusterID)
376+
handleResult, err := h.kubeManager.HandleResources(r.Context(), state.Token.Subject, consumerID, params.ClusterID)
371377
if err != nil {
372378
logger.Error(err, "failed to handle resources")
373379
statusCode, code, details := mapErrorToCode(err)

web/src/views/Resources.vue

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -326,10 +326,8 @@ const handleBind = async (templateName: string, bindingName: string) => {
326326
const sessionIdFromRoute = route.query.session_id as string || ''
327327
const clusterIdentity = consumerId.value || sessionIdFromRoute
328328
329-
if (!clusterIdentity) {
330-
showAlertModal('Missing cluster identity. Please ensure you have authenticated properly.', 'Binding Failed', 'error')
331-
return
332-
}
329+
// In UI-only flow, clusterIdentity may be empty - the backend will derive
330+
// identity from the authenticated session (OIDC subject/issuer).
333331
334332
const bindingRequest: BindableResourcesRequest = {
335333
metadata: {

0 commit comments

Comments
 (0)