wasAsked.

How did you handle authentication and authorization in your current project?

Altimetrik · Role not specified · technical

Published

Asked in 2026 · Authentication & Security

Community answers

Posted by wasAsked editorial collection

A strong answer describes the real design in layers. Example answer for a React or Angular frontend with an ASP.NET Core API: Authentication — "who are you?" - We use Microsoft Entra ID (or Keycloak or Auth0) with OpenID Connect. The frontend uses the Authorization Code flow with PKCE through MSAL; users sign in with corporate SSO and MFA. - The frontend receives an access token for our API, and an interceptor adds it as a Bearer header to each call. - The API validates tokens with AddJwtBearer (or Microsoft.Identity.Web): signature, issuer, audience and expiry. - Access tokens are short-lived; the library renews them silently with refresh tokens. Authorization — "what are you allowed to do?" - Roles or groups from the identity provider (Admin, Manager, User) are mapped to policies: options.AddPolicy("CanApprove", p => p.RequireRole("Manager", "Admin")); - Endpoints are protected with [Authorize(Policy = "CanApprove")]. A fallback policy requires authentication everywhere unless an endpoint is explicitly [AllowAnonymous]. - Resource-level rules use IAuthorizationService with custom handlers, for example "a manager can approve only expenses from their own department". - Data is filtered by tenant or owner in queries so users never receive records they should not see. Frontend role - Route guards and hidden buttons improve user experience, but every rule is enforced again on the server. Service-to-service calls - Background services and other APIs use the Client Credentials flow with managed identities, with app roles assigned to the calling identity. Operations and security - Secrets and certificates live in Key Vault. - We log sign-ins and authorization failures, and have integration tests for allowed and forbidden cases (anonymous, wrong role, other tenant). Finish with one challenge you solved, for example implementing department-level permissions or fixing token expiry problems in long-running sessions.

Ravindra Wadile · · 0 likes

Sign in to add your answer

Related interview topics