Skip to content

Commit

Permalink
0.9.1 - added HttpContextAccessor with default auth and in example
Browse files Browse the repository at this point in the history
  • Loading branch information
mgroves committed Dec 14, 2023
1 parent 6786087 commit b32defe
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 5 deletions.
5 changes: 4 additions & 1 deletion CMSprinkle.Example/ExampleAuthClass.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@ namespace CMSprinkle.Example;
// do NOT use this example
public class ExampleAuthClass : ICMSprinkleAuth
{
public ExampleAuthClass()
private readonly IHttpContextAccessor _httpContextAccessor;

public ExampleAuthClass(IHttpContextAccessor httpContextAccessor)
{
// inject your auth dependencies in here
_httpContextAccessor = httpContextAccessor;
}

public async Task<bool> IsAllowed()
Expand Down
2 changes: 1 addition & 1 deletion CMSprinkle.Example/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
// this adds auth to CMSprinkle
// if don't do this, it will be local only
// ExampleAuthClass enables anonymous public access, so don't use it as-is!
builder.Services.AddTransient<ICMSprinkleAuth, ExampleAuthClass>();
// builder.Services.AddTransient<ICMSprinkleAuth, ExampleAuthClass>();

// this adds CMSprinkle to your project
builder.Services.AddCMSprinkle(options =>
Expand Down
2 changes: 1 addition & 1 deletion CMSprinkle/CMSprinkle.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<PreserveCompilationContext>true</PreserveCompilationContext>
<GenerateEmbeddedFilesManifest>true</GenerateEmbeddedFilesManifest>
<Title>CMSprinkle</Title>
<Version>0.9.0</Version>
<Version>0.9.1</Version>
<Description>CMSprinkle is a micro-CMS (Content Management System) designed for quick integration with ASP.NET Core applications. It allows developers to easily incorporate managed content into ASP.NET MVC Razor pages, perfect for applications requiring a _sprinkle_ of dynamic content management.</Description>
<Copyright>Matthew D. Groves 2023-present</Copyright>
<Authors>Matthew D. Groves</Authors>
Expand Down
1 change: 1 addition & 0 deletions CMSprinkle/Infrastructure/ServiceCollectionExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public static IServiceCollection AddCMSprinkle(this IServiceCollection @this, Ac
var authService = serviceProvider.GetService<ICMSprinkleAuth>();
if (authService == null)
{
@this.AddHttpContextAccessor();
@this.AddTransient<ICMSprinkleAuth, DefaultLocalOnlyAuth>();
}

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,11 @@ __Database Connection__

Configure Couchbase for content storage:
```csharp
await builder.Services.AddCMSprinkleCouchbase("<bucket name>", "<scope name>", "<collection name>", createCollectionIfNecessary: true);
builder.Services.AddCMSprinkleCouchbase("<bucket name>", "<scope name>", "<collection name>", createCollectionIfNecessary: true);
```
Alternatively, use SQLServer as the provider:
```csharp
await builder.Services.AddCMSprinkleSqlServer("<sql server connection string>", "<table name>", "<schema name>", createTableIfNecessary: true);
builder.Services.AddCMSprinkleSqlServer("<sql server connection string>", "<table name>", "<schema name>", createTableIfNecessary: true);
```

## Configuration Details
Expand Down

0 comments on commit b32defe

Please sign in to comment.