Trying to create patch work for same site cookie issue in chrome 80 beta version
Reference :https://devblogs.microsoft.com/aspnet/upcoming-samesite-cookie-changes-in-asp-net-and-asp-net-core/
Steps done till now:
upgraded owin to 4.1
upgraded .net framework to 4.72
Added sameCookieManager as mentioned in Reference link
startup.cs
var options = new OpenIdConnectAuthenticationOptions
{
ClientId = clientId,
Authority = authority,
PostLogoutRedirectUri = redirectUri,
RedirectUri = redirectUri,
TokenValidationParameters = new TokenValidationParameters
{
ValidateIssuer = false,
SaveSigninToken=true
},
Notifications = new OpenIdConnectAuthenticationNotifications()
{
AuthenticationFailed = OnAuthenticationFailed,
AuthorizationCodeReceived = OnAuthorizationCodeReceived,
SecurityTokenValidated = OnSecurityTokenValidated
},
CookieManager = new SameSiteCookieManager(new SystemWebCookieManager())
};
It ends up in OnAuthenticationFailed with error "IDX21323 OpenIdConnectProtocolValidationContext.Nonce was null, OpenIdConnectProtocolValidatedIdToken.Paylocad.Nonce was not null"
Tried Few bypass methods mentioned in links below but it didn't work
MVC5 Azure AD IDX21323
Related
I have NLog code currently reading from NLog.config to set up logging to text files and then I'd like to add logging fatal errors to email. However, the email settings are in my appsettings.json file.
What I tried so far is this in my Startup.cs
var emailConfig = Configuration
.GetSection("EmailConfiguration")
.Get<EmailConfiguration>();
services.AddSingleton(emailConfig);
var mailTarget = new MailTarget()
{
SmtpServer = emailConfig.SmtpServer,
SmtpUserName = emailConfig.UserName,
SmtpPort = emailConfig.Port,
SmtpPassword = services.BuildServiceProvider().CreateScope().ServiceProvider.GetService<IEmailSender>().Decrypt(emailConfig.Password),
To = emailConfig.To
};
NLog.Config.SimpleConfigurator.ConfigureForTargetLogging(mailTarget, LogLevel.Fatal);
However I have 2 problems when I try to _logger.Fatal("testing, please ignore");:
Under _logger.Factory.Configuration.AllTargets I now only see the mail settings I configured above, which I understand is due to SimpleConfigurator overwriting (yet I'm not sure what I need to do so that I add rather than overwrite).
I still didn't receive an email despite and I'm not sure how I can debug this now.
I fixed both issues.
var mailTarget = new MailTarget()
{
SmtpServer = emailConfig.SmtpServer,
SmtpUserName = emailConfig.UserName,
SmtpPort = emailConfig.Port,
SmtpPassword = services.BuildServiceProvider().CreateScope().ServiceProvider.GetService<IEmailSender>().Decrypt(emailConfig.Password),
From = emailConfig.UserName,
To = emailConfig.To,
EnableSsl = true,
SmtpAuthentication = SmtpAuthenticationMode.Basic,
Html = true
};
var configuration = LogManager.Configuration;
configuration.AddRuleForOneLevel(LogLevel.Fatal, mailTarget);
LogManager.ReconfigExistingLoggers();
The first problem related to the last 3 lines, whereas the second issue was related to the SMTP configuration.
I'd like to send a binary attachment to Report Portal with .net client. How can I do it?
Example is in Tests project.
https://github.com/reportportal/client-net/blob/master/ReportPortal.Client.Tests/LogItem/LogItem.cs
Find CreateLogWithAttach test and see code.
var data = new byte[] { 1, 2, 3 };
var log = Service.AddLogItem(new AddLogItemRequest
{
TestItemId = _testId,
Text = "Log1",
Time = DateTime.UtcNow,
Level = LogLevel.Info,
Attach = new Attach("file1", "application/octet-stream", data)
});
Related documentation: Log Data in ReportPortal
I am trying to upload a Word Document to my personal box account using Box Windows SDK V2 using the following code.
using (Stream s = new FileStream("C:\\word.docx",
FileMode.Open, FileAccess.Read,
FileShare.ReadWrite))
{
MemoryStream memStream = new MemoryStream();
memStream.SetLength(s.Length);
s.Read(memStream.GetBuffer(), 0, (int)s.Length);
BoxFileRequest request = new BoxFileRequest()
{
Parent = new BoxRequestEntity() { Id = "0" },
Name = TxtSaveAS.Text
};
BoxFile f = await Client.FilesManager.UploadAsync(request, memStream)
The document gets uploaded successfully in root folder but the problem is, the extension of document is set to "File" (which is not previewed by Box because of having unsupported extension, neither it gets the icon of word document) rather than "docx" though it still gets open correctly in Microsoft word.
How to upload file using box windows sdk with respective extensions.
suggestions are greatly welcomed.
In order to upload the file with the correct extension, simply append the extension to the Name.
BoxFileRequest request = new BoxFileRequest()
{
Parent = new BoxRequestEntity() { Id = "0" },
Name = TxtSaveAS.Text + ".docx"
};
BoxApi.V2.BoxManager boxManager = new BoxManager(response1.Data.access_token);
var sharedLink = new SharedLink()
{
Access = Access.Open,
Permissions = new Permissions() { CanDownload = true, CanPreview = true },
UnsharedAt = DateTime.Now.AddYears(1)
};
boxManager.ShareLink(file, sharedLink);
This below code throws "Bad request" error to me, can anyone help me on this?
Can you verify what type of account you have with Box?
If you have a personal account, removing
UnsharedAt = DateTime.Now.AddYears(1)
should allow the request to work.
Expiring shared links requires an upgraded account
Following methods are not working properly.
Since GRID is used, capability is set as null here.
System.setProperty("webdriver.chrome.driver", "C:/chromedriver.exe");
DesiredCapabilities capability=null;
Method 1:
DesiredCapabilities capabilities = DesiredCapabilities.chrome();
capabilities.setCapability("chrome.switches", Arrays.asList("--user-data-dir=C:/Users /username/AppData/Local/Google/Chrome/User Data/Default"));
driver = new ChromeDriver(capabilities);
Method 2:
DesiredCapabilities capabilities = DesiredCapabilities.chrome();
String chromeProfile = "C:/Users/username/AppData/Local/Google/Chrome/Application /chrome.exe";
ArrayList<String> switches = new ArrayList<String>();
switches.add("C:/Users/username/AppData/Local/Google/Chrome/User Data/Default" + chromeProfile);
capabilities.setCapability("chrome.switches", switches);
driver = new ChromeDriver(capabilities);
System.setProperty("webdriver.chrome.driver","C:\\chromedriver.exe");
ChromeOptions options = new ChromeOptions();
options.addArguments("user-data-dir=C:/Users/user_name/AppData/Local/Google/Chrome/User Data");
options.addArguments("--start-maximized");
driver = new ChromeDriver(options);
If you face such error:
org.openqa.selenium.WebDriverException: unknown error: Chrome failed to start: exited normally
Then try to create a new Chrome profile and execute tests.
Copy the folder, 'User Data'
Paste & Rename the folder on the same location. e.g., New User
Now, locate the directory, C:/Users/user_name/AppData/Local/Google/Chrome/New User
If you like to test the profile, then bookmark some of the sites & observe them on next run.
1 Set the chromedriver property in starting the node. My approach:
java -jar selenium-server-standalone-2.31.0.jar -role node -hub http://localhost:4444/grid/register -maxSession 15 -browser browserName="chrome",version=ANY,platform=WINDOWS,maxInstances=15 -Dwebdriver.chrome.driver=lib\chromedriver.exe
2 Inside the code my approach:
capabilities = DesiredCapabilities.chrome();
capabilities.setCapability("chrome.switches", Arrays.asList("--start-maximized"));
driver = new RemoteWebDriver(new URL("http://127.0.0.1:4444/wd/hub"), capabilities);
3 loading the HTTP basic auth page:
String username = "Pavel";
String password = "Omgtoosecrettotellyou";
driver.get("http://" + username + ":" + password + "#" +"your-site.com");