简体   繁体   English

Azure API 管理中的重定向策略

[英]Redirect policy in Azure API Management

Azure API 管理 (Azure APIM) 是否提供任何重定向 URL 的方法,以复制Apigee RedirectToLoginPage功能

You can do it with a policy set at the global (All APIs) scope.您可以使用在全局(所有 API)范围内设置的策略来实现。

<choose>
    <when condition="@(!context.Request.OriginalUrl.Host.Contains("redirect.com"))">
        <return-response>
            <set-status code="303" reason="See Other" />
            <set-header name="Location" exists-action="override">
                <value>@("https://redirect.com/" + context.Request.OriginalUrl.Path + context.Request.OriginalUrl.QueryString)</value>
            </set-header>
        </return-response>
    </when>
</choose>

At the time of writing this isn't supported at Azure APIM level.在撰写本文时,Azure APIM 级别不支持此功能。 Since I was using IdentityServer for Oauth2 security, I accomplished this by writing an owin/katana authentication middleware.由于我将 IdentityServer 用于 Oauth2 安全性,因此我通过编写 owin/katana 身份验证中间件来实现这一点。 Anders Abel has a great post about it .安德斯·阿贝尔 (Anders Abel) 对此发表了一篇很棒的文章

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM