docs: dotnet integration tutorial#2127
Conversation
Integrate .NET language edit
# Conflicts: # site/_layouts/doc.liquid # site/docs/v1/tech/tutorials/index.adoc
# Conflicts: # site/docs/v1/tech/tutorials/index.adoc
| <li {% if page.url == "/docs/v1/tech/tutorials/integrate-python-django.html" %}class="active"{% endif %}><a href="/docs/v1/tech/tutorials/integrate-python-django">Python Django</a></li> | ||
| <li {% if page.url == "/docs/v1/tech/tutorials/integrate-python-flask.html" %}class="active"{% endif %}><a href="/docs/v1/tech/tutorials/integrate-python-flask">Python Flask</a></li> | ||
| <li {% if page.url == "/docs/v1/tech/tutorials/integrate-react.html" %}class="active"{% endif %}><a href="/docs/v1/tech/tutorials/integrate-react">React</a></li> | ||
| <li {% if page.url == "/docs/v1/tech/tutorials/integrate-dotnet.html" %}class="active"{% endif %}><a href="/docs/v1/tech/tutorials/integrate-dotnet">C# .NET</a></li> |
There was a problem hiding this comment.
Please move this up and put it in alphabetical order.
| Now, copy and paste the following code into `Program.cs`. | ||
|
|
||
| ```csharp | ||
| {% remote_include https://raw.githubusercontent.com/ritza-co/fusionauth-example-client-libraries/main/dotnet/Program.cs %} |
There was a problem hiding this comment.
Please update this, I merged in your changes to https://github.com/FusionAuth/fusionauth-example-client-libraries
| dotnet publish -r osx-x64 | ||
| fusionauth_api_key=<YOUR_API_KEY> bin/Debug/net7.0/osx-x64/publish/SetupFusionauth | ||
| ``` | ||
|
|
There was a problem hiding this comment.
Can you pull over the note about powershell here from the flask tutorial?
There was a problem hiding this comment.
Should add a note that the path to the SetupFusionauth executable will be different depending on your platform.
There was a problem hiding this comment.
Can you pull over the note from the flask tutorial about this only working with a single user and default tenant?
|
|
||
| ```shell | ||
| dotnet add package Microsoft.AspNetCore.Authentication.OpenIdConnect | ||
| dotnet add package IdentityModel.AspNetCore |
There was a problem hiding this comment.
This is now an archived library: https://github.com/IdentityModel/IdentityModel.AspNetCore
Is there another option supported by microsoft that you can use?
There was a problem hiding this comment.
They moved development to a new repository: https://github.com/DuendeSoftware/Duende.AccessTokenManagement
Replacing IdentityModel.AspNetCore with Duende.AccessTokenManagement.OpenIdConnect and using RevokeRefreshTokenAsync instead of RevokeUserRefreshTokenAsync seems to work.
| Copy the following code into `Secure.cshtml.cs`: | ||
|
|
||
| ```csharp | ||
| {% remote_include https://raw.githubusercontent.com/ritza-co/fusionauth-dotnet-integration/main/SetupDotnet/Pages/Secure.cshtml.cs %} |
There was a problem hiding this comment.
Pulled over the repo here: https://github.com/fusionauth/fusionauth-example-dotnet-guide
|
|
||
| If you do this, make sure to update the <span class="field">Authorized Redirect URL</span> to reflect the `https` protocol. Also note that the project will probably run on a different port when using SSL, so you must update that as well. To do so, log into the administrative user interface, navigate to <span class="breadcrumb">Applications</span>, then click the <span class="uielement">Edit</span> button on your application and navigate to the <span class="breadcrumb">OAuth</span> tab. You can have more than one URL. | ||
|
|
||
| This tutorial has example versions built for a few versions of ASP.NET. View the following repos for the full code for various versions: |
There was a problem hiding this comment.
Let's remove these, as they aren't actively maintained. I will archive these before merging this.
|
Also, can you please update the old .net blog posts with a callout saying "this post has been superseded".. Kinda like we did here: https://fusionauth.io/blog/2020/12/14/how-to-securely-implement-oauth-rails |
Co-authored-by: Dan Moore <github@mooreds.com>
ColinFrick
left a comment
There was a problem hiding this comment.
There are a lot of unused directives in the .cshtml.cs files
| {% remote_include https://raw.githubusercontent.com/FusionAuth/fusionauth-example-dotnet-guide/main/SetupDotnet/Pages/Shared/_Layout.cshtml %} | ||
| ``` | ||
|
|
||
| You also need to set up some services to specify how this page is protected. Create a `Startup.cs` file and add the following code: |
There was a problem hiding this comment.
Maybe note that the Startup.cs file should be created in the root directory.
|
|
||
| ```shell | ||
| dotnet add package Microsoft.AspNetCore.Authentication.OpenIdConnect | ||
| dotnet add package IdentityModel.AspNetCore |
There was a problem hiding this comment.
They moved development to a new repository: https://github.com/DuendeSoftware/Duende.AccessTokenManagement
Replacing IdentityModel.AspNetCore with Duende.AccessTokenManagement.OpenIdConnect and using RevokeRefreshTokenAsync instead of RevokeUserRefreshTokenAsync seems to work.
I think we should switch to a new library to avoid using Duende rather as that is deprecated. @TheMiniDriver found one to use for the C# API quickstart which will work here too. |
|
Would love to get this published. What's the next steps for this? |
# Conflicts: # site/_layouts/doc.liquid # site/docs/quickstarts/index.html # site/docs/v1/tech/tutorials/index.adoc
|
I opened a PR to the example project FusionAuth/fusionauth-example-dotnet-guide#1 to remove |
|
Is this ready for review, @rideam ? I just merged your changes for the example. |
# Conflicts: # site/_layouts/doc.liquid # site/docs/v1/tech/tutorials/index.adoc
|
@mooreds yes it is ready for a review |
|
Thanks @rideam . When something is ready for review, please re-request review in GH from me (upper right hand section, by my icon) so that I'm emailed. Thanks! |
|
Shipping under #2251 |
Note: this depends on #2126 as that one introduces partials and a liquid template for markdown.
TODO: