I have a question about authentication mechanism in CEF. Currently when I need to be authenticated I send my credentials in callback function.
- Code: Select all
bool IRequestHandler.GetAuthCredentials(IWebBrowser browserControl, IBrowser browser, IFrame frame, bool isProxy, string host, int port, string realm, string scheme, IAuthCallback callback)
{
try
{
if (isProxy && _proxySettings != null && _proxySettings.Credentials != null)
{
callback.Continue(_proxySettings.Credentials.UserName, _proxySettings.Credentials.UserPassword.SecureStringToString());
return true;
}
return false;
}
finally
{
if (!callback.IsDisposed)
{
callback.Dispose();
}
}
}
How I set proxy settings:
- Code: Select all
IRequestContext requestContext = _browser.GetBrowser().GetHost().RequestContext;
if (requestContext != null)
{
string proxyMode = "system";
IDictionary<string, object> proxyParameters = new Dictionary<string, object>();
if (proxySettings != null)
{
proxyMode = "fixed_servers";
proxyParameters.Add("server", proxySettings.Address);
}
proxyParameters.Add("mode", proxyMode);
string error;
if (!requestContext.SetPreference("proxy", proxyParameters, out error))
{
Log.Error(new ArgumentException(error), "Error occurs during setting preferences in requestContext");
}
}
I need to be authenticated with windows credentials. I can't use any dialog with inputs for user name and password. Do you know any ways to do it?