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);
}
}