Skip to content

Commit dcca6ce

Browse files
authored
Update README.md
1 parent 7b67d94 commit dcca6ce

File tree

1 file changed

+24
-3
lines changed

1 file changed

+24
-3
lines changed

README.md

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,26 @@
11
# Mihir.AspNetCore.Authentication.Basic
22
Basic Scheme Authentication Implementation for ASP.NET Core 2.0
33

4+
## Installing
5+
This library is published on NuGet. So the NuGet package can be installed directly to your project if you wish to use it with making any custom changes to the code.
6+
7+
Download directly from [Mihir.AspNetCore.Authentication.Basic](https://www.nuget.org/packages/Mihir.AspNetCore.Authentication.Basic).
8+
9+
Or by running the below command on your project.
10+
11+
```
12+
PM> Install-Package Mihir.AspNetCore.Authentication.Basic
13+
```
14+
15+
## Example Usage
16+
417
Setting it up is quite simple. You will need basic working knowledge of ASP.NET Core 2.0 to get started using this code.
518

19+
On Startup.cs, as shown below, add 2 lines in ConfigureServices method `services.AddAuthentication(BasicDefaults.AuthenticationScheme).AddBasic<BasicUserValidationService>(options => { options.Realm = "My App"; });`. And a line `app.UseAuthentication();` in Configure method.
20+
21+
Also add an implementation of IBasicUserValidationService as shown below in BasicUserValidationService.cs
22+
23+
#### Startup.cs
624

725
```C#
826
using Mihir.AspNetCore.Authentication.Basic;
@@ -32,8 +50,11 @@ public class Startup
3250
app.UseMvc();
3351
}
3452
}
53+
```
3554

36-
55+
#### BasicUserValidationService.cs
56+
```C#
57+
using Mihir.AspNetCore.Authentication.Basic;
3758
public class BasicUserValidationService : IBasicUserValidationService
3859
{
3960
private readonly ILogger<BasicUserValidationService> _logger;
@@ -47,7 +68,7 @@ public class BasicUserValidationService : IBasicUserValidationService
4768
{
4869
try
4970
{
50-
// write your implementation here..
71+
// write your implementation here and return true or false depending on the validation..
5172
return Task.FromResult(true);
5273
}
5374
catch (Exception e)
@@ -61,7 +82,7 @@ public class BasicUserValidationService : IBasicUserValidationService
6182

6283

6384

64-
__References__
85+
## References
6586
- [Creating an authentication scheme in ASP.NET Core 2.0](https://joonasw.net/view/creating-auth-scheme-in-aspnet-core-2)
6687
- [aspnet/Security](https://github.com/aspnet/Security)
6788
- [ASP.NET Core Security documentation](https://docs.microsoft.com/en-us/aspnet/core/security)

0 commit comments

Comments
 (0)