Skip to content

docs: dotnet integration tutorial#2127

Closed
sixhobbits wants to merge 28 commits into
FusionAuth:masterfrom
ritza-co:dotnet-integration
Closed

docs: dotnet integration tutorial#2127
sixhobbits wants to merge 28 commits into
FusionAuth:masterfrom
ritza-co:dotnet-integration

Conversation

@sixhobbits
Copy link
Copy Markdown
Collaborator

@sixhobbits sixhobbits commented Apr 28, 2023

Note: this depends on #2126 as that one introduces partials and a liquid template for markdown.

TODO:

  • archive all old .NET projects

@sixhobbits sixhobbits requested a review from mooreds April 28, 2023 13:07
@mooreds mooreds added the content Alert marketing to this change label Apr 28, 2023
Comment thread site/docs/quickstarts/index.html Outdated
Comment thread site/_layouts/doc.liquid Outdated
<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>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 %}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
```

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you pull over the note about powershell here from the flask tutorial?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should add a note that the path to the SetupFusionauth executable will be different depending on your platform.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is now an archived library: https://github.com/IdentityModel/IdentityModel.AspNetCore

Is there another option supported by microsoft that you can use?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 %}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


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:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's remove these, as they aren't actively maintained. I will archive these before merging this.

@mooreds
Copy link
Copy Markdown
Contributor

mooreds commented May 11, 2023

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

rideam and others added 2 commits May 15, 2023 16:46
Co-authored-by: Dan Moore <github@mooreds.com>
Copy link
Copy Markdown
Collaborator

@ColinFrick ColinFrick left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@sixhobbits
Copy link
Copy Markdown
Collaborator Author

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.

@mooreds
Copy link
Copy Markdown
Contributor

mooreds commented Jun 2, 2023

Would love to get this published. What's the next steps for this?

rideam added 2 commits June 5, 2023 10:04
# Conflicts:
#	site/_layouts/doc.liquid
#	site/docs/quickstarts/index.html
#	site/docs/v1/tech/tutorials/index.adoc
@rideam
Copy link
Copy Markdown
Collaborator

rideam commented Jun 5, 2023

I opened a PR to the example project FusionAuth/fusionauth-example-dotnet-guide#1 to remove IdentityModel.AspNetCore reference and cleanup unused directives.

@mooreds
Copy link
Copy Markdown
Contributor

mooreds commented Jun 14, 2023

Is this ready for review, @rideam ? I just merged your changes for the example.

rideam added 2 commits June 14, 2023 23:03
# Conflicts:
#	site/_layouts/doc.liquid
#	site/docs/v1/tech/tutorials/index.adoc
@rideam
Copy link
Copy Markdown
Collaborator

rideam commented Jun 14, 2023

@mooreds yes it is ready for a review

@mooreds
Copy link
Copy Markdown
Contributor

mooreds commented Jun 15, 2023

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!

@mooreds mooreds mentioned this pull request Jun 15, 2023
@mooreds
Copy link
Copy Markdown
Contributor

mooreds commented Jun 15, 2023

Shipping under #2251

@mooreds mooreds closed this Jun 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

content Alert marketing to this change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants