0

I am adding OIDC login to a WinForms application. I set up the application using the IdentityModel.OidcClient library and pulled the boilerplace code from their WinForm Sample. The OIDC successfully shows the login form, does MFA, and I get back the tokens.

However, if I close the application and open it again, I have to authenticate again. Usually, the SSO session in the browser allows me to bypass this step. It seems the OidcClient is using a browser session that gets destroyed when the application closes and is not shared between applications.

How can I configure my application to use the SystemBrowser or another browser that will maintain those SSO cookies between executions and/or for different applications that use this component.

Thanks in advance.

David Schwartz
  • 162
  • 1
  • 10

1 Answers1

0

First thing to check is that the session cookie that you set have an expire date in the future, otherwise it will just be a cookie that will last this browser session.

In your browser you can see that in the developer tools section, like in this example:

enter image description here

Alternatively, you can use a tool like Fiddler to check the response that sets the session cookie and make sure it contains a future expire date.

You can configure that in your ASP.NET application.

Tore Nestenius
  • 16,431
  • 5
  • 30
  • 40
  • Thank you #Tore... but this does not answer the question. The issue I am having is that the cookie is stored in the browser and the application is using its own Browser so the cookie only lasts until the application gets closed and also doesn't work for other applications. I am looking to have it work for several different applications. – David Schwartz Mar 18 '21 at 14:51
  • what browser are you using? Some browsers will remember the cookies, if the cookie have a future expire date set. Or try the approach here to retrieve the cookie from the browser, and then set it again when you need to open the browser the next time? https://www.c-sharpcorner.com/Resources/851/setcookie-and-getcookie-in-wpf-application.aspx – Tore Nestenius Mar 18 '21 at 15:04
  • or this link? https://stackoverflow.com/questions/17096932/get-cookies-on-a-browser-from-winform-c-sharp – Tore Nestenius Mar 18 '21 at 15:06
  • My question is essentially which browser to use and how to get IdentityModel.OidcClient to use that browser – David Schwartz Mar 18 '21 at 15:17