1

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);
        }
        }
Mysterious288
  • 365
  • 5
  • 24
  • `Asp.Net Core` introduces a new concept called middleware, so the authorization is very different from `.Net Framework`. In Asp.Net core, we use `OpenIdConnect`, Here is an [issue](https://stackoverflow.com/questions/29055477/oauth-authorization-service-in-asp-net-core) show more details about authorization in asp.net core. – Xinran Shen Apr 25 '22 at 09:38
  • @XinranShen I have seen that post, I think I have rewrite to middleware – Mysterious288 Apr 27 '22 at 05:32

0 Answers0