【问题标题】:OWIN OAuth 2.0 Authorization Server - Paths namespaceOWIN OAuth 2.0 授权服务器 - 路径命名空间
【发布时间】:2018-04-29 07:58:32
【问题描述】:

我使用OWIN OAuth 2.0 Authorization Server sample 作为使用我们公司的 Active Directory 创建我自己的 OAuth 服务提供商的圣殿。

“下载示例代码”不起作用,我在以下代码 sn-p 中找不到Paths 对象

// Enable the Application Sign In Cookie.
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
    AuthenticationType = "Application",
    AuthenticationMode = AuthenticationMode.Passive,
    LoginPath = new PathString(Paths.LoginPath),
    LogoutPath = new PathString(Paths.LogoutPath),
});

Paths 属于哪个命名空间?

【问题讨论】:

    标签: .net oauth-2.0 authorization owin


    【解决方案1】:

    我能够找到工作代码示例 here 并且 Paths 对象是 AuthorizationServer MVC 项目中的自定义对象

    public class Paths
    {
        public static string AuthorizePath { get; set; }
        public static string LoginPath { get; set; }
        public static string LogoutPath { get; set; }
        public static string TokenPath { get; set; }
    }
    

    【讨论】:

    • 此类定义与您链接到的示例中的定义不同。这些应该被定义为常量。
    【解决方案2】:

    这是该类的定义...来自https://code.msdn.microsoft.com/OWIN-OAuth-20-Authorization-ba2b8783/view/SourceCode#content

    public static class Paths
    {
        /// <summary>
        /// AuthorizationServer project should run on this URL
        /// </summary>
        public const string AuthorizationServerBaseAddress = "http://localhost:11625";
    
        /// <summary>
        /// ResourceServer project should run on this URL
        /// </summary>
        public const string ResourceServerBaseAddress = "http://localhost:38385";
    
        /// <summary>
        /// ImplicitGrant project should be running on this specific port '38515'
        /// </summary>
        public const string ImplicitGrantCallBackPath = "http://localhost:38515/Home/SignIn";
    
        /// <summary>
        /// AuthorizationCodeGrant project should be running on this URL.
        /// </summary>
        public const string AuthorizeCodeCallBackPath = "http://localhost:38500/";
    
        public const string AuthorizePath = "/OAuth/Authorize";
        public const string TokenPath = "/OAuth/Token";
        public const string LoginPath = "/Account/Login";
        public const string LogoutPath = "/Account/Logout";
        public const string MePath = "/api/Me";
    }
    

    【讨论】:

      猜你喜欢
      • 2015-01-15
      • 2014-07-09
      • 2013-10-05
      • 2016-08-12
      • 1970-01-01
      • 2012-10-01
      • 2014-09-08
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多