Skip to content

Commit 1774966

Browse files
committed
Basic documantation added
1 parent 11e8b78 commit 1774966

17 files changed

+257
-5
lines changed

.doc/img/1.landing.jpg

198 KB
Loading

.doc/img/2.1.registration.jpg

173 KB
Loading

.doc/img/2.2.login.jpg

198 KB
Loading

.doc/img/3.normal_user_view.jpg

188 KB
Loading

.doc/img/4.profile.jpg

125 KB
Loading

.doc/img/5.2fa.jpg

281 KB
Loading

.doc/img/6.super_admin.jpg

205 KB
Loading

.doc/img/7.roles.jpg

240 KB
Loading

.doc/img/8.1.roles_user.jpg

264 KB
Loading

.doc/img/8.2.roles_user.jpg

193 KB
Loading

.doc/img/9.access_denied.jpg

225 KB
Loading

.doc/img/bundleconfig.jpg

406 KB
Loading

.doc/img/libman.jpg

289 KB
Loading
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
using Microsoft.AspNetCore.Authorization;
2+
using StartupProject_Asp.NetCore_PostGRE.Data.Enums;
3+
4+
namespace StartupProject_Asp.NetCore_PostGRE.Attributes
5+
{
6+
public class AuthorizeClaimsAttribute : AuthorizeAttribute
7+
{
8+
public AuthorizeClaimsAttribute(params EClaim[] allowedRoles)
9+
{
10+
// Need to implement
11+
}
12+
}
13+
}

Readme.md

Lines changed: 105 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,105 @@
1-
# Startup Project for Asp.Net Core 3.1 with PostGRE - perfect for deployment in Linux Server
1+
# Startup Role Management Project for Asp.Net Core 3.1 with PostGRE - perfect for deployment in Linux Server
2+
3+
This application is created with [ASP.Net Core 3.1](https://dotnet.microsoft.com/download/dotnet-core/3.1) and [PostGRE SQL](https://www.postgresql.org/download/) (any version, tested with v11-v13). This project is a perfect startup place for a project targetting to deploy in Linux server. HTML, CSS, JS minifire all are configured in the project for better performance.
4+
5+
## Easy Run and Deploy with Requirements
6+
7+
To run this project, [CLI](https://www.c-sharpcorner.com/article/net-core-cli2/) can be enough, but [Visual Studio](https://visualstudio.microsoft.com/vs/) is recommanded because it offers various features to devs.
8+
9+
### Prerequisite
10+
11+
1. [ASP.Net Core SDK](https://dotnet.microsoft.com/download/dotnet-core/3.1)
12+
2. [PostGRE SQL Server](https://www.postgresql.org/download/), tested with 11+, should work with any version
13+
3. [Visual Studio 2019](https://visualstudio.microsoft.com/vs/)
14+
15+
### Running with VS
16+
17+
To run this project with [Visual Studio 2019](https://visualstudio.microsoft.com/vs/), you need to install the dotnet SDK in PC and a PostGRE connection string (connection string comes from PostGRE server which can exists in dev PC or remote server). After having both, you need to change [this line in code](./appsettings.json#L3) with your connection string. Then if you build and run the code, everything would be OK.
18+
19+
To apply the migration, you need to run migration update command in package manager console. The command is-
20+
21+
Update-Database
22+
23+
To get the package manager console, you need to go here in **VS 2019**-
24+
25+
- ***Tools*** -> *Library Package Manager* -> *Package Manager Console*
26+
27+
Most common migration commands are added in this project and can be found in [here](./.doc/Links_and_Commands.md).
28+
29+
## CSS and JS library with bundling and minification
30+
31+
Minimal configuration and easy to deploy library manager, bundler and minifire is used in this project which can be easily deployed in linux along with windows easily with zero configuration.
32+
33+
### Library management with Libman with different source
34+
All CSS and JS library are managed by [libman](https://docs.microsoft.com/en-us/aspnet/core/client-side/libman/libman-vs?view=aspnetcore-3.1) which is one of the bset option for managing client side libraries. The file can be found in [here](./libman.json) and look like this-
35+
![Libman file ](.doc/img/libman.jpg)
36+
where default provider is set to ***cdnjs*** and can be set to anything like ***jsdelivr*** or anything. All file download directory is set and only required files are downloaded, so list of required files are found from the included file in the [libman.json](./libman.json) file.
37+
No custom CSS and no custom JS are applied
38+
39+
### Bundling and Minification
40+
41+
Bundling and minification is configured with [this](./bundleconfig.json) file which is very easy to configure and used. More can be found in [here](https://docs.microsoft.com/en-us/aspnet/core/client-side/bundling-and-minification?view=aspnetcore-3.1). The file is looking like this-
42+
43+
![libman easy configuration](.doc/img/libman.jpg)
44+
45+
which generates a css file named **site.min.css** and a js file named **site.min.css** which includes all CSS and js file compliation including all libraries.
46+
47+
In the project, there is stored 1 custom CSS file can be found in [here](./wwwroot/css/site.css) and one custom js fle can be found in [here](./wwwroot/js/site.js) which is also configured with bundler and minifire. No code is added in the 2 file because of providing freedom to the developer who wishesh to use this project and customize it on his demand. AS well this 2 file is added to the bundler so that a developer who forks this repo, can know how to configure his own repo. And finally, version number is appended with the CSS and JS so that CSS and JS caching issue can't happen because after each build, browser will treat every CSS and JS as new one.
48+
49+
## Database and Migration with Seed
50+
51+
PostGRE SQL is used because it is most robust open source database having support for both relational DB and text based DB. In this project I am using the DB as a relational DB. The configuration of the database can be done from [here](/appsettings.json#L3) so that anyone can configure individual DB for both deployment and development.
52+
53+
### Migration
54+
All migration files are configured to be stored in [this](./Data/ApplicationDbContext.cs) folder. Useful migration commands can be found from [here](./.doc/Links_and_Commands.md).
55+
56+
### Seed
57+
58+
Seeds are configured in [here](/Data/Seeds/SeedController.cs#L19). After adding a seed, you need to run this command-
59+
60+
Add-Migration <Seed_Migration_Name>
61+
Update-Database
62+
63+
Replace `<Seed_Migration_Name>` with your seeder-migration name.
64+
65+
Default Superadmin set with seeder is-
66+
67+
- ***Username*** - `abrar@jahin.com`
68+
- ***Password*** - `abrar@jahin.com`
69+
70+
## Authentication and Authorization
71+
72+
In this project Role based authintication is implemented.
73+
74+
In this project, Role based authontication is implemented and some specific roles are created depending on an enum defined in [here](./Data/Enums/EClaims.cs). And also Any user can be assigned with any role and a user can have multiple roles. Moreover, the filtering based on different places are applied in following places-
75+
76+
1. Controller Level can be found in [here](./Controllers/SuperAdmin/RoleManagerController.cs#L11)
77+
2. Action level can be found in [here](./Controllers/HomeController.cs#L30)
78+
3. Razor page sections can be filtered with role can be found in [here](./Views/Shared/LayoutPartial/_navigator.cshtml#L27)
79+
4. Add *multiple roles* on a *Cntroller*/*Action*/*Razor page* can be found in [here](./Controllers/HomeController.cs#L30)
80+
5. Username change limit added and set limit to 10 by default
81+
6. 2FA with Google authinticator is added
82+
Custom [attributes are defined in here](./Attributes/AuthorizeRolesAttribute.cs#L11) which is used to convert *enum* to attribute.
83+
84+
## Application UI and Screen Shots
85+
86+
All forms has front end and back end validation at a same time.
87+
88+
0. Landing Page ![Landing Page](./.doc/img/1.landing.jpg)
89+
1. Registration page ![Login Page Design](./.doc/img/2.1.registration.jpg)
90+
2. Login page ![Login Page Design](./.doc/img/2.2.login.jpg)
91+
3. Normal User View ![Login Page Design](./.doc/img/3.normal_user_view.jpg)
92+
4. Super-Admin User View ![Login Page Design](./.doc/img/6.super_admin.jpg)
93+
5. Access Denied page for any unauthorised access ![Login Page Design](./.doc/img/9.access_denied.jpg)
94+
6. 2FA for user ![Login Page Design](./.doc/img/5.2fa.jpg)
95+
7. Profile Page ![Login Page Design](./.doc/img/4.profile.jpg)
96+
8. Role Page ![Login Page Design](./.doc/img/7.roles.jpg)
97+
9. User-Role Management Page ![Role List by User](./.doc/img/8.1.roles_user.jpg) and ![Change User Role](./.doc/img/8.2.roles_user.jpg)
98+
99+
and basic operation pages.
100+
101+
## Some important partials
102+
103+
1. Header partial are seperated and can be found in [here](./Views/Shared/LayoutPartial/_header.cshtml)
104+
2. Footer partial are seperated and can be found in [here](./Views/Shared/LayoutPartial/_footer.cshtml)
105+
3. Navbar partial are seperated and can be found in [here](./Views/Shared/LayoutPartial/_navigator.cshtml)

Views/Shared/LayoutPartial/_footer.cshtml

Lines changed: 138 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,143 @@
1-
<footer class="border-top footer text-muted">
2-
<div class="container">
3-
&copy; @@ @DateTime.Now.Year - Asp.NetCore PostGRE - StartupProject - <a asp-area="" asp-controller="Home" asp-action="Privacy">Privacy</a>
1+
@*Footer*@
2+
<footer class="page-footer font-small mdb-color pt-4">
3+
4+
<!-- Footer Links -->
5+
<div class="container text-center text-md-left">
6+
7+
<!-- Footer links -->
8+
<div class="row text-center text-md-left mt-3 pb-3">
9+
10+
<!-- Grid column -->
11+
<div class="col-md-3 col-lg-3 col-xl-3 mx-auto mt-3">
12+
<h6 class="text-uppercase mb-4 font-weight-bold">Company name</h6>
13+
<p>
14+
Here you can use rows and columns to organize your footer content. Lorem ipsum dolor sit amet,
15+
consectetur
16+
adipisicing elit.
17+
</p>
18+
</div>
19+
<!-- Grid column -->
20+
21+
<hr class="w-100 clearfix d-md-none">
22+
23+
<!-- Grid column -->
24+
<div class="col-md-2 col-lg-2 col-xl-2 mx-auto mt-3">
25+
<h6 class="text-uppercase mb-4 font-weight-bold">Products</h6>
26+
<p>
27+
<a href="#!">MDBootstrap</a>
28+
</p>
29+
<p>
30+
<a href="#!">MDWordPress</a>
31+
</p>
32+
<p>
33+
<a href="#!">BrandFlow</a>
34+
</p>
35+
<p>
36+
<a href="#!">Bootstrap Angular</a>
37+
</p>
38+
</div>
39+
<!-- Grid column -->
40+
41+
<hr class="w-100 clearfix d-md-none">
42+
43+
<!-- Grid column -->
44+
<div class="col-md-3 col-lg-2 col-xl-2 mx-auto mt-3">
45+
<h6 class="text-uppercase mb-4 font-weight-bold">Useful links</h6>
46+
<p>
47+
<a href="#!">Your Account</a>
48+
</p>
49+
<p>
50+
<a href="#!">Become an Affiliate</a>
51+
</p>
52+
<p>
53+
<a href="#!">Shipping Rates</a>
54+
</p>
55+
<p>
56+
<a href="#!">Help</a>
57+
</p>
58+
</div>
59+
60+
<!-- Grid column -->
61+
<hr class="w-100 clearfix d-md-none">
62+
63+
<!-- Grid column -->
64+
<div class="col-md-4 col-lg-3 col-xl-3 mx-auto mt-3">
65+
<h6 class="text-uppercase mb-4 font-weight-bold">Contact</h6>
66+
<p>
67+
<i class="fa fa-home" aria-hidden="true"></i> New York, NY 10012, US
68+
</p>
69+
<p>
70+
<i class="fa fa-envelope" aria-hidden="true"></i> info@gmail.com
71+
</p>
72+
<p>
73+
<i class="fa fa-phone" aria-hidden="true"></i> + 01 234 567 88
74+
</p>
75+
<p>
76+
<i class="fa fa-print" aria-hidden="true"></i> + 01 234 567 89
77+
</p>
78+
</div>
79+
<!-- Grid column -->
80+
81+
</div>
82+
<!-- Footer links -->
83+
84+
<hr>
85+
86+
<!-- Grid row -->
87+
<div class="row d-flex align-items-center">
88+
89+
<!-- Grid column -->
90+
<div class="col-md-7 col-lg-8">
91+
92+
<!--Copyright-->
93+
<p class="text-center text-md-left">
94+
@@ @DateTime.Now.Year Copyright:
95+
<a href="https://github.com/AbrarJahin/Asp.NetCore_3.1-PostGRE_StartupProject"><strong>Asp.NetCore PostGRE - StartupProject</strong></a>
96+
</p>
97+
98+
</div>
99+
<!-- Grid column -->
100+
<!-- Grid column -->
101+
<div class="col-md-5 col-lg-4 ml-lg-0">
102+
103+
<!-- Social buttons -->
104+
<div class="text-center text-md-right">
105+
<ul class="list-unstyled list-inline">
106+
<li class="list-inline-item">
107+
<a class="btn-floating btn-sm rgba-white-slight mx-1">
108+
<i class="fab fa-facebook-f"></i>
109+
</a>
110+
</li>
111+
<li class="list-inline-item">
112+
<a class="btn-floating btn-sm rgba-white-slight mx-1">
113+
<i class="fab fa-twitter"></i>
114+
</a>
115+
</li>
116+
<li class="list-inline-item">
117+
<a class="btn-floating btn-sm rgba-white-slight mx-1">
118+
<i class="fab fa-google-plus-g"></i>
119+
</a>
120+
</li>
121+
<li class="list-inline-item">
122+
<a class="btn-floating btn-sm rgba-white-slight mx-1">
123+
<i class="fab fa-linkedin-in"></i>
124+
</a>
125+
</li>
126+
</ul>
127+
</div>
128+
129+
</div>
130+
<!-- Grid column -->
131+
132+
</div>
133+
<!-- Grid row -->
134+
4135
</div>
136+
<!-- Footer Links -->
137+
5138
</footer>
139+
<!-- Footer -->
140+
@*Footer*@
6141

7142
<environment include="Development">
8143
<script src="~/lib/jquery/jquery.js"></script>

Views/Shared/LayoutPartial/_header.cshtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
</environment>
2121
<environment exclude="Development">
2222
<link rel="stylesheet" href="~/css/site.min.css"
23-
asp-fallback-href="~/lib/bootstrap/dist/css/bootstrap.min.css"
23+
asp-fallback-href="~/css/site.css"
2424
asp-fallback-test-class="sr-only"
2525
asp-fallback-test-property="position"
2626
asp-append-version="true"

0 commit comments

Comments
 (0)