OWIN扩展在.NET Core中的OauthauthorizationerverProvider支持?

发布于 2025-01-23 07:28:48 字数 1684 浏览 0 评论 0原文

我们已经从.NET框架迁移到.NET 6,但是转换后,不支持“ Microsoft.Owin.Security.oauth”之类的参考库,因此我无法使用“ OauthauthorizationerverProvider”,我们需要自定义提供商来验证针对AD的凭证,您能帮助您在.NET Core中实现相同的功能,适用于刷新令牌。

除此之外,Owin Cross Platform是吗?如果没有,最新或广泛使用的身份验证机制是什么?

public class AuthorizationProvider : OAuthAuthorizationServerProvider
    {
        

        public AuthorizationProvider()
        {
           // Code
        }

        public override async Task ValidateClientAuthentication(OAuthValidateClientAuthenticationContext context)
        {
            context.Validated();

            // token endpoint is called from configuration service and ui.
            // source parameter added to identify from where endpoint is called
            var source = context.Parameters.Where(f => f.Key == "source").Select(f => f.Value).SingleOrDefault();
            if (source != null && !string.IsNullOrEmpty(source[0]))
            {
                context.OwinContext.Set<string>("source", source[0]);
            }
        }


 public class RefreshTokenProvider : IAuthenticationTokenProvider
    {
        private static ConcurrentDictionary<string, AuthenticationTicket> _refreshTokens = new ConcurrentDictionary<string, AuthenticationTicket>();

        /// <summary>
        /// There are two create methods in this class as interface expects both to be implemented
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public async Task CreateAsync(AuthenticationTokenCreateContext context)
        {            
            Create(context);
        }
        }

We have migrated from .NET framework to .NET 6, however after conversion the reference libraries like "Microsoft.Owin.Security.OAuth" are not supported so I'm not able to use "OAuthAuthorizationServerProvider", we need the custom provider to validate credentials against AD, could you please help how to achieve the same in .NET core, same applies for Refresh token.

Apart from that, is OWIN cross platform? if not, what is the latest or widely used authentication mechanism?

public class AuthorizationProvider : OAuthAuthorizationServerProvider
    {
        

        public AuthorizationProvider()
        {
           // Code
        }

        public override async Task ValidateClientAuthentication(OAuthValidateClientAuthenticationContext context)
        {
            context.Validated();

            // token endpoint is called from configuration service and ui.
            // source parameter added to identify from where endpoint is called
            var source = context.Parameters.Where(f => f.Key == "source").Select(f => f.Value).SingleOrDefault();
            if (source != null && !string.IsNullOrEmpty(source[0]))
            {
                context.OwinContext.Set<string>("source", source[0]);
            }
        }


 public class RefreshTokenProvider : IAuthenticationTokenProvider
    {
        private static ConcurrentDictionary<string, AuthenticationTicket> _refreshTokens = new ConcurrentDictionary<string, AuthenticationTicket>();

        /// <summary>
        /// There are two create methods in this class as interface expects both to be implemented
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public async Task CreateAsync(AuthenticationTokenCreateContext context)
        {            
            Create(context);
        }
        }

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文