Skip to content

Commit

Permalink
Added image for readme
Browse files Browse the repository at this point in the history
  • Loading branch information
JonPSmith committed Dec 13, 2018
1 parent 621b5b1 commit 127d2b3
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 12 deletions.
3 changes: 2 additions & 1 deletion PermissionAccessControl.sln
Expand Up @@ -5,14 +5,15 @@ VisualStudioVersion = 15.0.28307.136
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{608F451A-9063-4191-AFCD-398A429CFC33}"
ProjectSection(SolutionItems) = preProject
PermissionAccessControlHomePage.png = PermissionAccessControlHomePage.png
README.md = README.md
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PermissionParts", "PermissionParts\PermissionParts.csproj", "{02633708-C1E3-45D1-9016-0499134BC581}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestWebApp", "TestWebApp\TestWebApp.csproj", "{9EE2BC43-3AC9-4D97-8E5E-15099A20C440}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DataLayer", "DataLayer\DataLayer.csproj", "{DBA80257-4697-480E-85C6-87C23047E415}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DataLayer", "DataLayer\DataLayer.csproj", "{DBA80257-4697-480E-85C6-87C23047E415}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down
Binary file added PermissionAccessControlHomePage.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions README.md
@@ -1 +1,7 @@
# PermissionAccessControl

This is an example application to go with the article
[A better way to handle authorization in ASP.NET Core](#).
It contains a ASP.NET Core application with extra code to implement an
authorization system I call "Roles-to-Permissions".

4 changes: 2 additions & 2 deletions TestWebApp/Startup.cs
Expand Up @@ -39,7 +39,7 @@ public void ConfigureServices(IServiceCollection services)
options.MinimumSameSitePolicy = SameSiteMode.None;
});

//Have own database for roles to Permissions
//Have own database for roles to Permissions and Modules - uses in-memory database
var rolesConnection = SetupSqliteInMemoryConnection();
services.AddDbContext<ExtraAuthorizeDbContext>(options => options.UseSqlite(rolesConnection));

Expand Down Expand Up @@ -68,7 +68,7 @@ public void ConfigureServices(IServiceCollection services)
options.Events.OnValidatePrincipal = authCookieValidate.ValidateAsync;
});

//Register the AuthorizeServices
//Register the Permission policy handlers
services.AddSingleton<IAuthorizationPolicyProvider, AuthorizationPolicyProvider>();
services.AddSingleton<IAuthorizationHandler, PermissionHandler>();

Expand Down
17 changes: 8 additions & 9 deletions TestWebApp/Views/Home/Index.cshtml
Expand Up @@ -12,15 +12,12 @@
</p>
<h4>Please read the article <a href="">???</a> for how this works.</h4>

<p>Here are some things to try</p>
<ol>
<li>
Log in as <strong>@StartupExtensions.StaffUserEmail</strong> using the "Login" button (top right). The password is the same as email.
<br />
Notice that a "Feature1" button appears in the nav bar. That's because that @StartupExtensions.StaffUserEmail has access to the Feature1 module.
</li>
<li>Now click the "Color" button in the nav bar.</li>
</ol>
<p>
<strong>NOTE:</strong> the @Html.ActionLink("ColorController", "Index", "Color") and the @Html.ActionLink("Feature1Controller", "Index", "Feature1")
are protected by Permissions, so try accessing them either of those when not logged in,
or logged in as user @StartupExtensions.StaffUserEmail or @StartupExtensions.ManagerUserEmail.
</p>


<h3>List of users <small>so you can log in</small> </h3>
<p>NOTE: The Email address is also the Password!</p>
Expand All @@ -40,6 +37,8 @@
}
</table>



<h3>List of roles, with their permission<small>, but remember that the permissions are filtered by what modules the user is allowed to access</small></h3>
<table class="table">
<tr>
Expand Down

0 comments on commit 127d2b3

Please sign in to comment.