Skip to content

Commit 63824cc

Browse files
Adapt README for the new version
1 parent 9ff58f9 commit 63824cc

File tree

2 files changed

+66
-6
lines changed

2 files changed

+66
-6
lines changed

README.md

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
# SimpleToken Authentication Middleware
1+
# SimpleToken Authentication
22

33
This package allows to extract token from authenticated requests and delegate it to an appropriated ISecurityTokenValidator and generate and AuthenticationTicket.
44

55
## Behavior
66

77
### Token extraction details
88

9-
This middleware tries to support almost [RFC 6750](http://tools.ietf.org/html/rfc6750) and some licenses based on [GitHub behavior](https://developer.github.com/v3/oauth/#use-the-access-token-to-access-the-api). But does not support Form-Encoded Body Parameter (http://tools.ietf.org/html/rfc6750#section-2.2).
9+
This tries to support almost [RFC 6750](http://tools.ietf.org/html/rfc6750) and some licenses based on [GitHub behavior](https://developer.github.com/v3/oauth/#use-the-access-token-to-access-the-api). But does not support Form-Encoded Body Parameter (http://tools.ietf.org/html/rfc6750#section-2.2).
1010

1111
There are three methods of sending tokens:
1212

@@ -76,7 +76,37 @@ For example:
7676
WWW-Authenticate: Bearer
7777
```
7878
79-
## Usage
79+
## Usage v2
80+
81+
It is necessary to register all valid `ISecurityTokenValidator` classes and configure the Authentication service using the `AddSimpleTokenAuthentication` extension method.
82+
83+
Example:
84+
85+
```csharp
86+
public class Startup
87+
{
88+
public void ConfigureServices(IServiceCollection services)
89+
{
90+
services.AddTransient<ISecurityTokenValidator, MyCustomTokenValidator>();
91+
services.AddAuthentication()
92+
.AddSimpleTokenAuthentication(options =>
93+
{
94+
options.SecurityTokenValidatorsFactory = () =>
95+
{
96+
var context = services.BuildServiceProvider().GetService<IHttpContextAccessor>().HttpContext;
97+
return context.RequestServices.GetServices<ISecurityTokenValidator>();
98+
};
99+
});
100+
}
101+
102+
public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory) {
103+
app.UseAuthentication();
104+
app.UseMvc();
105+
}
106+
}
107+
```
108+
109+
## Usage v1
80110

81111
It is necessary to register all valid `ISecurityTokenValidator` classes and add the middleware to ApplicationBuilder using `UseSimpleTokenAuthentication`.
82112

src/MakingSense.AspNetCore.Authentication.SimpleToken/README.md

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
# SimpleToken Authentication Middleware
1+
# SimpleToken Authentication
22

33
This package allows to extract token from authenticated requests and delegate it to an appropriated ISecurityTokenValidator and generate and AuthenticationTicket.
44

55
## Behavior
66

77
### Token extraction details
88

9-
This middleware tries to support almost [RFC 6750](http://tools.ietf.org/html/rfc6750) and some licenses based on [GitHub behavior](https://developer.github.com/v3/oauth/#use-the-access-token-to-access-the-api). But does not support Form-Encoded Body Parameter (http://tools.ietf.org/html/rfc6750#section-2.2).
9+
This tries to support almost [RFC 6750](http://tools.ietf.org/html/rfc6750) and some licenses based on [GitHub behavior](https://developer.github.com/v3/oauth/#use-the-access-token-to-access-the-api). But does not support Form-Encoded Body Parameter (http://tools.ietf.org/html/rfc6750#section-2.2).
1010

1111
There are three methods of sending tokens:
1212

@@ -76,7 +76,37 @@ For example:
7676
WWW-Authenticate: Bearer
7777
```
7878
79-
## Usage
79+
## Usage v2
80+
81+
It is necessary to register all valid `ISecurityTokenValidator` classes and configure the Authentication service using the `AddSimpleTokenAuthentication` extension method.
82+
83+
Example:
84+
85+
```csharp
86+
public class Startup
87+
{
88+
public void ConfigureServices(IServiceCollection services)
89+
{
90+
services.AddTransient<ISecurityTokenValidator, MyCustomTokenValidator>();
91+
services.AddAuthentication()
92+
.AddSimpleTokenAuthentication(options =>
93+
{
94+
options.SecurityTokenValidatorsFactory = () =>
95+
{
96+
var context = services.BuildServiceProvider().GetService<IHttpContextAccessor>().HttpContext;
97+
return context.RequestServices.GetServices<ISecurityTokenValidator>();
98+
};
99+
});
100+
}
101+
102+
public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory) {
103+
app.UseAuthentication();
104+
app.UseMvc();
105+
}
106+
}
107+
```
108+
109+
## Usage v1
80110

81111
It is necessary to register all valid `ISecurityTokenValidator` classes and add the middleware to ApplicationBuilder using `UseSimpleTokenAuthentication`.
82112

0 commit comments

Comments
 (0)