【问题标题】:itfoxtec-identity-saml2 SAML Request Destination Port being stripped outitfoxtec-identity-saml2 SAML 请求目标端口被剥离
【发布时间】:2021-11-02 09:14:05
【问题描述】:

在发出 SAML 请求时,端口号 (443) 将从目标中剥离。我知道这是 URI 对象的默认行为。但是,SAML 身份提供程序要求目标包含端口号以进行验证。

如何让 SAML 构建器包含端口? 443 正在从 https://sit-api.eat.xxxxxx.xxxx.xx:443/samlsso 中删除(见下文)

            Saml2Configuration samlconfig = GetSAMLConfig();

            var samlRequest = new Saml2AuthnRequest(samlconfig);
            samlRequest.AssertionConsumerServiceUrl = new Uri(_appConfiguration["Saml2:AssertionConsumerServiceUrl"]); 

            samlRequest.Destination = new Uri(_appConfiguration["Saml2:SingleSignOnDestination"]); // https://sit-api.eat.xxxxxx.xxxx.xx:443/samlsso

            samlRequest.NameIdPolicy = new NameIdPolicy()
            {
                AllowCreate = false,
                Format = "urn:oasis:names:tc:SAML:2.0:nameid-format:persistent",
                SPNameQualifier = _appConfiguration["Saml2:SPNameQualifier"]
            };

            samlRequest.Conditions = new Condition();
            samlRequest.Conditions.Items = new List<ITfoxtec.Identity.Saml2.Schemas.Conditions.ICondition>();
            samlRequest.Conditions.Items.Add(new ITfoxtec.Identity.Saml2.Schemas.Conditions.AudienceRestriction() { Audiences = new List<Audience>() { new Audience() { Uri = _appConfiguration["Saml2:AllowedAudienceUris"] } } });

            var bnd = binding.Bind(samlRequest);

【问题讨论】:

    标签: port uri itfoxtec-identity-saml2


    【解决方案1】:

    如果您使用的是Saml2RedirectBinding,则可以在调用ToActionResult 方法后更改目标URL。从而覆盖默认行为。

    像这样:

    var action = binding.ToActionResult() as RedirectResult;
    action.Url = action.Url.Replace("https://sit-api.eat.xxxxxx.xxxx.xx/samlsso", "https://sit-api.eat.xxxxxx.xxxx.xx:443/samlsso");
    return action;
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2022-09-30
      • 2019-08-26
      • 1970-01-01
      • 2022-10-23
      • 1970-01-01
      • 1970-01-01
      • 2018-12-11
      相关资源
      最近更新 更多