Skip to content

Commit 9e91d94

Browse files
manishtiwari25linkdotnet
authored andcommitted
Added Auth0
1 parent 750a2c2 commit 9e91d94

File tree

9 files changed

+144
-71
lines changed

9 files changed

+144
-71
lines changed

Readme.md

+106-71
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,80 @@
11
# LinkDotNet.Blog
2+
23
[![.NET](https://github.com/linkdotnet/Blog/actions/workflows/dotnet.yml/badge.svg?branch=master)](https://github.com/linkdotnet/Blog/actions/workflows/dotnet.yml)
34
[![CodeQL](https://github.com/linkdotnet/Blog/actions/workflows/codeql.yml/badge.svg)](https://github.com/linkdotnet/Blog/actions/workflows/codeql.yml)
45

5-
This is a blog software completely written in C# / Blazor. The aim is to have it configurable as possible.
6+
This is a blog software completely written in C# / Blazor. The aim is to have it configurable as possible.
67

78
## How does it work
8-
The basic idea is that the content creator writes his posts in markdown language (like this readme file).
9+
10+
The basic idea is that the content creator writes his posts in markdown language (like this readme file).
911
The markdown will then be translated into HTML and displayed to the client. This gives an easy entry to writing posts with all the flexibility markdown has.
1012
This also includes source code snippets. Highlighting is done via [highlight.js](https://highlightjs.org/) with the GitHub theme.
1113

1214
## In Action
15+
1316
![overview](assets/overview.gif)
1417

18+
## Components
19+
20+
- [Authorization](./docs/Authorization/Readme.md)
21+
- [Comments](./docs/Comments/Readme.md)
22+
- [Storage Provider](./docs/Storage/Readme.md)
23+
- [Search Engine Optimization (SEO)](./docs/SEO/Readme.md)
24+
- [Setup](./docs/Setup/Readme.md)
25+
1526
## Setup
16-
Just clone this repository and you are good to go. There are some settings you can tweak. The following chapter will guide you
27+
28+
Just clone this repository and you are good to go. There are some settings you can tweak. The following chapter will guide you
1729
through the possibilities.
1830

1931
### appsettings.json
32+
2033
The appsettings.json file has a lot of options to customize the content of the blog. The following table shows which values are used when.
2134

2235
```json
2336
{
24-
"BlogName": "linkdotnet",
25-
"BlogBrandUrl": "http//some.url/image.png",
26-
"GithubAccountUrl": "",
27-
"Social": {
28-
"GithubAccountUrl": "",
29-
"LinkedInAccountUrl": "",
30-
"TwitterAccountUrl": ""
31-
},
32-
"Introduction": {
33-
"Description": "Some nice text about yourself. Markup can be used [Github](https://github.com/someuser/somerepo)",
34-
"BackgroundUrl": "assets/profile-background.webp",
35-
"ProfilePictureUrl": "assets/profile-picture.webp"
36-
},
37-
"PersistenceProvider": "InMemory",
38-
"ConnectionString": "",
39-
"DatabaseName": "",
40-
"Auth0": {
41-
"Domain": "",
42-
"ClientId": "",
43-
"ClientSecret": ""
44-
},
45-
"BlogPostsPerPage": 10,
46-
"AboutMeProfileInformation": {
47-
"Name": "Steven Giesel",
48-
"Heading": "Software Engineer",
49-
"ProfilePictureUrl": "assets/profile-picture.webp"
50-
},
51-
"Giscus": {
52-
"Repository": "github/repo",
53-
"RepositoryId": "id",
54-
"Category": "general",
55-
"CategoryId": "id"
56-
},
57-
"Disqus": {
58-
"Shortname": "blog"
59-
},
60-
"KofiToken": "ABC123",
61-
"GithubSponsorName": "your-tag-here",
62-
"ShowReadingIndicator": true,
63-
"PatreonName": "your-tag-here"
37+
"BlogName": "linkdotnet",
38+
"BlogBrandUrl": "http//some.url/image.png",
39+
"GithubAccountUrl": "",
40+
"Social": {
41+
"GithubAccountUrl": "",
42+
"LinkedInAccountUrl": "",
43+
"TwitterAccountUrl": ""
44+
},
45+
"Introduction": {
46+
"Description": "Some nice text about yourself. Markup can be used [Github](https://github.com/someuser/somerepo)",
47+
"BackgroundUrl": "assets/profile-background.webp",
48+
"ProfilePictureUrl": "assets/profile-picture.webp"
49+
},
50+
"PersistenceProvider": "InMemory",
51+
"ConnectionString": "",
52+
"DatabaseName": "",
53+
"Auth0": {
54+
"Domain": "",
55+
"ClientId": "",
56+
"ClientSecret": ""
57+
},
58+
"BlogPostsPerPage": 10,
59+
"AboutMeProfileInformation": {
60+
"Name": "Steven Giesel",
61+
"Heading": "Software Engineer",
62+
"ProfilePictureUrl": "assets/profile-picture.webp"
63+
},
64+
"Giscus": {
65+
"Repository": "github/repo",
66+
"RepositoryId": "id",
67+
"Category": "general",
68+
"CategoryId": "id"
69+
},
70+
"Disqus": {
71+
"Shortname": "blog"
72+
},
73+
"KofiToken": "ABC123",
74+
"GithubSponsorName": "your-tag-here",
75+
"ShowReadingIndicator": true,
76+
"PatreonName": "your-tag-here"
6477
}
65-
6678
```
6779

6880
| Property | Type | Description |
@@ -97,44 +109,53 @@ The appsettings.json file has a lot of options to customize the content of the b
97109
| PatreonName | string | Enables the "Become a patreon" button that redirects to patreon.com. Only pass the user name (public profile) as user name. |
98110

99111
## Storage Provider
112+
100113
Currently, there are 5 Storage-Provider:
101-
* InMemory - Basically a list holding your data (per request). If the User hits a hard reload, the data is gone.
102-
* RavenDb - As the name suggests for RavenDb. RavenDb automatically creates all the documents, if a database name is provided.
103-
* Sqlite - Based on EF Core, it can be easily adapted for other Sql Dialects. The tables are automatically created.
104-
* SqlServer - Based on EF Core, it can be easily adapted for other Sql Dialects. The tables are automatically created.
105-
* MySql - Based on EF Core - also supports MariaDB.
114+
115+
- InMemory - Basically a list holding your data (per request). If the User hits a hard reload, the data is gone.
116+
- RavenDb - As the name suggests for RavenDb. RavenDb automatically creates all the documents, if a database name is provided.
117+
- Sqlite - Based on EF Core, it can be easily adapted for other Sql Dialects. The tables are automatically created.
118+
- SqlServer - Based on EF Core, it can be easily adapted for other Sql Dialects. The tables are automatically created.
119+
- MySql - Based on EF Core - also supports MariaDB.
106120

107121
The default (when you clone the repository) is the `InMemory` option. That means every time you restart the service, all posts and related objects are gone.
108122

109123
## Comment Section
110-
For comments, the blog is using [giscus](https://giscus.app/) or [disqus](https://disqus.com/).
124+
125+
For comments, the blog is using [giscus](https://giscus.app/) or [disqus](https://disqus.com/).
111126

112127
**Note**: Please only register one service or provide the configuration for one of the nodes. The given configuration shows both only for demonstrational purposes.
113128
If multiple comment plugins are configured at the same time a warning will be displayed under the blog post itself.
114129

115130
### Giscus
131+
116132
To provide the necessary values head over to https://giscus.app/ and go to the configuration section.
117133
There you can enter all the information. You will find a detailed guide on the site.
118134

119135
In short:
120-
* You need a public repository where the comments are hosted. Recommendation: Create a new repository just for the comments
121-
* You have to link the [giscus app](https://github.com/apps/giscus) to at least the repository where the comments are hosted
122-
* You have to enable the discussion feature in the repository (see [here](https://docs.github.com/en/github/administering-a-repository/managing-repository-settings/enabling-or-disabling-github-discussions-for-a-repository)
123-
)
124-
125-
After you configured everything on the site, you get the `<script>` tag which you could embed. The blog needs the following information.
126-
127-
Here you can find an example. This is how the script tag looks on giscus.
128-
```javascript
129-
<script src="https://giscus.app/client.js"
130-
data-repo="your_username/reponame"
131-
data-repo-id="M9/ab=="
132-
data-category="General"
133-
data-category-id="AbC==/8_D"
134-
async>
135-
</script>
136+
137+
- You need a public repository where the comments are hosted. Recommendation: Create a new repository just for the comments
138+
- You have to link the [giscus app](https://github.com/apps/giscus) to at least the repository where the comments are hosted
139+
- You have to enable the discussion feature in the repository (see [here](https://docs.github.com/en/github/administering-a-repository/managing-repository-settings/enabling-or-disabling-github-discussions-for-a-repository)
140+
)
141+
142+
After you configured everything on the site, you get the `<script>` tag which you could embed. The blog needs the following information.
143+
144+
Here you can find an example. This is how the script tag looks on giscus.
145+
146+
```javascript
147+
<script
148+
src="https://giscus.app/client.js"
149+
data-repo="your_username/reponame"
150+
data-repo-id="M9/ab=="
151+
data-category="General"
152+
data-category-id="AbC==/8_D"
153+
async
154+
></script>
136155
```
156+
137157
Now you can copy/paste that information into the appsettings.json. With the given information above your appsettings.json looks like this:
158+
138159
```json
139160
"Giscus": {
140161
"Repository": "your_username/reponame",
@@ -145,32 +166,40 @@ Now you can copy/paste that information into the appsettings.json. With the give
145166
```
146167

147168
### Disqus
169+
148170
For disqus you only need the short name (site-name) which you can find for example under your [home-tab](https://disqus.com/home/).
149171

150172
## Authorization
173+
151174
There is only one real mechanism enabled via Auth0. For more information go to: https://auth0.com/docs/applications
152175

153176
The main advantage of Auth0 is the easily configurable dashboard on their website.
154177
For testing purposes, you can use `services.UseDummyAuthentication();`. This allows every user, who presses Login, to be logged in.
155178

156179
## Donations
180+
157181
The blog software allows you to integrate via different micro-transaction services. The following chapter will show you how to set up donations.
158182

159183
### Ko-fi
184+
160185
You can use [Ko-fi](https://Ko-fi.com/) as a payment service to receive donations. To acquire the `KofiToken` as seen in the config above, head to [widgets page](https://Ko-fi.com/manage/widgets), click on "Ko-fi Button".
161186
Now choose "Image" as the type. In the field below under `Copy & Paste Code` you see an `<a href='https://ko-fi.com/XYZ'` tag. Just take the `XYZ` part and put it into `KofiToken`.
162187

163188
### GitHub Sponsor
189+
164190
Enables the usage of [GitHub Sponsors](https://github.com/sponsors) as a payment service to receive donations. Only pass in your username. The button will use the following url: `https://github.com/sponsors/{your-user-name}`.
165191

166192
## Search Engine Optimization (SEO)
193+
167194
The blog includes some of the most important tags to get indexed by a crawler. Furthermore, some aspects of the Open Graph specification are implemented.
168195

169196
### Robots.txt
197+
170198
In the wwwroot/ you can find a default robots.txt. It allows the site gets completely indexed. If you want to tweak that behavior - feel free.
171-
Also, you can provide a sitemap.xml to get a better ranking. The blog can create a sitemap.xml on its own. For that log in and click on the `Admin` button in the navigation bar and afterward on `Sitemap`. There you can let the blog create a new one for you. This is especially helpful after you created a new blog post to make it easier for indexers like Google.
199+
Also, you can provide a sitemap.xml to get a better ranking. The blog can create a sitemap.xml on its own. For that log in and click on the `Admin` button in the navigation bar and afterward on `Sitemap`. There you can let the blog create a new one for you. This is especially helpful after you created a new blog post to make it easier for indexers like Google.
172200

173201
### Open Graph Tags
202+
174203
To get better results when for example shared via LinkedIn some of the `<meta property="og:tag">` tags are implemented.
175204

176205
The following tags are set depending on the page:
@@ -191,13 +220,15 @@ Furthermore, the following tags are set:
191220
| &lt;meta name="keyword" content="" /&gt; | not set | Tags defined in the Blog Post |
192221

193222
## RSS Feed
223+
194224
This blog also offers an RSS feed ([RSS 2.0 specification](https://validator.w3.org/feed/docs/rss2.html)), which can be consumed by your users or programs like Feedly. Just append `feed.rss` to your URL or click on the RSS feed icon in the navigation bar to get the feed. The RSS feed does not expose the whole content of a given blog post but its title and short description including some other tags like preview image, publishing date and so on.
195225

196226
## Host Web in Docker containers
197227

198228
### Server configuration
199229

200230
To deploy with docker, you need to modify the variables in the docker-compose.yml file.
231+
201232
```yml
202233
volumes:
203234
- /root/.aspnet/DataProtection-Keys:/root/.aspnet/DataProtection-Keys
@@ -210,17 +241,19 @@ volumes:
210241
- ASPNETCORE_Kestrel__Certificates__Default__Path=/app/aspnetapp.pfx
211242
- ASPNETCORE_ENVIRONMENT=Production
212243
```
244+
213245
After modifying the settings, you can use the docker command `docker compose up -d`
214246
Deploy the web.
215247
If you don't use HTTPS, you can remove the related options.
216248
SQL Server
217249

218250
If you use SQL Server, you can add an instance in `docker-compose.yml`.
219-
``` yml
251+
252+
```yml
220253
sql:
221254
image: mcr.microsoft.com/mssql/server:2022-latest
222255
container_name: sql
223-
expose:
256+
expose:
224257
- 1433
225258
volumes:
226259
- sqlvolume:/var/opt/mssql
@@ -229,10 +262,12 @@ If you use SQL Server, you can add an instance in `docker-compose.yml`.
229262
- MSSQL_SA_PASSWORD= # Your sql password
230263
networks:
231264
- web_net
232-
volumes: # creates a shared data volume named sqlvolume if you use sqlserver
233-
sqlvolume:
265+
volumes: # creates a shared data volume named sqlvolume if you use sqlserver
266+
sqlvolume:
234267
```
268+
235269
Note the ConnectionString format of SQL Server needs to be consistent:
270+
236271
```
237272
"ConnectionString": "Data Source=sql;Initial Catalog=master;User ID=sa;Password=<YOURPASSWORD>;TrustServerCertificate=True;MultiSubnetFailover=True"
238273
```

docs/Authorization/Auth0.md

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
### Auth0
2+
3+
Auth0 is a prominent provider of OpenID Connect (OIDC) services, which is an authentication protocol built on top of OAuth 2.0. OpenID Connect is specifically designed for identity layer applications and provides a standardized way for users to authenticate and authorize themselves on websites or applications while allowing third-party applications to access limited user information in a secure manner.
4+
5+
For more information go to: https://auth0.com/docs/applications
6+
7+
### Configuration
8+
9+
In `appsettings.json` change the `AuthProvider` to `Auth0`
10+
and add following configurations
11+
12+
```json
13+
{
14+
//other configuration
15+
"AuthProvider": "Auth0",
16+
"Auth0": {
17+
"Domain": "",
18+
"ClientId": "",
19+
"ClientSecret": ""
20+
}
21+
// other configuration
22+
}
23+
```
24+
25+
| Property | Type | Description |
26+
| --------------------------- | ------ | ------------------------------------------------------------------------------------------------------- |
27+
| AuthProvider | | Name of the auth provider |
28+
| `name of the auth provider` | | Configuration for setting up the auth provider, it should be same as the value of AuthProvider property |
29+
| Domain | string | See more details here: https://manage.auth0.com/dashboard/ |
30+
| ClientId | string | See more details here: https://manage.auth0.com/dashboard/ |
31+
| ClientSecret | string | See more details here: https://manage.auth0.com/dashboard/ |

docs/Authorization/Readme.md

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
### Authentication and Authorization
2+
3+
When it comes to authentication and authorization, we employ [OpenID Connect](https://openid.net/developers/how-connect-works/) as our preferred method. The primary benefit of utilizing an OpenID Connect-based provider is the conveniently customizable dashboard accessible through their website. For the sake of testing, you have the option to employ the UseDummyAuthentication(); service. This grants every user who clicks "Login" immediate access, effectively logging them in. Here are the platforms we support:
4+
5+
- [Auth0](Auth0.md)
6+
- [Azure Active Directory](AzureAD.md)
7+
- And more...
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

docs/Storage/Sqlite.md

Whitespace-only changes.

0 commit comments

Comments
 (0)