📁 Sangam Dhakal - Portfolio v2.0 - Netscape Navigator 4.0
_
□
×

📚 Interview question

At 9:05 on a Monday, support reports that users suddenly can't sign in to your web app, and nobody deployed anything over the weekend. Your app uses OpenID Connect with Microsoft Entra ID (or another identity provider) and cookie sessions. How do you work out what broke: an expired client secret or certificate, signing key rollover, clock skew, lost Data Protection keys, or an identity provider outage, and how do you fix and prevent each?

A production playbook for sudden sign-in failures with no deployment: reading the OIDC error, and the usual time-based causes such as expired client secrets or certificates, signing key rollover with cached metadata, clock skew, lost Data Protection keys and identity provider outages, with fixes and prevention.

Mid-Level Debugging Intermediate authentication certificates data-protection entra-id openid-connect production

🎯 Key points

  • No deploy plus a sudden start points at time: something expired or rotated (secret, certificate, signing key, Data Protection key)
  • Find where the flow breaks: at the identity provider (error page with an AADSTS code), at the callback (token redemption or validation fails), or after sign-in (cookie not accepted)
  • Expired client secret: AADSTS7000222 at token redemption; fix by adding a new credential, ideally moving to a certificate or federated credential
  • Signing key rollover: IDX10503/IDX10501 signature errors if the app pinned keys or can't refresh OIDC metadata; ConfigurationManager refreshes automatically
  • Clock skew: IDX10223 lifetime errors from a host clock out of sync; default ClockSkew is 5 minutes
  • Lost Data Protection keys: users loop back to sign-in and logs show 'The key ... was not found in the key ring' after scale-out or restart without persisted keys
  • IdP outage: check the provider's status page and Azure Service Health; existing sessions keep working if cookies don't depend on the IdP
  • Prevent: expiry monitoring for every secret and certificate, managed identity or federated credentials, persisted and protected Data Protection keys, synthetic sign-in tests

⏱ 30-second answer

No deployment plus a sudden failure means something time-based expired or rotated. I first find where the flow breaks. An error at the identity provider with an AADSTS code points at the app registration; a failure at the callback points at token redemption or validation; a redirect loop after a successful sign-in points at the cookie. The usual suspects are an expired client secret (AADSTS7000222), signing key rollover that the app can't follow because it pinned keys or can't reach the metadata endpoint, clock skew (IDX10223), lost Data Protection keys so cookies can't be decrypted, or a genuine IdP outage. I fix the immediate cause, then prevent the class of failure: expiry alerts, managed identity or federated credentials instead of secrets, persisted Data Protection keys, and a synthetic sign-in test.

🗣 Full answer (senior)

How I would answer this in an interview

"Monday morning, no deploy, everyone at once: I immediately think of something with an expiry date. Client secrets in Entra ID have a maximum lifetime, certificates expire, identity providers roll their signing keys, and Data Protection keys rotate every 90 days by default. So I check two things in parallel: which step of the sign-in fails, and what expired recently.

The step matters. If users see an Entra error page with an AADSTS code, the provider is rejecting the request, often a redirect URI or app registration problem. If they come back to our /signin-oidc callback and get a 500, our app is failing to redeem the code or validate the token, and our logs will have the exception. AADSTS7000222 means the client secret expired; IDX10503 or IDX10501 means signature validation failed, which after a key rollover usually means the app pinned a signing key or can't reach the provider's metadata to refresh keys, for example because of a new egress firewall rule; IDX10223 means the token looks expired, which with fresh tokens means the server clock is wrong. If sign-in succeeds but users bounce straight back to the login page, the auth cookie isn't being accepted, and the classic cause is Data Protection keys that weren't persisted, so after a restart or scale-out each instance has its own keys and can't decrypt the others' cookies.

The fix for an expired secret is quick: add a new credential, update Key Vault, restart. The real fix is not having a secret to expire: a certificate stored in Key Vault, or better, a managed identity used as a federated identity credential on the app registration. The mistake I see is treating it as a one-off. If one secret expired silently, others will, so I'd inventory every credential with its expiry and alert 30 days ahead."


The playbook, in order

Step What I do Tool or command
1. Symptom Sign-in failing for everyone, no deploy Support tickets, failed request rate on /signin-oidc
2. First five minutes Check IdP status and Azure Service Health; confirm existing sessions still work; post a status update Status pages, a test account
3. Data to collect The exact error and where it occurs Browser network trace, app logs, Entra sign-in logs
4. Rule out IdP outage, recent config change, clock Service Health, App Configuration audit, server time
5. Root cause Which credential or key expired, or what blocked metadata App registration Certificates & secrets, Key Vault, egress rules
6. Fix New credential, fix clock, persist keys, unblock metadata Portal or IaC, Key Vault
7. Prevention Expiry alerts, secretless credentials, synthetic sign-in Azure Monitor, Key Vault events, availability tests

Where it breaks tells you what broke

Where What you see Likely cause
At the IdP Entra error page, AADSTS code Redirect URI, app registration, conditional access, IdP outage
At the callback 500 on /signin-oidc, AADSTS7000222 in logs Expired client secret or certificate
At the callback IDX10503 / IDX10501 (signature) Pinned signing key, metadata endpoint unreachable
At the callback IDX10223 (lifetime) Clock skew on the host
After sign-in Redirect loop, 'key not found in key ring' Data Protection keys not shared or lost
After sign-in Correlation or nonce cookie errors SameSite or HTTPS scheme issues behind a proxy

Production example

In a typical case, a client secret created with a 24-month lifetime expires on a Sunday. From Monday morning every sign-in fails at the callback with AADSTS7000222; users with existing cookies keep working until their sessions expire, so the failure rate climbs over the morning. Adding a new secret to Key Vault and restarting restores sign-in in 20 minutes; moving the app to a certificate in Key Vault with automatic renewal, and adding an Azure Monitor alert on credentials expiring within 30 days, removes the failure mode.

🔍 What the interviewer is checking

Checks that the candidate can localise a sign-in failure to a step in the OIDC flow, knows the time-based causes and their error codes, fixes the immediate problem quickly and removes the class of failure.

Green flags

  • Connects 'no deploy, sudden failure' to expiry and rotation
  • Locates the failing step: IdP, callback or cookie
  • Knows the common error codes (AADSTS7000222, IDX10503, IDX10223) and Data Protection key ring symptoms
  • Proposes secretless credentials, expiry alerts and synthetic sign-in tests

Red flags

  • Raises clock skew or disables validation to make it work
  • Doesn't know cookies depend on Data Protection keys
  • Treats it as a one-off with no prevention

📚 Learn in depth

1. The OIDC authorisation code flow and where each failure lives

browser ──► your app /login ──► 302 to IdP /authorize
                                       │  (user signs in; AADSTS errors appear here)
                                       ▼
browser ◄── 302 back to /signin-oidc?code=...
   │
   ▼
your app: redeem code at IdP /token  ── client secret / certificate / federated credential
          validate id_token: signature (keys from jwks_uri), issuer, audience, lifetime (clock)
          issue auth cookie (encrypted with Data Protection keys)
   │
   ▼
later requests: cookie decrypted with Data Protection keys ── any instance must have the key

2. Client credentials expire

Entra ID client secrets have a maximum lifetime (the portal offers up to 24 months, and many organisations restrict it further by policy). Certificates expire on their NotAfter date. When the credential expires, the token endpoint returns AADSTS7000222 (expired secret) or a related certificate error. Better options:

  • Certificate in Key Vault with auto-renewal; the app loads the latest version.
  • Federated identity credential: the app registration trusts tokens from a managed identity (or a workload identity in AKS), so there's no secret at all. Microsoft.Identity.Web supports this via ClientCredentials with SignedAssertionFromManagedIdentity.

3. Signing key rollover

Providers publish signing keys at the jwks_uri in their OpenID configuration and rotate them periodically, sometimes urgently. ASP.NET Core's OIDC and JWT handlers use a ConfigurationManager that caches metadata (refresh interval of about a day by default) and refreshes on demand when it sees an unknown key id, rate-limited to about every five minutes. Problems come from:

  • Hard-coding IssuerSigningKey in TokenValidationParameters (no rollover possible).
  • Egress rules or proxies that block the metadata endpoint, so refresh fails silently and the old keys stay cached.
  • Custom caching of metadata for too long.

4. Clock skew

Tokens carry nbf and exp. TokenValidationParameters.ClockSkew defaults to 5 minutes. A VM or container host with a drifting clock (NTP blocked, a suspended VM) rejects fresh tokens with IDX10223 or IDX10222. Fix the time sync; don't raise ClockSkew to an hour.

5. Data Protection keys

Cookie authentication encrypts the ticket with ASP.NET Core Data Protection. Keys rotate every 90 days by default and are stored, by default, in a location local to the machine or container. In a container without persistence, a restart creates a new key ring, so existing cookies can't be decrypted; across several instances, each has a different ring, so a cookie issued by one is rejected by another. Persist keys to shared storage (PersistKeysToAzureBlobStorage) and protect them (ProtectKeysWithAzureKeyVault), and set the same SetApplicationName on every instance.

6. IdP outages

Check the provider's status page and Azure Service Health. Your app can't issue new sessions during an outage, but existing sessions continue if the cookie lifetime doesn't depend on refreshing tokens at the IdP on every request. Plan for it: reasonable cookie lifetimes and a clear message on the sign-in page.

Try it yourself

  1. Create a test app registration with a client secret, sign in, then delete the secret and sign in again; read the error in the logs.
  2. Run two instances of a cookie-auth app behind a local load balancer without shared Data Protection keys and watch the redirect loop; then add PersistKeysToFileSystem on a shared volume.
  3. Set ClockSkew = TimeSpan.Zero and change the container clock with faketime to reproduce IDX10223.
  4. Block outbound access to login.microsoftonline.com metadata in a test network and observe what happens when a key id changes.
  5. Write a KQL alert or a small script that lists app registration credentials expiring in the next 30 days (Microsoft Graph applications with passwordCredentials and keyCredentials).

💻 Code

OIDC with a secretless credential and Data Protection that survives restarts and scale-out.

// Program.cs
using Azure.Identity;
using Microsoft.AspNetCore.DataProtection;
using Microsoft.Identity.Web;

var builder = WebApplication.CreateBuilder(args);

// Shared, protected key ring: every instance can decrypt every cookie, and keys survive restarts.
builder.Services.AddDataProtection()
    .SetApplicationName("orders-portal")
    .PersistKeysToAzureBlobStorage(new Uri(builder.Configuration["DataProtection:BlobUri"]!), new DefaultAzureCredential())
    .ProtectKeysWithAzureKeyVault(new Uri(builder.Configuration["DataProtection:KeyUri"]!), new DefaultAzureCredential());

// Microsoft.Identity.Web reads AzureAd config; metadata and signing keys refresh automatically.
builder.Services.AddAuthentication(Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectDefaults.AuthenticationScheme)
    .AddMicrosoftIdentityWebApp(builder.Configuration.GetSection("AzureAd"));

builder.Services.AddAuthorization();
var app = builder.Build();
app.UseAuthentication();
app.UseAuthorization();
app.Run();
{
  "AzureAd": {
    "Instance": "https://login.microsoftonline.com/",
    "TenantId": "<tenant-id>",
    "ClientId": "<client-id>",
    "CallbackPath": "/signin-oidc",
    "ClientCredentials": [
      {
        "SourceType": "SignedAssertionFromManagedIdentity",
        "ManagedIdentityClientId": "<user-assigned-mi-client-id>"
      }
    ]
  }
}
# List app registration credentials and their expiry (Azure CLI)
az ad app credential list --id <app-id> --query "[].{type:type, end:endDateTime, name:displayName}" -o table
az ad app credential list --id <app-id> --cert --query "[].{end:endDateTime, name:displayName}" -o table
# Check the host clock inside a container
kubectl exec <pod> -- date -u

⚠ Common mistakes

  • Mistake: Assuming no deploy means nothing changed. Why it is wrong: Secrets, certificates, signing keys and Data Protection keys change on their own schedules. Instead: Check expiries and rotations first.
  • Mistake: Raising ClockSkew to fix lifetime errors. Why it is wrong: It widens the replay window and hides a broken time sync. Instead: Fix NTP or the host clock.
  • Mistake: Hard-coding the IdP's signing key. Why it is wrong: Rollover breaks validation for everyone. Instead: Let ConfigurationManager fetch keys from the metadata endpoint and allow egress to it.
  • Mistake: Leaving Data Protection keys in the container's default location. Why it is wrong: Restarts and scale-out invalidate cookies and cause redirect loops. Instead: Persist to shared storage and protect with Key Vault.
  • Mistake: Renewing the expired secret with another 24-month secret and no alert. Why it is wrong: The same outage happens again in two years. Instead: Use certificates with auto-renewal or federated credentials, and alert on expiry.
  • Mistake: Debugging from user reports only. Why it is wrong: 'Can't sign in' covers several different failures. Instead: Reproduce with a test account and a browser network trace; read the Entra sign-in logs.
  • Mistake: Forgetting to communicate. Why it is wrong: Sign-in failures flood support quickly. Instead: Post a status update early, noting that existing sessions may still work.

🏛 Senior insight: trade-offs

Sudden sign-in failures with no deploy are almost always a credential lifecycle problem, which makes them an organisational problem as much as a technical one: someone created a secret two years ago and nobody owned its expiry. The senior fix is to remove expiring secrets wherever possible and to give every remaining credential an owner and an alert.

It helps to be precise about the secretless options. A managed identity is an identity Azure creates and rotates for a resource; on its own it lets your app call Azure resources such as Key Vault or SQL. A federated identity credential is a trust rule on an app registration that says "accept a token from this issuer and subject instead of a secret". Combining them, the app registration trusts the managed identity, so the web app proves who it is to Entra ID with a token Azure issues and rotates, and there is nothing to store, leak or let expire. Outside Azure, a certificate in Key Vault with auto-renewal is the next best thing.

Know the codes you'll meet most often: AADSTS7000222 (client secret expired), AADSTS7000215 (invalid client secret, usually a wrong or truncated value), AADSTS50011 (redirect URI mismatch), AADSTS700027 (client assertion or certificate failed validation), and on the app side IDX10503/IDX10501 (signature key not found or invalid) and IDX10223 (token lifetime, often clock skew).

Authentication is also a single point of failure for the whole product, so it deserves a synthetic test: an availability test that performs a real sign-in with a test account every few minutes catches expiry, rollover and IdP problems before users do.

Option When it fits Cost When not to
Client secret with expiry alert Quick start, low-risk apps Manual rotation, alert plumbing Production apps that can use managed identity
Certificate in Key Vault, auto-renewed Apps outside Azure or needing portability Certificate management When federated credentials are available
Federated credential via managed identity Apps hosted in Azure (App Service, AKS workload identity) Setup per environment Apps not running in Azure
Synthetic sign-in test Any customer-facing sign-in A test account and test plumbing, MFA exemptions handled carefully Never skip it for critical apps

🔗 Follow-ups the interviewer may ask

  1. When: Candidate mentions issuer, audience or signing key problems Why: Checks diagnosing 401s from token validation behind a proxy
    How to answer

    Start with evidence, not guesses. A JwtBearer 401 includes a WWW-Authenticate header with an error_description, and the Microsoft.AspNetCore.Authentication logs at Debug level show an IDX error code.

    • IDX10214 / IDX10205: audience or issuer mismatch, often a different tenant, App ID URI or v1 vs v2 token.
    • IDX10223: expired, or clock skew on the host.
    • IDX10500/10503: signing key not found or signature invalid, a hard-coded key after rollover.
    • IDX20803: the API can't reach the metadata/JWKS endpoint through the egress firewall or proxy.
    • No error at all: the Authorization header never arrived (stripped by the proxy, or dropped on an HTTP-to-HTTPS redirect).

    The trade-off: decoding a token at jwt.ms is fast, but only server logs tell you which check failed.

  2. When: Candidate mentions cookies or Data Protection keys Why: Checks how cookie authentication and Data Protection work
    How to answer

    After a successful login the app calls HttpContext.SignInAsync: the cookie handler serialises the ClaimsPrincipal into an authentication ticket, encrypts and signs it with Data Protection, and sends it as a cookie. On each request the handler decrypts the cookie and rebuilds HttpContext.User, with no database call.

    • Flags: HttpOnly (JavaScript can't read it), Secure (HTTPS only), SameSite=Lax by default (not sent on most cross-site requests).
    • Expiry: ExpireTimeSpan (default 14 days) with sliding expiration that reissues the cookie once half the window has passed; IsPersistent decides whether it survives closing the browser.
    • Keys: every instance must share the Data Protection key ring, or cookies issued by one server can't be read by another.

    The trade-off: a self-contained cookie is fast and stateless, but you can't revoke it without extra checks or a server-side ticket store.

  3. When: Candidate talks about token signatures Why: Checks JWT structure, signing algorithms and validation parameters
    How to answer

    A JWT is three base64url parts, header.payload.signature. The header says which algorithm and key (alg, kid) signed it; the payload holds claims (iss, aud, sub, exp, scopes); the signature proves nobody changed them. It is signed, not encrypted, so anyone holding it can read it: no personal or secret data.

    • RS256/ES256: the identity provider signs with a private key and APIs verify with the public key from its JWKS endpoint. HS256 uses one shared secret, so every verifier could also forge tokens.
    • In ASP.NET Core, AddJwtBearer with Authority and Audience validates issuer, audience, lifetime and signature (with a 5-minute ClockSkew).

    The trade-off: validation is local and fast, but a stolen token is valid until exp, so keep access tokens short-lived.

🛠 Real-world problems: how you handle them

Monday-morning sign-in outage from an expired client secret
Situation
A customer portal on [Azure App Service, three instances] using OpenID Connect with [Microsoft Entra External ID] and cookie sessions, [about 20,000] sign-ins per weekday. The client secret had been created [two years] earlier by a developer who had since left.
Signals
Support tickets from [9:05] on Monday; a spike in 500s on `/signin-oidc` in Application Insights; users with existing sessions were unaffected, so the failure rate rose gradually through the morning.
Investigation
Reproduced with a test account and a browser trace: the callback failed. App logs showed AADSTS7000222 during token redemption. The app registration's Certificates & secrets page showed the only secret had expired on Sunday. Azure Service Health showed no Entra incident.
Resolution
Immediate: created a new secret, stored it in Key Vault, restarted the app; sign-in recovered [20 minutes] after the first ticket was triaged. Real fix: moved the app to a federated identity credential using a user-assigned managed identity, removing the secret entirely.
Prevention
Inventoried all app registrations with Microsoft Graph and set an alert for credentials expiring within 30 days, assigned owners to each app registration, persisted Data Protection keys to Blob Storage protected by Key Vault, and added an Application Insights availability test that performs a real sign-in every five minutes.

How to tell it (STAR)

**S:** At [company], on a Monday morning, nobody could sign in to our customer portal, and nothing had been deployed. **T:** I picked up the incident and had to restore sign-in and make sure it couldn't happen again. **A:** I reproduced it with a test account and saw the failure was at our callback; the logs showed AADSTS7000222, an expired client secret created two years earlier. I added a new secret through Key Vault and restarted, then moved the app to a federated credential with a managed identity so there's no secret to expire. I also inventoried every app registration and set up a 30-day expiry alert and a synthetic sign-in test. **R:** Sign-in was back in [about 20 minutes], the inventory found [four] more credentials expiring within the year, and we haven't had a credential-expiry outage since.

More in Debugging Production Issues

Last updated 23 Nov 2026.

🌐 Sangam's Webring

⏪ Previous 🏠 Main Next ⏩
💬 Chat with me