Microsoft Technologies based on the .NET software framework. Miscellaneous topics that do not fit into specific categories.
Thanks for the follow-up and my apologies as I have been reading up on oauth. While I realize rolling my own is more difficult, it helps me learn when I implement libraries. I am still confused on the workflow. Once the jwttoken and passed to the secure endpoint, what does the endpoint need to do to validate the token. And does each call to the endpoint by the consuming application require authentication?
Kmcnet, the short answer is "it depends" on how the token is constructed by your identity provider. However, the standard mechanics break down into a few key areas:
Token Validation (Cryptography):
If you are using a library like OpenIddict, tokens can sometimes be formatted as encrypted reference tokens or opaque tokens, meaning the API needs the decryption key to read them.
More commonly with standard JWTs, the token is digitally signed using a private key by the authorization server. To validate it, your Web API needs the corresponding public key (usually fetched automatically via standard discovery endpoints like .well-known/openid-configuration) to verify the signature and ensure it hasn't been tampered with.
Per-Call Authentication:
Yes, conceptually, every single call to a secure endpoint requires the client to present credentials (the JWT Bearer token) in the HTTP Authorization header (Authorization: Bearer <token>).
However, from a performance standpoint, the API doesn't make a network call back to the auth server on every single request to validate it. Instead, once the API has the public key, it cryptographically validates the token locally, checks the expiration (exp), issuer (iss), and audience (aud) claims in memory.
Scopes and Grants:
Once the signature is verified, the API checks the claims inside the token—specifically scopes and roles—to determine if that specific client and user are authorized to access that particular endpoint (Authorization vs. Authentication).
This is essentially the core of what you'll be digging into as you research OAuth and token-based architecture. Looking into how ASP.NET Core handles the JwtBearer authentication handler will give you a good blueprint for how validation happens under the hood.