Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add doc pages for AddOpenIdConnect and AddJwtBearer specifically #33877

Open
halter73 opened this issue Oct 18, 2024 · 8 comments · May be fixed by #34310
Open

Add doc pages for AddOpenIdConnect and AddJwtBearer specifically #33877

halter73 opened this issue Oct 18, 2024 · 8 comments · May be fixed by #34310

Comments

@halter73
Copy link
Member

Help us make content visible

Describe the new topic

  • Explain why this topic is needed.

Currently in the TOC for ASP.NET Core Authentication, we have sections for Azure, cookie, Windows, cert, and WS-Fed auth, but nothing for generic OIDC or JWT bearer auth. ASP.NET Core's generic OIDC and JWT bearer auth handlers are used under the covers for Azure Entra auth on ASP.NET Core, but this is not clear from the documentation.

I think pointing this out would be enlightening to many customers, particularly the ones on Azure, because you can configure generic OpenIdConnectOptions and JwtBearerOptions when calling the Entra-specific AddMicrosoftIdentityWebApp and AddMicrosoftIdentityWebApi methods respectively.

And I think this will obviously be a big help to developers who are using something other than Entra as their OIDC provider. While documentation directly from third-party OIDC providers will likely be better in some ways because they can tell you step-by-step how to configure the provider, a lot of developers have a good understanding of OIDC and how to configure the provider, but just need help integrating with ASP.NET Core. And for those new to OIDC, we should link to https://learn.microsoft.com/en-us/entra/identity-platform/v2-protocols-oidc

  • Suggest a location in the Table of Contents.

I recommend adding "Configure OIDC authentication" and "Configure JWT bearer authentication" right below "Configure cookie authentication" in the TOC below.

Image

  • Write an abstract. In one short paragraph, describe what this topic will cover.

For the OIDC doc, we could follow the outline of https://learn.microsoft.com/en-us/entra/identity-platform/scenario-web-app-sign-user-app-configuration?tabs=aspnetcore. Anything that's specific to how to configure the provider or acquire the client id or secret will be left as an exercise for the reader. Of course, we'll also cross-reference the Entra docs and recommend using Microsoft.Identity.Web instead of the generic handlers when working with Entra specifically.

For the JWT bearer doc, we could follow the outline of https://learn.microsoft.com/en-us/entra/identity-platform/scenario-protected-web-api-app-configuration?tabs=aspnetcore with the same caveat about recommending Microsoft.Identity.Web when working with Entra.

@andrewlock Has a great writeup about Microsoft.AspNetCore.Authentication.OpenIdConnect shortly after it came out, and it's what often comes up if you search "ASP.NET Core OIDC", but it's very outdated. I'm guessing he wouldn't mind if we used it for inspiration. But be warned, the UseOpenIdConnectAuthentication method no longer even exists.

Fortunately, the much more up-to-date Secure an ASP.NET Core Blazor Web App with OpenID Connect (OIDC) is starting to rank higher in search results, and that does demonstrate both AddOpenIdConnect and AddJwtBearer, but this shouldn't be hidden away deep in the Blazor docs. Not everyone needs to authenticate an auto-rendering Blazor app which does add complexity. The OIDC and JWT bearer handlers can be used directly in many different kinds of web apps.

  • Create an outline for the new topic. We'll help review the outline and approve it before anyone writes a topic.

@guardrex @mikekistler @jennyf19 FYI

@damienbod
Copy link
Contributor

damienbod commented Oct 19, 2024

I created almost the same issue:

See this issue: #30647

It has an outline already. I would add web because OIDC for non web is different.

I can do this if you want.

@damienbod
Copy link
Contributor

@Rick-Anderson
Copy link
Contributor

@damienbod

I can do this if you want.

That would be fantastic. Let me know how I can help.

@damienbod
Copy link
Contributor

damienbod commented Oct 22, 2024

@Rick-Anderson Perfect. Once I get the feedback/ok from @halter73 , I will start. I have a structure of the doc in the linked issue, waiting for feedback there.

I will define a suggestion as well for the JWT doc.

Greetings Damien

@damienbod
Copy link
Contributor

I start to implement the OIDC page

@damienbod
Copy link
Contributor

Configure OIDC web authentication

PR: #33908

@damienbod
Copy link
Contributor

I start with the JWT Bearer and plan an outline.

Title: Suggestions:

  • Configure JWT Bearer authorization
  • Configure JWT Bearer security
  • Configure JSON Web Token (JWT) security

@halter73 @Rick-Anderson @guardrex @mikekistler @jennyf19 @kevinchalet

I am unsure about the title. Any preferences?

Sub sections
• Overview
• Token types
• Using JWT tokens to secure an API
• How OAuth fits into this?
• Examples with code snippets
• Recommended approaches to create a JWT
• Downstream APIs
• Demonstrating Proof-of-Possession (DPoP)
• Advanced features, standards

@dotnetrepoman dotnetrepoman bot added mapQuest clean move and removed mapQuest clean move labels Dec 3, 2024
@halter73
Copy link
Member Author

halter73 commented Dec 3, 2024

Thanks for your continued help! I would probably title the article "Configure JWT bearer authentication". I generally like your suggested subsections.

I think it's a really good idea to explain the relationship to OIDC/OAuth and include samples. It's also worth calling out how to test locally with dotnet user-jwts, but we can probably just cross-reference https://learn.microsoft.com/en-us/aspnet/core/security/authentication/jwt-authn.

I'm not sure we need a DPoP part yet. We plan to add built-in support for DPoP in .NET 10, but it seems hard to support today without a lot of code like you have in https://github.com/damienbod/DPOP-aspnetcore-idp/tree/main/api/DPoP.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

Successfully merging a pull request may close this issue.

3 participants