Skip to content

Commit

Permalink
s'more
Browse files Browse the repository at this point in the history
  • Loading branch information
lyleschemmerling committed Aug 9, 2023
1 parent 8a3653d commit 59a8c8d
Show file tree
Hide file tree
Showing 54 changed files with 143 additions and 114 deletions.
49 changes: 49 additions & 0 deletions astro/.astro/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1191,6 +1191,13 @@ declare module 'astro:content' {
collection: "blog",
data: any
} & { render(): Render[".mdx"] },
"dot-net-command-line-client.mdx": {
id: "dot-net-command-line-client.mdx",
slug: "dot-net-command-line-client",
body: string,
collection: "blog",
data: any
} & { render(): Render[".mdx"] },
"download-counts-from-google-cloud-storage.mdx": {
id: "download-counts-from-google-cloud-storage.mdx",
slug: "download-counts-from-google-cloud-storage",
Expand Down Expand Up @@ -1863,6 +1870,13 @@ declare module 'astro:content' {
collection: "blog",
data: any
} & { render(): Render[".mdx"] },
"securing-asp-netcore-razor-pages-app-with-oauth.mdx": {
id: "securing-asp-netcore-razor-pages-app-with-oauth.mdx",
slug: "securing-asp-netcore-razor-pages-app-with-oauth",
body: string,
collection: "blog",
data: any
} & { render(): Render[".mdx"] },
"securing-flutter-oauth.mdx": {
id: "securing-flutter-oauth.mdx",
slug: "securing-flutter-oauth",
Expand Down Expand Up @@ -1926,6 +1940,20 @@ declare module 'astro:content' {
collection: "blog",
data: any
} & { render(): Render[".mdx"] },
"setting-up-single-sign-on-for-nodebb.mdx": {
id: "setting-up-single-sign-on-for-nodebb.mdx",
slug: "setting-up-single-sign-on-for-nodebb",
body: string,
collection: "blog",
data: any
} & { render(): Render[".mdx"] },
"sharing-custom-oauth-claims-with-a-asp-netcore-app.mdx": {
id: "sharing-custom-oauth-claims-with-a-asp-netcore-app.mdx",
slug: "sharing-custom-oauth-claims-with-a-asp-netcore-app",
body: string,
collection: "blog",
data: any
} & { render(): Render[".mdx"] },
"single-sign-on-django-fusionauth.mdx": {
id: "single-sign-on-django-fusionauth.mdx",
slug: "single-sign-on-django-fusionauth",
Expand Down Expand Up @@ -2094,13 +2122,27 @@ declare module 'astro:content' {
collection: "blog",
data: any
} & { render(): Render[".mdx"] },
"user-registration-and-sign-in-with-laravel.mdx": {
id: "user-registration-and-sign-in-with-laravel.mdx",
slug: "user-registration-and-sign-in-with-laravel",
body: string,
collection: "blog",
data: any
} & { render(): Render[".mdx"] },
"using-fusionauth-with-cockroachdb.mdx": {
id: "using-fusionauth-with-cockroachdb.mdx",
slug: "using-fusionauth-with-cockroachdb",
body: string,
collection: "blog",
data: any
} & { render(): Render[".mdx"] },
"using-java-to-manage-fusionauth.mdx": {
id: "using-java-to-manage-fusionauth.mdx",
slug: "using-java-to-manage-fusionauth",
body: string,
collection: "blog",
data: any
} & { render(): Render[".mdx"] },
"using-oauth-and-pkce-to-add-authentication-to-your-gatsby-site.mdx": {
id: "using-oauth-and-pkce-to-add-authentication-to-your-gatsby-site.mdx",
slug: "using-oauth-and-pkce-to-add-authentication-to-your-gatsby-site",
Expand Down Expand Up @@ -2157,6 +2199,13 @@ declare module 'astro:content' {
collection: "blog",
data: any
} & { render(): Render[".mdx"] },
"whats-new-in-oauth-2-1.mdx": {
id: "whats-new-in-oauth-2-1.mdx",
slug: "whats-new-in-oauth-2-1",
body: string,
collection: "blog",
data: any
} & { render(): Render[".mdx"] },
"whats-wrong-with-implicit-grant.mdx": {
id: "whats-wrong-with-implicit-grant.mdx",
slug: "whats-wrong-with-implicit-grant",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@
---
layout: blog-post
publish_date: 2020-04-28
title: Creating a user in FusionAuth with a .NET Core CLI client
description: Use the FusionAuth APIs to create and manage a user using the .NET Core client libraries.
author: Dan Moore
image: blogs/dot-net-command-line-client/creating-user-cli-client.png
category: tutorial
authors: Dan Moore
image: /img/blogs/dot-net-command-line-client/creating-user-cli-client.png
categories: tutorial
tags: client-netcore tutorial tutorial-netcore netcore dotnet
excerpt_separator: "<!--more-->"
excerpt_separator: "{/* more */}"
---
import Aside from '../../components/Aside.astro';

In this post, we'll build a command line client for FusionAuth with C# and the .NET Core libraries. We'll set up FusionAuth and then add a user to an application from the command line interface (CLI) tool we've built.

<!--more-->
{/* more */}

{% include _callout-tip.liquid
content=
"This blog post has been [superseded by this guide](/docs/v1/tech/tutorials/integrate-dotnet)."
%}
<Aside type="tip" nodark="true">This blog post has been [superseded by this guide](/docs/v1/tech/tutorials/integrate-dotnet).</Aside>

At the end of this tutorial, you will have a working .NET Core application which will allow you to add users to your FusionAuth user database.

Expand Down Expand Up @@ -72,7 +70,7 @@ Check out the [Download FusionAuth page](/download) for other installation optio

Sign in as a FusionAuth administrator and create a new application. I creatively named mine 'dotnetcore', and will refer to this application throughout the tutorial. No need to tweak any defaults, but do note the "Id", which we'll use later.

{% include _image.liquid src="/assets/img/blogs/dot-net-command-line-client/create-application.png" alt="The application in FusionAuth after it has been created" class="img-fluid" figure=false %}
![The application in FusionAuth after it has been created.](/img/blogs/dot-net-command-line-client/create-application.png)

Then go to the APIs section. We'll need to create an API key for our CLI client. Head to "Settings" and then to "API Keys" in the UI. Create a new key, and set the permissions.

Expand Down Expand Up @@ -298,7 +296,7 @@ failed with status 400

If you look at the "Users" section of the FusionAuth UI, you will see "[email protected]". If you view that user, you can see they are associated with the "dotnetcore" application.

{% include _image.liquid src="/assets/img/blogs/dot-net-command-line-client/user-in-registration.png" alt="The user in FusionAuth after they have been created" class="img-fluid" figure=false %}
![The user in FusionAuth after they have been created.](/img/blogs/dot-net-command-line-client/user-in-registration.png)

If you want to build an executable to distribute to any user or server with the .NET Core runtime available, run `dotnet build` and you'll see an executable at `bin/Debug/netcoreapp3.1/usermanager.exe`. You can also look at the various [deployment options](https://docs.microsoft.com/en-us/dotnet/core/deploying/).

Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,21 @@
---
layout: blog-post
publish_date: 2020-05-06
title: Securing an ASP.NET Core Razor Pages app with OAuth
description: We'll build a web application using ASP.NET Core and control page access using FusionAuth and the Authorization Code grant.
author: Dan Moore
image: blogs/authorization-code-grant-asp-net/securing-asp-net-app-oauth.png
category: tutorial
authors: Dan Moore
image: /img/blogs/authorization-code-grant-asp-net/securing-asp-net-app-oauth.png
categories: tutorial
tags: client-netcore tutorial tutorial-netcore netcore dotnet
updated_date: 2021-10-07
excerpt_separator: "<!--more-->"
excerpt_separator: "{/* more */}"
---
import Aside from '../../components/Aside.astro';

Previously, we used .NET Core to [build a command line tool](/blog/2020/04/28/dot-net-command-line-client) to add users to a FusionAuth user identity management system. In this tutorial, we'll build out a web application with a protected page. We'll use Razor Pages and have both login and logout happen against FusionAuth, using the Authorization Code grant.

<!--more-->
{/* more */}

{% include _callout-tip.liquid
content=
"This blog post has been [superseded by this guide](/docs/v1/tech/tutorials/integrate-dotnet)."
%}
<Aside type="tip" nodark="true">This blog post has been [superseded by this guide](/docs/v1/tech/tutorials/integrate-dotnet).</Aside>

## Configuring FusionAuth

Expand All @@ -28,7 +26,7 @@ We are going to make a few changes to the FusionAuth configuration to allow inte
First, we're going to create a new signing key. There's a list of [supported algorithms](https://github.com/AzureAD/azure-activedirectory-identitymodel-extensions-for-dotnet/wiki/Supported-Algorithms) that work with the open source identity project we're using, but currently [symmetric algorithms are not supported](https://github.com/IdentityModel/IdentityModel.AspNetCore/issues/102)--I love the honesty of the library maintainer: "Don't use symmetric keys is the easy answer." Using the default HMAC key resulted in a `SecurityTokenSignatureKeyNotFoundException` and there was no easy way to change the `SignatureProvider`. Luckily, FusionAuth supports [different key types](/docs/v1/tech/apis/keys#generate-a-key), so let's generate an asymmetric key to use to sign our JSON Web Tokens (JWTs).

To generate the key, go to "Settings" then to "Key Master". In the upper right hand corner, click on the dropdown next to "Import Public Key" and choose "Generate RSA". Use a descriptive name like "For dotnetcore" and leave the rest of defaults and click "Submit".
{% include _image.liquid src="/assets/img/blogs/authorization-code-grant-asp-net/aspnet-keypair.png" alt="A new RSA keypair in FusionAuth." class="img-fluid" figure=false %}
![A new RSA keypair in FusionAuth..](/img/blogs/authorization-code-grant-asp-net/aspnet-keypair.png)

Next, we'll be modifying the previously created "dotnetcore"' application settings. Edit that application, then go to the "OAuth" tab. Make the following changes:

Expand All @@ -37,11 +35,11 @@ Next, we'll be modifying the previously created "dotnetcore"' application settin

The web application we are going to build is going to be on port 5000, and `signin-oidc` is an endpoint provided by the authentication library. We're setting things up so that the Authorization Code grant will work. Write down the `Client Id` and `Client Secret`, as we'll need that information later. When you are done configuring this section, the OAuth tab of your application should look like this:

{% include _image.liquid src="/assets/img/blogs/authorization-code-grant-asp-net/aspnet-application-oauth-setup-screen.png" alt="The OAuth settings for the 'dotnetcore' application." class="img-fluid" figure=false %}
![The OAuth settings for the 'dotnetcore' application..](/img/blogs/authorization-code-grant-asp-net/aspnet-application-oauth-setup-screen.png)

Next, go to the "JWT" tab. We need to enable JSON Web Token signing and tell FusionAuth to use the previously generated RSA keypair. Update the "Access token signing key" and "Id token signing key" to point to that keypair. When you are done, the JWT tab should look like this:

{% include _image.liquid src="/assets/img/blogs/authorization-code-grant-asp-net/aspnet-application-jwt-screen.png" alt="The JWT settings for the 'dotnetcore' application." class="img-fluid" figure=false %}
![The JWT settings for the 'dotnetcore' application..](/img/blogs/authorization-code-grant-asp-net/aspnet-application-jwt-screen.png)

Click the blue "Save" icon to save all the settings you just configured. We're done with FusionAuth. (Unless you need to add a user, in which case, go to the "Users" section and add one. Make sure to add them to the "dotnetcore" application by creating the appropriate user registration.)

Expand Down Expand Up @@ -374,11 +372,11 @@ dotnet publish -r win-x64 && SampleApp__ClientSecret=H4... bin/Debug/netcoreapp3

Once you've updated all these files, you can publish and start the application. You should be able to log in with a previously created user and see the claims. Go to `http://localhost:5000` and click on the "Secure" page. You'll be prompted to log in using FusionAuth's default login page. You can [theme the login screen of FusionAuth](/docs/v1/tech/themes/) if you want to make the login page look like your company's brand.

{% include _image.liquid src="/assets/img/blogs/authorization-code-grant-asp-net/login-asp-dot-net-example.png" alt="The login screen in FusionAuth." class="img-fluid" figure=false %}
![The login screen in FusionAuth..](/img/blogs/authorization-code-grant-asp-net/login-asp-dot-net-example.png)

After you've signed in, you'll end up at the "Secure" page and will see all claims encoded in the JWT.

{% include _image.liquid src="/assets/img/blogs/authorization-code-grant-asp-net/successful-login-secure-page-display.png" alt="The secure page." class="img-fluid" figure=false %}
![The secure page..](/img/blogs/authorization-code-grant-asp-net/successful-login-secure-page-display.png)

You can see the source of the application at this stage of development by looking at the [`add-authentication` branch](https://github.com/FusionAuth/fusionauth-example-asp-netcore/tree/add-authentication).
Expand Down
Loading

0 comments on commit 59a8c8d

Please sign in to comment.