-
Notifications
You must be signed in to change notification settings - Fork 272
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Code updates for sample projects in description (#197)
* Configuration, diagnostics, DPOP * Code update for MTLS, PAT, ScopesAndResources, SessionManagement, TokenExchange * Modernize code for AspNetIdentity and all BFF examples (#194) * Modernize code for AspNetIdentity and all BFF examples * Fixed log issues * Fixed more log issues * Added missing parenthesis --------- Co-authored-by: Roland Guijt <[email protected]> * Output accesstoken instead of JSON (#199) Co-authored-by: Roland Guijt <[email protected]> * Updates for UserInteraction (#198) Co-authored-by: Roland Guijt <[email protected]> * Update Angular CLI * Update to Angular CLI v. 17 * Update to Angular v17 2 * Update to Angular 18 * BFF now requests offline_access, useEndpoints removed (#202) * Request offline_access * Remove limited access token lifetime --------- Co-authored-by: Roland Guijt <[email protected]> * Use DI for HttpClient Use AccessTokenManagement to utilize refresh token Add missing link in layout page * Remove offline_access * Remove parenthesis * New qs: Token Management * Add commented out code for "manual" mode * Better name for token object * tweaks to quickstart 1 * Update to IdentityServer 7.0.7 * Update Aspire to latest version * Update OpenTelemetry.Instrumentation.GrpcNetClient * Configuration, diagnostics, DPOP * Code update for MTLS, PAT, ScopesAndResources, SessionManagement, TokenExchange * Update to IdentityServer 7.0.7 --------- Co-authored-by: Roland Guijt <[email protected]> Co-authored-by: Dominick Baier <[email protected]> Co-authored-by: Joe DeCock <[email protected]> Co-authored-by: Adam Ralph <[email protected]>
- Loading branch information
1 parent
a97c84b
commit 38ab386
Showing
92 changed files
with
1,008 additions
and
1,735 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 15 additions & 18 deletions
33
IdentityServer/v7/Configuration/Permissions/SimpleApi/IdentityController.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,23 @@ | ||
using Microsoft.AspNetCore.Mvc; | ||
using Microsoft.Extensions.Logging; | ||
using System.Linq; | ||
|
||
namespace SimpleApi.Controllers | ||
namespace SimpleApi.Controllers; | ||
|
||
[Route("identity")] | ||
public class IdentityController : ControllerBase | ||
{ | ||
[Route("identity")] | ||
public class IdentityController : ControllerBase | ||
{ | ||
private readonly ILogger<IdentityController> _logger; | ||
private readonly ILogger<IdentityController> _logger; | ||
|
||
public IdentityController(ILogger<IdentityController> logger) | ||
{ | ||
_logger = logger; | ||
} | ||
public IdentityController(ILogger<IdentityController> logger) | ||
{ | ||
_logger = logger; | ||
} | ||
|
||
[HttpGet] | ||
public ActionResult Get() | ||
{ | ||
var claims = User.Claims.Select(c => new { c.Type, c.Value }); | ||
_logger.LogInformation("claims: {claims}", claims); | ||
[HttpGet] | ||
public ActionResult Get() | ||
{ | ||
var claims = User.Claims.Select(c => new { c.Type, c.Value }); | ||
_logger.LogInformation("claims: {claims}", claims); | ||
|
||
return new JsonResult(claims); | ||
} | ||
return new JsonResult(claims); | ||
} | ||
} |
72 changes: 38 additions & 34 deletions
72
IdentityServer/v7/Configuration/Permissions/SimpleApi/Program.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,41 @@ | ||
using System; | ||
using Microsoft.AspNetCore; | ||
using Microsoft.AspNetCore.Hosting; | ||
using Microsoft.Extensions.Hosting; | ||
using Serilog; | ||
using Serilog.Events; | ||
using Serilog.Sinks.SystemConsole.Themes; | ||
using Serilog; | ||
|
||
namespace SimpleApi | ||
{ | ||
public class Program | ||
Console.Title = "API"; | ||
|
||
Log.Logger = new LoggerConfiguration() | ||
.MinimumLevel.Information() | ||
.Enrich.FromLogContext() | ||
.WriteTo.Console(outputTemplate: "[{Timestamp:HH:mm:ss} {Level}] {SourceContext}{NewLine}{Message:lj}{NewLine}{Exception}{NewLine}", theme: AnsiConsoleTheme.Code) | ||
.CreateLogger(); | ||
|
||
var builder = WebApplication.CreateBuilder(args); | ||
|
||
builder.Services.AddSerilog(); | ||
builder.Services.AddControllers(); | ||
|
||
// this API will accept any access token from the authority | ||
builder.Services.AddAuthentication("token") | ||
.AddJwtBearer("token", options => | ||
{ | ||
public static void Main(string[] args) | ||
{ | ||
Console.Title = "API"; | ||
|
||
BuildWebHost(args).Run(); | ||
} | ||
|
||
public static IHost BuildWebHost(string[] args) | ||
{ | ||
Log.Logger = new LoggerConfiguration() | ||
.MinimumLevel.Information() | ||
.Enrich.FromLogContext() | ||
.WriteTo.Console(outputTemplate: "[{Timestamp:HH:mm:ss} {Level}] {SourceContext}{NewLine}{Message:lj}{NewLine}{Exception}{NewLine}", theme: AnsiConsoleTheme.Code) | ||
.CreateLogger(); | ||
|
||
return Host.CreateDefaultBuilder(args) | ||
.ConfigureWebHostDefaults(webBuilder => | ||
{ | ||
webBuilder.UseStartup<Startup>(); | ||
}) | ||
.UseSerilog() | ||
.Build(); | ||
} | ||
} | ||
} | ||
options.Authority = "https://localhost:5001"; | ||
options.MapInboundClaims = false; | ||
|
||
options.TokenValidationParameters.ValidateAudience = false; | ||
options.TokenValidationParameters.ValidTypes = new[] { "at+jwt" }; | ||
}); | ||
|
||
builder.Services.AddAuthorization(options => | ||
{ | ||
options.AddPolicy("SimpleApi", p => p.RequireClaim("scope", "SimpleApi")); | ||
}); | ||
|
||
var app = builder.Build(); | ||
|
||
app.UseRouting(); | ||
app.UseAuthentication(); | ||
app.UseAuthorization(); | ||
|
||
app.MapControllers().RequireAuthorization(); | ||
|
||
app.Run(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 0 additions & 42 deletions
42
IdentityServer/v7/Configuration/Permissions/SimpleApi/Startup.cs
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 15 additions & 18 deletions
33
IdentityServer/v7/Configuration/PipelineRegistration/SimpleApi/IdentityController.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,23 @@ | ||
using Microsoft.AspNetCore.Mvc; | ||
using Microsoft.Extensions.Logging; | ||
using System.Linq; | ||
|
||
namespace SimpleApi.Controllers | ||
namespace SimpleApi.Controllers; | ||
|
||
[Route("identity")] | ||
public class IdentityController : ControllerBase | ||
{ | ||
[Route("identity")] | ||
public class IdentityController : ControllerBase | ||
{ | ||
private readonly ILogger<IdentityController> _logger; | ||
private readonly ILogger<IdentityController> _logger; | ||
|
||
public IdentityController(ILogger<IdentityController> logger) | ||
{ | ||
_logger = logger; | ||
} | ||
public IdentityController(ILogger<IdentityController> logger) | ||
{ | ||
_logger = logger; | ||
} | ||
|
||
[HttpGet] | ||
public ActionResult Get() | ||
{ | ||
var claims = User.Claims.Select(c => new { c.Type, c.Value }); | ||
_logger.LogInformation("claims: {claims}", claims); | ||
[HttpGet] | ||
public ActionResult Get() | ||
{ | ||
var claims = User.Claims.Select(c => new { c.Type, c.Value }); | ||
_logger.LogInformation("claims: {claims}", claims); | ||
|
||
return new JsonResult(claims); | ||
} | ||
return new JsonResult(claims); | ||
} | ||
} |
Oops, something went wrong.