Skip to content

Commit

Permalink
make subscription domain configurable (#98)
Browse files Browse the repository at this point in the history
Currently, when a subscription request happens, the subscription server
always uses the primary domain of the `CAPApplication` in the
subscription callback response. The aim of this PR is to make this
configurable by setting the optional annotation
`sme.sap.com/subscription-domain` on the `CAPApplication`. If unset, the
current behaviour will be applied.

Co-authored-by: Christoph Barbian <christoph.barbian@sap.com>
Co-authored-by: Pavan Nayak <pavan.nayak@sap.com>
  • Loading branch information
3 people authored Jun 28, 2024
1 parent 7adb86a commit c58b4b6
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion cmd/server/internal/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import (
const (
AnnotationSubscriptionContextSecret = "sme.sap.com/subscription-context-secret"
AnnotationSaaSAdditionalOutput = "sme.sap.com/saas-additional-output"
AnnotationSubscriptionDomain = "sme.sap.com/subscription-domain"
)

const (
Expand Down Expand Up @@ -316,7 +317,11 @@ func (s *SubscriptionHandler) checkAuthorization(authHeader string, saasData *ut
}

func (s *SubscriptionHandler) initializeCallback(tenantName string, ca *v1alpha1.CAPApplication, saasData *util.SaasRegistryCredentials, req *http.Request, tenantSubDomain string, isProvisioning bool) {
appUrl := "https://" + tenantSubDomain + "." + ca.Spec.Domains.Primary
subscriptionDomain := ca.Annotations[AnnotationSubscriptionDomain]
if subscriptionDomain == "" {
subscriptionDomain = ca.Spec.Domains.Primary
}
appUrl := "https://" + tenantSubDomain + "." + subscriptionDomain
asyncCallbackPath := req.Header.Get("STATUS_CALLBACK")
klog.InfoS("callback initialized", "subscription URL", appUrl, "async callback path", asyncCallbackPath, "tenantId", ca.Spec.Provider.TenantId, "tenantName", tenantName, LabelBTPApplicationIdentifierHash, ca.Labels[LabelBTPApplicationIdentifierHash])

Expand Down

0 comments on commit c58b4b6

Please sign in to comment.