本文整理汇总了C#中OwinContext.GetIdentityServerHost方法的典型用法代码示例。如果您正苦于以下问题:C# OwinContext.GetIdentityServerHost方法的具体用法?C# OwinContext.GetIdentityServerHost怎么用?C# OwinContext.GetIdentityServerHost使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OwinContext
的用法示例。
在下文中一共展示了OwinContext.GetIdentityServerHost方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetCorsPolicyAsync
public async Task<System.Web.Cors.CorsPolicy> GetCorsPolicyAsync(IOwinRequest request)
{
var path = request.Path.ToString();
var origin = request.Headers["Origin"];
// see if the Origin is different than this server's origin. if so
// that indicates a proper CORS request
var ctx = new OwinContext(request.Environment);
// using GetIdentityServerHost takes into account a configured PublicOrigin
var thisOrigin = ctx.GetIdentityServerHost();
if (origin != null && origin != thisOrigin)
{
if (IsPathAllowed(request))
{
Logger.InfoFormat("CORS request made for path: {0} from origin: {1}", path, origin);
if (await IsOriginAllowed(origin, request.Environment))
{
Logger.Info("CorsPolicyService allowed origin");
return Allow(origin);
}
else
{
Logger.Info("CorsPolicyService did not allow origin");
}
}
else
{
Logger.InfoFormat("CORS request made for path: {0} from origin: {1} but rejected because invalid CORS path", path, origin);
}
}
return null;
}