0

We are developing a web application communicating with its backend API. API is written in .NET Core and is running in Azure and is using OpenID authentication against Azure Active Directory. Configuration of the authentication process is below (as you can see we're using cookie based authentication):

services.AddAuthentication(options =>
         {
             options.DefaultAuthenticateScheme = AzureADDefaults.CookieScheme;
             options.DefaultChallengeScheme = AzureADDefaults.AuthenticationScheme;
             options.DefaultSignInScheme = AzureADDefaults.CookieScheme;
         })
        .AddAzureAD(options =>
        {
            configuration.Bind("AzureAd", options);
        });

services.Configure<CookieAuthenticationOptions>(AzureADDefaults.CookieScheme, options =>
         {
             options.Cookie.HttpOnly = true;
             options.Cookie.SecurePolicy = CookieSecurePolicy.Always;
             options.Cookie.SameSite = SameSiteMode.Lax;
             options.Cookie.MaxAge = new TimeSpan(7, 0, 0, 0);
         });
        services.Configure<OpenIdConnectOptions>(AzureADDefaults.OpenIdScheme, options =>
        {
            options.Authority = options.Authority + "/v2.0/";       
            options.TokenValidationParameters.ValidateIssuer = false; 
        });

We want to test our application API in Postman and we have set up a request with authentication against AAD (configuration below). Postman is able to make it through authentication and we get the access_token, however the request to API fails.

Postman authentication setting

When we compared Postman cookies and browser cookies we discovered, that browser contains a cookie postman is missing .AspNetCore.AzureADCookie. It's Friday afternoon and we really got into desperation phase and have no clue what may be wrong. How can we make Postman to call AAD in a way it returns such cookie in response and adds it to the API request.

Biggles
  • 1,306
  • 1
  • 12
  • 22

1 Answers1

1

You should be able to use your browser cookies by installing Postman Interceptor extension. Please try the same and let me know if it works.

https://learning.postman.com/docs/sending-requests/capturing-request-data/interceptor/#syncing-cookies

You can also ref the following -> Postman is not using cookie

RB-2902
  • 105
  • 1
  • 7
  • Yes, it is possible to use Postman interceptor to get the cookie, I was wondering whether it would be possible to generate the cookie just between Postman and .NET Core solution without cookie interception – Biggles Jan 18 '21 at 08:16