Skip to content

Commit

Permalink
Merge pull request #6 from adrianhall/0913
Browse files Browse the repository at this point in the history
09/13 blog post
  • Loading branch information
adrianhall authored Sep 13, 2024
2 parents a41cbc0 + f407e02 commit cd73408
Show file tree
Hide file tree
Showing 9 changed files with 594 additions and 60 deletions.
63 changes: 32 additions & 31 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,31 +1,32 @@
source "https://rubygems.org"

gem "jekyll", "~> 4.3.3"
gem "classifier-reborn"
gem "csv" # No longer bundled with ruby
gem "minimal-mistakes-jekyll", "~> 4.26.1"

group :jekyll_plugins do
gem "jekyll-algolia"
gem "jekyll-archives"
gem "jekyll-default-layout"
gem "jekyll-feed"
gem "jekyll-gist"
gem "jekyll-include-cache"
gem "jekyll-optional-front-matter"
gem "jekyll-paginate-v2"
gem "jekyll-relative-links"
gem "jekyll-seo-tag"
gem "jekyll-sitemap"
gem "jekyll-titles-from-headings"
gem "jekyll-toc"
gem "jemoji"
end

platforms :mingw, :x64_mingw, :mswin, :jruby do
gem "tzinfo", ">= 1", "< 3"
gem "tzinfo-data"
end

gem "wdm", "~> 0.1.1", :platforms => [:mingw, :x64_mingw, :mswin]
gem "http_parser.rb", "~> 0.6.0", :platforms => [:jruby]
source "https://rubygems.org"

gem "jekyll", "~> 4.3.3"
gem "classifier-reborn"
gem "csv" # No longer bundled with ruby
gem "faraday-retry"
gem "minimal-mistakes-jekyll", "~> 4.26.1"

group :jekyll_plugins do
gem "jekyll-algolia"
gem "jekyll-archives"
gem "jekyll-default-layout"
gem "jekyll-feed"
gem "jekyll-gist"
gem "jekyll-include-cache"
gem "jekyll-optional-front-matter"
gem "jekyll-paginate-v2"
gem "jekyll-relative-links"
gem "jekyll-seo-tag"
gem "jekyll-sitemap"
gem "jekyll-titles-from-headings"
gem "jekyll-toc"
gem "jemoji"
end

platforms :mingw, :x64_mingw, :mswin, :jruby do
gem "tzinfo", ">= 1", "< 3"
gem "tzinfo-data"
end

gem "wdm", "~> 0.1.1", :platforms => [:mingw, :x64_mingw, :mswin]
gem "http_parser.rb", "~> 0.6.0", :platforms => [:jruby]
3 changes: 3 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ GEM
faraday-net_http (>= 2.0, < 3.2)
faraday-net_http (3.1.0)
net-http
faraday-retry (2.2.1)
faraday (~> 2.0)
fast-stemmer (1.0.2)
ffi (1.17.0)
ffi (1.17.0-arm64-darwin)
Expand Down Expand Up @@ -205,6 +207,7 @@ PLATFORMS
DEPENDENCIES
classifier-reborn
csv
faraday-retry
http_parser.rb (~> 0.6.0)
jekyll (~> 4.3.3)
jekyll-algolia
Expand Down
33 changes: 17 additions & 16 deletions _includes/head/custom.html
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
<!-- start custom head snippets -->
<link rel="apple-touch-icon" sizes="180x180" href="/assets/icons/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="/assets/icons/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="/assets/icons/favicon-16x16.png">
<link rel="manifest" href="/assets/icons/site.webmanifest">
<link rel="mask-icon" href="/assets/icons/safari-pinned-tab.svg" color="#5bbad5">
<link rel="shortcut icon" href="/assets/icons/favicon.ico">
<meta name="msapplication-TileColor" content="#da532c">
<meta name="msapplication-config" content="/assets/icons/browserconfig.xml">
<meta name="theme-color" content="#ffffff">

<link rel="stylesheet" href="{{ '/assets/css/site.css' | relative_url }}">

<!-- ShareThis -->
<script type="text/javascript" src="https://platform-api.sharethis.com/js/sharethis.js#property=6664dc89bc91a90019554985&product=inline-share-buttons&source=platform" async="async"></script>
<!-- end custom head snippets -->
<!-- start custom head snippets -->
<link rel="apple-touch-icon" sizes="180x180" href="/assets/icons/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="/assets/icons/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="/assets/icons/favicon-16x16.png">
<link rel="manifest" href="/assets/icons/site.webmanifest">
<link rel="mask-icon" href="/assets/icons/safari-pinned-tab.svg" color="#5bbad5">
<link rel="shortcut icon" href="/assets/icons/favicon.ico">
<meta name="msapplication-TileColor" content="#da532c">
<meta name="msapplication-config" content="/assets/icons/browserconfig.xml">
<meta name="theme-color" content="#ffffff">

<link rel="stylesheet" href="{{ '/assets/css/site.css' | relative_url }}">

<!-- ShareThis -->
<script type="text/javascript" src="https://platform-api.sharethis.com/js/sharethis.js#property=6664dc89bc91a90019554985&product=inline-share-buttons&source=platform" async="async"></script>
<!-- end custom head snippets -->

9 changes: 9 additions & 0 deletions _includes/mermaid.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{% if page.mermaid %}
<script type="module">
import mermaid from 'https://cdn.jsdelivr.net/npm/mermaid@11.2.0/+esm'
mermaid.initialize({
startOnLoad:true,
theme: 'dark'
});
</script>
{% endif %}
29 changes: 29 additions & 0 deletions _includes/scripts.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{% if site.footer_scripts %}
{% for script in site.footer_scripts %}
<script src="{{ script | relative_url }}"></script>
{% endfor %}
{% else %}
<script src="{{ '/assets/js/main.min.js' | relative_url }}"></script>
{% endif %}

{% if site.search == true or page.layout == "search" %}
{%- assign search_provider = site.search_provider | default: "lunr" -%}
{%- case search_provider -%}
{%- when "lunr" -%}
{% include_cached search/lunr-search-scripts.html %}
{%- when "google" -%}
{% include_cached search/google-search-scripts.html %}
{%- when "algolia" -%}
{% include_cached search/algolia-search-scripts.html %}
{%- endcase -%}
{% endif %}

{% include analytics.html %}
{% include /comments-providers/scripts.html %}
{% include mermaid.html %}

{% if site.after_footer_scripts %}
{% for script in site.after_footer_scripts %}
<script src="{{ script | relative_url }}"></script>
{% endfor %}
{% endif %}
9 changes: 0 additions & 9 deletions _includes/social-share-old.html

This file was deleted.

11 changes: 7 additions & 4 deletions _posts/2024/09/2024-09-11-aspnet-identity-part1.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ All of these options will have you writing less code and getting to the real mea

But you (like me for this project) have decided to go it alone. So how is it done? This article is one of a number of articles I will write over the coming month and will go into depth about the [ASP.NET Identity](https://learn.microsoft.com/aspnet/core/security/authentication/identity) system. My outline thus far:

* Project setup (this article).
* Account registration.
* Email confirmation.
* [Project setup]({% post_url 2024/09/2024-09-11-aspnet-identity-part1 %}).
* [Account registration]({% post_url 2024/09/2024-09-13-aspnet-identity-part2 %}).
* Signing in and out with a username and password.
* Password reset.
* Email confirmations.
* Social logins.
* Two-factor authentication.
* Going passwordless with magic links.
Expand Down Expand Up @@ -153,7 +153,8 @@ builder.Services
options.SignIn.RequireConfirmedAccount = true;
options.User.RequireUniqueEmail = true;
})
.AddEntityFrameworkStores<ApplicationDbContext>();
.AddEntityFrameworkStores<ApplicationDbContext>()
.AddDefaultTokenProviders();

// ASP.NET MVC
builder.Services.AddControllersWithViews();
Expand Down Expand Up @@ -197,6 +198,8 @@ Let's focus in on the `builder.Services.AddIdentity()` call. There are lots of

One of the most common requirements for an identity service is account confirmation. As we will see in the next article, we send the user a link that they need to use to confirm the account. The `options.SignIn.RequireConfirmedAccount = true` option sets up ASP.NET Identity so that a confirmed account is required before they can sign in. I'm going to be using the email address for my user ID, so I need to ensure that each user has a unique email address.

The `.AddDefaultTokenProviders()` is also a part of the account confirmation and reset password capabilities. When we go through the process of confirming an account, we ask the system to generate a token that the user then must submit back to the system to validate that the email address is correct. This is done with a token provider. ASP.NET Identity provides default implementations of the token provider so that you don't have to worry about it. If you want to use short and easily entered tokens (for example, if you are doing authentication for a set-top box), then you will want to override the default token providers.

> **Use extension methods to simplify setup**
> I don't put all this setup in `Program.cs`. Instead I put the setup in extension methods. This allows me to store the database setup with the database context and initializer, for instance. Using extension methods also improves readability of your code.
> {: .notice--success}
Expand Down
Loading

0 comments on commit cd73408

Please sign in to comment.