Skip to content

Commit

Permalink
Merge pull request #1 from giuliohome-org/jwt
Browse files Browse the repository at this point in the history
Jwt
  • Loading branch information
giuliohome authored Oct 9, 2023
2 parents b2624a8 + 0df94b9 commit 87ac101
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/api/ListsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public ListsController(ListsRepository repository)

// [HttpGet("public")]

[HttpGet("private-scoped")]
[HttpGet]
[Authorize("read:lists")]
[ProducesResponseType(200)]
public async Task<ActionResult<IEnumerable<TodoList>>> GetLists([FromQuery] int? skip = null, [FromQuery] int? batchSize = null)
Expand Down
14 changes: 9 additions & 5 deletions src/api/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@
using SimpleTodo.Api;

var builder = WebApplication.CreateBuilder(args);
var credential = new DefaultAzureCredential();
builder.Configuration.AddAzureKeyVault(new Uri(builder.Configuration["AZURE_KEY_VAULT_ENDPOINT"]), credential);
// var credential = new DefaultAzureCredential();
// builder.Configuration.AddAzureKeyVault(new Uri(builder.Configuration["AZURE_KEY_VAULT_ENDPOINT"]), credential);

builder.Services.AddScoped<ListsRepository>();
/* builder.Services.AddScoped<ListsRepository>();
builder.Services.AddDbContext<TodoDb>(options =>
{
var connectionString = builder.Configuration[builder.Configuration["AZURE_SQL_CONNECTION_STRING_KEY"]];
options.UseSqlServer(connectionString, sqlOptions => sqlOptions.EnableRetryOnFailure());
});
}); */

builder.Services.AddControllers();
// configure and then enable app insights
Expand All @@ -31,7 +31,11 @@
builder.Services.AddAuthorization();*/

var domain = $"https://{builder.Configuration["AUTH0_DOMAIN"]}/";
builder.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
builder.Services.AddAuthentication(options =>
{
options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
options.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme;
})
.AddJwtBearer(options =>
{
options.Authority = domain;
Expand Down

0 comments on commit 87ac101

Please sign in to comment.